diff --git a/app/client/cypress/support/Pages/JSEditor.ts b/app/client/cypress/support/Pages/JSEditor.ts index 85bc32fcd3..03dc0ca510 100644 --- a/app/client/cypress/support/Pages/JSEditor.ts +++ b/app/client/cypress/support/Pages/JSEditor.ts @@ -51,10 +51,10 @@ export class JSEditor { "div.t--js-response-parse-error-call-out"; private _onPageLoadSwitch = (functionName: string) => - `.${functionName}-on-page-load-setting - input[role="switch"]`; + `.${functionName}-run-behavior + input[role="combobox"]`; private _onPageLoadSwitchStatus = (functionName: string) => - `//div[contains(@class, '${functionName}-on-page-load-setting')]//label/input`; + `//div[contains(@class, '${functionName}-run-behavior-setting')]//label/input`; private _jsObjName = this.locator._activeEntityTab; public _jsObjTxt = this.locator._activeEntityTabInput; diff --git a/app/client/src/PluginActionEditor/components/PluginActionSettings/SettingsPopover.tsx b/app/client/src/PluginActionEditor/components/PluginActionSettings/SettingsPopover.tsx index d8d88c368a..af8fc16585 100644 --- a/app/client/src/PluginActionEditor/components/PluginActionSettings/SettingsPopover.tsx +++ b/app/client/src/PluginActionEditor/components/PluginActionSettings/SettingsPopover.tsx @@ -13,7 +13,7 @@ import { isPluginActionSettingsOpen, openPluginActionSettings, } from "../../store"; -import { THEME } from "../../constants/PluginActionConstants"; +import { THEME } from "../../types/PluginActionTypes"; import { type DocsLink, openDoc } from "constants/DocumentationLinks"; import { ToolbarSettingsPopover } from "IDE"; diff --git a/app/client/src/PluginActionEditor/constants/PluginActionConstants.ts b/app/client/src/PluginActionEditor/types/PluginActionTypes.ts similarity index 92% rename from app/client/src/PluginActionEditor/constants/PluginActionConstants.ts rename to app/client/src/PluginActionEditor/types/PluginActionTypes.ts index ce50c573b8..cb3947afcd 100644 --- a/app/client/src/PluginActionEditor/constants/PluginActionConstants.ts +++ b/app/client/src/PluginActionEditor/types/PluginActionTypes.ts @@ -12,11 +12,13 @@ export const RUN_BEHAVIOR = { label: "On page load", subText: "Query runs when the page loads or when manually triggered", value: ActionRunBehaviour.ON_PAGE_LOAD, + children: "On page load", }, MANUAL: { label: "Manual", subText: "Query only runs when called in an event or JS with .run()", value: ActionRunBehaviour.MANUAL, + children: "Manual", }, }; diff --git a/app/client/src/actions/pluginActionActions.ts b/app/client/src/actions/pluginActionActions.ts index 4f06d71710..2db9e6dc01 100644 --- a/app/client/src/actions/pluginActionActions.ts +++ b/app/client/src/actions/pluginActionActions.ts @@ -20,7 +20,7 @@ import type { EventLocation } from "ee/utils/analyticsUtilTypes"; import type { GenerateDestinationIdInfoReturnType } from "ee/sagas/helpers"; import type { Span } from "instrumentation/types"; import type { EvaluationReduxAction } from "./EvaluationReduxActionTypes"; -import type { ActionRunBehaviourType } from "PluginActionEditor/constants/PluginActionConstants"; +import type { ActionRunBehaviourType } from "PluginActionEditor/types/PluginActionTypes"; export const createActionRequest = ( payload: Partial, diff --git a/app/client/src/api/ActionAPI.tsx b/app/client/src/api/ActionAPI.tsx index 3855f9d4c1..f832e2fa41 100644 --- a/app/client/src/api/ActionAPI.tsx +++ b/app/client/src/api/ActionAPI.tsx @@ -10,7 +10,7 @@ import type { APIRequest } from "constants/AppsmithActionConstants/ActionConstan import type { WidgetType } from "constants/WidgetConstants"; import type { ActionParentEntityTypeInterface } from "ee/entities/Engine/actionHelpers"; import type { PostActionRunConfig } from "./types"; -import type { ActionRunBehaviourType } from "PluginActionEditor/constants/PluginActionConstants"; +import type { ActionRunBehaviourType } from "PluginActionEditor/types/PluginActionTypes"; export interface Property { key: string; diff --git a/app/client/src/api/PageApi.tsx b/app/client/src/api/PageApi.tsx index d233da5734..90bc7ddc49 100644 --- a/app/client/src/api/PageApi.tsx +++ b/app/client/src/api/PageApi.tsx @@ -9,7 +9,7 @@ import type { import type { DSLWidget } from "WidgetProvider/constants"; import type { FetchApplicationResponse } from "ee/api/ApplicationApi"; import type { APP_MODE } from "entities/App"; -import type { ActionRunBehaviourType } from "PluginActionEditor/constants/PluginActionConstants"; +import type { ActionRunBehaviourType } from "PluginActionEditor/types/PluginActionTypes"; export interface FetchPageRequest { pageId: string; diff --git a/app/client/src/ce/components/editorComponents/GPT/index.tsx b/app/client/src/ce/components/editorComponents/GPT/index.tsx index a23e560fd5..a545494abc 100644 --- a/app/client/src/ce/components/editorComponents/GPT/index.tsx +++ b/app/client/src/ce/components/editorComponents/GPT/index.tsx @@ -3,7 +3,7 @@ import type { FieldEntityInformation, TEditorModes, } from "components/editorComponents/CodeEditor/EditorConfig"; -import type { EntityNavigationData } from "selectors/navigationSelectors"; +import type { EntityNavigationData } from "entities/DataTree/dataTreeTypes"; import React from "react"; import type CodeMirror from "codemirror"; diff --git a/app/client/src/ce/reducers/entityReducers/actionsReducer.tsx b/app/client/src/ce/reducers/entityReducers/actionsReducer.tsx index 2f7937d723..36c773911e 100644 --- a/app/client/src/ce/reducers/entityReducers/actionsReducer.tsx +++ b/app/client/src/ce/reducers/entityReducers/actionsReducer.tsx @@ -13,7 +13,7 @@ import type { UpdateActionPropertyActionPayload, } from "actions/pluginActionActions"; import { klona } from "klona"; -import type { ActionRunBehaviourType } from "PluginActionEditor/constants/PluginActionConstants"; +import type { ActionRunBehaviourType } from "PluginActionEditor/types/PluginActionTypes"; export interface ActionData { isLoading: boolean; diff --git a/app/client/src/ce/reducers/entityReducers/jsActionsReducer.tsx b/app/client/src/ce/reducers/entityReducers/jsActionsReducer.tsx index 9ff70ca543..ad390f8f6c 100644 --- a/app/client/src/ce/reducers/entityReducers/jsActionsReducer.tsx +++ b/app/client/src/ce/reducers/entityReducers/jsActionsReducer.tsx @@ -8,7 +8,7 @@ import { import { set, keyBy, findIndex, unset } from "lodash"; import { create } from "mutative"; import { klona } from "klona"; -import type { ActionRunBehaviourType } from "PluginActionEditor/constants/PluginActionConstants"; +import type { ActionRunBehaviourType } from "PluginActionEditor/types/PluginActionTypes"; export const initialState: JSCollectionDataState = []; diff --git a/app/client/src/ce/utils/moduleInstanceNavigationData.ts b/app/client/src/ce/utils/moduleInstanceNavigationData.ts index 9328a106ba..8248b6d670 100644 --- a/app/client/src/ce/utils/moduleInstanceNavigationData.ts +++ b/app/client/src/ce/utils/moduleInstanceNavigationData.ts @@ -1,5 +1,5 @@ import type { ModuleInstance } from "ee/constants/ModuleInstanceConstants"; -import type { EntityNavigationData } from "selectors/navigationSelectors"; +import type { EntityNavigationData } from "entities/DataTree/dataTreeTypes"; export const getModuleInstanceNavigationData = ( /* eslint-disable @typescript-eslint/no-unused-vars */ diff --git a/app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts b/app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts index 1c31557f9a..5dcf999198 100644 --- a/app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts +++ b/app/client/src/components/editorComponents/CodeEditor/EditorConfig.ts @@ -1,8 +1,10 @@ import type CodeMirror from "codemirror"; import type { EntityTypeValue } from "ee/entities/DataTree/types"; -import type { DataTree } from "entities/DataTree/dataTreeTypes"; +import type { + DataTree, + EntityNavigationData, +} from "entities/DataTree/dataTreeTypes"; import type { AutocompleteDataType } from "utils/autocomplete/AutocompleteDataType"; -import type { EntityNavigationData } from "selectors/navigationSelectors"; import type { ExpectedValueExample } from "utils/validation/common"; import { editorSQLModes } from "./sql/config"; diff --git a/app/client/src/components/editorComponents/CodeEditor/MarkHelpers/entityMarker.ts b/app/client/src/components/editorComponents/CodeEditor/MarkHelpers/entityMarker.ts index 9eb2a57673..7ae54f9d0b 100644 --- a/app/client/src/components/editorComponents/CodeEditor/MarkHelpers/entityMarker.ts +++ b/app/client/src/components/editorComponents/CodeEditor/MarkHelpers/entityMarker.ts @@ -1,7 +1,7 @@ import type { EntityNavigationData, NavigationData, -} from "selectors/navigationSelectors"; +} from "entities/DataTree/dataTreeTypes"; import type { MarkHelper } from "../EditorConfig"; export const NAVIGATE_TO_ATTRIBUTE = "data-navigate-to"; diff --git a/app/client/src/components/editorComponents/CodeEditor/commandsHelper.ts b/app/client/src/components/editorComponents/CodeEditor/commandsHelper.ts index 1ccbb28876..3bbb391d88 100644 --- a/app/client/src/components/editorComponents/CodeEditor/commandsHelper.ts +++ b/app/client/src/components/editorComponents/CodeEditor/commandsHelper.ts @@ -18,7 +18,7 @@ import type { FeatureFlags } from "ee/entities/FeatureFlag"; import type { EntityNavigationData, NavigationData, -} from "selectors/navigationSelectors"; +} from "entities/DataTree/dataTreeTypes"; import { getAIContext } from "ee/components/editorComponents/GPT/trigger"; import type { Plugin } from "entities/Plugin"; diff --git a/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx b/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx index 6168325f06..7f8d45e621 100644 --- a/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/generateQuickCommands.tsx @@ -14,7 +14,7 @@ import { APPSMITH_AI } from "ee/components/editorComponents/GPT/trigger"; import { DatasourceCreateEntryPoints } from "constants/Datasource"; import AnalyticsUtil from "ee/utils/AnalyticsUtil"; import BetaCard from "../BetaCard"; -import type { NavigationData } from "selectors/navigationSelectors"; +import type { NavigationData } from "entities/DataTree/dataTreeTypes"; import type { AIEditorContext } from "ee/components/editorComponents/GPT"; import type { EntityTypeValue } from "ee/entities/DataTree/types"; import history, { NavigationMethod } from "utils/history"; diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index 7e5c0f734a..beb62b5d8d 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -122,7 +122,7 @@ import { updateCustomDef } from "utils/autocomplete/customDefUtils"; import { shouldFocusOnPropertyControl } from "utils/editorContextUtils"; import { getEntityLintErrors } from "selectors/lintingSelectors"; import { getCodeCommentKeyMap, handleCodeComment } from "./utils/codeComment"; -import type { EntityNavigationData } from "selectors/navigationSelectors"; +import type { EntityNavigationData } from "entities/DataTree/dataTreeTypes"; import { getEntitiesForNavigation } from "selectors/navigationSelectors"; import history, { NavigationMethod } from "utils/history"; import { CursorPositionOrigin } from "ee/reducers/uiReducers/editorContextReducer"; diff --git a/app/client/src/components/editorComponents/utils.test.ts b/app/client/src/components/editorComponents/utils.test.ts index 3315e19454..ba64f41e36 100644 --- a/app/client/src/components/editorComponents/utils.test.ts +++ b/app/client/src/components/editorComponents/utils.test.ts @@ -1,5 +1,5 @@ import { getJSResponseViewState, JSResponseState } from "./utils"; -import { ActionRunBehaviour } from "PluginActionEditor/constants/PluginActionConstants"; +import { ActionRunBehaviour } from "PluginActionEditor/types/PluginActionTypes"; const TEST_JS_FUNCTION_ID = "627ccff468e1fa5185b7f901"; const TEST_JS_FUNCTION_BASE_ID = "627ccff468e1fa5185b7f912"; diff --git a/app/client/src/constants/AppsmithActionConstants/formConfig/ApiSettingsConfig.ts b/app/client/src/constants/AppsmithActionConstants/formConfig/ApiSettingsConfig.ts index b644f68a59..9dd3c60918 100644 --- a/app/client/src/constants/AppsmithActionConstants/formConfig/ApiSettingsConfig.ts +++ b/app/client/src/constants/AppsmithActionConstants/formConfig/ApiSettingsConfig.ts @@ -9,7 +9,7 @@ import { import { RUN_BEHAVIOR, RUN_BEHAVIOR_VALUES, -} from "PluginActionEditor/constants/PluginActionConstants"; +} from "PluginActionEditor/types/PluginActionTypes"; export default [ { diff --git a/app/client/src/constants/AppsmithActionConstants/formConfig/GoogleSheetsSettingsConfig.ts b/app/client/src/constants/AppsmithActionConstants/formConfig/GoogleSheetsSettingsConfig.ts index dfe84f4040..3b574cb078 100644 --- a/app/client/src/constants/AppsmithActionConstants/formConfig/GoogleSheetsSettingsConfig.ts +++ b/app/client/src/constants/AppsmithActionConstants/formConfig/GoogleSheetsSettingsConfig.ts @@ -1,7 +1,7 @@ import { RUN_BEHAVIOR, RUN_BEHAVIOR_VALUES, -} from "PluginActionEditor/constants/PluginActionConstants"; +} from "PluginActionEditor/types/PluginActionTypes"; export default [ { diff --git a/app/client/src/constants/AppsmithActionConstants/formConfig/QuerySettingsConfig.ts b/app/client/src/constants/AppsmithActionConstants/formConfig/QuerySettingsConfig.ts index 8e7137d4da..1eb23f3497 100644 --- a/app/client/src/constants/AppsmithActionConstants/formConfig/QuerySettingsConfig.ts +++ b/app/client/src/constants/AppsmithActionConstants/formConfig/QuerySettingsConfig.ts @@ -1,7 +1,7 @@ import { RUN_BEHAVIOR, RUN_BEHAVIOR_VALUES, -} from "PluginActionEditor/constants/PluginActionConstants"; +} from "PluginActionEditor/types/PluginActionTypes"; export default [ { diff --git a/app/client/src/entities/Action/index.ts b/app/client/src/entities/Action/index.ts index 61a7687cdb..e5d1fc0627 100644 --- a/app/client/src/entities/Action/index.ts +++ b/app/client/src/entities/Action/index.ts @@ -10,7 +10,7 @@ import { type Plugin, type PluginName, } from "../Plugin"; -import type { ActionRunBehaviourType } from "PluginActionEditor/constants/PluginActionConstants"; +import type { ActionRunBehaviourType } from "PluginActionEditor/types/PluginActionTypes"; export enum PaginationType { NONE = "NONE", diff --git a/app/client/src/entities/DataTree/dataTreeTypes.ts b/app/client/src/entities/DataTree/dataTreeTypes.ts index 8758e18bb1..3e283c1066 100644 --- a/app/client/src/entities/DataTree/dataTreeTypes.ts +++ b/app/client/src/entities/DataTree/dataTreeTypes.ts @@ -3,6 +3,7 @@ import type { DataTreeEntityObject, UnEvalTreeEntityObject, AppsmithEntity, + EntityTypeValue, } from "ee/entities/DataTree/types"; export interface unEvalAndConfigTree { @@ -23,3 +24,23 @@ export type UnEvalTreeEntity = UnEvalTreeEntityObject | AppsmithEntity; export interface UnEvalTree { [entityName: string]: UnEvalTreeEntity; } + +export interface NavigationData { + name: string; + id: string; + type: EntityTypeValue; + isfunction?: boolean; + url: string | undefined; + navigable: boolean; + children: EntityNavigationData; + key?: string; + pluginName?: string; + pluginId?: string; + isMock?: boolean; + datasourceId?: string; + actionType?: string; + widgetType?: string; + value?: boolean | string; +} + +export type EntityNavigationData = Record; diff --git a/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.test.tsx b/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.test.tsx index 5dff0fde77..4d4fce5505 100644 --- a/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.test.tsx +++ b/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.test.tsx @@ -2,13 +2,8 @@ import React from "react"; import "@testing-library/jest-dom"; import { render, screen } from "test/testUtils"; import { JSFunctionSettings } from "./JSFunctionSettings"; -import { useFeatureFlag } from "utils/hooks/useFeatureFlag"; import { JSObjectFactory } from "test/factories/Actions/JSObject"; -import { ActionRunBehaviour } from "PluginActionEditor/constants/PluginActionConstants"; - -// Mock the useFeatureFlag hook -jest.mock("utils/hooks/useFeatureFlag"); -const mockUseFeatureFlag = useFeatureFlag as jest.Mock; +import { ActionRunBehaviour } from "PluginActionEditor/types/PluginActionTypes"; const JSObject = JSObjectFactory.build(); @@ -21,9 +16,7 @@ describe("JSFunctionSettings", () => { jest.clearAllMocks(); }); - it("disables the switch when the component is disabled", () => { - mockUseFeatureFlag.mockReturnValue(true); - + it("disables the run behavior when the component is disabled", () => { render( { expect(screen.getByLabelText(actions[0].name)).toBeDisabled(); }); - it("renders the correct number of switches for the actions", () => { - mockUseFeatureFlag.mockReturnValue(true); - + it("renders the correct number of dropdowns for the actions", () => { render( { />, ); - expect(screen.getAllByRole("switch")).toHaveLength(actions.length); + expect(screen.getAllByRole(`combobox`)).toHaveLength(actions.length); }); - it("renders the switch state correctly", () => { - mockUseFeatureFlag.mockReturnValue(true); - + it("renders the run behavior correctly", () => { const updatedJSActions = [ { ...actions[0], @@ -71,10 +60,14 @@ describe("JSFunctionSettings", () => { />, ); - const switchElement1 = screen.getByLabelText(updatedJSActions[0].name); - const switchElement2 = screen.getByLabelText(updatedJSActions[1].name); + const selectedItem1 = screen.getByText("On page load", { + selector: ".myFun1-run-behavior-setting .rc-select-selection-item", + }); + const selectedItem2 = screen.getByText("Manual", { + selector: ".myFun2-run-behavior-setting .rc-select-selection-item", + }); - expect(switchElement1).toBeChecked(); - expect(switchElement2).not.toBeChecked(); + expect(selectedItem1).toBeInTheDocument(); + expect(selectedItem2).toBeInTheDocument(); }); }); diff --git a/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.tsx b/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.tsx index 169ff0d3ed..5a03ec8890 100644 --- a/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.tsx +++ b/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.tsx @@ -14,8 +14,10 @@ import { } from "ee/constants/messages"; import AnalyticsUtil from "ee/utils/AnalyticsUtil"; import type { OnUpdateSettingsProps } from "../types"; -import type { ActionRunBehaviour } from "PluginActionEditor/constants/PluginActionConstants"; -import { RUN_BEHAVIOR_VALUES } from "PluginActionEditor/constants/PluginActionConstants"; +import { + RUN_BEHAVIOR_VALUES, + type ActionRunBehaviourType, +} from "PluginActionEditor/types/PluginActionTypes"; import styled from "styled-components"; const OptionLabel = styled(Text)` @@ -45,10 +47,11 @@ interface FunctionSettingsRowProps extends Omit { const FunctionSettingRow = (props: FunctionSettingsRowProps) => { const [runBehavior, setRunBehavior] = useState(props.action.runBehavior); - const options = RUN_BEHAVIOR_VALUES as Omit[]; + const options = RUN_BEHAVIOR_VALUES as SelectOptionProps[]; + const selectedValue = options.find((opt) => opt.value === runBehavior); const onSelectOptions = useCallback( - (newRunBehavior: ActionRunBehaviour) => { + (newRunBehavior: ActionRunBehaviourType) => { setRunBehavior(newRunBehavior); props.onUpdateSettings?.({ value: newRunBehavior, @@ -67,29 +70,30 @@ const FunctionSettingRow = (props: FunctionSettingsRowProps) => { return ( - {props.action.name} + + {props.action.name} + {options.map((option) => (