fix: credit display and top up and other UI display if personal membe… (#8784)

## Summary

Consolidate scattered role checks for credits, top-up, and subscribe
buttons into centralized workspace permissions (canTopUp,
canManageSubscription), ensuring "Add Credits" requires an active
subscription, subscribe buttons only appear when needed, and team
members see appropriately restricted billing UI.

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8784-fix-credit-display-and-top-up-and-other-UI-display-if-personal-membe-3036d73d3650810fbc2de084f738943c)
by [Unito](https://www.unito.io)
This commit is contained in:
Simula_r
2026-02-11 14:26:35 -08:00
committed by GitHub
parent adcb663b3e
commit dd1fefe843
4 changed files with 107 additions and 104 deletions

View File

@@ -172,16 +172,11 @@
</div>
</div>
<div class="flex flex-col lg:flex-row gap-6 pt-9">
<div class="flex flex-col shrink-0">
<div class="flex flex-col gap-3">
<div class="flex flex-col lg:flex-row lg:items-stretch gap-6 pt-6">
<div class="flex flex-col">
<div class="flex flex-col gap-3 h-full">
<div
:class="
cn(
'relative flex flex-col gap-6 rounded-2xl p-5',
'bg-modal-panel-background'
)
"
class="relative flex flex-col gap-6 rounded-2xl p-5 bg-modal-panel-background justify-between h-full"
>
<Button
variant="muted-textonly"
@@ -246,9 +241,15 @@
</tbody>
</table>
<div class="flex items-center justify-between">
<div
v-if="
isActiveSubscription &&
!showZeroState &&
permissions.canTopUp
"
class="flex items-center justify-between"
>
<Button
v-if="isActiveSubscription && !showZeroState"
variant="secondary"
class="p-2 min-h-8 rounded-lg text-sm font-normal text-text-primary bg-interface-menu-component-surface-selected"
@click="handleAddApiCredits"
@@ -296,7 +297,11 @@
<!-- Members invoice card -->
<div
v-if="isActiveSubscription && !isInPersonalWorkspace"
v-if="
isActiveSubscription &&
!isInPersonalWorkspace &&
permissions.canManageSubscription
"
class="mt-6 flex gap-1 rounded-2xl border border-interface-stroke p-6 justify-between items-center text-sm"
>
<div class="flex flex-col gap-2">
@@ -319,7 +324,10 @@
</div>
<!-- View More Details - Outside main content -->
<div class="flex items-center gap-2 py-6">
<div
v-if="permissions.canManageSubscription"
class="flex items-center gap-2 py-6"
>
<i class="pi pi-external-link text-muted"></i>
<a
href="https://www.comfy.org/cloud/pricing"
@@ -366,7 +374,7 @@ import { cn } from '@/utils/tailwindUtil'
const workspaceStore = useTeamWorkspaceStore()
const { isWorkspaceSubscribed, isInPersonalWorkspace, members } =
storeToRefs(workspaceStore)
const { permissions, workspaceRole } = useWorkspaceUI()
const { permissions } = useWorkspaceUI()
const { t, n } = useI18n()
const toast = useToast()
@@ -421,7 +429,7 @@ const isCancelled = computed(
// Show subscribe prompt to owners without active subscription
// Don't show if subscription is cancelled (still active until end date)
const showSubscribePrompt = computed(() => {
if (workspaceRole.value !== 'owner') return false
if (!permissions.value.canManageSubscription) return false
if (isCancelled.value) return false
if (isInPersonalWorkspace.value) return !isActiveSubscription.value
return !isWorkspaceSubscribed.value

View File

@@ -14,6 +14,7 @@ interface WorkspacePermissions {
canLeaveWorkspace: boolean
canAccessWorkspaceMenu: boolean
canManageSubscription: boolean
canTopUp: boolean
}
/** UI configuration for workspace role */
@@ -44,7 +45,8 @@ function getPermissions(
canRemoveMembers: false,
canLeaveWorkspace: false,
canAccessWorkspaceMenu: false,
canManageSubscription: true
canManageSubscription: true,
canTopUp: true
}
}
@@ -57,7 +59,8 @@ function getPermissions(
canRemoveMembers: true,
canLeaveWorkspace: true,
canAccessWorkspaceMenu: true,
canManageSubscription: true
canManageSubscription: true,
canTopUp: true
}
}
@@ -70,7 +73,8 @@ function getPermissions(
canRemoveMembers: false,
canLeaveWorkspace: true,
canAccessWorkspaceMenu: true,
canManageSubscription: false
canManageSubscription: false,
canTopUp: false
}
}