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
1 change: 1 addition & 0 deletions src/composables/__mocks__/useFeatureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const defaultFlags: FeatureFlags = {
showSignInButton: undefined,
unifiedCloudAuthEnabled: false,
billingControlEnabled: false,
memberCreditLimitsEnabled: false,
legacyBillingMigrationEnabled: false,
embeddedCheckoutEnabled: false,
billingSdkTopupEnabled: false,
Expand Down
9 changes: 9 additions & 0 deletions src/composables/useFeatureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export enum ServerFeatureFlag {
SHOW_SIGNIN_BUTTON = 'show_signin_button',
UNIFIED_CLOUD_AUTH = 'unified_cloud_auth',
BILLING_CONTROL_ENABLED = 'billing_control_enabled',
MEMBER_CREDIT_LIMITS_ENABLED = 'member_credit_limits_enabled',
LEGACY_BILLING_MIGRATION_ENABLED = 'legacy_billing_migration_enabled',
EMBEDDED_CHECKOUT_ENABLED = 'embedded_checked_enabled',
BILLING_SDK_TOPUP_ENABLED = 'billing_sdk_topup_enabled',
Expand Down Expand Up @@ -297,6 +298,12 @@ export function useFeatureFlags() {
cachedBillingControlEnabled
)
},
get memberCreditLimitsEnabled() {
return resolveStrictBooleanFlag(
ServerFeatureFlag.MEMBER_CREDIT_LIMITS_ENABLED,
remoteConfig.value.member_credit_limits_enabled
)
},
get legacyBillingMigrationEnabled() {
return resolveAuthGatedFlag(
ServerFeatureFlag.LEGACY_BILLING_MIGRATION_ENABLED,
Expand Down Expand Up @@ -430,6 +437,8 @@ export function startFeatureFlagTelemetry() {
[ServerFeatureFlag.SHOW_SIGNIN_BUTTON]: flags.showSignInButton,
[ServerFeatureFlag.UNIFIED_CLOUD_AUTH]: flags.unifiedCloudAuthEnabled,
[ServerFeatureFlag.BILLING_CONTROL_ENABLED]: flags.billingControlEnabled,
[ServerFeatureFlag.MEMBER_CREDIT_LIMITS_ENABLED]:
flags.memberCreditLimitsEnabled,
[ServerFeatureFlag.LEGACY_BILLING_MIGRATION_ENABLED]:
flags.legacyBillingMigrationEnabled,
[ServerFeatureFlag.EMBEDDED_CHECKOUT_ENABLED]:
Expand Down
1 change: 1 addition & 0 deletions src/platform/remoteConfig/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export type RemoteConfig = GetFeaturesResponses[200] & {
billing_sdk_topup_enabled?: boolean
billing_sdk_subscription_enabled?: boolean
billing_control_enabled?: boolean
member_credit_limits_enabled?: boolean
legacy_billing_migration_enabled?: boolean
v1_payment_recovery?: boolean
churnkey_app_id?: string
Expand Down
19 changes: 16 additions & 3 deletions src/platform/workspace/composables/useMembersPanel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ describe('useMembersPanel', () => {
workspaceMembers = []
workspacePendingInvites = []
updateWorkspaceStore()
vi.mocked(useFeatureFlags().flags).billingControlEnabled = true
vi.mocked(useFeatureFlags().flags).memberCreditLimitsEnabled = true
mockMaxSeats.value = 73
mockOccupiedSeats.value = 0
mockCanAccessSubscriptionFeatures.value = true
Expand Down Expand Up @@ -878,7 +878,20 @@ describe('useMembersPanel', () => {
})

it('omits the credit-limit action when the flag is disabled', async () => {
vi.mocked(useFeatureFlags().flags).billingControlEnabled = false
vi.mocked(useFeatureFlags().flags).memberCreditLimitsEnabled = false
const panel = await setup()

expect(panel.memberMenuItems(createMember()).map((i) => i.label)).toEqual(
[
'workspacePanel.members.actions.changeRole',
'workspacePanel.members.actions.removeMember'
]
)
})

it('omits the credit-limit action under billing controls alone', async () => {
vi.mocked(useFeatureFlags().flags).memberCreditLimitsEnabled = false
vi.mocked(useFeatureFlags().flags).billingControlEnabled = true
const panel = await setup()

expect(panel.memberMenuItems(createMember()).map((i) => i.label)).toEqual(
Expand All @@ -890,7 +903,7 @@ describe('useMembersPanel', () => {
})

it('keeps the creator menu hidden when the flag is disabled', async () => {
vi.mocked(useFeatureFlags().flags).billingControlEnabled = false
vi.mocked(useFeatureFlags().flags).memberCreditLimitsEnabled = false
setOriginalOwner()
const panel = await setup()

Expand Down
2 changes: 1 addition & 1 deletion src/platform/workspace/composables/useMembersPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export function useMembersPanel() {
roleMenuItem(member, 'member', t('workspaceSwitcher.roleMember'))
]
},
...(flags.billingControlEnabled && member.role === 'member'
...(flags.memberCreditLimitsEnabled && member.role === 'member'
? [creditLimitItem]
: []),
{
Expand Down
14 changes: 13 additions & 1 deletion src/platform/workspace/composables/useWorkspaceUI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const mockIsActiveSubscription = vi.hoisted(() => ({ value: false }))
const mockIsCancelled = vi.hoisted(() => ({ value: false }))
const mockIsTeamPlan = vi.hoisted(() => ({ value: false }))
const mockBillingControlEnabled = vi.hoisted(() => ({ value: false }))
const mockMemberCreditLimitsEnabled = vi.hoisted(() => ({ value: false }))

vi.mock(import('@/platform/distribution/types'), () => ({
get isCloud() {
Expand Down Expand Up @@ -40,6 +41,9 @@ vi.mock<unknown>(import('@/composables/useFeatureFlags'), () => ({
flags: {
get billingControlEnabled() {
return mockBillingControlEnabled.value
},
get memberCreditLimitsEnabled() {
return mockMemberCreditLimitsEnabled.value
}
}
})
Expand Down Expand Up @@ -91,6 +95,7 @@ function resetStore() {
mockIsCancelled.value = false
mockIsTeamPlan.value = false
mockBillingControlEnabled.value = false
mockMemberCreditLimitsEnabled.value = false
mockIsCloud.value = true
mockShouldUseWorkspaceBilling.value = true
}
Expand Down Expand Up @@ -286,10 +291,17 @@ describe('useWorkspaceUI', () => {
expect(ui.uiConfig.value.showCreditsColumn).toBe(false)
})

it('adds the credits column when billing controls are enabled', async () => {
it('keeps the credits column hidden under billing controls alone', async () => {
mockBillingControlEnabled.value = true
const ui = await loadComposable()

expect(ui.uiConfig.value.showCreditsColumn).toBe(false)
})

it('adds the credits column when member credit limits are enabled', async () => {
mockMemberCreditLimitsEnabled.value = true
const ui = await loadComposable()

expect(ui.uiConfig.value.showCreditsColumn).toBe(true)
expect(ui.uiConfig.value.membersGridCols).toBe(
'grid-cols-[38%_18%_30%_14%]'
Expand Down
2 changes: 1 addition & 1 deletion src/platform/workspace/composables/useWorkspaceUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function useWorkspaceUIInternal() {
const uiConfig = computed<WorkspaceUIConfig>(() => {
const base = getUIConfig(workspaceType.value, workspaceRole.value)
const showCreditsColumn =
flags.billingControlEnabled &&
flags.memberCreditLimitsEnabled &&
workspaceType.value === 'team' &&
workspaceRole.value === 'owner'
if (!showCreditsColumn) return base
Expand Down
9 changes: 7 additions & 2 deletions src/storybook/mocks/useWorkspaceUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface WorkspaceUIMockState {
canManageSubscriptionLifecycle: boolean
canDowngradeToPersonal: boolean
isSubscriptionCancelled: boolean
canReactivatePlan: boolean
}

const defaultState: WorkspaceUIMockState = {
Expand All @@ -21,7 +22,8 @@ const defaultState: WorkspaceUIMockState = {
canManageSubscription: true,
canManageSubscriptionLifecycle: true,
canDowngradeToPersonal: true,
isSubscriptionCancelled: false
isSubscriptionCancelled: false,
canReactivatePlan: true
}

const state = ref<WorkspaceUIMockState>({ ...defaultState })
Expand All @@ -42,6 +44,9 @@ export function useWorkspaceUI() {
state.value.canManageSubscriptionLifecycle,
canDowngradeToPersonal: state.value.canDowngradeToPersonal
})),
isSubscriptionCancelled: computed(() => state.value.isSubscriptionCancelled)
isSubscriptionCancelled: computed(
() => state.value.isSubscriptionCancelled
),
canReactivatePlan: computed(() => state.value.canReactivatePlan)
}
}
Loading