PromucFlow_constructor/app/client/src/ce/actions/helpers.ts
Ankita Kinger 235122e7e3
chore: Refactoring API wiring for actions and JS actions to support private entity renaming on EE (#29763)
## Description

Refactoring API wiring for actions and JS actions to support private
entity renaming on EE. Also handles a couple of other issues (refer the
issue attached below)

#### PR fixes following issue(s)
Fixes [#29762](https://github.com/appsmithorg/appsmith/issues/29762)

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

## Testing
>
#### How Has This Been Tested?
- [x] Manual
- [ ] JUnit
- [ ] Jest
- [x] Cypress

## 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
- [ ] 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:
- [ ] [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


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Enhanced action and JS object naming capabilities with new
context-aware options.
  - Added support for organizing actions and JS objects within modules.

- **Improvements**
- Streamlined the process of renaming actions and JS objects to be more
intuitive and context-sensitive.

- **Refactor**
- Updated internal type declarations for consistency and future
extensibility.

- **User Interface**
- Improved UI elements to reflect the new naming and organizational
features for actions and JS objects.

- **Bug Fixes**
- Corrected logic to ensure proper handling of the `isPublic` flag
within JS collections.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2023-12-21 10:22:54 +05:30

62 lines
1.8 KiB
TypeScript

import type { EventLocation } from "@appsmith/utils/analyticsUtilTypes";
import {
createNewApiAction,
createNewQueryAction,
} from "actions/apiPaneActions";
import { createNewJSCollection } from "actions/jsPaneActions";
import { ACTION_PARENT_ENTITY_TYPE } from "@appsmith/entities/Engine/actionHelpers";
import { saveActionName } from "actions/pluginActionActions";
import { saveJSObjectName } from "actions/jsActionActions";
export const createNewQueryBasedOnParentEntity = (
entityId: string,
from: EventLocation,
dsId: string,
// Used in EE
// eslint-disable-next-line @typescript-eslint/no-unused-vars
parentEntityType = ACTION_PARENT_ENTITY_TYPE.PAGE,
) => {
return createNewQueryAction(entityId, from, dsId);
};
export const createNewAPIBasedOnParentEntity = (
entityId: string,
from: EventLocation,
apiType?: string,
// Used in EE
// eslint-disable-next-line @typescript-eslint/no-unused-vars
parentEntityType = ACTION_PARENT_ENTITY_TYPE.PAGE,
) => {
return createNewApiAction(entityId, from, apiType);
};
export const createNewJSCollectionBasedOnParentEntity = (
entityId: string,
from: EventLocation,
// Used in EE
// eslint-disable-next-line @typescript-eslint/no-unused-vars
parentEntityType = ACTION_PARENT_ENTITY_TYPE.PAGE,
) => {
return createNewJSCollection(entityId, from);
};
export const saveActionNameBasedOnParentEntity = (
id: string,
name: string,
// Used in EE
// eslint-disable-next-line @typescript-eslint/no-unused-vars
parentEntityType = ACTION_PARENT_ENTITY_TYPE.PAGE,
) => {
return saveActionName({ id, name });
};
export const saveJSObjectNameBasedOnParentEntity = (
id: string,
name: string,
// Used in EE
// eslint-disable-next-line @typescript-eslint/no-unused-vars
parentEntityType = ACTION_PARENT_ENTITY_TYPE.PAGE,
) => {
return saveJSObjectName({ id, name });
};