Skip to content

Commit e55dd4b

Browse files
Glary-Botchristian-byrne
authored andcommitted
refactor: rename isActiveSubscription to canAccessSubscriptionFeatures
The name isActiveSubscription was misleading: it's defined as !isCloud || !subscription_required || subscription.is_active so it returns true on non-cloud builds and when subscription is not required, regardless of actual subscription state. The new name canAccessSubscriptionFeatures reads correctly at every call site: 'if can access features, show UI / allow action'. This revives the spirit of PR #7127 which attempted the internal rename (isSubscribed -> isSubscribedOrIsNotCloud) but never tackled the exported public name. Scope: - Renamed exported composable property from isActiveSubscription to canAccessSubscriptionFeatures in useSubscription, useBillingContext, useWorkspaceBilling, useLegacyBilling. - Renamed the internal alias isSubscribedOrIsNotCloud to match. - Updated all 112 call sites across 37 files (templates, composables, services, tests, prop names in kebab-case). No behavioral changes. Pure identifier rename.
1 parent b4b9598 commit e55dd4b

45 files changed

Lines changed: 187 additions & 156 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/components/actionbar/ComfyRunButton/CloudRunButtonWrapper.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { nextTick, ref } from 'vue'
44

55
import CloudRunButtonWrapper from './CloudRunButtonWrapper.vue'
66

7-
const mockIsActiveSubscription = ref(true)
7+
const mockCanAccessSubscriptionFeatures = ref(true)
88

99
vi.mock('@/composables/billing/useBillingContext', () => ({
1010
useBillingContext: () => ({
11-
isActiveSubscription: mockIsActiveSubscription
11+
canAccessSubscriptionFeatures: mockCanAccessSubscriptionFeatures
1212
})
1313
}))
1414

@@ -32,7 +32,7 @@ function renderWrapper() {
3232

3333
describe('CloudRunButtonWrapper', () => {
3434
beforeEach(() => {
35-
mockIsActiveSubscription.value = true
35+
mockCanAccessSubscriptionFeatures.value = true
3636
})
3737

3838
it('renders the runnable queue button when the subscription is active', () => {
@@ -45,20 +45,20 @@ describe('CloudRunButtonWrapper', () => {
4545
})
4646

4747
it('locks the run button when the subscription is inactive', () => {
48-
mockIsActiveSubscription.value = false
48+
mockCanAccessSubscriptionFeatures.value = false
4949
renderWrapper()
5050

5151
expect(screen.getByTestId('subscribe-to-run-button')).toBeInTheDocument()
5252
expect(screen.queryByTestId('queue-button')).not.toBeInTheDocument()
5353
})
5454

5555
it('unlocks the run button once the subscription becomes active again', async () => {
56-
mockIsActiveSubscription.value = false
56+
mockCanAccessSubscriptionFeatures.value = false
5757
renderWrapper()
5858

5959
expect(screen.getByTestId('subscribe-to-run-button')).toBeInTheDocument()
6060

61-
mockIsActiveSubscription.value = true
61+
mockCanAccessSubscriptionFeatures.value = true
6262
await nextTick()
6363

6464
expect(screen.getByTestId('queue-button')).toBeInTheDocument()
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<component
33
:is="currentButton"
4-
:key="isActiveSubscription ? 'queue' : 'subscribe'"
4+
:key="canAccessSubscriptionFeatures ? 'queue' : 'subscribe'"
55
/>
66
</template>
77
<script setup lang="ts">
@@ -11,9 +11,9 @@ import ComfyQueueButton from '@/components/actionbar/ComfyRunButton/ComfyQueueBu
1111
import { useBillingContext } from '@/composables/billing/useBillingContext'
1212
import SubscribeToRunButton from '@/platform/cloud/subscription/components/SubscribeToRun.vue'
1313
14-
const { isActiveSubscription } = useBillingContext()
14+
const { canAccessSubscriptionFeatures } = useBillingContext()
1515
1616
const currentButton = computed(() =>
17-
isActiveSubscription.value ? ComfyQueueButton : SubscribeToRunButton
17+
canAccessSubscriptionFeatures.value ? ComfyQueueButton : SubscribeToRunButton
1818
)
1919
</script>

src/components/dialog/content/setting/LegacyCreditsPanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<UserCredit text-class="text-3xl font-bold" />
1717
<Skeleton v-if="loading" width="2rem" height="2rem" />
1818
<Button
19-
v-else-if="isActiveSubscription"
19+
v-else-if="canAccessSubscriptionFeatures"
2020
:loading="loading"
2121
@click="handlePurchaseCreditsClick"
2222
>
@@ -137,7 +137,7 @@ const authStore = useAuthStore()
137137
const authActions = useAuthActions()
138138
const commandStore = useCommandStore()
139139
const telemetry = useTelemetry()
140-
const { isActiveSubscription } = useBillingContext()
140+
const { canAccessSubscriptionFeatures } = useBillingContext()
141141
const loading = computed(() => authStore.loading)
142142
const balanceLoading = computed(() => authStore.isFetchingBalance)
143143

src/components/topbar/CurrentUserPopoverLegacy.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ const mockFetchStatus = vi.fn().mockResolvedValue(undefined)
106106
const mockIsFreeTier = ref(false)
107107
vi.mock('@/platform/cloud/subscription/composables/useSubscription', () => ({
108108
useSubscription: vi.fn(() => ({
109-
isActiveSubscription: ref(true),
109+
canAccessSubscriptionFeatures: ref(true),
110110
isFreeTier: mockIsFreeTier,
111111
subscriptionTierName: ref('Creator'),
112112
subscriptionTier: ref('CREATOR'),

src/components/topbar/CurrentUserPopoverLegacy.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
</div>
3131

3232
<!-- Credits Section -->
33-
<div v-if="isActiveSubscription" class="flex items-center gap-2 px-4 py-2">
33+
<div
34+
v-if="canAccessSubscriptionFeatures"
35+
class="flex items-center gap-2 px-4 py-2"
36+
>
3437
<i class="icon-[lucide--component] text-sm text-amber-400" />
3538
<Skeleton
3639
v-if="authStore.isFetchingBalance"
@@ -85,7 +88,7 @@
8588
<Divider class="mx-0 my-2" />
8689

8790
<div
88-
v-if="isActiveSubscription"
91+
v-if="canAccessSubscriptionFeatures"
8992
class="flex cursor-pointer items-center gap-2 px-4 py-2 hover:bg-secondary-background-hover"
9093
data-testid="partner-nodes-menu-item"
9194
@click="handleOpenPartnerNodesInfo"
@@ -115,7 +118,7 @@
115118
</div>
116119

117120
<div
118-
v-if="isActiveSubscription"
121+
v-if="canAccessSubscriptionFeatures"
119122
class="flex cursor-pointer items-center gap-2 px-4 py-2 hover:bg-secondary-background-hover"
120123
data-testid="manage-plan-menu-item"
121124
@click="handleOpenPlanAndCreditsSettings"
@@ -186,7 +189,7 @@ const authStore = useAuthStore()
186189
const settingsDialog = useSettingsDialog()
187190
const dialogService = useDialogService()
188191
const {
189-
isActiveSubscription,
192+
canAccessSubscriptionFeatures,
190193
isFreeTier,
191194
subscriptionTierName,
192195
subscriptionTier,

src/composables/auth/useAuthActions.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ vi.mock('@/stores/authStore', () => ({
7373

7474
vi.mock('@/composables/billing/useBillingContext', () => ({
7575
useBillingContext: vi.fn(() => ({
76-
isActiveSubscription: { value: false },
76+
canAccessSubscriptionFeatures: { value: false },
7777
isFreeTier: { value: true },
7878
type: { value: 'free' }
7979
}))

src/composables/auth/useAuthActions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ export const useAuthActions = () => {
118118
)
119119

120120
const purchaseCredits = wrapWithErrorHandlingAsync(async (amount: number) => {
121-
const { isActiveSubscription } = useBillingContext()
122-
if (!isActiveSubscription.value) return
121+
const { canAccessSubscriptionFeatures } = useBillingContext()
122+
if (!canAccessSubscriptionFeatures.value) return
123123

124124
const response = await authStore.initiateCreditPurchase({
125125
amount_micros: usdToMicros(amount),

src/composables/billing/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ export interface BillingState {
7373
currentPlanSlug: ComputedRef<string | null>
7474
isLoading: Ref<boolean>
7575
error: Ref<string | null>
76-
isActiveSubscription: ComputedRef<boolean>
76+
/**
77+
* Convenience computed for checking if subscription is active.
78+
* Equivalent to `subscription.value?.isActive ?? false`
79+
*/
80+
canAccessSubscriptionFeatures: ComputedRef<boolean>
7781
isFreeTier: ComputedRef<boolean>
7882
billingStatus: ComputedRef<BillingStatus | null>
7983
subscriptionStatus: ComputedRef<BillingSubscriptionStatus | null>

src/composables/billing/useBillingContext.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ vi.mock('@/platform/workspace/stores/teamWorkspaceStore', () => ({
5151

5252
vi.mock('@/platform/cloud/subscription/composables/useSubscription', () => ({
5353
useSubscription: () => ({
54-
isActiveSubscription: { value: true },
54+
canAccessSubscriptionFeatures: { value: true },
5555
subscriptionTier: { value: 'PRO' },
5656
subscriptionDuration: { value: 'MONTHLY' },
5757
subscriptionStatus: {
@@ -191,9 +191,9 @@ describe('useBillingContext', () => {
191191
expect(mockPurchaseCredits).toHaveBeenCalledWith(5)
192192
})
193193

194-
it('provides isActiveSubscription convenience computed', () => {
195-
const { isActiveSubscription } = useBillingContext()
196-
expect(isActiveSubscription.value).toBe(true)
194+
it('provides canAccessSubscriptionFeatures convenience computed', () => {
195+
const { canAccessSubscriptionFeatures } = useBillingContext()
196+
expect(canAccessSubscriptionFeatures.value).toBe(true)
197197
})
198198

199199
it('exposes requireActiveSubscription action', async () => {

src/composables/billing/useBillingContext.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ function useBillingContextInternal(): BillingContext {
116116
toValue(activeContext.value.currentPlanSlug)
117117
)
118118

119-
const isActiveSubscription = computed(() =>
120-
toValue(activeContext.value.isActiveSubscription)
119+
const canAccessSubscriptionFeatures = computed(() =>
120+
toValue(activeContext.value.canAccessSubscriptionFeatures)
121121
)
122122

123123
const isFreeTier = computed(() => subscription.value?.tier === 'FREE')
@@ -256,7 +256,7 @@ function useBillingContextInternal(): BillingContext {
256256
currentPlanSlug,
257257
isLoading,
258258
error,
259-
isActiveSubscription,
259+
canAccessSubscriptionFeatures,
260260
isFreeTier,
261261
billingStatus,
262262
subscriptionStatus,

0 commit comments

Comments
 (0)