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

46 lines
1.3 KiB
TypeScript
Raw Normal View History

import { createReducer } from "../../utils/AppsmithUtils";
2019-08-26 12:41:21 +00:00
import {
ReduxActionTypes,
2019-08-26 12:41:21 +00:00
ReduxAction,
2019-09-13 09:56:11 +00:00
LoadCanvasWidgetsPayload,
LoadWidgetCardsPanePayload,
} from "../../constants/ReduxActionConstants";
import { WidgetCardProps, WidgetProps } from "../../widgets/BaseWidget";
import { ContainerWidgetProps } from "../../widgets/ContainerWidget";
2019-08-26 12:41:21 +00:00
const initialState: EditorReduxState = {
pageWidgetId: "0",
currentPageId: "5d807e76795dc6000482bc76",
currentLayoutId: "5d807e76795dc6000482bc75",
};
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.dsl, ...action.payload };
2019-08-26 12:41:21 +00:00
},
[ReduxActionTypes.ADD_PAGE_WIDGET]: (state: EditorReduxState) => {
return state;
2019-08-26 12:41:21 +00:00
},
[ReduxActionTypes.LOAD_CANVAS_WIDGETS]: (
2019-08-26 12:41:21 +00:00
state: EditorReduxState,
action: ReduxAction<LoadCanvasWidgetsPayload>,
2019-08-26 12:41:21 +00:00
) => {
return { pageWidgetId: action.payload.pageWidgetId };
},
});
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;
2019-08-26 12:41:21 +00:00
}
export default editorReducer;