TypeChangeModal: add potential data loss warning

This commit is contained in:
Sidney Alcantara
2022-06-01 15:03:17 +10:00
parent 72f4f742dd
commit f0f1f0a9d1

View File

@@ -4,9 +4,11 @@ import { IColumnModalProps } from ".";
import Modal from "@src/components/Modal";
import FieldsDropdown from "./FieldsDropdown";
import { Alert, AlertTitle } from "@mui/material";
import { tableScope, updateColumnAtom } from "@src/atoms/tableScope";
import { FieldType } from "@src/constants/fields";
import { getFieldProp } from "@src/components/fields";
import { analytics, logEvent } from "analytics";
export default function TypeChangeModal({
@@ -20,7 +22,20 @@ export default function TypeChangeModal({
<Modal
onClose={handleClose}
title="Change column type"
children={<FieldsDropdown value={newType} onChange={setType} />}
children={
<>
<FieldsDropdown value={newType} onChange={setType} />
{getFieldProp("dataType", column.type) !==
getFieldProp("dataType", newType) && (
<Alert severity="warning">
<AlertTitle>Potential data loss</AlertTitle>
{getFieldProp("name", newType)} has an incompatible data type.
Selecting this can result in data loss.
</Alert>
)}
</>
}
actions={{
primary: {
onClick: () => {