diff --git a/app/client/src/components/formControls/DropDownControl.test.tsx b/app/client/src/components/formControls/DropDownControl.test.tsx index fce08eefa8..4cd3bbd7c6 100644 --- a/app/client/src/components/formControls/DropDownControl.test.tsx +++ b/app/client/src/components/formControls/DropDownControl.test.tsx @@ -9,6 +9,10 @@ import type { SelectOptionProps } from "@appsmith/ads"; import type { ReduxAction } from "actions/ReduxActionTypes"; import { PluginType } from "entities/Plugin"; +jest.mock("ee/selectors/featureFlagsSelectors", () => ({ + selectFeatureFlags: jest.fn(() => {}), +})); + const mockStore = configureStore([]); const initialValues = { diff --git a/app/client/src/components/formControls/DropDownControl.tsx b/app/client/src/components/formControls/DropDownControl.tsx index 11404ca53b..328f3f70b7 100644 --- a/app/client/src/components/formControls/DropDownControl.tsx +++ b/app/client/src/components/formControls/DropDownControl.tsx @@ -30,6 +30,9 @@ import type { } from "reducers/evaluationReducers/formEvaluationReducer"; import NoSearchCommandFound from "./CustomActionsConfigControl/NoSearchCommandFound"; import styled from "styled-components"; +import { ActionRunBehaviour } from "PluginActionEditor/types/PluginActionTypes"; +import type { FeatureFlags } from "ee/entities/FeatureFlag"; +import { selectFeatureFlags } from "ee/selectors/featureFlagsSelectors"; const OptionLabel = styled(Text)` color: var(--ads-v2-color-fg); @@ -139,6 +142,7 @@ export interface DropDownControlProps extends ControlProps { pluginId: string; identifier: string; }; + featureFlags?: FeatureFlags; } interface ReduxDispatchProps { @@ -298,6 +302,15 @@ function renderDropdown( selectedValue = uniqBy(selectedValue, (v) => v); } + /* temporary check added to switch from automatic to page load as the run behaviour when feature flag is turned off */ + if ( + selectedValue === ActionRunBehaviour.AUTOMATIC && + input?.name === "runBehaviour" && + !props.featureFlags?.release_reactive_actions_enabled + ) { + selectedValue = ActionRunBehaviour.ON_PAGE_LOAD; + } + // Use memoized grouping const groupedOptions = memoizedBuildGroupedOptions( options, @@ -558,11 +571,13 @@ const mapStateToProps = ( pluginId: string; identifier: string; }; + featureFlags: FeatureFlags; } => { let isLoading = false; // Start with the user-provided options if not fetching conditionally let options = ownProps.fetchOptionsConditionally ? [] : ownProps.options; const formValues: Partial = getFormValues(ownProps.formName)(state); + const featureFlags = selectFeatureFlags(state); let nextPageNeeded = false; let paginationPayload; @@ -631,6 +646,7 @@ const mapStateToProps = ( formValues, nextPageNeeded, paginationPayload, + featureFlags, }; }; 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 e73db4ee7d..d537ae3cbc 100644 --- a/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.tsx +++ b/app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/JSFunctionSettings.tsx @@ -58,15 +58,24 @@ interface FunctionSettingsRowProps extends Omit { const FunctionSettingRow = (props: FunctionSettingsRowProps) => { const [runBehaviour, setRunBehaviour] = useState(props.action.runBehaviour); - const flagValueForReactiveActions = useFeatureFlag( + const isReactiveActionsEnabled = useFeatureFlag( FEATURE_FLAG.release_reactive_actions_enabled, ); const options = RUN_BEHAVIOR_VALUES.filter( (option) => - flagValueForReactiveActions || - option.value !== ActionRunBehaviour.AUTOMATIC, + isReactiveActionsEnabled || option.value !== ActionRunBehaviour.AUTOMATIC, ) as SelectOptionProps[]; - const selectedValue = options.find((opt) => opt.value === runBehaviour); + let selectedValue = options.find((opt) => opt.value === runBehaviour); + + /* temporary check added to switch from automatic to page load as the run behaviour when feature flag is turned off */ + if ( + runBehaviour === ActionRunBehaviour.AUTOMATIC && + !isReactiveActionsEnabled + ) { + selectedValue = options.find( + (opt) => opt.value === ActionRunBehaviour.ON_PAGE_LOAD, + ); + } const onSelectOptions = useCallback( (newRunBehaviour: ActionRunBehaviourType) => {