fix: workspace environment list reset (#4361)
This commit is contained in:
@@ -112,6 +112,12 @@ const adapterLoading = useReadonlyStream(adapter.loading$, false)
|
|||||||
const adapterError = useReadonlyStream(adapter.error$, null)
|
const adapterError = useReadonlyStream(adapter.error$, null)
|
||||||
const teamEnvironmentList = useReadonlyStream(adapter.teamEnvironmentList$, [])
|
const teamEnvironmentList = useReadonlyStream(adapter.teamEnvironmentList$, [])
|
||||||
|
|
||||||
|
const selectedEnvironmentIndex = useStream(
|
||||||
|
selectedEnvironmentIndex$,
|
||||||
|
{ type: "NO_ENV_SELECTED" },
|
||||||
|
setSelectedEnvironmentIndex
|
||||||
|
)
|
||||||
|
|
||||||
const loading = computed(
|
const loading = computed(
|
||||||
() => adapterLoading.value && teamEnvironmentList.value.length === 0
|
() => adapterLoading.value && teamEnvironmentList.value.length === 0
|
||||||
)
|
)
|
||||||
@@ -138,29 +144,33 @@ const workspace = workspaceService.currentWorkspace
|
|||||||
|
|
||||||
// Switch to my environments if workspace is personal and to team environments if workspace is team
|
// 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
|
// also resets selected environment if workspace is personal and the previous selected environment was a team environment
|
||||||
watch(workspace, (newWorkspace) => {
|
watch(
|
||||||
const { type: newWorkspaceType } = newWorkspace
|
workspace,
|
||||||
|
(newWorkspace) => {
|
||||||
|
const { type: newWorkspaceType } = newWorkspace
|
||||||
|
|
||||||
if (newWorkspaceType === "personal") {
|
if (newWorkspaceType === "personal") {
|
||||||
switchToMyEnvironments()
|
switchToMyEnvironments()
|
||||||
} else {
|
} else {
|
||||||
updateSelectedTeam(newWorkspace)
|
updateSelectedTeam(newWorkspace)
|
||||||
}
|
}
|
||||||
|
|
||||||
const newTeamID =
|
const newTeamID =
|
||||||
newWorkspaceType === "team" ? newWorkspace.teamID : undefined
|
newWorkspaceType === "team" ? newWorkspace.teamID : undefined
|
||||||
|
|
||||||
// Set active environment to the `No environment` state
|
// Set active environment to the `No environment` state
|
||||||
// if navigating away from a team workspace
|
// if navigating away from a team workspace
|
||||||
if (
|
if (
|
||||||
selectedEnvironmentIndex.value.type === "TEAM_ENV" &&
|
selectedEnvironmentIndex.value.type === "TEAM_ENV" &&
|
||||||
selectedEnvironmentIndex.value.teamID !== newTeamID
|
selectedEnvironmentIndex.value.teamID !== newTeamID
|
||||||
) {
|
) {
|
||||||
setSelectedEnvironmentIndex({
|
setSelectedEnvironmentIndex({
|
||||||
type: "NO_ENV_SELECTED",
|
type: "NO_ENV_SELECTED",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => currentUser.value,
|
() => currentUser.value,
|
||||||
@@ -256,12 +266,6 @@ defineActionHandler(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const selectedEnvironmentIndex = useStream(
|
|
||||||
selectedEnvironmentIndex$,
|
|
||||||
{ type: "NO_ENV_SELECTED" },
|
|
||||||
setSelectedEnvironmentIndex
|
|
||||||
)
|
|
||||||
|
|
||||||
/* Checking if there are any changes in the selected team environment when there are any updates
|
/* Checking if there are any changes in the selected team environment when there are any updates
|
||||||
in the selected team environment list */
|
in the selected team environment list */
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
Reference in New Issue
Block a user