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

56 lines
1.6 KiB
TypeScript
Raw Normal View History

2019-11-25 05:07:27 +00:00
import { createReducer } from "utils/AppsmithUtils";
import { WidgetProps } from "widgets/BaseWidget";
import { ContainerWidgetProps } from "widgets/ContainerWidget";
import {
ReduxAction,
ReduxActionTypes,
PageListPayload,
2019-11-25 05:07:27 +00:00
} from "constants/ReduxActionConstants";
import { FetchPublishedPageSuccessPayload } from "actions/pageActions";
const initialState: AppViewReduxState = {
isFetchingPage: false,
2020-01-24 09:54:40 +00:00
initialized: false,
pages: [],
pageWidgetId: "0",
};
const appViewReducer = createReducer(initialState, {
[ReduxActionTypes.INITIALIZE_PAGE_VIEWER]: (state: AppViewReduxState) => {
2020-01-24 09:54:40 +00:00
return { ...state, initialized: false };
},
[ReduxActionTypes.INITIALIZE_PAGE_VIEWER_SUCCESS]: (
state: AppViewReduxState,
) => {
return { ...state, initialized: true };
},
[ReduxActionTypes.FETCH_PUBLISHED_PAGE_INIT]: (state: AppViewReduxState) => {
2019-11-06 06:21:56 +00:00
return { ...state, dsl: undefined, isFetchingPage: true };
},
[ReduxActionTypes.FETCH_PUBLISHED_PAGE_ERROR]: (state: AppViewReduxState) => {
return { ...state, isFetchingPage: false };
},
[ReduxActionTypes.FETCH_PUBLISHED_PAGE_SUCCESS]: (
state: AppViewReduxState,
action: ReduxAction<FetchPublishedPageSuccessPayload>,
) => {
return {
2020-01-24 09:54:40 +00:00
...state,
dsl: action.payload.dsl,
isFetchingPage: false,
pageWidgetId: action.payload.pageWidgetId,
};
},
});
export interface AppViewReduxState {
2020-01-24 09:54:40 +00:00
initialized: boolean;
dsl?: ContainerWidgetProps<WidgetProps>;
isFetchingPage: boolean;
currentLayoutId?: string;
pages: PageListPayload;
pageWidgetId: string;
}
export default appViewReducer;