From f6cfe32bc733247d29e9563d47d962a7e2f42ffe Mon Sep 17 00:00:00 2001 From: rahulramesha <71900764+rahulramesha@users.noreply.github.com> Date: Mon, 13 Jun 2022 11:31:25 +0530 Subject: [PATCH] chore: remove addChildrenSaga dead code and it's associated redux actions (#14425) --- .../src/ce/constants/ReduxActionConstants.tsx | 2 - app/client/src/sagas/WidgetAdditionSagas.ts | 60 +------------------ 2 files changed, 1 insertion(+), 61 deletions(-) diff --git a/app/client/src/ce/constants/ReduxActionConstants.tsx b/app/client/src/ce/constants/ReduxActionConstants.tsx index 792cdbfe0c..f36ce8ff40 100644 --- a/app/client/src/ce/constants/ReduxActionConstants.tsx +++ b/app/client/src/ce/constants/ReduxActionConstants.tsx @@ -867,7 +867,6 @@ export const ReduxActionErrorTypes = { TOGGLE_ACTION_EXECUTE_ON_LOAD_ERROR: "TOGGLE_ACTION_EXECUTE_ON_LOAD_ERROR", COPY_SELECTED_WIDGET_ERROR: "COPY_SELECTED_WIDGET_ERROR", PASTE_COPIED_WIDGET_ERROR: "PASTE_COPIED_WIDGET_ERROR", - WIDGET_ADD_CHILDREN_ERROR: "WIDGET_ADD_CHILDREN_ERROR", FAILED_CORRECTING_BINDING_PATHS: "FAILED_CORRECTING_BINDING_PATHS", CREATE_JS_ACTION_ERROR: "CREATE_JS_ACTION_ERROR", UPDATE_JS_ACTION_ERROR: "UPDATE_JS_ACTION_ERROR", @@ -931,7 +930,6 @@ export const WidgetReduxActionTypes: { [key: string]: string } = { WIDGET_DELETE: "WIDGET_DELETE", WIDGET_BULK_DELETE: "WIDGET_BULK_DELETE", WIDGET_SINGLE_DELETE: "WIDGET_SINGLE_DELETE", - WIDGET_ADD_CHILDREN: "WIDGET_ADD_CHILDREN", WIDGET_UPDATE_PROPERTY: "WIDGET_UPDATE_PROPERTY", }; diff --git a/app/client/src/sagas/WidgetAdditionSagas.ts b/app/client/src/sagas/WidgetAdditionSagas.ts index 895edd9bec..8e470c9577 100644 --- a/app/client/src/sagas/WidgetAdditionSagas.ts +++ b/app/client/src/sagas/WidgetAdditionSagas.ts @@ -1,8 +1,4 @@ -import { - updateAndSaveLayout, - WidgetAddChild, - WidgetAddChildren, -} from "actions/pageActions"; +import { updateAndSaveLayout, WidgetAddChild } from "actions/pageActions"; import { Toaster } from "components/ads/Toast"; import { ReduxAction, @@ -340,59 +336,6 @@ export function* addChildSaga(addChildAction: ReduxAction) { } } -// This is different from addChildSaga -// It does not go through the blueprint based creation -// It simply uses the provided widget props to create widgets -// Use this only when we're 100% sure of all the props the children will need -export function* addChildrenSaga( - addChildrenAction: ReduxAction, -) { - try { - const { children, widgetId } = addChildrenAction.payload; - const stateWidgets = yield select(getWidgets); - const widgets = { ...stateWidgets }; - const widgetNames = Object.keys(widgets).map((w) => widgets[w].widgetName); - const entityNames = yield call(getEntityNames); - - children.forEach((child) => { - // Create only if it doesn't already exist - if (!widgets[child.widgetId]) { - const defaultConfig: any = WidgetFactory.widgetConfigMap.get( - child.type, - ); - const newWidgetName = getNextEntityName(defaultConfig.widgetName, [ - ...widgetNames, - ...entityNames, - ]); - // update the list of widget names for the next iteration - widgetNames.push(newWidgetName); - widgets[child.widgetId] = { - ...child, - widgetName: newWidgetName, - renderMode: RenderModes.CANVAS, - }; - - const existingChildren = widgets[widgetId].children || []; - - widgets[widgetId] = { - ...widgets[widgetId], - children: [...existingChildren, child.widgetId], - }; - } - }); - - yield put(updateAndSaveLayout(widgets)); - } catch (error) { - yield put({ - type: ReduxActionErrorTypes.WIDGET_OPERATION_ERROR, - payload: { - action: WidgetReduxActionTypes.WIDGET_ADD_CHILDREN, - error, - }, - }); - } -} - const getChildTabData = ( tabProps: WidgetProps, tab: { @@ -469,7 +412,6 @@ function* addNewTabChildSaga( export default function* widgetAdditionSagas() { yield all([ takeEvery(WidgetReduxActionTypes.WIDGET_ADD_CHILD, addChildSaga), - takeEvery(WidgetReduxActionTypes.WIDGET_ADD_CHILDREN, addChildrenSaga), takeEvery(ReduxActionTypes.WIDGET_ADD_NEW_TAB_CHILD, addNewTabChildSaga), ]); }