Skip to content

Commit

Permalink
fix: workspace list section bugs (#3925)
Browse files Browse the repository at this point in the history
Co-authored-by: jamesgeorge007 <jamesgeorge998001@gmail.com>
  • Loading branch information
nivedin and jamesgeorge007 committed Mar 22, 2024
1 parent 380397c commit ba8c448
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
25 changes: 25 additions & 0 deletions packages/hoppscotch-common/src/components/teams/Team.vue
Expand Up @@ -131,6 +131,7 @@
<HoppSmartConfirmModal
:show="confirmRemove"
:title="t('confirm.remove_team')"
:loading-state="loading"
@hide-modal="confirmRemove = false"
@resolve="deleteTeam()"
/>
Expand Down Expand Up @@ -161,6 +162,8 @@ import IconMoreVertical from "~icons/lucide/more-vertical"
import IconUserX from "~icons/lucide/user-x"
import IconUserPlus from "~icons/lucide/user-plus"
import IconTrash2 from "~icons/lucide/trash-2"
import { useService } from "dioc/vue"
import { WorkspaceService } from "~/services/workspace.service"
const t = useI18n()
Expand All @@ -173,24 +176,46 @@ const props = defineProps<{
const emit = defineEmits<{
(e: "edit-team"): void
(e: "invite-team"): void
(e: "refetch-teams"): void
}>()
const toast = useToast()
const confirmRemove = ref(false)
const confirmExit = ref(false)
const loading = ref(false)
const workspaceService = useService(WorkspaceService)
const deleteTeam = () => {
loading.value = true
pipe(
backendDeleteTeam(props.teamID),
TE.match(
(err) => {
// TODO: Better errors ? We know the possible errors now
toast.error(`${t("error.something_went_wrong")}`)
console.error(err)
loading.value = false
confirmRemove.value = false
},
() => {
toast.success(`${t("team.deleted")}`)
loading.value = false
emit("refetch-teams")
const currentWorkspace = workspaceService.currentWorkspace.value
// If the current workspace is the deleted workspace, change the workspace to personal
if (
currentWorkspace.type === "team" &&
currentWorkspace.teamID === props.teamID
) {
workspaceService.changeWorkspace({ type: "personal" })
}
confirmRemove.value = false
}
)
)() // Tasks (and TEs) are lazy, so call the function returned
Expand Down
10 changes: 3 additions & 7 deletions packages/hoppscotch-common/src/components/teams/index.vue
Expand Up @@ -4,6 +4,7 @@
<HoppButtonSecondary
:label="`${t('team.create_new')}`"
outline
:icon="IconPlus"
@click="displayModalAdd(true)"
/>
<div v-if="loading" class="flex flex-col items-center justify-center">
Expand All @@ -16,13 +17,6 @@
:alt="`${t('empty.teams')}`"
:text="`${t('empty.teams')}`"
>
<template #body>
<HoppButtonSecondary
:label="`${t('team.create_new')}`"
filled
@click="displayModalAdd(true)"
/>
</template>
</HoppSmartPlaceholder>
<div
v-else-if="!loading"
Expand All @@ -39,6 +33,7 @@
:compact="modal"
@edit-team="editTeam(team, team.id)"
@invite-team="inviteTeam(team, team.id)"
@refetch-teams="refetchTeams"
/>
</div>
<div v-if="!loading && adapterError" class="flex flex-col items-center">
Expand Down Expand Up @@ -76,6 +71,7 @@ import { useReadonlyStream } from "@composables/stream"
import { useColorMode } from "@composables/theming"
import { WorkspaceService } from "~/services/workspace.service"
import { useService } from "dioc/vue"
import IconPlus from "~icons/lucide/plus"
const t = useI18n()
Expand Down

0 comments on commit ba8c448

Please sign in to comment.