mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-12 08:30:08 +00:00
refactor: debug naming and misc
This commit is contained in:
@@ -324,8 +324,8 @@ import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI'
|
||||
import type {
|
||||
PendingInvite,
|
||||
WorkspaceMember
|
||||
} from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
} from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { cn } from '@/utils/tailwindUtil'
|
||||
|
||||
@@ -337,7 +337,7 @@ const {
|
||||
showRevokeInviteDialog,
|
||||
showCreateWorkspaceDialog
|
||||
} = useDialogService()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const {
|
||||
members,
|
||||
pendingInvites,
|
||||
|
||||
@@ -100,7 +100,7 @@ import MembersPanelContent from '@/components/dialog/content/setting/MembersPane
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import SubscriptionPanelContent from '@/platform/cloud/subscription/components/SubscriptionPanelContent.vue'
|
||||
import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
|
||||
const { defaultTab = 'plan' } = defineProps<{
|
||||
@@ -113,7 +113,7 @@ const {
|
||||
showDeleteWorkspaceDialog,
|
||||
showInviteMemberDialog
|
||||
} = useDialogService()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const { workspaceName, members, isInviteLimitReached, isWorkspaceSubscribed } =
|
||||
storeToRefs(workspaceStore)
|
||||
const { fetchMembers, fetchPendingInvites } = workspaceStore
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import { storeToRefs } from 'pinia'
|
||||
|
||||
import WorkspaceProfilePic from '@/components/common/WorkspaceProfilePic.vue'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
|
||||
const { workspaceName } = storeToRefs(useWorkspaceStore())
|
||||
const { workspaceName } = storeToRefs(useTeamWorkspaceStore())
|
||||
</script>
|
||||
|
||||
@@ -63,7 +63,7 @@ import { computed, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
|
||||
const { onConfirm } = defineProps<{
|
||||
@@ -73,7 +73,7 @@ const { onConfirm } = defineProps<{
|
||||
const { t } = useI18n()
|
||||
const dialogStore = useDialogStore()
|
||||
const toast = useToast()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const loading = ref(false)
|
||||
const workspaceName = ref('')
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import { ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
|
||||
const { workspaceId, workspaceName } = defineProps<{
|
||||
@@ -60,7 +60,7 @@ const { workspaceId, workspaceName } = defineProps<{
|
||||
const { t } = useI18n()
|
||||
const toast = useToast()
|
||||
const dialogStore = useDialogStore()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const loading = ref(false)
|
||||
|
||||
function onCancel() {
|
||||
|
||||
@@ -57,13 +57,13 @@ import { computed, ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
|
||||
const { t } = useI18n()
|
||||
const toast = useToast()
|
||||
const dialogStore = useDialogStore()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const loading = ref(false)
|
||||
const newWorkspaceName = ref(workspaceStore.workspaceName)
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ import { useToast } from 'primevue/usetoast'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
|
||||
const { onConfirm } = defineProps<{
|
||||
@@ -126,7 +126,7 @@ const { onConfirm } = defineProps<{
|
||||
|
||||
const dialogStore = useDialogStore()
|
||||
const toast = useToast()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
|
||||
const loading = ref(false)
|
||||
const email = ref('')
|
||||
|
||||
@@ -43,13 +43,13 @@ import { ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
|
||||
const { t } = useI18n()
|
||||
const toast = useToast()
|
||||
const dialogStore = useDialogStore()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const loading = ref(false)
|
||||
|
||||
function onCancel() {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
|
||||
const { memberId } = defineProps<{
|
||||
@@ -49,7 +49,7 @@ const { memberId } = defineProps<{
|
||||
}>()
|
||||
|
||||
const dialogStore = useDialogStore()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const loading = ref(false)
|
||||
|
||||
function onCancel() {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
import { ref } from 'vue'
|
||||
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogStore } from '@/stores/dialogStore'
|
||||
|
||||
const { inviteId } = defineProps<{
|
||||
@@ -49,7 +49,7 @@ const { inviteId } = defineProps<{
|
||||
}>()
|
||||
|
||||
const dialogStore = useDialogStore()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const loading = ref(false)
|
||||
|
||||
function onCancel() {
|
||||
|
||||
@@ -47,7 +47,7 @@ import { ref } from 'vue'
|
||||
import WorkspaceProfilePic from '@/components/common/WorkspaceProfilePic.vue'
|
||||
import Button from '@/components/ui/button/Button.vue'
|
||||
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { cn } from '@/utils/tailwindUtil'
|
||||
|
||||
import CurrentUserPopover from './CurrentUserPopover.vue'
|
||||
@@ -58,7 +58,7 @@ const { showArrow = true, compact = false } = defineProps<{
|
||||
}>()
|
||||
|
||||
const { isLoggedIn } = useCurrentUser()
|
||||
const { workspaceName } = storeToRefs(useWorkspaceStore())
|
||||
const { workspaceName } = storeToRefs(useTeamWorkspaceStore())
|
||||
|
||||
const popover = ref<InstanceType<typeof Popover> | null>(null)
|
||||
|
||||
|
||||
@@ -240,11 +240,11 @@ import { useSubscriptionDialog } from '@/platform/cloud/subscription/composables
|
||||
import { isCloud } from '@/platform/distribution/types'
|
||||
import { useTelemetry } from '@/platform/telemetry'
|
||||
import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
|
||||
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const {
|
||||
workspaceName,
|
||||
isInPersonalWorkspace: isPersonalWorkspace,
|
||||
|
||||
@@ -120,7 +120,7 @@ import type {
|
||||
WorkspaceRole,
|
||||
WorkspaceType
|
||||
} from '@/platform/workspace/api/workspaceApi'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
import { cn } from '@/utils/tailwindUtil'
|
||||
|
||||
@@ -140,7 +140,7 @@ const emit = defineEmits<{
|
||||
const { t } = useI18n()
|
||||
const { switchWithConfirmation } = useWorkspaceSwitch()
|
||||
const { showDeleteWorkspaceDialog } = useDialogService()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const { workspaceId, workspaces, canCreateWorkspace, isFetchingWorkspaces } =
|
||||
storeToRefs(workspaceStore)
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import { useWorkspaceSwitch } from '@/platform/auth/workspace/useWorkspaceSwitch'
|
||||
import type { WorkspaceWithRole } from '@/platform/auth/workspace/workspaceTypes'
|
||||
import type { WorkspaceWithRole } from '@/platform/workspace/api/workspaceApi'
|
||||
|
||||
const mockSwitchWorkspace = vi.hoisted(() => vi.fn())
|
||||
const mockActiveWorkspace = vi.hoisted(() => ({
|
||||
value: null as WorkspaceWithRole | null
|
||||
}))
|
||||
|
||||
vi.mock('@/platform/workspace/stores/workspaceStore', () => ({
|
||||
useWorkspaceStore: () => ({
|
||||
vi.mock('@/platform/workspace/stores/teamWorkspaceStore', () => ({
|
||||
useTeamWorkspaceStore: () => ({
|
||||
switchWorkspace: mockSwitchWorkspace
|
||||
})
|
||||
}))
|
||||
|
||||
@@ -2,12 +2,12 @@ import { storeToRefs } from 'pinia'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import { useWorkflowStore } from '@/platform/workflow/management/stores/workflowStore'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
|
||||
export function useWorkspaceSwitch() {
|
||||
const { t } = useI18n()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const { activeWorkspace } = storeToRefs(workspaceStore)
|
||||
const workflowStore = useWorkflowStore()
|
||||
const dialogService = useDialogService()
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
export interface WorkspaceWithRole {
|
||||
id: string
|
||||
name: string
|
||||
type: 'personal' | 'team'
|
||||
role: 'owner' | 'member'
|
||||
}
|
||||
@@ -257,11 +257,11 @@ import {
|
||||
getTierPrice
|
||||
} from '@/platform/cloud/subscription/constants/tierPricing'
|
||||
import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI'
|
||||
import { useWorkspaceStore } from '@/platform/workspace/stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore'
|
||||
import { cn } from '@/utils/tailwindUtil'
|
||||
|
||||
const authActions = useFirebaseAuthActions()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const { isWorkspaceSubscribed } = storeToRefs(workspaceStore)
|
||||
const { subscribeWorkspace } = workspaceStore
|
||||
const { permissions, workspaceRole } = useWorkspaceUI()
|
||||
|
||||
@@ -142,12 +142,6 @@ async function withAuth<T>(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper for workspace-scoped endpoints (e.g., /api/workspace/members).
|
||||
* The workspace context is determined from the Bearer token.
|
||||
*/
|
||||
const withWorkspaceAuth = withAuth
|
||||
|
||||
/**
|
||||
* Wrapper that uses Firebase ID token directly (not workspace token).
|
||||
* Used for token exchange where we need the Firebase token to get a workspace token.
|
||||
@@ -236,7 +230,7 @@ export const workspaceApi = {
|
||||
* POST /api/workspace/leave
|
||||
*/
|
||||
leave: (): Promise<void> =>
|
||||
withWorkspaceAuth((headers) =>
|
||||
withAuth((headers) =>
|
||||
workspaceApiClient.post(api.apiURL('/workspace/leave'), null, { headers })
|
||||
),
|
||||
|
||||
@@ -245,7 +239,7 @@ export const workspaceApi = {
|
||||
* GET /api/workspace/members
|
||||
*/
|
||||
listMembers: (params?: ListMembersParams): Promise<ListMembersResponse> =>
|
||||
withWorkspaceAuth((headers) =>
|
||||
withAuth((headers) =>
|
||||
workspaceApiClient.get(api.apiURL('/workspace/members'), {
|
||||
headers,
|
||||
params
|
||||
@@ -257,7 +251,7 @@ export const workspaceApi = {
|
||||
* DELETE /api/workspace/members/:userId
|
||||
*/
|
||||
removeMember: (userId: string): Promise<void> =>
|
||||
withWorkspaceAuth((headers) =>
|
||||
withAuth((headers) =>
|
||||
workspaceApiClient.delete(api.apiURL(`/workspace/members/${userId}`), {
|
||||
headers
|
||||
})
|
||||
@@ -268,7 +262,7 @@ export const workspaceApi = {
|
||||
* GET /api/workspace/invites
|
||||
*/
|
||||
listInvites: (): Promise<ListInvitesResponse> =>
|
||||
withWorkspaceAuth((headers) =>
|
||||
withAuth((headers) =>
|
||||
workspaceApiClient.get(api.apiURL('/workspace/invites'), { headers })
|
||||
),
|
||||
|
||||
@@ -277,7 +271,7 @@ export const workspaceApi = {
|
||||
* POST /api/workspace/invites
|
||||
*/
|
||||
createInvite: (payload: CreateInviteRequest): Promise<PendingInvite> =>
|
||||
withWorkspaceAuth((headers) =>
|
||||
withAuth((headers) =>
|
||||
workspaceApiClient.post(api.apiURL('/workspace/invites'), payload, {
|
||||
headers
|
||||
})
|
||||
@@ -288,7 +282,7 @@ export const workspaceApi = {
|
||||
* DELETE /api/workspace/invites/:inviteId
|
||||
*/
|
||||
revokeInvite: (inviteId: string): Promise<void> =>
|
||||
withWorkspaceAuth((headers) =>
|
||||
withAuth((headers) =>
|
||||
workspaceApiClient.delete(api.apiURL(`/workspace/invites/${inviteId}`), {
|
||||
headers
|
||||
})
|
||||
@@ -328,10 +322,12 @@ export const workspaceApi = {
|
||||
* Uses workspace-scoped token to get billing portal URL.
|
||||
*/
|
||||
accessBillingPortal: (returnUrl?: string): Promise<BillingPortalResponse> =>
|
||||
withWorkspaceAuth((headers) =>
|
||||
withAuth((headers) =>
|
||||
workspaceApiClient.post(
|
||||
api.apiURL('/billing/portal'),
|
||||
{ return_url: returnUrl ?? window.location.href } satisfies BillingPortalRequest,
|
||||
{
|
||||
return_url: returnUrl ?? window.location.href
|
||||
} satisfies BillingPortalRequest,
|
||||
{ headers }
|
||||
)
|
||||
)
|
||||
|
||||
@@ -9,9 +9,7 @@ import {
|
||||
} from '@/platform/navigation/preservedQueryManager'
|
||||
import { PRESERVED_QUERY_NAMESPACES } from '@/platform/navigation/preservedQueryNamespaces'
|
||||
|
||||
import { useWorkspaceStore } from '../stores/workspaceStore'
|
||||
|
||||
const LOG_PREFIX = '[useInviteUrlLoader]'
|
||||
import { useTeamWorkspaceStore } from '../stores/teamWorkspaceStore'
|
||||
|
||||
/**
|
||||
* Composable for loading workspace invites from URL query parameters
|
||||
@@ -28,7 +26,7 @@ export function useInviteUrlLoader() {
|
||||
const router = useRouter()
|
||||
const { t } = useI18n()
|
||||
const toast = useToast()
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
const INVITE_NAMESPACE = PRESERVED_QUERY_NAMESPACES.INVITE
|
||||
|
||||
/**
|
||||
@@ -70,32 +68,16 @@ export function useInviteUrlLoader() {
|
||||
* 5. Clean up URL and preserved query
|
||||
*/
|
||||
const loadInviteFromUrl = async () => {
|
||||
console.log(LOG_PREFIX, 'Starting invite URL loading')
|
||||
console.log(LOG_PREFIX, 'Current route.query:', route.query)
|
||||
|
||||
// Restore preserved query from sessionStorage (handles login redirect case)
|
||||
const query = await ensureInviteQueryFromIntent()
|
||||
console.log(LOG_PREFIX, 'Query after hydration:', query)
|
||||
|
||||
const inviteParam = query.invite
|
||||
console.log(
|
||||
LOG_PREFIX,
|
||||
'Invite param:',
|
||||
inviteParam,
|
||||
'type:',
|
||||
typeof inviteParam
|
||||
)
|
||||
|
||||
if (!inviteParam || typeof inviteParam !== 'string') {
|
||||
console.log(LOG_PREFIX, 'No valid invite param found, skipping')
|
||||
return
|
||||
}
|
||||
|
||||
console.log(LOG_PREFIX, 'Accepting invite with token:', inviteParam)
|
||||
|
||||
try {
|
||||
const result = await workspaceStore.acceptInvite(inviteParam)
|
||||
console.log(LOG_PREFIX, 'Invite accepted successfully:', result)
|
||||
|
||||
toast.add({
|
||||
severity: 'success',
|
||||
@@ -106,7 +88,6 @@ export function useInviteUrlLoader() {
|
||||
life: 5000
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(LOG_PREFIX, 'Failed to accept invite:', error)
|
||||
toast.add({
|
||||
severity: 'error',
|
||||
summary: t('workspace.inviteFailed'),
|
||||
|
||||
@@ -2,7 +2,7 @@ import { computed, ref } from 'vue'
|
||||
import { createSharedComposable } from '@vueuse/core'
|
||||
|
||||
import type { WorkspaceRole, WorkspaceType } from '../api/workspaceApi'
|
||||
import { useWorkspaceStore } from '../stores/workspaceStore'
|
||||
import { useTeamWorkspaceStore } from '../stores/teamWorkspaceStore'
|
||||
|
||||
/** Permission flags for workspace actions */
|
||||
export interface WorkspacePermissions {
|
||||
@@ -131,7 +131,7 @@ function getUIConfig(
|
||||
* Internal implementation of UI configuration composable.
|
||||
*/
|
||||
function useWorkspaceUIInternal() {
|
||||
const store = useWorkspaceStore()
|
||||
const store = useTeamWorkspaceStore()
|
||||
|
||||
// Tab management (shared UI state)
|
||||
const activeTab = ref<string>('plan')
|
||||
|
||||
@@ -74,7 +74,7 @@ function createWorkspaceState(workspace: WorkspaceWithRole): WorkspaceState {
|
||||
const MAX_OWNED_WORKSPACES = 10
|
||||
const MAX_WORKSPACE_MEMBERS = 50
|
||||
|
||||
export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
export const useTeamWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// STATE
|
||||
// ════════════════════════════════════════════════════════════
|
||||
@@ -332,7 +332,6 @@ export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
async function initialize(): Promise<void> {
|
||||
if (initState.value !== 'uninitialized') return
|
||||
|
||||
console.log('[workspaceStore] Initializing workspace store...')
|
||||
initState.value = 'loading'
|
||||
isFetchingWorkspaces.value = true
|
||||
error.value = null
|
||||
@@ -340,16 +339,6 @@ export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
try {
|
||||
// 1. Fetch all workspaces
|
||||
const response = await workspaceApi.list()
|
||||
console.log('[workspaceStore] initialize API response:', response)
|
||||
console.log(
|
||||
'[workspaceStore] Workspaces from API:',
|
||||
response.workspaces.map((w) => ({
|
||||
id: w.id,
|
||||
name: w.name,
|
||||
type: w.type,
|
||||
role: w.role
|
||||
}))
|
||||
)
|
||||
workspaces.value = response.workspaces.map(createWorkspaceState)
|
||||
|
||||
if (workspaces.value.length === 0) {
|
||||
@@ -418,15 +407,6 @@ export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
isFetchingWorkspaces.value = true
|
||||
try {
|
||||
const response = await workspaceApi.list()
|
||||
console.log('[workspaceStore] refreshWorkspaces API response:', response)
|
||||
console.log(
|
||||
'[workspaceStore] Workspace IDs:',
|
||||
response.workspaces.map((w) => w.id)
|
||||
)
|
||||
console.log(
|
||||
'[workspaceStore] Workspace names:',
|
||||
response.workspaces.map((w) => w.name)
|
||||
)
|
||||
workspaces.value = response.workspaces.map(createWorkspaceState)
|
||||
} finally {
|
||||
isFetchingWorkspaces.value = false
|
||||
@@ -588,23 +568,10 @@ export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
async function fetchMembers(
|
||||
params?: ListMembersParams
|
||||
): Promise<WorkspaceMember[]> {
|
||||
const sessionWorkspaceId = sessionManager.getCurrentWorkspaceId()
|
||||
console.log('[workspaceStore] fetchMembers called')
|
||||
console.log(
|
||||
'[workspaceStore] activeWorkspaceId (store):',
|
||||
activeWorkspaceId.value
|
||||
)
|
||||
console.log('[workspaceStore] sessionWorkspaceId:', sessionWorkspaceId)
|
||||
console.log(
|
||||
'[workspaceStore] IDs match:',
|
||||
activeWorkspaceId.value === sessionWorkspaceId
|
||||
)
|
||||
console.log('[workspaceStore] activeWorkspace:', activeWorkspace.value)
|
||||
if (!activeWorkspaceId.value) return []
|
||||
if (activeWorkspace.value?.type === 'personal') return []
|
||||
|
||||
const response = await workspaceApi.listMembers(params)
|
||||
console.log('[workspaceStore] fetchMembers response:', response)
|
||||
const members = response.members.map(mapApiMemberToWorkspaceMember)
|
||||
updateActiveWorkspace({ members })
|
||||
return members
|
||||
@@ -631,23 +598,10 @@ export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
* Fetch pending invites for the current workspace.
|
||||
*/
|
||||
async function fetchPendingInvites(): Promise<PendingInvite[]> {
|
||||
const sessionWorkspaceId = sessionManager.getCurrentWorkspaceId()
|
||||
console.log('[workspaceStore] fetchPendingInvites called')
|
||||
console.log(
|
||||
'[workspaceStore] activeWorkspaceId (store):',
|
||||
activeWorkspaceId.value
|
||||
)
|
||||
console.log('[workspaceStore] sessionWorkspaceId:', sessionWorkspaceId)
|
||||
console.log(
|
||||
'[workspaceStore] IDs match:',
|
||||
activeWorkspaceId.value === sessionWorkspaceId
|
||||
)
|
||||
console.log('[workspaceStore] activeWorkspace:', activeWorkspace.value)
|
||||
if (!activeWorkspaceId.value) return []
|
||||
if (activeWorkspace.value?.type === 'personal') return []
|
||||
|
||||
const response = await workspaceApi.listInvites()
|
||||
console.log('[workspaceStore] fetchPendingInvites response:', response)
|
||||
const invites = response.invites.map(mapApiInviteToPendingInvite)
|
||||
updateActiveWorkspace({ pendingInvites: invites })
|
||||
return invites
|
||||
@@ -690,23 +644,11 @@ export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
async function acceptInvite(
|
||||
token: string
|
||||
): Promise<{ workspaceId: string; workspaceName: string }> {
|
||||
console.log('[workspaceStore] acceptInvite called with token:', token)
|
||||
console.log(
|
||||
'[workspaceStore] Workspaces BEFORE accept:',
|
||||
workspaces.value.map((w) => ({ id: w.id, name: w.name, type: w.type }))
|
||||
)
|
||||
|
||||
const response = await workspaceApi.acceptInvite(token)
|
||||
console.log('[workspaceStore] acceptInvite API response:', response)
|
||||
|
||||
// Refresh workspace list to include newly joined workspace
|
||||
await refreshWorkspaces()
|
||||
|
||||
console.log(
|
||||
'[workspaceStore] Workspaces AFTER refresh:',
|
||||
workspaces.value.map((w) => ({ id: w.id, name: w.name, type: w.type }))
|
||||
)
|
||||
|
||||
return {
|
||||
workspaceId: response.workspace_id,
|
||||
workspaceName: response.workspace_name
|
||||
@@ -778,22 +720,6 @@ export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
clearTokenContext()
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// DEV HELPERS
|
||||
// ════════════════════════════════════════════════════════════
|
||||
|
||||
function setMockRole(role: 'owner' | 'member') {
|
||||
updateActiveWorkspace({ role })
|
||||
}
|
||||
|
||||
function setMockSubscribed(subscribed: boolean) {
|
||||
updateActiveWorkspace({ isSubscribed: subscribed })
|
||||
}
|
||||
|
||||
function setMockType(type: 'personal' | 'team') {
|
||||
updateActiveWorkspace({ type })
|
||||
}
|
||||
|
||||
// ════════════════════════════════════════════════════════════
|
||||
// RETURN
|
||||
// ════════════════════════════════════════════════════════════
|
||||
@@ -852,11 +778,6 @@ export const useWorkspaceStore = defineStore('teamWorkspace', () => {
|
||||
copyInviteLink,
|
||||
|
||||
// Subscription
|
||||
subscribeWorkspace,
|
||||
|
||||
// Dev helpers
|
||||
setMockRole,
|
||||
setMockSubscribed,
|
||||
setMockType
|
||||
subscribeWorkspace
|
||||
}
|
||||
})
|
||||
@@ -187,9 +187,9 @@ if (isCloud) {
|
||||
// TODO: Use flags.teamWorkspacesEnabled when backend enables the flag
|
||||
const teamWorkspacesEnabled = true
|
||||
if (to.path === '/' && teamWorkspacesEnabled) {
|
||||
const { useWorkspaceStore } =
|
||||
await import('@/platform/workspace/stores/workspaceStore')
|
||||
const workspaceStore = useWorkspaceStore()
|
||||
const { useTeamWorkspaceStore } =
|
||||
await import('@/platform/workspace/stores/teamWorkspaceStore')
|
||||
const workspaceStore = useTeamWorkspaceStore()
|
||||
|
||||
if (workspaceStore.initState === 'uninitialized') {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user