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/locales/ar/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "الحد الشهري: تم استخدام {spent} من {limit}",
"limitTooltip": "يحتسب عمليات تحصيل الشحن التلقائي فقط. يُعاد تعيينه في {date}.",
"limitTooltipNoDate": "يحتسب عمليات تحصيل الشحن التلقائي فقط.",
"member": "يمكن شحن الأرصدة تلقائيًا عندما تنخفض. تواصل مع مالك مساحة العمل لإدارة ذلك.",
"off": "يعيد شحن الأرصدة عندما ينخفض رصيدك",
"onHold": "لا توجد طريقة دفع افتراضية. عيّن واحدة لاستئناف الشحن التلقائي.",
"paused": "تم بلوغ الحد الشهري. يُستأنف في {date}.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/de/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "Monatliches Limit: {spent} von {limit} verwendet",
"limitTooltip": "Berücksichtigt nur Abbuchungen für automatische Aufladungen. Wird am {date} zurückgesetzt.",
"limitTooltipNoDate": "Berücksichtigt nur Abbuchungen für automatische Aufladungen.",
"member": "Credits können automatisch aufgeladen werden, wenn sie zur Neige gehen. Wenden Sie sich an einen Workspace-Inhaber, um dies zu verwalten.",
"off": "Füllt Credits auf, wenn Ihr Guthaben zur Neige geht",
"onHold": "Keine Standardzahlungsmethode. Legen Sie eine fest, um die automatische Aufladung fortzusetzen.",
"paused": "Monatliches Limit erreicht. Wird am {date} fortgesetzt.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -3653,6 +3653,7 @@
"pausedByRemainderNoDate": "Next top-up would go over your monthly limit.",
"maximumReached": "Monthly maximum reached. Resets {date}.",
"maximumReachedNoDate": "Monthly maximum reached.",
"member": "Credits can top up automatically when they run low. Contact a workspace owner to manage this.",
"rule": "Tops up to {target} credits when below {threshold} credits.",
"status": {
"failed": "Failed",
Expand Down
1 change: 1 addition & 0 deletions src/locales/es/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "Límite mensual: se han usado {spent} de {limit}",
"limitTooltip": "Solo cuenta los cobros de recarga automática. Se restablece el {date}.",
"limitTooltipNoDate": "Solo cuenta los cobros de recarga automática.",
"member": "Los créditos se pueden recargar automáticamente cuando se agotan. Contacta con un propietario del espacio de trabajo para gestionarlo.",
"off": "Recarga créditos cuando tu saldo es bajo",
"onHold": "No hay un método de pago predeterminado. Configura uno para reanudar la recarga automática.",
"paused": "Se alcanzó el límite mensual. Se reanuda el {date}.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fa/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "سقف ماهانه: {spent} از {limit} استفاده شده است",
"limitTooltip": "فقط پرداخت‌های افزایش اعتبار خودکار را محاسبه می‌کند. در {date} بازنشانی می‌شود.",
"limitTooltipNoDate": "فقط پرداخت‌های افزایش اعتبار خودکار را محاسبه می‌کند.",
"member": "اعتبارها می‌توانند هنگام کم شدن به‌طور خودکار افزایش یابند. برای مدیریت این مورد با مالک فضای کاری تماس بگیرید.",
"off": "وقتی موجودی‌تان کم می‌شود، اعتبارها را افزایش می‌دهد",
"onHold": "روش پرداخت پیش‌فرضی وجود ندارد. برای ازسرگیری افزایش اعتبار خودکار، یکی تنظیم کنید.",
"paused": "سقف ماهانه پر شده است. در {date} از سر گرفته می‌شود.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "Limite mensuelle : {spent} sur {limit} utilisés",
"limitTooltip": "Ne compte que les paiements de rechargement automatique. Réinitialisation le {date}.",
"limitTooltipNoDate": "Ne compte que les paiements de rechargement automatique.",
"member": "Les crédits peuvent être rechargés automatiquement lorsqu'ils sont bas. Contactez un propriétaire de l'espace de travail pour gérer ce paramètre.",
"off": "Recharge les crédits lorsque votre solde est faible",
"onHold": "Aucun moyen de paiement par défaut. Définissez-en un pour reprendre le rechargement automatique.",
"paused": "Limite mensuelle atteinte. Reprend le {date}.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/he/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "מגבלה חודשית: נעשה שימוש ב-{spent} מתוך {limit}",
"limitTooltip": "נספרים רק חיובים של טעינה אוטומטית. מתאפס ב-{date}.",
"limitTooltipNoDate": "נספרים רק חיובים של טעינה אוטומטית.",
"member": "ניתן לטעון קרדיטים אוטומטית כשהם עומדים להיגמר. פנו לבעלים של סביבת העבודה כדי לנהל זאת.",
"off": "ממלא קרדיטים מחדש כשהיתרה שלכם נמוכה",
"onHold": "אין אמצעי תשלום ברירת מחדל. הגדירו אמצעי כדי לחדש את הטעינה האוטומטית.",
"paused": "המגבלה החודשית הושגה. יתחדש ב-{date}.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/it/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "Limite mensile: {spent} di {limit} utilizzati",
"limitTooltip": "Conteggia solo gli addebiti per la ricarica automatica. Si reimposta il {date}.",
"limitTooltipNoDate": "Conteggia solo gli addebiti per la ricarica automatica.",
"member": "I crediti possono essere ricaricati automaticamente quando stanno per esaurirsi. Contatta un proprietario dello spazio di lavoro per gestire questa opzione.",
"off": "Ricarica i crediti quando il saldo è basso",
"onHold": "Nessun metodo di pagamento predefinito. Impostane uno per riprendere la ricarica automatica.",
"paused": "Limite mensile raggiunto. Riprende il {date}.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ja/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "月間上限: {limit} 中 {spent} を使用",
"limitTooltip": "自動チャージの請求のみをカウントします。{date} にリセットされます。",
"limitTooltipNoDate": "自動チャージの請求のみをカウントします。",
"member": "クレジットが少なくなると自動でチャージできます。管理するにはワークスペースのオーナーにお問い合わせください。",
"off": "残高が少なくなるとクレジットを補充します",
"onHold": "デフォルトの支払い方法がありません。設定して自動チャージを再開してください。",
"paused": "月間上限に達しました。{date} に再開します。",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ko/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "월간 한도: {limit} 중 {spent} 사용",
"limitTooltip": "자동 충전 청구만 집계합니다. {date}에 재설정됩니다.",
"limitTooltipNoDate": "자동 충전 청구만 집계합니다.",
"member": "크레딧이 부족해지면 자동으로 충전할 수 있습니다. 관리하려면 워크스페이스 소유자에게 문의하세요.",
"off": "잔액이 부족해지면 크레딧을 충전합니다.",
"onHold": "기본 결제 수단이 없습니다. 자동 충전을 재개하려면 설정하세요.",
"paused": "월간 한도에 도달했습니다. {date}에 재개됩니다.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/pt-BR/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "Limite mensal: {spent} de {limit} usados",
"limitTooltip": "Conta apenas cobranças de recarga automática. Redefine em {date}.",
"limitTooltipNoDate": "Conta apenas cobranças de recarga automática.",
"member": "Os créditos podem ser recarregados automaticamente quando estiverem acabando. Fale com um proprietário do espaço de trabalho para gerenciar isso.",
"off": "Recarrega créditos quando seu saldo está baixo",
"onHold": "Nenhuma forma de pagamento padrão. Defina uma para retomar a recarga automática.",
"paused": "Limite mensal atingido. Retoma em {date}.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/ru/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "Месячный лимит: использовано {spent} из {limit}",
"limitTooltip": "Учитываются только списания при автоматическом пополнении. Сброс {date}.",
"limitTooltipNoDate": "Учитываются только списания при автоматическом пополнении.",
"member": "Кредиты могут пополняться автоматически, когда их становится мало. Чтобы управлять этим, обратитесь к владельцу рабочего пространства.",
"off": "Пополняет кредиты, когда баланс становится низким",
"onHold": "Нет способа оплаты по умолчанию. Укажите его, чтобы возобновить автоматическое пополнение.",
"paused": "Достигнут месячный лимит. Возобновится {date}.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/tr/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "Aylık sınır: {limit} tutarın {spent} kadarı kullanıldı",
"limitTooltip": "Yalnızca otomatik kredi yükleme ücretlendirmeleri sayılır. {date} tarihinde sıfırlanır.",
"limitTooltipNoDate": "Yalnızca otomatik kredi yükleme ücretlendirmeleri sayılır.",
"member": "Krediler azaldığında otomatik olarak yüklenebilir. Bunu yönetmek için bir çalışma alanı sahibiyle iletişime geçin.",
"off": "Bakiyeniz azaldığında kredileri yeniden yükler",
"onHold": "Varsayılan ödeme yöntemi yok. Otomatik kredi yüklemeyi sürdürmek için bir tane ayarlayın.",
"paused": "Aylık sınıra ulaşıldı. {date} tarihinde devam eder.",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-TW/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "每月上限:已使用 {spent}/{limit}",
"limitTooltip": "僅計入自動儲值扣款。將於 {date} 重設。",
"limitTooltipNoDate": "僅計入自動儲值扣款。",
"member": "點數不足時可自動儲值。如需管理,請聯絡工作區擁有者。",
"off": "當您的點數餘額不足時自動儲值",
"onHold": "沒有預設付款方式。請設定付款方式以恢復自動儲值。",
"paused": "已達每月上限。將於 {date} 恢復。",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5845,6 +5845,7 @@
"limit": "每月限额:已使用 {spent} / {limit}",
"limitTooltip": "仅统计自动充值的扣费。将于 {date} 重置。",
"limitTooltipNoDate": "仅统计自动充值的扣费。",
"member": "积分不足时可自动充值。如需管理,请联系工作区所有者。",
"off": "当你的余额不足时自动补充积分",
"onHold": "没有默认付款方式。请设置一个以恢复自动充值。",
"paused": "已达到每月限额。将于 {date} 恢复。",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ interface Scenario {
balance?: BalanceInfo | null
autoTopUpEnabled?: boolean
canManageAutoTopUp?: boolean
manageAutoTopUpDenial?: string
canTopUp?: boolean
topUpDenial?: BillingTopUpDenial
isPaused?: boolean
Expand Down Expand Up @@ -210,6 +211,12 @@ function arrange(scenario: Scenario = {}) {
scenario.autoTopUpEnabled ?? true
)
),
manageAutoTopUpDenial: computed(() =>
receiveServerFact(
'denied_reasons.can_manage_auto_top_up',
scenario.manageAutoTopUpDenial
)
),
autoTopUpSetup: computed(() => null),
isReady: computed(() => scenario.capabilitiesReady ?? true),
hasResolvedCapabilities: computed(
Expand Down Expand Up @@ -1852,6 +1859,60 @@ describe('BillingTab', () => {
expect(billingApi.getBillingAutoReload).toHaveBeenCalledTimes(reads)
})

describe('member block', () => {
const member: Scenario = {
canManageAutoTopUp: false,
manageAutoTopUpDenial: 'not_workspace_owner',
canTopUp: false
}

it('tells a member who manages auto top-up, without status, action or a settings read', () => {
arrange(member)

const block = screen.getByTestId('billing-auto-top-up-member-card')
expect(
within(block).getByRole('heading', { name: 'Auto top-up' })
).toBeInTheDocument()
expect(block).toHaveTextContent(
'Credits can top up automatically when they run low. Contact a workspace owner to manage this.'
)
expect(within(block).queryByRole('button')).not.toBeInTheDocument()
expect(within(block).queryByRole('link')).not.toBeInTheDocument()
expect(
screen.queryByTestId('billing-auto-top-up-status')
).not.toBeInTheDocument()
expect(
within(screen.getByTestId('billing-credits-section')).queryByRole(
'button',
{ name: 'Add credits' }
)
).not.toBeInTheDocument()
expect(billingApi.getBillingAutoReload).not.toHaveBeenCalled()
})

it.for<{ case: string; scenario: Scenario }>([
{
case: 'the flag is off',
scenario: { ...member, autoTopUpEnabled: false }
},
{
case: 'the denial is not not_workspace_owner',
scenario: { ...member, manageAutoTopUpDenial: 'not_a_member' }
},
{
case: 'the server sends no denial',
scenario: { ...member, manageAutoTopUpDenial: undefined }
},
{ case: 'the actor is an owner', scenario: {} }
])('hides the member block when $case', ({ scenario }) => {
arrange(scenario)

expect(
screen.queryByTestId('billing-auto-top-up-member-card')
).not.toBeInTheDocument()
})
})

it('reads the auto top-up settings once for the card and the banner', async () => {
arrange({})
await screen.findByTestId('billing-auto-top-up-status')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<template v-if="capabilities.canManageAutoTopUp.value">
<BillingAutoTopUpCard v-if="capabilities.canTopUp.value" />
</template>
<BillingAutoTopUpMemberCard />
</template>
</section>

Expand Down Expand Up @@ -174,6 +175,7 @@ import BillingTopupCheckoutBanner from '@/platform/billing/components/billingTab
import BillingStatusBanner from '@/platform/billing/components/settings/BillingStatusBanner.vue'
import { usePlanCheckoutBanner } from '@/platform/billing/composables/usePlanCheckoutBanner'
import BillingAutoTopUpCard from '@/platform/billing/components/billingTab/BillingAutoTopUpCard.vue'
import BillingAutoTopUpMemberCard from '@/platform/billing/components/billingTab/BillingAutoTopUpMemberCard.vue'
import BillingCreditsCard from '@/platform/billing/components/billingTab/BillingCreditsCard.vue'
import BillingPlanRow from '@/platform/billing/components/billingTab/BillingPlanRow.vue'
import { addCreditsEmphasis } from '@/platform/billing/components/billingTab/creditsCard'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div
v-if="manageAutoTopUpDenial === 'not_workspace_owner'"
class="flex flex-col gap-1 rounded-xl border border-card px-5 py-4"
data-testid="billing-auto-top-up-member-card"
>
<h3 class="m-0 text-sm font-medium text-foreground">
{{ $t('workspacePanel.billingTab.autoTopUp.title') }}
</h3>
<p class="m-0 text-sm text-muted-foreground">
{{ $t('workspacePanel.billingTab.autoTopUp.member') }}
</p>
</div>
</template>

<script setup lang="ts">
import { useBillingCapabilities } from '@/platform/billing/composables/useBillingCapabilities'

const { manageAutoTopUpDenial } = useBillingCapabilities()
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const defaults: ReturnType<typeof realUseBillingCapabilities> = {
canManageAutoTopUp: computed(() =>
receiveServerFact('can_manage_auto_top_up', false)
),
manageAutoTopUpDenial: manageAutoTopUpDenialFact(undefined),
autoTopUpEnabled: computed(() =>
receiveServerFact('auto_top_up_enabled', false)
),
Expand Down Expand Up @@ -94,6 +95,12 @@ export function runWorkflowsDenialFact(
)
}

export function manageAutoTopUpDenialFact(denial: string | undefined) {
return computed(() =>
receiveServerFact('denied_reasons.can_manage_auto_top_up', denial)
)
}

export function runDeniedPaymentPastDueFact(
deniedPastDue: MaybeRefOrGetter<boolean>
) {
Expand Down
21 changes: 21 additions & 0 deletions src/platform/billing/composables/useBillingCapabilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,27 @@ describe('useBillingCapabilities on the SDK rail', () => {
expect(billingCapabilities.runWorkflowsDenial.value).toBe(denial)
}
)

it.for([
{ denial: 'not_workspace_owner' },
{ denial: 'not_a_member' },
{ denial: undefined }
])(
'exposes a can_manage_auto_top_up denial of $denial as the server sent it',
async ({ denial }) => {
readCapabilities.mockResolvedValueOnce({
status: 'ok',
value: {
...capabilitiesResponse(true),
denied_reasons: { can_manage_auto_top_up: denial }
}
})

await billingCapabilities.initialize()

expect(billingCapabilities.manageAutoTopUpDenial.value).toBe(denial)
}
)
})

describe('useBillingCapabilities capability gates', () => {
Expand Down
7 changes: 7 additions & 0 deletions src/platform/billing/composables/useBillingCapabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ function useBillingCapabilitiesInternal() {
capabilities.value?.can_manage_auto_top_up ?? false
)
)
const manageAutoTopUpDenial = computed(() =>
receiveServerFact(
'denied_reasons.can_manage_auto_top_up',
resolvedResponse.value?.denied_reasons?.can_manage_auto_top_up
)
)
const autoTopUpEnabled = computed(() =>
receiveServerFact(
'auto_top_up_enabled',
Expand Down Expand Up @@ -577,6 +583,7 @@ function useBillingCapabilitiesInternal() {
canManageSubscription,
canDowngradeToPersonal,
canManageAutoTopUp,
manageAutoTopUpDenial,
autoTopUpEnabled,
autoTopUpSetup,
canRunWorkflows,
Expand Down
Loading