show snackbar while derivative is evaluting

This commit is contained in:
shamsmosowi
2022-03-08 19:07:32 +08:00
parent d80bfa28d6
commit 3a553887f5
2 changed files with 6 additions and 4 deletions

View File

@@ -153,7 +153,6 @@ export default function useMonacoCustomizations({
return;
} else {
const jsonInput = jsonInputForTargetLanguage("typescript");
console.log("jsonInput", jsonInput);
await jsonInput.addSource({
name: interfaceName,
samples,
@@ -196,7 +195,6 @@ export default function useMonacoCustomizations({
const column = columns[columnKey];
const type = getColumnType(column);
if (type === "JSON") {
console.log("adding json field definition");
const interfaceName =
columnKey[0].toUpperCase() + columnKey.slice(1);
addJsonFieldDefinition(columnKey, interfaceName);

View File

@@ -19,7 +19,7 @@ export default function ContextMenuActions(
reset: () => void | Promise<void>
): IContextMenuActions[] {
const { tableState, rowyRun } = useProjectContext();
const { enqueueSnackbar } = useSnackbar();
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const columns = tableState?.columns;
const rows = tableState?.rows;
const selectedRowIndex = selectedCell.rowIndex as number;
@@ -37,6 +37,10 @@ export default function ContextMenuActions(
const handleEvaluate = async () => {
try {
if (!selectedCol || !rowyRun || !selectedRow) return;
handleClose();
const evaluatingSnackKey = enqueueSnackbar("Evaluating...", {
variant: "info",
});
const result = await rowyRun({
route: runRoutes.evaluateDerivative,
body: {
@@ -47,13 +51,13 @@ export default function ContextMenuActions(
columnKey: selectedCol.key,
},
});
closeSnackbar(evaluatingSnackKey);
if (result.success === false) {
enqueueSnackbar(result.message, { variant: "error" });
}
} catch (error) {
enqueueSnackbar(`Failed: ${error}`, { variant: "error" });
}
handleClose();
};
const isEmpty =
cellValue === "" || cellValue === null || cellValue === undefined;