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

217 lines
6.4 KiB
TypeScript
Raw Normal View History

2019-11-25 05:07:27 +00:00
import { createReducer } from "utils/AppsmithUtils";
import {
2019-12-16 08:49:10 +00:00
ReduxAction,
UpdateCanvasPayload,
ReduxActionTypes,
ReduxActionErrorTypes,
2019-11-25 05:07:27 +00:00
} from "constants/ReduxActionConstants";
import moment from "moment";
import { PageAction } from "constants/AppsmithActionConstants/ActionConstants";
[Feature] new nav sniping mode (#5746) * added sniping mode toggle option to header * added cover to components on hover in sniping mode * fixed the transition time * using filled icon * Show dependencies in action pane * Added a wrapper to make a widget snipeable * removed older parts of sniping from Positioned Container * removed onclick action from snipeable wrapper * Showing widget name in different color * Added a mechanism to send user to sniping mode from successful API screen * created new property pane saga to bind the data * Fix datasource list width issue * Fix sidebar going out of view when the response is a table * Minor refactor * Show add widgets section on the sidebar * Stop showing autocomplete option after adding a widget * fetching pageId, appId from store * Get suggested widget from response * Fix table data not getting evaluated after adding binding * Fix property pane going below the entity explorer while navigating from query/api pane * Fix width of sidepane shifting for apis * Fix vertical margins of connections * Fix api pane suggested widget showing up for errors * Fix margins * can show select in canvas btn in sidebar * can get the action object at the end to bind the data * updated saga and action names * can bind data to table * Use themes * Use new image url for Table widget * Added conditional mapping for sniping mode binding. * updated the widget name tags and seq of calls to open property pane * pushed all sniping mode decoration to header * moved setting sniping mode logic to editor reducer * Added keyboard short cut to get out of sniping mode * updated reset sniping mechanism * removed a divider line * if there are no relationships, will not show the complete section * Connect Data will automatically show relevant tab in integrations * Update list and dropdown image urls * Remove create table button * no wrapping bind to text * minor review considerations * showing the widget name to left in sniping mode * can set data to datepicker * will not show snipe btn if there are no widgets in canvas * Changes for multiple suggested widgets * removed dependency of sniping from suggested widgets * Added analytics events for sniping mode * logic for binding data to a widget, moved to snipeable component * changed binding widget func from capture to onClick and took care of sniping from widget wrapper too. * added tests to check sniping mode for table * updated test spec * minor fix * Fix copy changes * Update test to use table widget from suggested widget list * if fails to bind will generate warning and keep user in sniping mode * in sniping mode will only show name plate if it is under focus * fixed the test case * added a comment * minor fix to capture on click event in sniping mode * updated text * Hide connections UI when there are no connections * Increase width to 90% * Show placeholder text and back button in sidepane * Show tooltip on hover * Add analyitcs events for suggested widgets and connections * Update label based on whether widgets are there or not * binding related changes * renamed the saga file containing sinping mode sagas * Changes for inspect entity * Revert "binding related changes" temporarily This reverts commit 54ae9667fecf24bc3cf9912a5356d06600b25c84. * Update suggested widgets url * Update table url * Fix chart data field not getting evaluated * a minor fix to show proper tool tip when user hovers on widget name * Show sidepane when there is output * Update locators * Use constants for messages * Update file name to ApiRightPane * Remove delay * Revert "Revert "binding related changes" temporarily" This reverts commit ee7f75e83218137250b4b9a28fcf63080c185150. * Fix width * Fix overlap Co-authored-by: Akash N <akash@codemonk.in>
2021-07-26 16:44:10 +00:00
import { CommentsReduxState } from "./commentsReducer/interfaces";
2019-09-27 16:05:33 +00:00
const initialState: EditorReduxState = {
2020-01-24 09:54:40 +00:00
initialized: false,
loadingStates: {
publishing: false,
publishingError: false,
saving: false,
savingError: false,
loading: false,
loadingError: false,
pageSwitchingError: false,
isPageSwitching: false,
2020-01-27 08:24:58 +00:00
creatingPage: false,
creatingPageError: false,
cloningPage: false,
cloningPageError: false,
2020-02-21 12:16:49 +00:00
updatingWidgetName: false,
updateWidgetNameError: false,
},
[Feature] new nav sniping mode (#5746) * added sniping mode toggle option to header * added cover to components on hover in sniping mode * fixed the transition time * using filled icon * Show dependencies in action pane * Added a wrapper to make a widget snipeable * removed older parts of sniping from Positioned Container * removed onclick action from snipeable wrapper * Showing widget name in different color * Added a mechanism to send user to sniping mode from successful API screen * created new property pane saga to bind the data * Fix datasource list width issue * Fix sidebar going out of view when the response is a table * Minor refactor * Show add widgets section on the sidebar * Stop showing autocomplete option after adding a widget * fetching pageId, appId from store * Get suggested widget from response * Fix table data not getting evaluated after adding binding * Fix property pane going below the entity explorer while navigating from query/api pane * Fix width of sidepane shifting for apis * Fix vertical margins of connections * Fix api pane suggested widget showing up for errors * Fix margins * can show select in canvas btn in sidebar * can get the action object at the end to bind the data * updated saga and action names * can bind data to table * Use themes * Use new image url for Table widget * Added conditional mapping for sniping mode binding. * updated the widget name tags and seq of calls to open property pane * pushed all sniping mode decoration to header * moved setting sniping mode logic to editor reducer * Added keyboard short cut to get out of sniping mode * updated reset sniping mechanism * removed a divider line * if there are no relationships, will not show the complete section * Connect Data will automatically show relevant tab in integrations * Update list and dropdown image urls * Remove create table button * no wrapping bind to text * minor review considerations * showing the widget name to left in sniping mode * can set data to datepicker * will not show snipe btn if there are no widgets in canvas * Changes for multiple suggested widgets * removed dependency of sniping from suggested widgets * Added analytics events for sniping mode * logic for binding data to a widget, moved to snipeable component * changed binding widget func from capture to onClick and took care of sniping from widget wrapper too. * added tests to check sniping mode for table * updated test spec * minor fix * Fix copy changes * Update test to use table widget from suggested widget list * if fails to bind will generate warning and keep user in sniping mode * in sniping mode will only show name plate if it is under focus * fixed the test case * added a comment * minor fix to capture on click event in sniping mode * updated text * Hide connections UI when there are no connections * Increase width to 90% * Show placeholder text and back button in sidepane * Show tooltip on hover * Add analyitcs events for suggested widgets and connections * Update label based on whether widgets are there or not * binding related changes * renamed the saga file containing sinping mode sagas * Changes for inspect entity * Revert "binding related changes" temporarily This reverts commit 54ae9667fecf24bc3cf9912a5356d06600b25c84. * Update suggested widgets url * Update table url * Fix chart data field not getting evaluated * a minor fix to show proper tool tip when user hovers on widget name * Show sidepane when there is output * Update locators * Use constants for messages * Update file name to ApiRightPane * Remove delay * Revert "Revert "binding related changes" temporarily" This reverts commit ee7f75e83218137250b4b9a28fcf63080c185150. * Fix width * Fix overlap Co-authored-by: Akash N <akash@codemonk.in>
2021-07-26 16:44:10 +00:00
isSnipingMode: false,
};
2019-08-26 12:41:21 +00:00
const editorReducer = createReducer(initialState, {
2021-03-08 08:24:12 +00:00
[ReduxActionTypes.RESET_EDITOR_SUCCESS]: (state: EditorReduxState) => {
return { ...state, initialized: false };
},
2020-01-24 09:54:40 +00:00
[ReduxActionTypes.INITIALIZE_EDITOR_SUCCESS]: (state: EditorReduxState) => {
return { ...state, initialized: true };
},
[ReduxActionTypes.UPDATE_PAGE_SUCCESS]: (
state: EditorReduxState,
action: ReduxAction<{ id: string; name: string }>,
) => {
if (action.payload.id === state.currentPageId) {
return { ...state, currentPageName: action.payload.name };
}
return state;
},
[ReduxActionTypes.FETCH_PAGE_INIT]: (state: EditorReduxState) => ({
...state,
loadingStates: {
...state.loadingStates,
isPageSwitching: true,
},
}),
[ReduxActionTypes.FETCH_PAGE_SUCCESS]: (state: EditorReduxState) => ({
...state,
loadingStates: {
...state.loadingStates,
isPageSwitching: false,
},
}),
[ReduxActionErrorTypes.FETCH_PAGE_ERROR]: (state: EditorReduxState) => ({
...state,
loadingStates: {
...state.loadingStates,
isPageSwitching: false,
},
}),
[ReduxActionTypes.PUBLISH_APPLICATION_INIT]: (state: EditorReduxState) => {
state.loadingStates.publishing = true;
state.loadingStates.publishingError = false;
return { ...state };
},
[ReduxActionErrorTypes.PUBLISH_APPLICATION_ERROR]: (
state: EditorReduxState,
) => {
state.loadingStates.publishing = false;
state.loadingStates.publishingError = true;
return { ...state };
},
[ReduxActionTypes.PUBLISH_APPLICATION_SUCCESS]: (state: EditorReduxState) => {
state.loadingStates.publishing = false;
state.loadingStates.publishingError = false;
state.loadingStates.published = moment().format();
return { ...state };
},
[ReduxActionTypes.SAVE_PAGE_INIT]: (state: EditorReduxState) => {
state.loadingStates.saving = true;
state.loadingStates.savingError = false;
return { ...state };
},
[ReduxActionTypes.SAVE_PAGE_SUCCESS]: (state: EditorReduxState) => {
state.loadingStates.saving = false;
return { ...state };
},
[ReduxActionErrorTypes.SAVE_PAGE_ERROR]: (state: EditorReduxState) => {
state.loadingStates.saving = false;
state.loadingStates.savingError = true;
return { ...state };
},
[ReduxActionTypes.SET_LAST_UPDATED_TIME]: (
state: EditorReduxState,
actions: ReduxAction<number>,
) => {
return { ...state, lastUpdatedTime: actions.payload };
},
[ReduxActionTypes.INIT_CANVAS_LAYOUT]: (
state: EditorReduxState,
action: ReduxAction<UpdateCanvasPayload>,
) => {
const {
currentApplicationId,
currentLayoutId,
currentPageId,
currentPageName,
pageActions,
pageWidgetId,
} = action.payload;
state.loadingStates.publishing = false;
state.loadingStates.publishingError = false;
return {
...state,
currentPageName,
currentLayoutId,
pageWidgetId,
currentApplicationId,
currentPageId,
pageActions,
};
},
[ReduxActionTypes.CLONE_PAGE_INIT]: (state: EditorReduxState) => {
state.loadingStates.cloningPage = true;
state.loadingStates.cloningPageError = false;
return { ...state };
},
[ReduxActionErrorTypes.CLONE_PAGE_ERROR]: (state: EditorReduxState) => {
state.loadingStates.cloningPageError = true;
state.loadingStates.cloningPage = false;
return { ...state };
},
[ReduxActionTypes.CLONE_PAGE_SUCCESS]: (state: EditorReduxState) => {
state.loadingStates.cloningPage = false;
return { ...state };
},
2020-01-27 08:24:58 +00:00
[ReduxActionTypes.CREATE_PAGE_INIT]: (state: EditorReduxState) => {
state.loadingStates.creatingPage = true;
state.loadingStates.creatingPageError = false;
return { ...state };
},
[ReduxActionErrorTypes.CREATE_PAGE_ERROR]: (state: EditorReduxState) => {
state.loadingStates.creatingPageError = true;
state.loadingStates.creatingPage = false;
return { ...state };
},
[ReduxActionTypes.CREATE_PAGE_SUCCESS]: (state: EditorReduxState) => {
state.loadingStates.creatingPage = false;
return { ...state };
},
2020-02-21 12:16:49 +00:00
[ReduxActionTypes.UPDATE_WIDGET_NAME_INIT]: (state: EditorReduxState) => {
state.loadingStates.updatingWidgetName = true;
state.loadingStates.updateWidgetNameError = false;
return { ...state };
},
[ReduxActionTypes.UPDATE_WIDGET_NAME_SUCCESS]: (state: EditorReduxState) => {
state.loadingStates.updatingWidgetName = false;
state.loadingStates.updateWidgetNameError = false;
return { ...state };
},
[ReduxActionErrorTypes.UPDATE_WIDGET_NAME_ERROR]: (
state: EditorReduxState,
) => {
state.loadingStates.updatingWidgetName = false;
state.loadingStates.updateWidgetNameError = true;
return { ...state };
},
[Feature] new nav sniping mode (#5746) * added sniping mode toggle option to header * added cover to components on hover in sniping mode * fixed the transition time * using filled icon * Show dependencies in action pane * Added a wrapper to make a widget snipeable * removed older parts of sniping from Positioned Container * removed onclick action from snipeable wrapper * Showing widget name in different color * Added a mechanism to send user to sniping mode from successful API screen * created new property pane saga to bind the data * Fix datasource list width issue * Fix sidebar going out of view when the response is a table * Minor refactor * Show add widgets section on the sidebar * Stop showing autocomplete option after adding a widget * fetching pageId, appId from store * Get suggested widget from response * Fix table data not getting evaluated after adding binding * Fix property pane going below the entity explorer while navigating from query/api pane * Fix width of sidepane shifting for apis * Fix vertical margins of connections * Fix api pane suggested widget showing up for errors * Fix margins * can show select in canvas btn in sidebar * can get the action object at the end to bind the data * updated saga and action names * can bind data to table * Use themes * Use new image url for Table widget * Added conditional mapping for sniping mode binding. * updated the widget name tags and seq of calls to open property pane * pushed all sniping mode decoration to header * moved setting sniping mode logic to editor reducer * Added keyboard short cut to get out of sniping mode * updated reset sniping mechanism * removed a divider line * if there are no relationships, will not show the complete section * Connect Data will automatically show relevant tab in integrations * Update list and dropdown image urls * Remove create table button * no wrapping bind to text * minor review considerations * showing the widget name to left in sniping mode * can set data to datepicker * will not show snipe btn if there are no widgets in canvas * Changes for multiple suggested widgets * removed dependency of sniping from suggested widgets * Added analytics events for sniping mode * logic for binding data to a widget, moved to snipeable component * changed binding widget func from capture to onClick and took care of sniping from widget wrapper too. * added tests to check sniping mode for table * updated test spec * minor fix * Fix copy changes * Update test to use table widget from suggested widget list * if fails to bind will generate warning and keep user in sniping mode * in sniping mode will only show name plate if it is under focus * fixed the test case * added a comment * minor fix to capture on click event in sniping mode * updated text * Hide connections UI when there are no connections * Increase width to 90% * Show placeholder text and back button in sidepane * Show tooltip on hover * Add analyitcs events for suggested widgets and connections * Update label based on whether widgets are there or not * binding related changes * renamed the saga file containing sinping mode sagas * Changes for inspect entity * Revert "binding related changes" temporarily This reverts commit 54ae9667fecf24bc3cf9912a5356d06600b25c84. * Update suggested widgets url * Update table url * Fix chart data field not getting evaluated * a minor fix to show proper tool tip when user hovers on widget name * Show sidepane when there is output * Update locators * Use constants for messages * Update file name to ApiRightPane * Remove delay * Revert "Revert "binding related changes" temporarily" This reverts commit ee7f75e83218137250b4b9a28fcf63080c185150. * Fix width * Fix overlap Co-authored-by: Akash N <akash@codemonk.in>
2021-07-26 16:44:10 +00:00
[ReduxActionTypes.SET_SNIPING_MODE]: (
state: CommentsReduxState,
action: ReduxAction<boolean>,
) => {
return {
...state,
isSnipingMode: action.payload,
};
},
});
2019-08-26 12:41:21 +00:00
export interface EditorReduxState {
2020-01-24 09:54:40 +00:00
initialized: boolean;
pageWidgetId?: string;
currentLayoutId?: string;
currentPageName?: string;
currentPageId?: string;
lastUpdatedTime?: number;
pageActions?: PageAction[][];
[Feature] new nav sniping mode (#5746) * added sniping mode toggle option to header * added cover to components on hover in sniping mode * fixed the transition time * using filled icon * Show dependencies in action pane * Added a wrapper to make a widget snipeable * removed older parts of sniping from Positioned Container * removed onclick action from snipeable wrapper * Showing widget name in different color * Added a mechanism to send user to sniping mode from successful API screen * created new property pane saga to bind the data * Fix datasource list width issue * Fix sidebar going out of view when the response is a table * Minor refactor * Show add widgets section on the sidebar * Stop showing autocomplete option after adding a widget * fetching pageId, appId from store * Get suggested widget from response * Fix table data not getting evaluated after adding binding * Fix property pane going below the entity explorer while navigating from query/api pane * Fix width of sidepane shifting for apis * Fix vertical margins of connections * Fix api pane suggested widget showing up for errors * Fix margins * can show select in canvas btn in sidebar * can get the action object at the end to bind the data * updated saga and action names * can bind data to table * Use themes * Use new image url for Table widget * Added conditional mapping for sniping mode binding. * updated the widget name tags and seq of calls to open property pane * pushed all sniping mode decoration to header * moved setting sniping mode logic to editor reducer * Added keyboard short cut to get out of sniping mode * updated reset sniping mechanism * removed a divider line * if there are no relationships, will not show the complete section * Connect Data will automatically show relevant tab in integrations * Update list and dropdown image urls * Remove create table button * no wrapping bind to text * minor review considerations * showing the widget name to left in sniping mode * can set data to datepicker * will not show snipe btn if there are no widgets in canvas * Changes for multiple suggested widgets * removed dependency of sniping from suggested widgets * Added analytics events for sniping mode * logic for binding data to a widget, moved to snipeable component * changed binding widget func from capture to onClick and took care of sniping from widget wrapper too. * added tests to check sniping mode for table * updated test spec * minor fix * Fix copy changes * Update test to use table widget from suggested widget list * if fails to bind will generate warning and keep user in sniping mode * in sniping mode will only show name plate if it is under focus * fixed the test case * added a comment * minor fix to capture on click event in sniping mode * updated text * Hide connections UI when there are no connections * Increase width to 90% * Show placeholder text and back button in sidepane * Show tooltip on hover * Add analyitcs events for suggested widgets and connections * Update label based on whether widgets are there or not * binding related changes * renamed the saga file containing sinping mode sagas * Changes for inspect entity * Revert "binding related changes" temporarily This reverts commit 54ae9667fecf24bc3cf9912a5356d06600b25c84. * Update suggested widgets url * Update table url * Fix chart data field not getting evaluated * a minor fix to show proper tool tip when user hovers on widget name * Show sidepane when there is output * Update locators * Use constants for messages * Update file name to ApiRightPane * Remove delay * Revert "Revert "binding related changes" temporarily" This reverts commit ee7f75e83218137250b4b9a28fcf63080c185150. * Fix width * Fix overlap Co-authored-by: Akash N <akash@codemonk.in>
2021-07-26 16:44:10 +00:00
isSnipingMode: boolean;
loadingStates: {
saving: boolean;
savingError: boolean;
publishing: boolean;
published?: string;
publishingError: boolean;
loading: boolean;
loadingError: boolean;
isPageSwitching: boolean;
pageSwitchingError: boolean;
2020-01-27 08:24:58 +00:00
creatingPage: boolean;
creatingPageError: boolean;
cloningPage: boolean;
cloningPageError: boolean;
2020-02-21 12:16:49 +00:00
updatingWidgetName: boolean;
updateWidgetNameError: boolean;
};
2019-08-26 12:41:21 +00:00
}
export default editorReducer;