-
Notifications
You must be signed in to change notification settings - Fork 673
feat(workspace): enable local credit workspace switching FE-1584 #15164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
82d7f23
f027006
12e926b
8070e42
8537d1c
c3d0f97
31a8b18
60c4033
c96280f
ae42812
ff4b46d
17d5c27
f2ab080
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,9 +30,39 @@ | |
| </span> | ||
| </div> | ||
|
|
||
| <div v-if="showWorkspaceSwitcher" class="relative"> | ||
| <Button | ||
| v-tooltip="{ value: workspaceName, showDelay: 300 }" | ||
| variant="muted-textonly" | ||
| class="flex h-auto w-full items-center justify-between rounded-lg px-4 py-2 hover:bg-secondary-background-hover" | ||
| :aria-expanded="isWorkspaceSwitcherOpen" | ||
| data-testid="workspace-switcher-trigger" | ||
| @click="isWorkspaceSwitcherOpen = !isWorkspaceSwitcherOpen" | ||
| > | ||
| <div class="flex w-0 flex-1 items-center gap-2"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (non-blocking): The trigger button sets Minimum fix: <Button
:aria-expanded="isWorkspaceSwitcherOpen"
+ aria-haspopup="true"
+ aria-controls="workspace-switcher-panel"
+ @keydown.escape.stop="isWorkspaceSwitcherOpen = false"
...
/>
<div
+ id="workspace-switcher-panel"
+ role="menu"
v-if="isWorkspaceSwitcherOpen"
...
/>The Cloud version has the same gap -- good opportunity to fix both.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in c96280f for both variants. The triggers now expose |
||
| <WorkspaceProfilePic | ||
| class="size-6 shrink-0 text-xs" | ||
| :workspace-name="workspaceName" | ||
| /> | ||
| <span class="truncate text-sm text-base-foreground"> | ||
| {{ workspaceName }} | ||
| </span> | ||
| </div> | ||
| <i class="pi pi-chevron-down shrink-0 text-sm text-muted-foreground" /> | ||
| </Button> | ||
|
|
||
| <div | ||
| v-if="isWorkspaceSwitcherOpen" | ||
| class="absolute top-0 right-full z-10 mr-4 rounded-lg border border-border-default bg-base-background shadow-[1px_1px_8px_0_rgba(0,0,0,0.4)]" | ||
| data-testid="workspace-switcher-panel" | ||
| > | ||
| <WorkspaceSwitcherPopover @select="isWorkspaceSwitcherOpen = false" /> | ||
| </div> | ||
| </div> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pos-test
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: The Cloud version (
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in c96280f. The Local flyout now mirrors the Cloud implementation with |
||
|
|
||
| <!-- Credits Section --> | ||
| <div | ||
| v-if="canAccessSubscriptionFeatures" | ||
| v-if="canAccessSubscriptionFeatures || showWorkspaceSwitcher" | ||
| class="flex items-center gap-2 px-4 py-2" | ||
| > | ||
| <i class="icon-[lucide--component] text-sm text-credit" /> | ||
|
|
@@ -60,7 +90,7 @@ | |
| {{ $t('subscription.upgradeToAddCredits') }} | ||
| </Button> | ||
| <Button | ||
| v-else | ||
| v-else-if="showAddCredits" | ||
| variant="secondary" | ||
| size="sm" | ||
| class="text-base-foreground" | ||
|
|
@@ -114,7 +144,7 @@ | |
| </div> | ||
|
|
||
| <div | ||
| v-if="canAccessSubscriptionFeatures" | ||
| v-if="canAccessSubscriptionFeatures || showWorkspaceSwitcher" | ||
| class="flex cursor-pointer items-center gap-2 px-4 py-2 hover:bg-secondary-background-hover" | ||
| data-testid="manage-plan-menu-item" | ||
| @click="handleOpenPlanAndCreditsSettings" | ||
|
|
@@ -160,9 +190,10 @@ | |
|
|
||
| <script setup lang="ts"> | ||
| import { cn } from '@comfyorg/tailwind-utils' | ||
| import { storeToRefs } from 'pinia' | ||
| import Divider from 'primevue/divider' | ||
| import Skeleton from 'primevue/skeleton' | ||
| import { computed, onMounted } from 'vue' | ||
| import { computed, onMounted, ref } from 'vue' | ||
| import { useI18n } from 'vue-i18n' | ||
|
|
||
| import { formatCreditsFromCents } from '@/base/credits/comfyCredits' | ||
|
|
@@ -176,7 +207,11 @@ import { useSubscriptionDialog } from '@/platform/cloud/subscription/composables | |
| import { isCloud } from '@/platform/distribution/types' | ||
| import { useTelemetry } from '@/platform/telemetry' | ||
| import { useSettingsDialog } from '@/platform/settings/composables/useSettingsDialog' | ||
| import WorkspaceProfilePic from '@/platform/workspace/components/WorkspaceProfilePic.vue' | ||
| import WorkspaceSwitcherPopover from '@/platform/workspace/components/WorkspaceSwitcherPopover.vue' | ||
| import { useWorkspaceTierLabel } from '@/platform/workspace/composables/useWorkspaceTierLabel' | ||
| import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI' | ||
| import { useTeamWorkspaceStore } from '@/platform/workspace/stores/teamWorkspaceStore' | ||
| import { useDialogService } from '@/services/dialogService' | ||
|
|
||
| const emit = defineEmits<{ | ||
|
|
@@ -203,6 +238,21 @@ const { formatTierName } = useWorkspaceTierLabel() | |
| const subscriptionDialog = useSubscriptionDialog() | ||
| const { locale, t } = useI18n() | ||
|
|
||
| const { initState, workspaces, workspaceName } = storeToRefs( | ||
| useTeamWorkspaceStore() | ||
| ) | ||
| const isWorkspaceSwitcherOpen = ref(false) | ||
| const showWorkspaceSwitcher = computed( | ||
| () => initState.value === 'ready' && workspaces.value.length > 0 | ||
| ) | ||
|
|
||
| const { permissions } = useWorkspaceUI() | ||
| const showAddCredits = computed(() => | ||
| showWorkspaceSwitcher.value | ||
| ? permissions.value.canTopUp | ||
| : canAccessSubscriptionFeatures.value | ||
| ) | ||
|
|
||
| const subscriptionTierName = computed(() => | ||
| formatTierName(tier.value, subscription.value?.duration === 'ANNUAL') | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pos-test