From 83345b6555a70eb286e42b5149e65e32c2cde5e5 Mon Sep 17 00:00:00 2001 From: John Obelenus Date: Thu, 19 Dec 2024 14:51:02 -0500 Subject: [PATCH] Fix: when creating a new change set stay on the view you're on --- app/web/src/components/ApprovalPendingModalCard.vue | 2 +- app/web/src/components/layout/navbar/ChangeSetPanel.vue | 3 +-- app/web/src/store/apis.ts | 1 + app/web/src/store/change_sets.store.ts | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/web/src/components/ApprovalPendingModalCard.vue b/app/web/src/components/ApprovalPendingModalCard.vue index 4f4a4942e3..16d9242262 100644 --- a/app/web/src/components/ApprovalPendingModalCard.vue +++ b/app/web/src/components/ApprovalPendingModalCard.vue @@ -70,7 +70,7 @@ defineProps({ }); const goToChangeSet = (id: ChangeSetId) => { - changeSetsStore.setActiveChangeset(id); + changeSetsStore.setActiveChangeset(id, true); emit("closeModal"); }; const rejectChangeSet = (id: ChangeSetId) => { diff --git a/app/web/src/components/layout/navbar/ChangeSetPanel.vue b/app/web/src/components/layout/navbar/ChangeSetPanel.vue index a1e6aebc80..ee202790d0 100644 --- a/app/web/src/components/layout/navbar/ChangeSetPanel.vue +++ b/app/web/src/components/layout/navbar/ChangeSetPanel.vue @@ -238,8 +238,7 @@ function onSelectChangeSet(newVal: string) { // keep everything in the current route except the change set id // note - we use push here, so there is a new browser history entry - let name = route.name; - if (name === "workspace-compose-view") name = "workspace-compose"; + const name = route.name; router.push({ name, params: { diff --git a/app/web/src/store/apis.ts b/app/web/src/store/apis.ts index 4899d0f48f..6d5dc65f80 100644 --- a/app/web/src/store/apis.ts +++ b/app/web/src/store/apis.ts @@ -50,6 +50,7 @@ async function handleForcedChangesetRedirection(response: AxiosResponse) { const changeSetsStore = useChangeSetsStore(); await changeSetsStore.setActiveChangeset( response.headers.force_change_set_id, + true, ); } diff --git a/app/web/src/store/change_sets.store.ts b/app/web/src/store/change_sets.store.ts index fe70d91836..0e79ef0c91 100644 --- a/app/web/src/store/change_sets.store.ts +++ b/app/web/src/store/change_sets.store.ts @@ -121,7 +121,7 @@ export function useChangeSetsStore() { selectedWorkspacePk: () => workspacePk, }, actions: { - async setActiveChangeset(changeSetId: string) { + async setActiveChangeset(changeSetId: string, stayOnView = false) { // We need to force refetch changesets since there's a race condition in which redirects // will be triggered but the frontend won't have refreshed the list of changesets if (!this.changeSetsById[changeSetId]) { @@ -132,7 +132,7 @@ export function useChangeSetsStore() { const params = { ...route.params }; let name = route.name; // if abandoning changeset and you were looking at view, it may not exist in HEAD - if (name === "workspace-compose-view") { + if (!stayOnView && name === "workspace-compose-view") { name = "workspace-compose"; delete params.viewId; } @@ -530,7 +530,7 @@ export function useChangeSetsStore() { const changeSetName = this.selectedChangeSet?.name; if (data.changeSetId === this.selectedChangeSetId) { if (this.headChangeSetId) { - await this.setActiveChangeset(this.headChangeSetId); + await this.setActiveChangeset(this.headChangeSetId, false); toast({ component: MovedToHead, props: {