diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 63c176ca5a5..9904e0db653 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -3405,14 +3405,14 @@ "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", @@ -3420,8 +3420,10 @@ }, "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", @@ -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}", diff --git a/src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts b/src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts index 09e5f09acbc..eb7986624b8 100644 --- a/src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts +++ b/src/platform/workspace/components/SubscriptionPanelContentWorkspace.test.ts @@ -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( + 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')) @@ -312,6 +330,7 @@ describe('SubscriptionPanelContentWorkspace', () => { : null ) mockDistributionState.isCloud = true + mockBillingBanner.kind = null mockSubscriptionStatus.value = 'active' mockBillingStatus.value = 'paid' mockBillingType.value = 'workspace' @@ -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 diff --git a/src/platform/workspace/components/SubscriptionPanelContentWorkspace.vue b/src/platform/workspace/components/SubscriptionPanelContentWorkspace.vue index bc7c8d7660e..5f6c72e74f2 100644 --- a/src/platform/workspace/components/SubscriptionPanelContentWorkspace.vue +++ b/src/platform/workspace/components/SubscriptionPanelContentWorkspace.vue @@ -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' @@ -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(() => diff --git a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.stories.ts b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.stories.ts index ce3e08d01e9..743ea58e3ea 100644 --- a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.stories.ts +++ b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.stories.ts @@ -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 @@ -260,3 +260,48 @@ const endedEnterprise: Partial = { export const PlanEndedEnterpriseOwner: Story = story(endedEnterprise, owner) export const PlanEndedEnterpriseMember: Story = story(endedEnterprise, member) + +const personalOwner: Partial = { + workspaceType: 'personal' +} + +function personalPlan( + subscription: SubscriptionInfo, + billing: Partial +): Partial { + 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 +) diff --git a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.test.ts b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.test.ts index 54ef573febf..979b9d68174 100644 --- a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.test.ts +++ b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.test.ts @@ -124,10 +124,6 @@ const i18n = createI18n({ 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." }, @@ -135,6 +131,10 @@ const i18n = createI18n({ 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: @@ -144,8 +144,11 @@ const i18n = createI18n({ }, 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.', @@ -157,6 +160,10 @@ const i18n = createI18n({ 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}', @@ -176,6 +183,9 @@ const i18n = createI18n({ teamPlanName: 'Team', unknownTierName: 'Unknown', tiers: { + standard: { name: 'Standard' }, + creator: { name: 'Creator' }, + founder: { name: "Founder's Edition" }, pro: { name: 'Pro' }, enterprise: { name: 'Enterprise' } } @@ -188,8 +198,11 @@ const globalOptions = { plugins: [i18n] } -function renderBanner() { - return render(BillingStatusBanner, { global: globalOptions }) +function renderBanner(section?: 'planCredits' | 'members' | 'allowlist') { + return render(BillingStatusBanner, { + props: { section }, + global: globalOptions + }) } function exhausted() { @@ -448,42 +461,27 @@ describe('BillingStatusBanner', () => { ).toBeInTheDocument() }) - it('shows payment recovery to personal workspace owners', async () => { - paymentFailedState() - state.isTeamPlan = false - state.workspaceType = 'personal' - // A known personal tier: an unrecognized one is denied recovery outright. - state.subscription = { ...state.subscription!, tier: 'PRO' } - renderBanner() - - expect(screen.getByRole('status')).toHaveTextContent('Subscription paused') - expect(screen.getByRole('status')).toHaveTextContent( - "Your payment didn't go through. Update your payment method to resume." - ) - expect(screen.getByRole('status')).not.toHaveTextContent('workspace') - await userEvent.click( - screen.getByRole('button', { name: 'Update payment' }) - ) - expect(state.manageSubscription).toHaveBeenCalledTimes(1) - }) - - it('shows the paused banner to personal workspace owners', async () => { - pausedState() - state.isTeamPlan = false - state.workspaceType = 'personal' - state.subscription = { ...state.subscription!, tier: 'PRO' } - renderBanner() + it.for([ + { name: 'paused', enter: pausedState }, + { name: 'payment failed', enter: paymentFailedState } + ])( + 'gives a personal owner the workspace copy when $name', + async ({ enter }) => { + enter() + state.isTeamPlan = false + state.workspaceType = 'personal' + state.subscription = { ...state.subscription!, tier: 'PRO' } + renderBanner() - expect(screen.getByRole('status')).toHaveTextContent('Subscription paused') - expect(screen.getByRole('status')).toHaveTextContent( - 'Your subscription is paused. Update your payment method to resume.' - ) - expect(screen.getByRole('status')).not.toHaveTextContent('workspace') - await userEvent.click( - screen.getByRole('button', { name: 'Update payment' }) - ) - expect(state.manageSubscription).toHaveBeenCalledTimes(1) - }) + expect(screen.getByRole('status')).toHaveTextContent( + "This workspace's subscription is paused. Update payment to resume." + ) + await userEvent.click( + screen.getByRole('button', { name: 'Update payment' }) + ) + expect(state.manageSubscription).toHaveBeenCalledTimes(1) + } + ) it('points members to the owner on a failed renewal, without payment controls', () => { paymentFailedState() @@ -787,4 +785,218 @@ describe('BillingStatusBanner', () => { expect(screen.queryByRole('button')).not.toBeInTheDocument() }) }) + + describe('personal plan', () => { + function personalPlan(tier: SubscriptionInfo['tier'] = 'PRO') { + state.isTeamPlan = false + state.workspaceType = 'personal' + state.subscription = { ...state.subscription!, tier } + } + + function endingPlan() { + state.subscription = { + ...state.subscription!, + isCancelled: true, + endDate: '2026-08-01T00:00:00Z' + } + } + + function endedPlan(endDate: string | null) { + state.subscriptionStatus = 'ended' + state.billingStatus = 'inactive' + state.canAccessSubscriptionFeatures = false + state.subscription = { + ...state.subscription!, + hasFunds: false, + isCancelled: true, + endDate + } + } + + it.for([ + { + personal: false, + renewalDate: '2026-10-01T00:00:00Z', + body: 'Your team has used all its credits. Add more credits or wait until credits refill on October 1, 2026.' + }, + { + personal: false, + renewalDate: null, + body: 'Your team has used all its credits. Add more credits.' + }, + { + personal: true, + renewalDate: '2026-10-01T00:00:00Z', + body: "You've used all your credits. Add more credits or wait until credits refill on October 1, 2026." + }, + { + personal: true, + renewalDate: null, + body: "You've used all your credits. Add more credits." + } + ])( + 'words out of credits for the audience (personal: $personal, date: $renewalDate)', + async ({ personal, renewalDate, body }) => { + if (personal) personalPlan() + state.renewalDate = renewalDate + state.subscription = { ...state.subscription!, hasFunds: false } + renderBanner() + + expect(screen.getByRole('status')).toHaveTextContent(body) + await userEvent.click( + screen.getByRole('button', { name: 'Add credits' }) + ) + expect(useDialogService().showTopUpCreditsDialog).toHaveBeenCalled() + } + ) + + it.for([ + { + tier: null, + title: 'Your Team plan ends on August 1, 2026', + body: "You won't be charged again. Members keep full access until then. Resume your plan to keep your team's shared credits." + }, + { + tier: 'PRO', + title: 'Your Pro plan ends on August 1, 2026', + body: "You won't be charged again. Resume your plan to keep your monthly credits." + }, + { + tier: 'FOUNDERS_EDITION', + title: "Your Founder's Edition plan ends on August 1, 2026", + body: "You won't be charged again. Resume your plan to keep your monthly credits." + } + ] as const)( + 'words the ending notice for $title', + async ({ tier, title, body }) => { + if (tier) personalPlan(tier) + endingPlan() + renderBanner() + + expect(screen.getByRole('status')).toHaveTextContent(title) + expect(screen.getByRole('status')).toHaveTextContent(body) + await userEvent.click( + screen.getByRole('button', { name: 'Resume plan' }) + ) + expect(state.handleResubscribe).toHaveBeenCalledTimes(1) + } + ) + + it.for([ + { + endDate: '2026-09-12T12:00:00Z', + title: 'Your Creator plan ended on September 12, 2026' + }, + { endDate: null, title: 'Your Creator plan has ended' } + ])( + 'tells an ended personal plan "$title" and resubscribes on Personal plans', + async ({ endDate, title }) => { + personalPlan('CREATOR') + endedPlan(endDate) + renderBanner() + + expect(screen.getByRole('status')).toHaveTextContent(title) + expect(screen.getByRole('status')).toHaveTextContent( + 'Resubscribe to run workflows and get monthly credits again.' + ) + await userEvent.click( + screen.getByRole('button', { name: 'Resubscribe' }) + ) + expect(state.showSubscriptionDialog).toHaveBeenCalledWith( + expect.objectContaining({ planMode: 'personal' }) + ) + } + ) + + it('dismisses an ended personal plan for the session', async () => { + personalPlan() + endedPlan('2026-09-12T12:00:00Z') + renderBanner() + + await userEvent.click(screen.getByRole('button', { name: 'Dismiss' })) + expect(screen.queryByRole('status')).not.toBeInTheDocument() + }) + + it('shows no banner for an ended plan on an unrecognized tier', () => { + state.isTeamPlan = false + state.workspaceType = 'personal' + endedPlan('2026-09-12T12:00:00Z') + state.subscription = { ...state.subscription!, tier: null } + renderBanner() + + expect(screen.queryByRole('status')).not.toBeInTheDocument() + }) + + describe('on the Members tab', () => { + it.for([ + { name: 'plan ended', enter: () => endedPlan('2026-09-12T12:00:00Z') }, + { name: 'ending', enter: endingPlan }, + { + name: 'plan change', + enter: () => { + state.isTeamPlan = true + scheduledFor('pro-annual') + } + } + ])('hides $name in a personal workspace', ({ enter }) => { + personalPlan() + enter() + renderBanner('members') + + expect(screen.queryByRole('status')).not.toBeInTheDocument() + }) + + it.for([ + { name: 'paused', enter: pausedState, text: 'Subscription paused' }, + { + name: 'payment failed', + enter: paymentFailedState, + text: 'Subscription paused' + }, + { + name: 'out of credits', + enter: () => { + state.subscription = { ...state.subscription!, hasFunds: false } + }, + text: 'Out of credits' + } + ])('keeps $name in a personal workspace', ({ enter, text }) => { + personalPlan() + enter() + renderBanner('members') + + expect(screen.getByRole('status')).toHaveTextContent(text) + }) + + it('keeps the ending notice on the Plan & Credits tab', () => { + personalPlan() + endingPlan() + renderBanner('planCredits') + + expect(screen.getByRole('status')).toHaveTextContent( + 'Your Pro plan ends on' + ) + }) + + it.for([ + { + name: 'plan ended', + enter: () => endedPlan('2026-09-12T12:00:00Z'), + text: 'Your Team plan ended on' + }, + { name: 'ending', enter: endingPlan, text: 'Your Team plan ends on' }, + { + name: 'plan change', + enter: () => scheduledFor('pro-annual'), + text: 'Your plan changes to Pro' + } + ])('keeps $name in a team workspace', ({ enter, text }) => { + state.subscription = { ...state.subscription!, tier: 'PRO' } + enter() + renderBanner('members') + + expect(screen.getByRole('status')).toHaveTextContent(text) + }) + }) + }) }) diff --git a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.vue b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.vue index 0181d667799..440c22a4f1b 100644 --- a/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.vue +++ b/src/platform/workspace/components/dialogs/settings/BillingStatusBanner.vue @@ -97,11 +97,15 @@ import { useBillingContext } from '@/composables/billing/useBillingContext' import { ENTERPRISE_URL } from '@/platform/cloud/subscription/constants/tierPricing' import { useSubscriptionDialog } from '@/platform/cloud/subscription/composables/useSubscriptionDialog' import { useBillingBanner } from '@/platform/workspace/composables/useBillingBanner' -import type { BillingBannerKind } from '@/platform/workspace/composables/useBillingBanner' +import type { + BillingBannerAudience, + BillingBannerKind +} from '@/platform/workspace/composables/useBillingBanner' import { useBillingCapabilities } from '@/platform/workspace/composables/useBillingCapabilities' import { usePlanEnded } from '@/platform/workspace/composables/usePlanEnded' import { useResubscribe } from '@/platform/workspace/composables/useResubscribe' import { useScheduledPlanChange } from '@/platform/workspace/composables/useScheduledPlanChange' +import { useWorkspaceTierLabel } from '@/platform/workspace/composables/useWorkspaceTierLabel' import { useWorkspaceUI } from '@/platform/workspace/composables/useWorkspaceUI' import { useDialogService } from '@/services/dialogService' @@ -112,12 +116,17 @@ type BannerAction = | 'contactSales' | 'updatePayment' +const { section } = defineProps<{ + section?: 'planCredits' | 'members' | 'allowlist' +}>() + const { t, d } = useI18n() const { renewalDate, renewalInvoice, subscription, manageSubscription } = useBillingContext() const { permissions, canReactivatePlan, workspaceType } = useWorkspaceUI() const { canTopUp } = useBillingCapabilities() -const { kind, dismiss } = useBillingBanner() +const { kind, audience, dismiss } = useBillingBanner() +const { formatTierName } = useWorkspaceTierLabel() const { isResubscribing, handleResubscribe } = useResubscribe() const { scheduledChange, @@ -142,6 +151,7 @@ function longDate(raw: string | null | undefined): string { } const cycleResetDate = computed(() => longDate(renewalDate.value)) const planEndDate = computed(() => longDate(subscription.value?.endDate)) +const planName = computed(() => formatTierName(subscription.value?.tier, false)) interface BannerView { muted: boolean @@ -154,6 +164,39 @@ interface BannerView { const bs = 'workspacePanel.billingStatus' +const audienceCopy = { + team: { + outOfCreditsBody: `${bs}.outOfCredits.body`, + outOfCreditsBodyNoDate: `${bs}.outOfCredits.bodyNoDate`, + endingTitle: `${bs}.ending.title`, + endingBody: `${bs}.ending.body` + }, + personal: { + outOfCreditsBody: `${bs}.outOfCredits.personalBody`, + outOfCreditsBodyNoDate: `${bs}.outOfCredits.personalBodyNoDate`, + endingTitle: `${bs}.ending.personalTitle`, + endingBody: `${bs}.ending.personalBody` + } +} satisfies Record> + +const copy = computed(() => audienceCopy[audience.value ?? 'team']) + +const PLAN_LIFECYCLE_KINDS: ReadonlySet = new Set([ + 'planEnded', + 'ending', + 'planChange' +]) + +// A personal workspace's Members tab carries its own upgrade pitch, so the +// plan lifecycle notices stay on the Plan & Credits tab. +const isHiddenOnSection = computed( + () => + section === 'members' && + workspaceType.value === 'personal' && + kind.value !== null && + PLAN_LIFECYCLE_KINDS.has(kind.value) +) + // Only an https payment page is opened; anything else hides the action. function safeInvoiceUrl(value: string | undefined): string | undefined { if (!value) return undefined @@ -164,19 +207,10 @@ function safeInvoiceUrl(value: string | undefined): string | undefined { } } -function pausedOwnerBody(): string { - if (workspaceType.value !== 'personal') return t(`${bs}.paused.body`) - return t( - kind.value === 'paymentFailed' - ? `${bs}.paused.personalPaymentFailedBody` - : `${bs}.paused.personalBody` - ) -} - const pausedView = (): BannerView => ({ muted: !canManage.value, title: t(`${bs}.paused.title`), - body: canManage.value ? pausedOwnerBody() : t(`${bs}.paused.memberBody`), + body: canManage.value ? t(`${bs}.paused.body`) : t(`${bs}.paused.memberBody`), action: canManage.value ? 'updatePayment' : null, dismissible: false, payInvoiceUrl: safeInvoiceUrl(renewalInvoice.value?.hosted_invoice_url) @@ -190,6 +224,17 @@ function planEndedCopy(): { memberBody: string } { const date = planEndDate.value + if (audience.value === 'personal') { + const plan = planName.value + const body = t(`${bs}.planEnded.personalBody`) + return { + title: date + ? t(`${bs}.planEnded.personalTitle`, { plan, date }) + : t(`${bs}.planEnded.personalTitleNoDate`, { plan }), + ownerBody: body, + memberBody: body + } + } if (!isSalesManagedPlan.value) { return { title: date @@ -215,7 +260,10 @@ function planEndedCopy(): { const planEndedView = (): BannerView => { const copy = planEndedCopy() - const ownerAction = isSalesManagedPlan.value ? 'contactSales' : 'resubscribe' + const ownerAction = + audience.value !== 'personal' && isSalesManagedPlan.value + ? 'contactSales' + : 'resubscribe' return { muted: true, title: copy.title, @@ -225,10 +273,8 @@ const planEndedView = (): BannerView => { } } -const outOfCreditsBody = (key: 'body' | 'memberBody'): string => - cycleResetDate.value - ? t(`${bs}.outOfCredits.${key}`, { date: cycleResetDate.value }) - : t(`${bs}.outOfCredits.${key}NoDate`) +const outOfCreditsBody = (key: string, noDateKey: string): string => + cycleResetDate.value ? t(key, { date: cycleResetDate.value }) : t(noDateKey) // An owner who cannot top up only reaches this once the plan has ended, which // the plan ended notice covers, so that case shows nothing. @@ -237,7 +283,10 @@ const outOfCreditsView = (): BannerView | null => { return { muted: false, title: t(`${bs}.outOfCredits.title`), - body: outOfCreditsBody('memberBody'), + body: outOfCreditsBody( + `${bs}.outOfCredits.memberBody`, + `${bs}.outOfCredits.memberBodyNoDate` + ), action: null, dismissible: true } @@ -246,7 +295,10 @@ const outOfCreditsView = (): BannerView | null => { return { muted: false, title: t(`${bs}.outOfCredits.title`), - body: outOfCreditsBody('body'), + body: outOfCreditsBody( + copy.value.outOfCreditsBody, + copy.value.outOfCreditsBodyNoDate + ), action: 'addCredits', dismissible: true } @@ -265,16 +317,21 @@ const enterpriseEndingView = (): BannerView => ({ dismissible: false }) -const teamEndingView = (): BannerView => ({ +const selfServeEndingView = (): BannerView => ({ muted: true, - title: t(`${bs}.ending.title`, { date: planEndDate.value }), - body: canManage.value ? t(`${bs}.ending.body`) : t(`${bs}.ending.memberBody`), + title: t(copy.value.endingTitle, { + plan: planName.value, + date: planEndDate.value + }), + body: canManage.value + ? t(copy.value.endingBody) + : t(`${bs}.ending.memberBody`), action: canManage.value && canReactivatePlan.value ? 'reactivate' : null, dismissible: false }) const endingView = (): BannerView => - isEnterprisePlan.value ? enterpriseEndingView() : teamEndingView() + isEnterprisePlan.value ? enterpriseEndingView() : selfServeEndingView() const planChangeView = (): BannerView | null => canShowScheduledChange.value @@ -301,7 +358,7 @@ const bannerViews: Record BannerView | null> = { } const banner = computed(() => - kind.value ? bannerViews[kind.value]() : null + kind.value && !isHiddenOnSection.value ? bannerViews[kind.value]() : null ) function handleAddCredits() { @@ -309,7 +366,7 @@ function handleAddCredits() { } function handleResubscribePlan() { subscriptionDialog.show({ - planMode: 'team', + planMode: audience.value === 'personal' ? 'personal' : 'team', reason: 'settings_billing_panel' }) } diff --git a/src/platform/workspace/components/dialogs/settings/MembersPanelContent.test.ts b/src/platform/workspace/components/dialogs/settings/MembersPanelContent.test.ts index db5671d9140..b80d1e6b797 100644 --- a/src/platform/workspace/components/dialogs/settings/MembersPanelContent.test.ts +++ b/src/platform/workspace/components/dialogs/settings/MembersPanelContent.test.ts @@ -334,6 +334,38 @@ describe('MembersPanelContent', () => { renderComponent() expect(screen.queryByRole('textbox')).toBeNull() }) + + it.for([ + { name: 'active', isPlanEnded: false, isSalesManagedPlan: false }, + { + name: 'ended self-serve', + isPlanEnded: true, + isSalesManagedPlan: false + }, + { + name: 'ended sales-managed', + isPlanEnded: true, + isSalesManagedPlan: true + } + ])( + 'pitches the Team plan whatever the plan state ($name)', + async ({ isPlanEnded, isSalesManagedPlan }) => { + mockIsPlanEnded.value = isPlanEnded + mockIsSalesManagedPlan.value = isSalesManagedPlan + renderComponent() + + expect( + screen.getByText('workspacePanel.members.upsellBanner') + ).toBeTruthy() + expect(screen.queryByText(/workspacePanel\.members\.ended/)).toBeNull() + await userEvent.click( + screen.getByRole('button', { + name: /workspacePanel\.members\.upgradeToTeam/ + }) + ) + expect(mockShowTeamPlans).toHaveBeenCalled() + } + ) }) describe('pending invite counts', () => { diff --git a/src/platform/workspace/components/dialogs/settings/MembersPanelContent.vue b/src/platform/workspace/components/dialogs/settings/MembersPanelContent.vue index 2144350f28f..9994d4c147f 100644 --- a/src/platform/workspace/components/dialogs/settings/MembersPanelContent.vue +++ b/src/platform/workspace/components/dialogs/settings/MembersPanelContent.vue @@ -8,7 +8,7 @@ permissions.canManageSubscription " :variant=" - isPlanEnded + showsEndedUpsell ? isSalesManagedPlan ? 'contactSales' : 'reactivate' @@ -16,7 +16,7 @@ " :enterprise="isEnterprisePlan" @action=" - isPlanEnded && isSalesManagedPlan + showsEndedUpsell && isSalesManagedPlan ? handleContactSales() : showTeamPlans() " @@ -332,6 +332,12 @@ watch(isHeaderCollapsed, async () => { const { t } = useI18n() +// A personal workspace always pitches the Team plan here; its own plan +// lifecycle lives on the Plan & Credits tab. +const showsEndedUpsell = computed( + () => isPlanEnded.value && !isInPersonalWorkspace.value +) + const emptyStateMessage = computed(() => { if (!uiConfig.value.showMembersList) return null if (!membersLoaded.value) return null diff --git a/src/platform/workspace/components/dialogs/settings/WorkspaceSettingsPanelContent.vue b/src/platform/workspace/components/dialogs/settings/WorkspaceSettingsPanelContent.vue index 1d189408330..bab6632be1f 100644 --- a/src/platform/workspace/components/dialogs/settings/WorkspaceSettingsPanelContent.vue +++ b/src/platform/workspace/components/dialogs/settings/WorkspaceSettingsPanelContent.vue @@ -1,6 +1,6 @@