appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
32.64k stars 3.55k forks source link

[Task]: Converge selectors used by property pane and entity selector #9850

Open nidhi-nair opened 2 years ago

nidhi-nair commented 2 years ago

Is there an existing issue for this?

SubTasks

The two files below seem to have redundant selectors: app/client/src/selectors/widgetSelectors.ts app/client/src/sagas/selectors.tsx

rohan-arthur commented 2 months ago

From chatgpt:

Here is the complete list of redundant selectors found in both widgetSelectors.ts and selectors.tsx:

Redundant Selectors

  1. getExistingWidgetNames

    • Defined in both widgetSelectors.ts and selectors.tsx.
  2. getFocusedWidget

    • Defined in both widgetSelectors.ts and selectors.tsx.
  3. getWidgets

    • Defined in both widgetSelectors.ts and selectors.tsx.

Details

1. getExistingWidgetNames

widgetSelectors.ts import { getExistingWidgetNames } from "sagas/selectors"; // ... export const getExistingWidgetNames = createSelector( getWidgets, (widgets: { [widgetId: string]: FlattenedWidgetProps }) => { return Object.values(widgets).map((widget) => widget.widgetName); }, );

selectors.tsx export const getExistingWidgetNames = createSelector( getWidgets, (widgets: { [widgetId: string]: FlattenedWidgetProps }) => { return Object.values(widgets).map((widget) => widget.widgetName); }, );

2. getFocusedWidget

widgetSelectors.ts const getCanvasWidgets = (state: AppState) => state.entities.canvasWidgets;

selectors.tsx export const getWidgets = (state: AppState): CanvasWidgetsReduxState => { return state.entities.canvasWidgets; };

3. Solution

To resolve these redundancies, you should keep the selectors in one file and remove or refactor them in the other. Here is an example of what you can do:

•   Decide which file should be the primary source for these selectors.
•   Remove or refactor the redundant selectors in the other file.
•   Ensure that any imports or usages of these selectors are updated accordingly to avoid referencing the removed definitions.