-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: add onPageUnload option in UI behind feature flag. #41008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rahulbarwal
merged 6 commits into
release
from
rahulbarwal/issue40995/Task-UI-Components-Add-onPageUnload-Toggle-to-Action-Config
Jun 23, 2025
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7e88386
Adds feature flag for on page unload actions.
rahulbarwal ca6f1dd
feat: Add ON_PAGE_UNLOAD action run behavior and update related settings
rahulbarwal ee95f3f
Corrects flag name
rahulbarwal 298bcfb
Enhances readability of matrix and test
rahulbarwal 5bc697d
Adds proper comments
rahulbarwal fe0b500
Refactor: Replace RUN_BEHAVIOR_VALUES with JS_OBJECT_RUN_BEHAVIOR_VAL…
rahulbarwal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/utils.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| import { | ||
| ActionRunBehaviour, | ||
| type ActionRunBehaviourType, | ||
| } from "PluginActionEditor/types/PluginActionTypes"; | ||
| import { | ||
| getDefaultRunBehaviorOptionWhenFeatureFlagIsDisabled, | ||
| getRunBehaviorOptionsBasedOnFeatureFlags, | ||
| } from "./utils"; | ||
| import { RUN_BEHAVIOR_VALUES } from "constants/AppsmithActionConstants/formConfig/PluginSettings"; | ||
| import type { SelectOptionProps } from "@appsmith/ads"; | ||
|
|
||
| describe("getRunBehaviorOptions", () => { | ||
| it("should return the correct options", () => { | ||
| const flagsOutputMatrix: [boolean, boolean, SelectOptionProps[]][] = [ | ||
| [true, true, RUN_BEHAVIOR_VALUES], | ||
| [ | ||
| false, | ||
| true, | ||
| RUN_BEHAVIOR_VALUES.filter( | ||
| (option) => option.value !== ActionRunBehaviour.AUTOMATIC, | ||
| ), | ||
| ], | ||
| [ | ||
| true, | ||
| false, | ||
| RUN_BEHAVIOR_VALUES.filter( | ||
| (option) => option.value !== ActionRunBehaviour.ON_PAGE_UNLOAD, | ||
| ), | ||
| ], | ||
| [ | ||
| false, | ||
| false, | ||
| RUN_BEHAVIOR_VALUES.filter( | ||
| (option) => | ||
| option.value !== ActionRunBehaviour.AUTOMATIC && | ||
| option.value !== ActionRunBehaviour.ON_PAGE_UNLOAD, | ||
| ), | ||
| ], | ||
| ]; | ||
|
|
||
| flagsOutputMatrix.forEach( | ||
| ([isReactiveActionsEnabled, isOnPageUnloadEnabled, expectedOptions]) => { | ||
| const options = getRunBehaviorOptionsBasedOnFeatureFlags( | ||
| isReactiveActionsEnabled, | ||
| isOnPageUnloadEnabled, | ||
| ); | ||
|
|
||
| expect(options).toEqual(expectedOptions); | ||
| }, | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("getDefaultRunBehaviorOptionWhenFeatureFlagIsDisabled", () => { | ||
| const onPageLoadOption = | ||
| RUN_BEHAVIOR_VALUES.find( | ||
| (option) => option.value === ActionRunBehaviour.ON_PAGE_LOAD, | ||
| ) ?? null; | ||
| const manualOption = | ||
| RUN_BEHAVIOR_VALUES.find( | ||
| (option) => option.value === ActionRunBehaviour.MANUAL, | ||
| ) ?? null; | ||
|
|
||
| const flagsOutputMatrix: { | ||
| runBehaviour: ActionRunBehaviourType; | ||
| isReactiveActionsEnabled: boolean; | ||
| isOnPageUnloadEnabled: boolean; | ||
| expectedOption: SelectOptionProps | null; | ||
| }[] = [ | ||
| { | ||
| runBehaviour: ActionRunBehaviour.AUTOMATIC, | ||
| isReactiveActionsEnabled: true, | ||
| isOnPageUnloadEnabled: true, | ||
| expectedOption: null, | ||
| }, | ||
| { | ||
| runBehaviour: ActionRunBehaviour.AUTOMATIC, | ||
| isReactiveActionsEnabled: false, | ||
| isOnPageUnloadEnabled: true, | ||
| expectedOption: onPageLoadOption, | ||
| }, | ||
| { | ||
| runBehaviour: ActionRunBehaviour.AUTOMATIC, | ||
| isReactiveActionsEnabled: true, | ||
| isOnPageUnloadEnabled: false, | ||
| expectedOption: null, | ||
| }, | ||
| { | ||
| runBehaviour: ActionRunBehaviour.AUTOMATIC, | ||
| isReactiveActionsEnabled: false, | ||
| isOnPageUnloadEnabled: false, | ||
| expectedOption: onPageLoadOption, | ||
| }, | ||
| { | ||
| runBehaviour: ActionRunBehaviour.ON_PAGE_UNLOAD, | ||
| isReactiveActionsEnabled: true, | ||
| isOnPageUnloadEnabled: true, | ||
| expectedOption: null, | ||
| }, | ||
| { | ||
| runBehaviour: ActionRunBehaviour.ON_PAGE_UNLOAD, | ||
| isReactiveActionsEnabled: false, | ||
| isOnPageUnloadEnabled: true, | ||
| expectedOption: null, | ||
| }, | ||
| { | ||
| runBehaviour: ActionRunBehaviour.ON_PAGE_UNLOAD, | ||
| isReactiveActionsEnabled: true, | ||
| isOnPageUnloadEnabled: false, | ||
| expectedOption: manualOption, | ||
| }, | ||
| { | ||
| runBehaviour: ActionRunBehaviour.ON_PAGE_UNLOAD, | ||
| isReactiveActionsEnabled: false, | ||
| isOnPageUnloadEnabled: false, | ||
| expectedOption: manualOption, | ||
| }, | ||
| ]; | ||
|
|
||
| it("should return the correct options", () => { | ||
| flagsOutputMatrix.forEach( | ||
| ({ | ||
| expectedOption, | ||
| isOnPageUnloadEnabled, | ||
| isReactiveActionsEnabled, | ||
| runBehaviour, | ||
| }) => { | ||
| const option = getDefaultRunBehaviorOptionWhenFeatureFlagIsDisabled( | ||
| runBehaviour, | ||
| isReactiveActionsEnabled, | ||
| isOnPageUnloadEnabled, | ||
| RUN_BEHAVIOR_VALUES, | ||
| ); | ||
|
|
||
| expect(option).toEqual(expectedOption); | ||
| }, | ||
| ); | ||
| }); | ||
| }); |
47 changes: 47 additions & 0 deletions
47
app/client/src/pages/Editor/JSEditor/JSEditorToolbar/components/utils.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { | ||
| ActionRunBehaviour, | ||
| type ActionRunBehaviourType, | ||
| } from "PluginActionEditor/types/PluginActionTypes"; | ||
| import { RUN_BEHAVIOR_VALUES } from "constants/AppsmithActionConstants/formConfig/PluginSettings"; | ||
|
|
||
| import { type SelectOptionProps } from "@appsmith/ads"; | ||
|
|
||
| export const getRunBehaviorOptionsBasedOnFeatureFlags = ( | ||
| isReactiveActionsEnabled: boolean, | ||
| isOnPageUnloadEnabled: boolean, | ||
| ) => | ||
| RUN_BEHAVIOR_VALUES.filter( | ||
| (option) => | ||
| (isReactiveActionsEnabled || | ||
| option.value !== ActionRunBehaviour.AUTOMATIC) && | ||
| (isOnPageUnloadEnabled || | ||
| option.value !== ActionRunBehaviour.ON_PAGE_UNLOAD), | ||
| ) as SelectOptionProps[]; | ||
|
|
||
| export const getDefaultRunBehaviorOptionWhenFeatureFlagIsDisabled = ( | ||
| runBehaviour: ActionRunBehaviourType, | ||
| isReactiveActionsEnabled: boolean, | ||
| isOnPageUnloadEnabled: boolean, | ||
| options: SelectOptionProps[], | ||
| ): SelectOptionProps | null => { | ||
| if ( | ||
| runBehaviour === ActionRunBehaviour.AUTOMATIC && | ||
| !isReactiveActionsEnabled | ||
| ) { | ||
| return ( | ||
| options.find((opt) => opt.value === ActionRunBehaviour.ON_PAGE_LOAD) ?? | ||
| null | ||
| ); | ||
| } | ||
|
|
||
| if ( | ||
| runBehaviour === ActionRunBehaviour.ON_PAGE_UNLOAD && | ||
| !isOnPageUnloadEnabled | ||
| ) { | ||
| return ( | ||
| options.find((opt) => opt.value === ActionRunBehaviour.MANUAL) ?? null | ||
| ); | ||
| } | ||
|
|
||
| return null; | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.