PromucFlow_constructor/app/client/src/selectors/actionSelectors.tsx
arunvjn af9e89d2a1
chore: remove xml parser v3 as a default library (#28012)
## Description
Contains the changes to remove fast-xml-parserV3.17.5 as a default
library and migrate all existing apps to install it as a custom JS
library on page load. Installations no longer fail when there is a
naming collision, we determine a unique accessor that can work inside
the application both for UMD & ESM builds.

#### PR fixes following issue(s)
Fixes https://github.com/appsmithorg/appsmith-ee/issues/2562
Fixes https://github.com/appsmithorg/appsmith-ee/issues/2563
Fixes https://github.com/appsmithorg/appsmith-ee/issues/2073
Fixes https://github.com/appsmithorg/appsmith-ee/issues/2403

#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)
>

## Testing
>
#### How Has This Been Tested?
- [x] Manual
- [x] JUnit
- [x] Jest
- [x] Cypress
>
>
#### Test Plan
https://github.com/appsmithorg/TestSmith/issues/2536
Scenarios for existing apps will be tested post-merge since DP's are
created with fresh DB that don't have release data
>
>
#### Issues raised during DP testing

https://github.com/appsmithorg/appsmith/pull/28012#issuecomment-1767711382
response:
https://github.com/appsmithorg/appsmith/pull/28012#issuecomment-1767781029
>
>
>
## Checklist:
#### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [x] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [x] 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
- [x] 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
- [x] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed

---------

Co-authored-by: manish kumar <manish@appsmith.com>
Co-authored-by: Manish Kumar <107841575+sondermanish@users.noreply.github.com>
2023-10-20 11:08:47 +05:30

79 lines
2.2 KiB
TypeScript

import type { DataTree } from "entities/DataTree/dataTreeTypes";
import { createSelector } from "reselect";
import WidgetFactory from "WidgetProvider/factory";
import type { FlattenedWidgetProps } from "WidgetProvider/constants";
import type { JSLibrary } from "workers/common/JSLibrary";
import { getDataTree } from "./dataTreeSelectors";
import {
getExistingPageNames,
selectInstalledLibraries,
} from "@appsmith/selectors/entitiesSelector";
import {
getErrorForApiName,
getErrorForJSObjectName,
getIsSavingForApiName,
getIsSavingForJSObjectName,
} from "./ui";
import { getParentWidget } from "./widgetSelectors";
/**
* Selector to return names that are already taken by other api, js objects, pagenames etc.
*/
export const getUsedActionNames = createSelector(
getExistingPageNames,
getDataTree,
getParentWidget,
selectInstalledLibraries,
(
pageNames: Record<string, any>,
dataTree: DataTree,
parentWidget: FlattenedWidgetProps | undefined,
installedLibraries: JSLibrary[],
) => {
const map: Record<string, boolean> = {};
// The logic has been copied from Explorer/Entity/Name.tsx Component.
// Todo(abhinav): abstraction leak
if (
parentWidget &&
parentWidget.type === WidgetFactory.widgetTypes.TABS_WIDGET
) {
Object.values(parentWidget.tabsObj).forEach((tab: any) => {
map[tab.label] = true;
});
} else {
pageNames.forEach((pageName: string) => {
map[pageName] = true;
});
Object.keys(dataTree).forEach((treeItem: string) => {
map[treeItem] = true;
});
const libAccessors = ([] as string[]).concat(
...installedLibraries.map((lib) => lib.accessor),
);
for (const accessor of libAccessors) {
map[accessor] = true;
}
}
return map;
},
);
export const getSavingStatusForActionName = createSelector(
getIsSavingForApiName,
getErrorForApiName,
(isSaving: boolean, error: boolean) => ({
isSaving,
error,
}),
);
export const getSavingStatusForJSObjectName = createSelector(
getIsSavingForJSObjectName,
getErrorForJSObjectName,
(isSaving: boolean, error: boolean) => ({
isSaving,
error,
}),
);