Skip to content

Commit b4d5685

Browse files
authored
feat: integrates on page unload behavior with backend for deployed mode of the app (#41036)
## Description **TLDR:** Adds support for executing page unload actions during navigation in deployed mode, refactors related components, and improves action handling. <ins>Problem</ins> Page unload actions were not triggered during navigation in deployed mode, leading to incomplete workflows especially for cleanup. <ins>Root cause</ins> The application lacked integration for executing unload actions on page transitions, and related components did not properly handle navigation or action execution. <ins>Solution</ins> This PR handles the integration of page unload action execution during navigation in deployed mode. It introduces selectors for unload actions, refactors the MenuItem component for better navigation handling, and improves the PluginActionSaga for executing plugin actions. Unused parameters and functions are removed for clarity and maintainability. Fixes #40997 _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="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/16021075820> > Commit: f09e3c4 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=16021075820&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Wed, 02 Jul 2025 10:21:00 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** * Added support for actions that execute automatically when navigating away from a page. * Introduced new navigation logic and hooks for consistent page transitions within the app. * Added new menu and dropdown components for improved navigation UI. * **Bug Fixes** * Updated navigation item styling and active state detection for improved accuracy. * **Tests** * Added comprehensive tests for navigation sagas and page unload actions. * Added unit tests for navigation menu components. * **Chores** * Refactored and centralized navigation logic for maintainability. * Improved type safety and selector usage in navigation and action execution. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 481988d commit b4d5685

File tree

19 files changed

+1550
-94
lines changed

19 files changed

+1550
-94
lines changed

app/client/cypress/support/Pages/AppSettings/AppSettings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class AppSettings {
5959
".t--app-viewer-navigation-top-inline-more-dropdown-item",
6060
_scrollArrows: ".scroll-arrows",
6161
_getActivePage: (pageName: string) =>
62-
`//span[contains(text(),"${pageName}")]//ancestor::a[contains(@class,'is-active')]`,
62+
`//span[contains(text(),"${pageName}")]//ancestor::div[contains(@class,'is-active')]`,
6363
_importBtn: "[data-testid='t--app-setting-import-btn']",
6464
};
6565

app/client/src/actions/pageActions.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import type { PACKAGE_PULL_STATUS } from "ee/constants/ModuleConstants";
3030
import type { ApiResponse } from "api/ApiResponses";
3131
import type { EvaluationReduxAction } from "./EvaluationReduxActionTypes";
3232
import { appsmithTelemetry } from "instrumentation";
33+
import type { NavigateToAnotherPagePayload } from "sagas/ActionExecution/NavigateActionSaga/types";
3334

3435
export interface FetchPageListPayload {
3536
applicationId: string;
@@ -696,3 +697,10 @@ export const setupPublishedPage = (
696697
pageWithMigratedDsl,
697698
},
698699
});
700+
701+
export const navigateToAnotherPage = (
702+
payload: NavigateToAnotherPagePayload,
703+
) => ({
704+
type: ReduxActionTypes.NAVIGATE_TO_ANOTHER_PAGE,
705+
payload,
706+
});

app/client/src/ce/constants/ReduxActionConstants.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ const PageActionTypes = {
620620
RESET_PAGE_LIST: "RESET_PAGE_LIST",
621621
SET_ONLOAD_ACTION_EXECUTED: "SET_ONLOAD_ACTION_EXECUTED",
622622
EXECUTE_REACTIVE_QUERIES: "EXECUTE_REACTIVE_QUERIES",
623+
NAVIGATE_TO_ANOTHER_PAGE: "NAVIGATE_TO_ANOTHER_PAGE",
623624
};
624625

625626
const PageActionErrorTypes = {
@@ -731,6 +732,9 @@ const ActionExecutionTypes = {
731732
CANCEL_ACTION_MODAL: "CANCEL_ACTION_MODAL",
732733
CONFIRM_ACTION_MODAL: "CONFIRM_ACTION_MODAL",
733734
EXECUTE_PAGE_LOAD_ACTIONS: "EXECUTE_PAGE_LOAD_ACTIONS",
735+
EXECUTE_PAGE_UNLOAD_ACTIONS: "EXECUTE_PAGE_UNLOAD_ACTIONS",
736+
EXECUTE_PAGE_UNLOAD_ACTIONS_SUCCESS: "EXECUTE_PAGE_UNLOAD_ACTIONS_SUCCESS",
737+
EXECUTE_PAGE_UNLOAD_ACTIONS_ERROR: "EXECUTE_PAGE_UNLOAD_ACTIONS_ERROR",
734738
EXECUTE_PLUGIN_ACTION_REQUEST: "EXECUTE_PLUGIN_ACTION_REQUEST",
735739
EXECUTE_PLUGIN_ACTION_SUCCESS: "EXECUTE_PLUGIN_ACTION_SUCCESS",
736740
SET_ACTION_RESPONSE_DISPLAY_FORMAT: "SET_ACTION_RESPONSE_DISPLAY_FORMAT",

app/client/src/entities/Action/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export enum ActionExecutionContext {
3939
PAGE_LOAD = "PAGE_LOAD",
4040
EVALUATION_ACTION_TRIGGER = "EVALUATION_ACTION_TRIGGER",
4141
REFRESH_ACTIONS_ON_ENV_CHANGE = "REFRESH_ACTIONS_ON_ENV_CHANGE",
42+
PAGE_UNLOAD = "PAGE_UNLOAD",
4243
}
4344

4445
export interface KeyValuePair {

app/client/src/pages/AppViewer/Navigation/components/MenuItem.styled.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@ import {
55
getMenuItemBackgroundColorWhenActive,
66
getMenuItemTextColor,
77
} from "pages/AppViewer/utils";
8-
import { NavLink } from "react-router-dom";
98
import styled from "styled-components";
109

11-
export const StyledMenuItem = styled(NavLink)<{
10+
export const StyledMenuItem = styled.div<{
1211
borderRadius: string;
1312
primaryColor: string;
1413
navColorStyle: NavigationSetting["colorStyle"];

0 commit comments

Comments
 (0)