PromucFlow_constructor/app/client/src/pages/Editor/loader.tsx

75 lines
1.9 KiB
TypeScript
Raw Normal View History

import React from "react";
import PageLoadingBar from "pages/common/PageLoadingBar";
import { retryPromise } from "utils/AppsmithUtils";
perf: Optimise App loading apis (#24365) ## Description Start downloading app data earlier to improve load times. #### PR fixes following issue(s) Fixes #24618 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [ ] Cypress #### Test Plan - [x] Loading apps in view/edit mode from home page and having them work perfectly - [x] Opening apps in view/edit mode directly via links and having them work perfectly - [x] Having apps with on page load actions - [x] Test with complex widgets and see if they work properly > > #### Issues raised during DP testing https://github.com/appsmithorg/appsmith/pull/24365#issuecomment-1624013687 > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
2023-07-10 05:51:40 +00:00
import { connect } from "react-redux";
import type { InitializeEditorPayload } from "actions/initActions";
import { initEditor } from "actions/initActions";
import { getSearchQuery } from "../../utils/helpers";
import { GIT_BRANCH_QUERY_KEY } from "../../constants/routes";
import { APP_MODE } from "../../entities/App";
import type { RouteComponentProps } from "react-router";
fix: clear eval cache when editor/appviewer loader unmounts (#26950) ## Description Previously, while editing an app, if a user navigates to the applications page the eval cache remains unchanged. As a result, setInterval callbacks still get executed. This PR clears the eval cache when the appViewer/Editor loader component is unmounted. #### PR fixes following issue(s) Fixes #26969 #### Type of change - Bug fix (non-breaking change which fixes an issue) - ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-09-07 07:37:32 +00:00
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
perf: Optimise App loading apis (#24365) ## Description Start downloading app data earlier to improve load times. #### PR fixes following issue(s) Fixes #24618 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [ ] Cypress #### Test Plan - [x] Loading apps in view/edit mode from home page and having them work perfectly - [x] Opening apps in view/edit mode directly via links and having them work perfectly - [x] Having apps with on page load actions - [x] Test with complex widgets and see if they work properly > > #### Issues raised during DP testing https://github.com/appsmithorg/appsmith/pull/24365#issuecomment-1624013687 > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
2023-07-10 05:51:40 +00:00
type Props = {
initEditor: (payload: InitializeEditorPayload) => void;
fix: clear eval cache when editor/appviewer loader unmounts (#26950) ## Description Previously, while editing an app, if a user navigates to the applications page the eval cache remains unchanged. As a result, setInterval callbacks still get executed. This PR clears the eval cache when the appViewer/Editor loader component is unmounted. #### PR fixes following issue(s) Fixes #26969 #### Type of change - Bug fix (non-breaking change which fixes an issue) - ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-09-07 07:37:32 +00:00
clearCache: () => void;
perf: Optimise App loading apis (#24365) ## Description Start downloading app data earlier to improve load times. #### PR fixes following issue(s) Fixes #24618 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [ ] Cypress #### Test Plan - [x] Loading apps in view/edit mode from home page and having them work perfectly - [x] Opening apps in view/edit mode directly via links and having them work perfectly - [x] Having apps with on page load actions - [x] Test with complex widgets and see if they work properly > > #### Issues raised during DP testing https://github.com/appsmithorg/appsmith/pull/24365#issuecomment-1624013687 > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
2023-07-10 05:51:40 +00:00
} & RouteComponentProps<{ pageId: string }>;
class EditorLoader extends React.PureComponent<Props, { Page: any }> {
constructor(props: any) {
super(props);
this.state = {
Page: null,
};
}
perf: Optimise App loading apis (#24365) ## Description Start downloading app data earlier to improve load times. #### PR fixes following issue(s) Fixes #24618 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [ ] Cypress #### Test Plan - [x] Loading apps in view/edit mode from home page and having them work perfectly - [x] Opening apps in view/edit mode directly via links and having them work perfectly - [x] Having apps with on page load actions - [x] Test with complex widgets and see if they work properly > > #### Issues raised during DP testing https://github.com/appsmithorg/appsmith/pull/24365#issuecomment-1624013687 > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
2023-07-10 05:51:40 +00:00
initialise() {
const {
initEditor,
location: { search },
match: { params },
} = this.props;
const branch = getSearchQuery(search, GIT_BRANCH_QUERY_KEY);
const { pageId } = params;
if (pageId) {
initEditor({
pageId,
branch,
mode: APP_MODE.EDIT,
});
}
}
componentDidMount() {
perf: Optimise App loading apis (#24365) ## Description Start downloading app data earlier to improve load times. #### PR fixes following issue(s) Fixes #24618 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [ ] Cypress #### Test Plan - [x] Loading apps in view/edit mode from home page and having them work perfectly - [x] Opening apps in view/edit mode directly via links and having them work perfectly - [x] Having apps with on page load actions - [x] Test with complex widgets and see if they work properly > > #### Issues raised during DP testing https://github.com/appsmithorg/appsmith/pull/24365#issuecomment-1624013687 > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
2023-07-10 05:51:40 +00:00
this.initialise();
retryPromise(
async () => import(/* webpackChunkName: "editor" */ "./index"),
).then((module) => {
this.setState({ Page: module.default });
});
}
fix: clear eval cache when editor/appviewer loader unmounts (#26950) ## Description Previously, while editing an app, if a user navigates to the applications page the eval cache remains unchanged. As a result, setInterval callbacks still get executed. This PR clears the eval cache when the appViewer/Editor loader component is unmounted. #### PR fixes following issue(s) Fixes #26969 #### Type of change - Bug fix (non-breaking change which fixes an issue) - ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-09-07 07:37:32 +00:00
componentWillUnmount() {
const { clearCache } = this.props;
clearCache();
}
render() {
const { Page } = this.state;
return Page ? <Page {...this.props} /> : <PageLoadingBar />;
}
}
perf: Optimise App loading apis (#24365) ## Description Start downloading app data earlier to improve load times. #### PR fixes following issue(s) Fixes #24618 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [ ] Cypress #### Test Plan - [x] Loading apps in view/edit mode from home page and having them work perfectly - [x] Opening apps in view/edit mode directly via links and having them work perfectly - [x] Having apps with on page load actions - [x] Test with complex widgets and see if they work properly > > #### Issues raised during DP testing https://github.com/appsmithorg/appsmith/pull/24365#issuecomment-1624013687 > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
2023-07-10 05:51:40 +00:00
const mapDispatchToProps = (dispatch: any) => {
return {
initEditor: (payload: InitializeEditorPayload) =>
dispatch(initEditor(payload)),
fix: clear eval cache when editor/appviewer loader unmounts (#26950) ## Description Previously, while editing an app, if a user navigates to the applications page the eval cache remains unchanged. As a result, setInterval callbacks still get executed. This PR clears the eval cache when the appViewer/Editor loader component is unmounted. #### PR fixes following issue(s) Fixes #26969 #### Type of change - Bug fix (non-breaking change which fixes an issue) - ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
2023-09-07 07:37:32 +00:00
clearCache: () => {
dispatch({ type: ReduxActionTypes.CLEAR_CACHE });
},
perf: Optimise App loading apis (#24365) ## Description Start downloading app data earlier to improve load times. #### PR fixes following issue(s) Fixes #24618 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing > #### How Has This Been Tested? - [ ] Cypress #### Test Plan - [x] Loading apps in view/edit mode from home page and having them work perfectly - [x] Opening apps in view/edit mode directly via links and having them work perfectly - [x] Having apps with on page load actions - [x] Test with complex widgets and see if they work properly > > #### Issues raised during DP testing https://github.com/appsmithorg/appsmith/pull/24365#issuecomment-1624013687 > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --------- Co-authored-by: akash-codemonk <67054171+akash-codemonk@users.noreply.github.com>
2023-07-10 05:51:40 +00:00
};
};
export default connect(null, mapDispatchToProps)(EditorLoader);