Merge branch 'develop' of https://github.com/rowyio/rowy into develop

This commit is contained in:
Sidney Alcantara
2021-12-17 18:02:54 +11:00
3 changed files with 40 additions and 24 deletions

View File

@@ -15,6 +15,7 @@ import { useConfirmation } from "@src/components/ConfirmationDialog";
import { useSnackLogContext } from "@src/contexts/SnackLogContext";
import { FieldType } from "@src/constants/fields";
import { runRoutes } from "@src/constants/runRoutes";
import { useSnackbar } from "notistack";
export default function FieldSettings(props: IMenuModalProps) {
const { name, fieldName, type, open, config, handleClose, handleSave } =
@@ -27,6 +28,7 @@ export default function FieldSettings(props: IMenuModalProps) {
const initializable = getFieldProp("initializable", type);
const { requestConfirmation } = useConfirmation();
const { enqueueSnackbar } = useSnackbar();
const { tableState, rowyRun } = useProjectContext();
const snackLogContext = useSnackLogContext();
@@ -157,29 +159,34 @@ export default function FieldSettings(props: IMenuModalProps) {
});
return;
}
if (showRebuildPrompt) {
requestConfirmation({
title: "Deploy changes",
body: "You have made changes that affect the behavior of the cloud function of this table, Would you like to redeploy it now?",
confirm: "Deploy",
cancel: "Later",
handleConfirm: async () => {
if (!rowyRun) return;
snackLogContext.requestSnackLog();
rowyRun({
route: runRoutes.buildFunction,
body: {
tablePath: tableState?.tablePath,
pathname: window.location.pathname,
tableConfigPath: tableState?.config.tableConfig.path,
},
params: [],
});
},
enqueueSnackbar("Saving changes...", {
autoHideDuration: 1500,
});
handleSave(fieldName, { config: newConfig }, () => {
requestConfirmation({
title: "Deploy changes",
body: "You have made changes that affect the behavior of the cloud function of this table, Would you like to redeploy it now?",
confirm: "Deploy",
cancel: "Later",
handleConfirm: async () => {
if (!rowyRun) return;
snackLogContext.requestSnackLog();
rowyRun({
route: runRoutes.buildFunction,
body: {
tablePath: tableState?.tablePath,
pathname: window.location.pathname,
tableConfigPath: tableState?.config.tableConfig.path,
},
});
},
});
});
} else {
handleSave(fieldName, { config: newConfig });
}
handleSave(fieldName, { config: newConfig });
handleClose();
setShowRebuildPrompt(false);
},

View File

@@ -67,7 +67,11 @@ export interface IMenuModalProps {
config: Record<string, any>;
handleClose: () => void;
handleSave: (fieldName: string, config: Record<string, any>) => void;
handleSave: (
fieldName: string,
config: Record<string, any>,
onSuccess?: Function
) => void;
}
export default function ColumnMenu() {
@@ -125,8 +129,12 @@ export default function ColumnMenu() {
setTimeout(() => handleClose(), 300);
};
const handleModalSave = (key: string, update: Record<string, any>) => {
actions.update(key, update);
const handleModalSave = (
key: string,
update: Record<string, any>,
onSuccess?: Function
) => {
actions.update(key, update, onSuccess);
};
const openSettings = (column) => {
setSelectedColumnHeader({

View File

@@ -99,7 +99,7 @@ const useTableConfig = (tablePath?: string) => {
* @param index of column.
* @param {updatable[]} updatables properties to be updated
*/
const updateColumn = (key: string, updates: any) => {
const updateColumn = (key: string, updates: any, onSuccess?: Function) => {
const { columns } = tableConfigState;
const updatedColumns = {
@@ -110,6 +110,7 @@ const useTableConfig = (tablePath?: string) => {
documentDispatch({
action: DocActions.update,
data: { columns: updatedColumns },
callback: onSuccess,
});
};
/** remove column by index