mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
Merge branch 'develop' of https://github.com/rowyio/rowy into develop
This commit is contained in:
@@ -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);
|
||||
},
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user