Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ describe(
it("2. To verify add a widget navigation using URL containing widgetID", () => {
EditorNavigation.SelectEntityByName("Page2", EntityType.Page);
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT, 200, 600);
cy.url().then((url) => {
pageTwoUrl = url;
});

EditorNavigation.SelectEntityByName("Page1", EntityType.Page);
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
propPane.ToggleJSMode("onClick", false);
Expand Down Expand Up @@ -253,7 +251,6 @@ describe(
EditorNavigation.SelectEntityByName("Page1", EntityType.Page);
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
});

it("4. To verify navigation to a hidden page in same as well a new window", () => {
agHelper.RefreshPage();
PageList.AddNewPage();
Expand All @@ -268,15 +265,14 @@ describe(
});
EditorNavigation.SelectEntityByName("Page1", EntityType.Page);
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
propPane.ToggleJSMode("onClick", false);
propPane.SelectPlatformFunction("onClick", "Navigate to");
propPane.SelectActionByTitleAndValue("Navigate to", "Select page");
agHelper.GetNClick(propPane._navigateToType("URL"));
agHelper.TypeText(
propPane._actionSelectorFieldByLabel("Enter URL"),
pageTwoUrl,

propPane.ToggleJSMode("onClick", true);
propPane.EnterJSContext(
"onClick",
`{{navigateTo('${pageTwoUrl}', {}, 'SAME_WINDOW');}}`,
true,
false,
);
agHelper.GetNClick(propPane._actionSelectorPopupClose);
agHelper.ClickButton("Submit");
agHelper.AssertURL(pageTwoUrl);
EditorNavigation.SelectEntityByName("Page1", EntityType.Page);
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/ce/constants/ReduxActionConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ const PageActionTypes = {
SET_PAGE_ORDER_INIT: "SET_PAGE_ORDER_INIT",
SET_PAGE_ORDER_SUCCESS: "SET_PAGE_ORDER_SUCCESS",
RESET_PAGE_LIST: "RESET_PAGE_LIST",
SET_ONLOAD_ACTION_EXECUTED: "SET_ONLOAD_ACTION_EXECUTED",
EXECUTE_REACTIVE_QUERIES: "EXECUTE_REACTIVE_QUERIES",
};

const PageActionErrorTypes = {
Expand Down
27 changes: 27 additions & 0 deletions app/client/src/ce/entities/DataTree/dataTreeAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
ActionEntity,
ActionEntityConfig,
} from "ee/entities/DataTree/types";
import { EvaluationSubstitutionType } from "constants/EvaluationConstants";

export const generateDataTreeAction = (
action: ActionData,
Expand Down Expand Up @@ -55,6 +56,30 @@ export const generateDataTreeAction = (
dynamicBindingPathList,
);

//this is for view mode
if (action.config.jsonPathKeys && !action.config?.datasource) {
dependencyMap["config.body"] = action.config.jsonPathKeys;
const result = action.config.jsonPathKeys
.map((item) => `{{${item}}}`)
.join(" ");

action.config.actionConfiguration = {
...action.config.actionConfiguration,
body: result,
};
dynamicBindingPathList.push({
key: "config.body",
});
bindingPaths["config.body"] = EvaluationSubstitutionType.TEMPLATE;
reactivePaths["config.body"] = EvaluationSubstitutionType.TEMPLATE;
}

dependencyMap["run"] = dynamicBindingPathList.map(
(path: { key: string }) => path.key,
);

const dynamicTriggerPathList = [{ key: "run" }, { key: "clear" }];

return {
unEvalEntity: {
actionId: action.config.id,
Expand Down Expand Up @@ -84,6 +109,8 @@ export const generateDataTreeAction = (
reactivePaths,
dependencyMap,
logBlackList: {},
dynamicTriggerPathList,
runBehaviour: action.config.runBehaviour,
},
};
};
24 changes: 24 additions & 0 deletions app/client/src/ce/entities/DataTree/dataTreeJSAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,12 @@ describe("generateDataTreeJSAction", () => {
myFun2: {
arguments: [],
confirmBeforeExecute: false,
runBehaviour: "MANUAL",
},
myFun1: {
arguments: [],
confirmBeforeExecute: false,
runBehaviour: "MANUAL",
},
},
bindingPaths: {
Expand Down Expand Up @@ -184,10 +186,20 @@ describe("generateDataTreeJSAction", () => {
dependencyMap: {
body: ["myFun2", "myFun1"],
},
dynamicTriggerPathList: [
{
key: "myFun2",
},
{
key: "myFun1",
},
],
reactivePaths: {
body: "SMART_SUBSTITUTE",
myFun1: "SMART_SUBSTITUTE",
"myFun1.data": "SMART_SUBSTITUTE",
myFun2: "SMART_SUBSTITUTE",
"myFun2.data": "SMART_SUBSTITUTE",
myVar1: "SMART_SUBSTITUTE",
myVar2: "SMART_SUBSTITUTE",
},
Expand Down Expand Up @@ -347,10 +359,12 @@ describe("generateDataTreeJSAction", () => {
myFun2: {
arguments: [],
confirmBeforeExecute: false,
runBehaviour: "MANUAL",
},
myFun1: {
arguments: [],
confirmBeforeExecute: false,
runBehaviour: "MANUAL",
},
},
bindingPaths: {
Expand Down Expand Up @@ -381,12 +395,22 @@ describe("generateDataTreeJSAction", () => {
dependencyMap: {
body: ["myFun2", "myFun1"],
},
dynamicTriggerPathList: [
{
key: "myFun2",
},
{
key: "myFun1",
},
],
name: "JSObject2",
pluginType: "JS",
reactivePaths: {
body: "SMART_SUBSTITUTE",
myFun1: "SMART_SUBSTITUTE",
"myFun1.data": "SMART_SUBSTITUTE",
myFun2: "SMART_SUBSTITUTE",
"myFun2.data": "SMART_SUBSTITUTE",
myVar1: "SMART_SUBSTITUTE",
myVar2: "SMART_SUBSTITUTE",
},
Expand Down
11 changes: 9 additions & 2 deletions app/client/src/ce/entities/DataTree/dataTreeJSAction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ENTITY_TYPE } from "ee/entities/DataTree/types";
import type { JSCollectionData } from "ee/reducers/entityReducers/jsActionsReducer";
import { EvaluationSubstitutionType } from "ee/entities/DataTree/types";
import { EvaluationSubstitutionType } from "constants/EvaluationConstants";
import type { DependencyMap } from "utils/DynamicBindingUtils";
import type {
JSActionEntity,
Expand All @@ -19,6 +19,7 @@ export const generateDataTreeJSAction = (
const meta: Record<string, MetaArgs> = {};
const dynamicBindingPathList = [];
const bindingPaths: Record<string, EvaluationSubstitutionType> = {};
const reactivePaths: Record<string, EvaluationSubstitutionType> = {};
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const variableList: Record<string, any> = {};
Expand Down Expand Up @@ -50,6 +51,7 @@ export const generateDataTreeJSAction = (
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const actionsData: Record<string, any> = {};
const dynamicTriggerPathList = [];

if (actions) {
for (let i = 0; i < actions.length; i++) {
Expand All @@ -58,6 +60,7 @@ export const generateDataTreeJSAction = (
meta[action.name] = {
arguments: action.actionConfiguration?.jsArguments || [],
confirmBeforeExecute: !!action.confirmBeforeExecute,
runBehaviour: action.runBehaviour,
};
bindingPaths[action.name] = EvaluationSubstitutionType.SMART_SUBSTITUTE;
dynamicBindingPathList.push({ key: action.name });
Expand All @@ -67,6 +70,9 @@ export const generateDataTreeJSAction = (
// Action data is updated directly to the dataTree (see updateActionData.ts)
data: {},
};
dynamicTriggerPathList.push({ key: action.name });
reactivePaths[`${action.name}.data`] =
EvaluationSubstitutionType.SMART_SUBSTITUTE;
}
}

Expand All @@ -85,11 +91,12 @@ export const generateDataTreeJSAction = (
pluginType: js.config.pluginType,
ENTITY_TYPE: ENTITY_TYPE.JSACTION,
bindingPaths: bindingPaths, // As all js object function referred to as action is user javascript code, we add them as binding paths.
reactivePaths: { ...bindingPaths },
reactivePaths: { ...reactivePaths, ...bindingPaths },
dynamicBindingPathList: dynamicBindingPathList,
variables: listVariables,
dependencyMap: dependencyMap,
actionNames: new Set(actions.map((action) => action.name)),
dynamicTriggerPathList: dynamicTriggerPathList,
},
};
};
43 changes: 6 additions & 37 deletions app/client/src/ce/entities/DataTree/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,12 @@ import type { ActionDescription } from "ee/workers/Evaluation/fns";
import type { Variable } from "entities/JSCollection";
import type { DependencyMap, DynamicPath } from "utils/DynamicBindingUtils";
import type { Page } from "entities/Page";
import type { MetaWidgetsReduxState } from "reducers/entityReducers/metaWidgetsReducer";
import type { WidgetConfigProps } from "WidgetProvider/types";
import type { ActionDataState } from "ee/reducers/entityReducers/actionsReducer";
import type { WidgetProps } from "widgets/BaseWidget";
import type { CanvasWidgetsReduxState } from "ee/reducers/entityReducers/canvasWidgetsReducer";
import type { MetaState } from "reducers/entityReducers/metaReducer";
import type { AppDataState } from "reducers/entityReducers/appReducer";
import type { JSCollectionDataState } from "ee/reducers/entityReducers/jsActionsReducer";
import type { AppTheme } from "entities/AppTheming";
import type { LoadingEntitiesState } from "reducers/evaluationReducers/loadingEntitiesReducer";
import type { LayoutSystemTypes } from "layoutSystems/types";
import type { Module } from "ee/constants/ModuleConstants";
import type { ModuleInstance } from "ee/constants/ModuleInstanceConstants";
import type { ActionRunBehaviourType } from "PluginActionEditor/types/PluginActionTypes";
import type { EvaluationSubstitutionType } from "constants/EvaluationConstants";

// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -36,12 +29,6 @@ export const ACTION_TYPE = ENTITY_TYPE.ACTION;
type ValueOf<T> = T[keyof T];
export type EntityTypeValue = ValueOf<typeof ENTITY_TYPE>;

export enum EvaluationSubstitutionType {
TEMPLATE = "TEMPLATE",
PARAMETER = "PARAMETER",
SMART_SUBSTITUTE = "SMART_SUBSTITUTE",
}

// Action entity types
export interface ActionEntity {
actionId: string;
Expand Down Expand Up @@ -73,13 +60,16 @@ export interface ActionEntityConfig extends EntityConfig {
moduleId?: string;
moduleInstanceId?: string;
isPublic?: boolean;
dynamicTriggerPathList: DynamicPath[];
runBehaviour: ActionRunBehaviourType;
}

// JSAction (JSObject) entity Types

export interface MetaArgs {
arguments: Variable[];
confirmBeforeExecute: boolean;
runBehaviour: ActionRunBehaviourType;
}

export interface JSActionEntityConfig extends EntityConfig {
Expand All @@ -97,6 +87,7 @@ export interface JSActionEntityConfig extends EntityConfig {
moduleInstanceId?: string;
isPublic?: boolean;
actionNames: Set<string>;
dynamicTriggerPathList: DynamicPath[];
}

export interface JSActionEntity {
Expand Down Expand Up @@ -196,28 +187,6 @@ export interface AppsmithEntity extends Omit<AppDataState, "store"> {
currentEnvironmentName: string;
}

export interface DataTreeSeed {
actions: ActionDataState;
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
editorConfigs: Record<string, any[]>;
pluginDependencyConfig: Record<string, DependencyMap>;
widgets: CanvasWidgetsReduxState;
widgetsMeta: MetaState;
appData: AppDataState;
jsActions: JSCollectionDataState;
theme: AppTheme["properties"];
metaWidgets: MetaWidgetsReduxState;
isMobile: boolean;
moduleInputs: Module["inputsForm"];
moduleInstances: Record<string, ModuleInstance> | null;
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
moduleInstanceEntities: any;
layoutSystemType: LayoutSystemTypes;
loadingEntities: LoadingEntitiesState;
}

export type DataTreeEntityConfig =
| WidgetEntityConfig
| ActionEntityConfig
Expand Down
34 changes: 34 additions & 0 deletions app/client/src/ce/entities/DataTree/types/DataTreeSeed.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { CanvasWidgetsReduxState } from "ee/reducers/entityReducers/canvasWidgetsReducer";
import type { ActionDataState } from "ee/reducers/entityReducers/actionsReducer";
import type DependencyMap from "entities/DependencyMap";
import type { MetaState } from "reducers/entityReducers/metaReducer";
import type { AppDataState } from "reducers/entityReducers/appReducer";
import type { JSCollectionDataState } from "ee/reducers/entityReducers/jsActionsReducer";
import type { MetaWidgetsReduxState } from "reducers/entityReducers/metaWidgetsReducer";
import type { AppTheme } from "entities/AppTheming";
import type { Module } from "ee/constants/ModuleConstants";
import type { ModuleInstance } from "ee/constants/ModuleInstanceConstants";
import type { LayoutSystemTypes } from "layoutSystems/types";
import type { LoadingEntitiesState } from "reducers/evaluationReducers/loadingEntitiesReducer";

export interface DataTreeSeed {
actions: ActionDataState;
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
editorConfigs: Record<string, any[]>;
pluginDependencyConfig: Record<string, DependencyMap>;
widgets: CanvasWidgetsReduxState;
widgetsMeta: MetaState;
appData: AppDataState;
jsActions: JSCollectionDataState;
theme: AppTheme["properties"];
metaWidgets: MetaWidgetsReduxState;
isMobile: boolean;
moduleInputs: Module["inputsForm"];
moduleInstances: Record<string, ModuleInstance> | null;
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
moduleInstanceEntities: any;
layoutSystemType: LayoutSystemTypes;
loadingEntities: LoadingEntitiesState;
}
Loading
Loading