PromucFlow_constructor/app/client/src/reducers/uiReducers/editorReducer.tsx

47 lines
1.4 KiB
TypeScript
Raw Normal View History

import { createReducer } from "../../utils/AppsmithUtils";
2019-09-26 11:11:28 +00:00
import { getEditorConfigs } from "../../constants/ApiConstants";
2019-08-26 12:41:21 +00:00
import {
ReduxActionTypes,
2019-08-26 12:41:21 +00:00
ReduxAction,
LoadWidgetCardsPanePayload,
} from "../../constants/ReduxActionConstants";
import { WidgetCardProps, WidgetProps } from "../../widgets/BaseWidget";
import { ContainerWidgetProps } from "../../widgets/ContainerWidget";
2019-09-26 11:11:28 +00:00
const editorConfigs = getEditorConfigs();
const initialState: EditorReduxState = {
pageWidgetId: "0",
2019-09-26 11:11:28 +00:00
...editorConfigs,
isSaving: false,
};
2019-08-26 12:41:21 +00:00
const editorReducer = createReducer(initialState, {
[ReduxActionTypes.SUCCESS_FETCHING_WIDGET_CARDS]: (
2019-08-26 12:41:21 +00:00
state: EditorReduxState,
action: ReduxAction<LoadWidgetCardsPanePayload>,
2019-08-26 12:41:21 +00:00
) => {
return { ...state, ...action.payload };
2019-08-26 12:41:21 +00:00
},
[ReduxActionTypes.SAVE_PAGE_INIT]: (state: EditorReduxState) => {
return { ...state, isSaving: true };
},
[ReduxActionTypes.SAVE_PAGE_SUCCESS]: (state: EditorReduxState) => {
return { ...state, isSaving: false };
},
[ReduxActionTypes.SAVE_PAGE_ERROR]: (state: EditorReduxState) => {
return { ...state, isSaving: false };
},
});
2019-08-26 12:41:21 +00:00
export interface EditorReduxState {
dsl?: ContainerWidgetProps<WidgetProps>;
2019-08-26 12:41:21 +00:00
cards?: {
[id: string]: WidgetCardProps[];
2019-09-02 10:58:11 +00:00
};
pageWidgetId: string;
currentPageId: string;
currentLayoutId: string;
isSaving: boolean;
2019-08-26 12:41:21 +00:00
}
export default editorReducer;