mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
TypeChangeModal: add potential data loss warning
This commit is contained in:
@@ -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: () => {
|
||||
|
||||
Reference in New Issue
Block a user