## Description combining currentActions has failed unit test case in EE hence removing and creating new ones for modules #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
168 lines
4.8 KiB
TypeScript
168 lines
4.8 KiB
TypeScript
import { createSelector } from "reselect";
|
|
import {
|
|
getCurrentActions,
|
|
getAppData,
|
|
getPluginDependencyConfig,
|
|
getPluginEditorConfigs,
|
|
getCurrentJSCollections,
|
|
getInputsForModule,
|
|
getModuleInstances,
|
|
getModuleInstanceEntities,
|
|
getCurrentModuleActions,
|
|
getCurrentModuleJSCollections,
|
|
} from "@appsmith/selectors/entitiesSelector";
|
|
import type { WidgetEntity } from "@appsmith/entities/DataTree/types";
|
|
import type { DataTree } from "entities/DataTree/dataTreeTypes";
|
|
import { DataTreeFactory } from "entities/DataTree/dataTreeFactory";
|
|
import {
|
|
getIsMobileBreakPoint,
|
|
getMetaWidgets,
|
|
getWidgetsForEval,
|
|
getWidgetsMeta,
|
|
} from "sagas/selectors";
|
|
import "url-search-params-polyfill";
|
|
import { getPageList } from "./appViewSelectors";
|
|
import type { AppState } from "@appsmith/reducers";
|
|
import { getSelectedAppThemeProperties } from "./appThemingSelectors";
|
|
import type { LoadingEntitiesState } from "reducers/evaluationReducers/loadingEntitiesReducer";
|
|
import _, { get } from "lodash";
|
|
import type { EvaluationError } from "utils/DynamicBindingUtils";
|
|
import { getEvalErrorPath } from "utils/DynamicBindingUtils";
|
|
import ConfigTreeActions from "utils/configTree";
|
|
import { DATATREE_INTERNAL_KEYWORDS } from "constants/WidgetValidation";
|
|
import { getLayoutSystemType } from "./layoutSystemSelectors";
|
|
|
|
export const getLoadingEntities = (state: AppState) =>
|
|
state.evaluations.loadingEntities;
|
|
|
|
/**
|
|
* This selector is created to combine a couple of data points required by getUnevaluatedDataTree selector.
|
|
* Current version of reselect package only allows upto 12 arguments. Hence, this workaround.
|
|
* TODO: Figure out a better way to do this in a separate task. Or update the package if possible.
|
|
*/
|
|
const getLayoutSystemPayload = createSelector(
|
|
getLayoutSystemType,
|
|
getIsMobileBreakPoint,
|
|
(layoutSystemType, isMobile) => {
|
|
return {
|
|
layoutSystemType,
|
|
isMobile,
|
|
};
|
|
},
|
|
);
|
|
|
|
const getCurrentActionEntities = createSelector(
|
|
getCurrentActions,
|
|
getCurrentModuleActions,
|
|
getCurrentJSCollections,
|
|
getCurrentModuleJSCollections,
|
|
(actions, moduleActions, jsActions, moduleJSActions) => {
|
|
return {
|
|
actions: [...actions, ...moduleActions],
|
|
jsActions: [...jsActions, ...moduleJSActions],
|
|
};
|
|
},
|
|
);
|
|
|
|
const getModulesData = createSelector(
|
|
getInputsForModule,
|
|
getModuleInstances,
|
|
getModuleInstanceEntities,
|
|
(moduleInputs, moduleInstances, moduleInstanceEntities) => {
|
|
return {
|
|
moduleInputs: moduleInputs,
|
|
moduleInstances: moduleInstances,
|
|
moduleInstanceEntities: moduleInstanceEntities,
|
|
};
|
|
},
|
|
);
|
|
|
|
export const getUnevaluatedDataTree = createSelector(
|
|
getCurrentActionEntities,
|
|
getWidgetsForEval,
|
|
getWidgetsMeta,
|
|
getPageList,
|
|
getAppData,
|
|
getPluginEditorConfigs,
|
|
getPluginDependencyConfig,
|
|
getSelectedAppThemeProperties,
|
|
getMetaWidgets,
|
|
getLayoutSystemPayload,
|
|
getLoadingEntities,
|
|
getModulesData,
|
|
(
|
|
currentActionEntities,
|
|
widgets,
|
|
widgetsMeta,
|
|
pageListPayload,
|
|
appData,
|
|
editorConfigs,
|
|
pluginDependencyConfig,
|
|
selectedAppThemeProperty,
|
|
metaWidgets,
|
|
layoutSystemPayload,
|
|
loadingEntities,
|
|
modulesData,
|
|
) => {
|
|
const pageList = pageListPayload || [];
|
|
return DataTreeFactory.create({
|
|
...currentActionEntities,
|
|
widgets,
|
|
widgetsMeta,
|
|
pageList,
|
|
appData,
|
|
editorConfigs,
|
|
pluginDependencyConfig,
|
|
theme: selectedAppThemeProperty,
|
|
metaWidgets,
|
|
loadingEntities,
|
|
...layoutSystemPayload,
|
|
...modulesData,
|
|
});
|
|
},
|
|
);
|
|
|
|
export const getEvaluationInverseDependencyMap = (state: AppState) =>
|
|
state.evaluations.dependencies.inverseDependencyMap;
|
|
|
|
export const getIsWidgetLoading = createSelector(
|
|
[getLoadingEntities, (_state: AppState, widgetName: string) => widgetName],
|
|
(loadingEntities: LoadingEntitiesState, widgetName: string) =>
|
|
loadingEntities.has(widgetName),
|
|
);
|
|
|
|
/**
|
|
* returns evaluation tree object
|
|
*
|
|
* @param state
|
|
*/
|
|
export const getDataTree = (state: AppState): DataTree =>
|
|
state.evaluations.tree;
|
|
|
|
export const getConfigTree = (): any => {
|
|
return ConfigTreeActions.getConfigTree();
|
|
};
|
|
|
|
export const getWidgetEvalValues = createSelector(
|
|
[getDataTree, (_state: AppState, widgetName: string) => widgetName],
|
|
(tree: DataTree, widgetName: string) => tree[widgetName] as WidgetEntity,
|
|
);
|
|
|
|
// For autocomplete. Use actions cached responses if
|
|
// there isn't a response already
|
|
export const getDataTreeForAutocomplete = createSelector(
|
|
getDataTree,
|
|
(tree: DataTree) => {
|
|
return _.omit(tree, Object.keys(DATATREE_INTERNAL_KEYWORDS));
|
|
},
|
|
);
|
|
|
|
export const getPathEvalErrors = createSelector(
|
|
[
|
|
getDataTreeForAutocomplete,
|
|
(_: unknown, dataTreePath: string) => dataTreePath,
|
|
],
|
|
(dataTree: DataTree, dataTreePath: string) =>
|
|
get(dataTree, getEvalErrorPath(dataTreePath), []) as EvaluationError[],
|
|
);
|