From ff64f4d02fe1b43ce5327ebb9b5a3f1ea4e29afc Mon Sep 17 00:00:00 2001 From: Favour Ohanekwu Date: Wed, 15 Feb 2023 11:21:33 +0100 Subject: [PATCH] fix: Fetch app's current branch from redux store (#20601) ## Description ### Cause of issue Appsmith's persistent data is stored in the browser's localStorage under a key generated using the `applicationId` and `branch name`. When fetching the store's value on page load, if the branch's name is not present in the URL string, its value defaults to an emptyString. ### Solution Default value of `branch name` should be the current git branch. Fixes #15692 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? manual ### Test Plan Cypress covers test case ### 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: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [x] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [x] Added Test Plan Approved label after reveiwing all Cypress test --- app/client/cypress/support/Pages/GitSync.ts | 4 ++-- app/client/src/entities/Engine/index.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/client/cypress/support/Pages/GitSync.ts b/app/client/cypress/support/Pages/GitSync.ts index 020ee9a66e..08127b1c7f 100644 --- a/app/client/cypress/support/Pages/GitSync.ts +++ b/app/client/cypress/support/Pages/GitSync.ts @@ -35,7 +35,7 @@ export class GitSync { } CreateNConnectToGit( - repoName: string = "Test", + repoName = "Test", assertConnect = true, privateFlag = false, ) { @@ -129,7 +129,7 @@ export class GitSync { }); } - CreateGitBranch(branch: string = "Test", toUseNewGuid = false) { + CreateGitBranch(branch = "Test", toUseNewGuid = false) { if (toUseNewGuid) this.agHelper.GenerateUUID(); this.agHelper.AssertElementExist(this._bottomBarCommit); this.agHelper.GetNClick(this._branchButton); diff --git a/app/client/src/entities/Engine/index.ts b/app/client/src/entities/Engine/index.ts index d32e66416a..6fcb1dd258 100644 --- a/app/client/src/entities/Engine/index.ts +++ b/app/client/src/entities/Engine/index.ts @@ -16,6 +16,7 @@ import history from "utils/history"; import URLRedirect from "entities/URLRedirect/index"; import URLGeneratorFactory from "entities/URLRedirect/factory"; import { updateBranchLocally } from "actions/gitSyncActions"; +import { getCurrentGitBranch } from "selectors/gitSyncSelectors"; export type AppEnginePayload = { applicationId?: string; @@ -69,7 +70,14 @@ export default abstract class AppEngine { if (!apiCalls) throw new PageNotFoundError(`Cannot find page with id: ${pageId}`); const application: ApplicationPayload = yield select(getCurrentApplication); - yield put(updateAppStore(getPersistentAppStore(application.id, branch))); + const currentGitBranch: ReturnType = yield select( + getCurrentGitBranch, + ); + yield put( + updateAppStore( + getPersistentAppStore(application.id, branch || currentGitBranch), + ), + ); const toLoadPageId: string = pageId || (yield select(getDefaultPageId)); this._urlRedirect = URLGeneratorFactory.create( application.applicationVersion,