From 252fe9e5d61995dd720ae55f2ec8b244349b4781 Mon Sep 17 00:00:00 2001 From: Nivedin Date: Mon, 8 May 2023 16:19:05 +0530 Subject: [PATCH] fix: reset env when workspace change --- .../src/components/environments/index.vue | 196 ++---------------- 1 file changed, 17 insertions(+), 179 deletions(-) diff --git a/packages/hoppscotch-common/src/components/environments/index.vue b/packages/hoppscotch-common/src/components/environments/index.vue index 02af537fa..ba981bd84 100644 --- a/packages/hoppscotch-common/src/components/environments/index.vue +++ b/packages/hoppscotch-common/src/components/environments/index.vue @@ -4,153 +4,15 @@ class="sticky top-0 z-10 flex flex-col flex-shrink-0 overflow-x-auto bg-primary" > - - - - - - - - - - - - - - + { if (!teamID) { switchToMyEnvironments() + + setSelectedEnvironmentIndex({ + type: "NO_ENV_SELECTED", + }) } else if (teamID) { const team = myTeams.value?.find((t) => t.id === teamID) if (team) { updateSelectedTeam(team) + + setSelectedEnvironmentIndex({ + type: "NO_ENV_SELECTED", + }) } } } @@ -388,33 +256,6 @@ watch( { deep: true } ) -const selectedEnv = computed(() => { - if (selectedEnvironmentIndex.value.type === "MY_ENV") { - return { - type: "MY_ENV", - index: selectedEnvironmentIndex.value.index, - } - } else if (selectedEnvironmentIndex.value.type === "TEAM_ENV") { - const teamEnv = teamEnvironmentList.value.find( - (env) => - env.id === - (selectedEnvironmentIndex.value.type === "TEAM_ENV" && - selectedEnvironmentIndex.value.teamEnvID) - ) - if (teamEnv) { - return { - type: "TEAM_ENV", - name: teamEnv.environment.name, - teamEnvID: selectedEnvironmentIndex.value.teamEnvID, - } - } else { - return { type: "NO_ENV_SELECTED" } - } - } else { - return { type: "NO_ENV_SELECTED" } - } -}) - const getErrorMessage = (err: GQLError) => { if (err.type === "network_error") { return t("error.network_error") @@ -427,7 +268,4 @@ const getErrorMessage = (err: GQLError) => { } } } - -// Template refs -const tippyActions = ref(null)