diff --git a/packages/hoppscotch-common/src/components/environments/Selector.vue b/packages/hoppscotch-common/src/components/environments/Selector.vue index 0d67ce7d0..3674700a5 100644 --- a/packages/hoppscotch-common/src/components/environments/Selector.vue +++ b/packages/hoppscotch-common/src/components/environments/Selector.vue @@ -46,93 +46,138 @@ } " /> -
-
- -
-
-
+ - - {{ t("state.loading") }} -
-
-
-
-
+ + + {{ t("empty.environments") }} + +
+ + - - {{ errorMessage }} -
- +
+ + {{ t("state.loading") }} +
+
+ +
+ + + {{ t("empty.environments") }} + +
+
+
+ + {{ getErrorMessage(teamAdapterError) }} +
+ + diff --git a/packages/hoppscotch-common/src/components/environments/index.vue b/packages/hoppscotch-common/src/components/environments/index.vue index 0635deb1d..afde48121 100644 --- a/packages/hoppscotch-common/src/components/environments/index.vue +++ b/packages/hoppscotch-common/src/components/environments/index.vue @@ -4,15 +4,6 @@ class="sticky top-0 z-10 flex flex-col flex-shrink-0 overflow-x-auto bg-primary" > - { const workspace = useReadonlyStream(workspaceStatus$, { type: "personal" }) -// Used to switch environment type and team when user switch workspace in the global workspace switcher -// Check if there is a teamID in the workspace, if yes, switch to team environment and select the team -// If there is no teamID, switch to my environment +// Switch to my environments if workspace is personal and to team environments if workspace is team +// also resets selected environment if workspace is personal and the previous selected environment was a team environment watch(workspace, (newWorkspace) => { if (newWorkspace.type === "personal") { switchToMyEnvironments() - setSelectedEnvironmentIndex({ - type: "NO_ENV_SELECTED", - }) - } else if (newWorkspace.type === "team") { - const team = myTeams.value?.find((t) => t.id === newWorkspace.teamID) - updateSelectedTeam(team) - if (selectedEnvironmentIndex.value.type !== "MY_ENV") { setSelectedEnvironmentIndex({ type: "NO_ENV_SELECTED", }) } + } else if (newWorkspace.type === "team") { + const team = myTeams.value?.find((t) => t.id === newWorkspace.teamID) + updateSelectedTeam(team) } }) @@ -207,8 +191,6 @@ defineActionHandler( } ) -const myEnvironments = useReadonlyStream(environments$, []) - const selectedEnvironmentIndex = useStream( selectedEnvironmentIndex$, { type: "NO_ENV_SELECTED" }, @@ -251,17 +233,4 @@ watch( }, { deep: true } ) - -const getErrorMessage = (err: GQLError) => { - if (err.type === "network_error") { - return t("error.network_error") - } else { - switch (err.error) { - case "team_environment/not_found": - return t("team_environment.not_found") - default: - return t("error.something_went_wrong") - } - } -} diff --git a/packages/hoppscotch-common/src/components/environments/teams/index.vue b/packages/hoppscotch-common/src/components/environments/teams/index.vue index 21517e914..ea36f0182 100644 --- a/packages/hoppscotch-common/src/components/environments/teams/index.vue +++ b/packages/hoppscotch-common/src/components/environments/teams/index.vue @@ -1,7 +1,7 @@