mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-28 16:06:41 +01:00
better error message
This commit is contained in:
@@ -97,7 +97,15 @@ export function useMenuAction(
|
||||
const handlePaste = useCallback(async () => {
|
||||
try {
|
||||
if (!selectedCell || !selectedCol) return;
|
||||
const text = await navigator.clipboard.readText();
|
||||
let text;
|
||||
try {
|
||||
text = await navigator.clipboard.readText();
|
||||
} catch (e) {
|
||||
enqueueSnackbar(`Read clilboard permission denied.`, {
|
||||
variant: "error",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const cellDataType = getFieldProp("dataType", getFieldType(selectedCol));
|
||||
let parsed;
|
||||
switch (cellDataType) {
|
||||
@@ -118,7 +126,10 @@ export function useMenuAction(
|
||||
value: parsed,
|
||||
});
|
||||
} catch (error) {
|
||||
enqueueSnackbar(`Failed to paste: ${error}`, { variant: "error" });
|
||||
enqueueSnackbar(
|
||||
`${selectedCol?.type} field does not support the data type being pasted`,
|
||||
{ variant: "error" }
|
||||
);
|
||||
}
|
||||
if (handleClose) handleClose();
|
||||
}, [selectedCell, selectedCol, updateField, enqueueSnackbar, handleClose]);
|
||||
@@ -141,9 +152,12 @@ export function useMenuAction(
|
||||
if (enableAction) {
|
||||
return func();
|
||||
} else {
|
||||
enqueueSnackbar(`Simple copy not supported with this type.`, {
|
||||
variant: "info",
|
||||
});
|
||||
enqueueSnackbar(
|
||||
`${selectedCol?.type} field cannot be copied using keyboard shortcut`,
|
||||
{
|
||||
variant: "info",
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user