PromucFlow_constructor/app/client/src/utils/NavigationSelector/JsChildren.ts
Ankita Kinger d1af0b8c20
fix: Cyclic dependencies for reactive queries run behavior changes (#40481)
## Description

Fixing cyclic dependencies for reactive queries run behavior changes

Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!WARNING]
> Tests have not run on the HEAD
72c296cf462909ee85e7411dde5ca91705d81731 yet
> <hr>Tue, 29 Apr 2025 16:52:23 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


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

- **New Features**
- Introduced a "Run behavior" dropdown for actions and queries, allowing
users to choose between running on page load or manually.
- Enhanced dropdown controls now display descriptive labels and subtexts
for run behavior options.

- **Improvements**
- Replaced the previous "Run on page load" toggle with a more flexible
run behavior selection across all supported plugins and action types.
  - Updated UI labels and tooltips to clarify run behavior settings.

- **Bug Fixes**
- Ensured consistent handling and display of run behavior settings
throughout the application.

- **Documentation**
- Updated descriptions and labels to reflect the new run behavior
terminology.

- **Tests**
- Revised and added tests to validate the new run behavior functionality
and its backward compatibility.

- **Chores**
- Deprecated the old execute-on-load property and API, migrating to the
new run behavior approach for future extensibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-04-30 11:14:26 +05:30

68 lines
2.1 KiB
TypeScript

import type { JSActionEntity } from "ee/entities/DataTree/types";
import type { DataTree } from "entities/DataTree/dataTreeTypes";
import { ENTITY_TYPE } from "ee/entities/DataTree/types";
import { keyBy } from "lodash";
import type { JSCollectionData } from "ee/reducers/entityReducers/jsActionsReducer";
import { jsCollectionIdURL } from "ee/RouteBuilder";
import type {
EntityNavigationData,
NavigationData,
} from "entities/DataTree/dataTreeTypes";
import { createNavData } from "./common";
export const getJsChildrenNavData = (
jsAction: JSCollectionData,
basePageId: string,
dataTree: DataTree,
) => {
let childNavData: EntityNavigationData = {};
const dataTreeAction = dataTree[jsAction.config.name] as JSActionEntity;
const jsActionVariables = jsAction.config.variables || [];
if (dataTreeAction) {
let children: NavigationData[] = jsAction.config.actions.map((jsChild) => {
return createNavData({
id: `${jsAction.config.name}.${jsChild.name}`,
name: `${jsAction.config.name}.${jsChild.name}`,
type: ENTITY_TYPE.JSACTION,
isfunction: true, // use this to identify function
url: jsCollectionIdURL({
basePageId,
baseCollectionId: jsAction.config.baseId,
functionName: jsChild.name,
}),
children: {},
key: jsChild.name,
});
});
const variableChildren: NavigationData[] = jsActionVariables.map(
(jsChild) => {
return createNavData({
id: `${jsAction.config.name}.${jsChild.name}`,
name: `${jsAction.config.name}.${jsChild.name}`,
type: ENTITY_TYPE.JSACTION,
isfunction: false,
url: jsCollectionIdURL({
basePageId,
baseCollectionId: jsAction.config.baseId,
functionName: jsChild.name,
}),
children: {},
key: jsChild.name,
});
},
);
children = children.concat(variableChildren);
childNavData = keyBy(children, (data) => data.key) as Record<
string,
NavigationData
>;
return { childNavData };
}
};