Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -3405,23 +3405,25 @@
"paused": {
"title": "Subscription paused",
"body": "This workspace's subscription is paused. Update payment to resume.",
"personalBody": "Your subscription is paused. Update your payment method to resume.",
"personalPaymentFailedBody": "Your payment didn't go through. Update your payment method to resume.",
"memberBody": "Ask your workspace owner to restore the workspace's subscription."
},
"outOfCredits": {
"title": "Out of credits",
"body": "Your team has used all its credits. Add more credits or wait until credits refill on {date}.",
"bodyNoDate": "Your team has used all its credits. Add more credits.",
"personalBody": "You've used all your credits. Add more credits or wait until credits refill on {date}.",
"personalBodyNoDate": "You've used all your credits. Add more credits.",
"memberBody": "Your team has used all its credits. Ask your workspace owner to add more credits or wait until credits refill on {date}.",
"memberBodyNoDate": "Your team has used all its credits. Ask your workspace owner to add more credits.",
"addCredits": "Add credits",
"dismiss": "Dismiss"
},
"ending": {
"title": "Your Team plan ends on {date}",
"body": "Members keep full access until then. Resume your plan to keep your team's shared credits.",
"body": "You won't be charged again. Members keep full access until then. Resume your plan to keep your team's shared credits.",
"memberBody": "You can run workflows until then.",
"personalTitle": "Your {plan} plan ends on {date}",
"personalBody": "You won't be charged again. Resume your plan to keep your monthly credits.",
"enterpriseTitle": "Your Enterprise plan ends on {date}",
"enterpriseBody": "Members keep full access until then. Reach out to our sales team to extend.",
"reactivate": "Resume plan",
Expand All @@ -3431,6 +3433,9 @@
"teamTitle": "Your Team plan ended on {date}",
"teamBody": "Resubscribe to run workflows and get shared credits again.",
"teamMemberBody": "Ask your workspace owner to resubscribe.",
"personalTitle": "Your {plan} plan ended on {date}",
"personalTitleNoDate": "Your {plan} plan has ended",
"personalBody": "Resubscribe to run workflows and get monthly credits again.",
"enterpriseTitle": "Your Enterprise plan ended on {date}",
"enterpriseBody": "Contact sales to start a new Enterprise plan.",
"planTitle": "Your plan ended on {date}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,29 @@ import type {
TeamCreditStops,
TeamCreditStopSummary
} from '@/platform/workspace/api/workspaceApi'
import type { BillingBannerKind } from '@/platform/workspace/composables/useBillingBanner'

import SubscriptionPanelContentWorkspace from './SubscriptionPanelContentWorkspace.vue'
import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI'

const mockDistributionState = vi.hoisted(() => ({ isCloud: true }))
const mockBillingBanner = vi.hoisted(() => ({
kind: null as BillingBannerKind | null
}))

vi.mock<unknown>(
import('@/platform/workspace/composables/useBillingBanner'),
async () => {
const { computed } = await import('vue')
return {
useBillingBanner: () => ({
kind: computed(() => mockBillingBanner.kind),
audience: computed(() => null),
dismiss: vi.fn()
})
}
}
)

vi.mock(import('@/composables/billing/useBillingRouting'))

Expand Down Expand Up @@ -312,6 +330,7 @@ describe('SubscriptionPanelContentWorkspace', () => {
: null
)
mockDistributionState.isCloud = true
mockBillingBanner.kind = null
mockSubscriptionStatus.value = 'active'
mockBillingStatus.value = 'paid'
mockBillingType.value = 'workspace'
Expand Down Expand Up @@ -1082,6 +1101,24 @@ describe('SubscriptionPanelContentWorkspace', () => {
expect(useBillingContext().resubscribe).not.toHaveBeenCalled()
})

it.for([
{ kind: null, showsCard: true },
{ kind: 'ending', showsCard: false },
{ kind: 'outOfCredits', showsCard: true },
{ kind: 'planChange', showsCard: true }
] as const)(
'lets the ending banner replace the canceled card (banner: $kind)',
({ kind, showsCard }) => {
mockSubscriptionStatus.value = 'canceled'
mockBillingBanner.kind = kind
renderComponent()

expect(screen.queryByTestId('subscription-state-card') !== null).toBe(
showsCard
)
}
)

it('keeps ended Team credits inactive when self-serve capabilities are unavailable', () => {
mockSubscriptionStatus.value = 'canceled'
mockIsActiveSubscription.value = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ import {
import type { TierBenefit } from '@/platform/cloud/subscription/utils/tierBenefits'
import { getCommonTierBenefits } from '@/platform/cloud/subscription/utils/tierBenefits'
import { isCloud } from '@/platform/distribution/types'
import { useBillingBanner } from '@/platform/workspace/composables/useBillingBanner'
import { useResubscribe } from '@/platform/workspace/composables/useResubscribe'
import { useScheduledPlanChange } from '@/platform/workspace/composables/useScheduledPlanChange'
import { useBillingCapabilities } from '@/platform/workspace/composables/useBillingCapabilities'
Expand Down Expand Up @@ -636,13 +637,17 @@ const isQuietEnterpriseEnding = computed(
!isWithinEnterpriseEndingNotice(subscription.value?.endDate, now.value)
)

const { kind: billingBannerKind } = useBillingBanner()

// An end-dated Enterprise plan never shows the amber card; inside the notice
// window the muted ending banner carries the message instead.
// window the muted ending banner carries the message instead. The banner is
// still rolling out, so the card stays wherever the ending banner is not shown.
const showSubscriptionStateCard = computed(
() =>
isSubscriptionCancelled.value &&
!isSubscriptionEnded.value &&
!hasScheduledEnterpriseEnd.value
!hasScheduledEnterpriseEnd.value &&
billingBannerKind.value !== 'ending'
)

const subscriptionStateCardTitle = computed(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { setWorkspaceUIMock } from '@/storybook/mocks/useWorkspaceUI'
import BillingStatusBanner from './BillingStatusBanner.vue'

/**
* The single billing banner slot for team workspaces (FE-1246), rendered in
* The single billing banner slot for team and personal plans (FE-1246), rendered in
* priority order: paused > payment declined > out of credits > ending. At most
* one state shows at a time. Each story drives the real `deriveBillingBanner`
* through the stubbed billing context, so these are the states the backend can
Expand Down Expand Up @@ -260,3 +260,48 @@ const endedEnterprise: Partial<BillingContextMockState> = {
export const PlanEndedEnterpriseOwner: Story = story(endedEnterprise, owner)

export const PlanEndedEnterpriseMember: Story = story(endedEnterprise, member)

const personalOwner: Partial<WorkspaceUIMockState> = {
workspaceType: 'personal'
}

function personalPlan(
subscription: SubscriptionInfo,
billing: Partial<BillingContextMockState>
): Partial<BillingContextMockState> {
return {
...billing,
subscription: { ...subscription, tier: 'PRO', planSlug: 'pro-monthly' },
isTeamPlan: false
}
}

/** Personal plans get first-person copy and no member version. */
export const OutOfCreditsPersonal: Story = story(
personalPlan(exhausted, {
canAccessSubscriptionFeatures: true,
billingStatus: 'paid',
subscriptionStatus: 'active',
renewalDate: RENEWAL_DATE
}),
personalOwner
)

export const EndingPersonal: Story = story(
personalPlan(cancelled, {
canAccessSubscriptionFeatures: true,
billingStatus: 'paid',
subscriptionStatus: 'canceled'
}),
personalOwner
)

/** Resubscribe opens the pricing table on Personal plans. */
export const PlanEndedPersonal: Story = story(
personalPlan(endedTeam.subscription!, {
canAccessSubscriptionFeatures: false,
billingStatus: 'inactive',
subscriptionStatus: 'ended'
}),
personalOwner
)
Loading
Loading