From 2fc0dcc10a5c9a32187e4c73d8b7c84bd0be9676 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 26 Jan 2024 18:06:54 +0800 Subject: [PATCH] feat: team admin can pay billing (#2240) --- web/app/components/billing/billing-page/index.tsx | 8 ++++---- web/app/components/billing/pricing/index.tsx | 4 ++-- .../account-setting/model-provider-page/declarations.ts | 1 + .../provider-added-card/quota-panel.tsx | 3 +++ web/i18n/lang/billing.en.ts | 4 ++-- web/i18n/lang/billing.pt.ts | 3 ++- web/i18n/lang/billing.zh.ts | 4 ++-- web/i18n/lang/common.en.ts | 1 + web/i18n/lang/common.zh.ts | 1 + 9 files changed, 18 insertions(+), 11 deletions(-) diff --git a/web/app/components/billing/billing-page/index.tsx b/web/app/components/billing/billing-page/index.tsx index a079bf2cb1..6cf720c5b8 100644 --- a/web/app/components/billing/billing-page/index.tsx +++ b/web/app/components/billing/billing-page/index.tsx @@ -11,23 +11,23 @@ import { useProviderContext } from '@/context/provider-context' const Billing: FC = () => { const { t } = useTranslation() - const { isCurrentWorkspaceOwner } = useAppContext() + const { isCurrentWorkspaceManager } = useAppContext() const [billingUrl, setBillingUrl] = React.useState('') const { enableBilling } = useProviderContext() useEffect(() => { - if (!enableBilling || !isCurrentWorkspaceOwner) + if (!enableBilling || !isCurrentWorkspaceManager) return (async () => { const { url } = await fetchBillingUrl() setBillingUrl(url) })() - }, [isCurrentWorkspaceOwner]) + }, [isCurrentWorkspaceManager]) return (
- {enableBilling && isCurrentWorkspaceOwner && billingUrl && ( + {enableBilling && isCurrentWorkspaceManager && billingUrl && (
diff --git a/web/app/components/billing/pricing/index.tsx b/web/app/components/billing/pricing/index.tsx index de67e52835..7e05bd3570 100644 --- a/web/app/components/billing/pricing/index.tsx +++ b/web/app/components/billing/pricing/index.tsx @@ -20,8 +20,8 @@ const Pricing: FC = ({ }) => { const { t } = useTranslation() const { plan } = useProviderContext() - const { isCurrentWorkspaceOwner } = useAppContext() - const canPay = isCurrentWorkspaceOwner + const { isCurrentWorkspaceManager } = useAppContext() + const canPay = isCurrentWorkspaceManager const [planRange, setPlanRange] = React.useState(PlanRange.monthly) return createPortal( diff --git a/web/app/components/header/account-setting/model-provider-page/declarations.ts b/web/app/components/header/account-setting/model-provider-page/declarations.ts index d8eaf5f625..90aa758187 100644 --- a/web/app/components/header/account-setting/model-provider-page/declarations.ts +++ b/web/app/components/header/account-setting/model-provider-page/declarations.ts @@ -132,6 +132,7 @@ export enum CurrentSystemQuotaTypeEnum { export enum QuotaUnitEnum { times = 'times', tokens = 'tokens', + credits = 'credits', } export type QuotaConfiguration = { diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/quota-panel.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/quota-panel.tsx index e13e2bc29c..921d4b4c97 100644 --- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/quota-panel.tsx +++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/quota-panel.tsx @@ -62,6 +62,9 @@ const QuotaPanel: FC = ({ { currentQuota?.quota_unit === QuotaUnitEnum.times && t('common.modelProvider.callTimes') } + { + currentQuota?.quota_unit === QuotaUnitEnum.credits && t('common.modelProvider.credits') + }
) } diff --git a/web/i18n/lang/billing.en.ts b/web/i18n/lang/billing.en.ts index 038922f62e..7742f4a852 100644 --- a/web/i18n/lang/billing.en.ts +++ b/web/i18n/lang/billing.en.ts @@ -20,7 +20,7 @@ const translation = { save: 'Save ', free: 'Free', currentPlan: 'Current Plan', - contractOwner: 'Contact your workspace owner', + contractOwner: 'Contact team manager', startForFree: 'Start for free', getStartedWith: 'Get started with ', contactSales: 'Contact Sales', @@ -68,7 +68,7 @@ const translation = { tooltip: 'Manual editing and annotation of responses provides customizable high-quality question-answering abilities for apps. (Applicable only in chat apps)', }, ragAPIRequestTooltip: 'Refers to the number of API calls invoking only the knowledge base processing capabilities of Dify.', - receiptInfo: 'Only team owner can subscribe and view billing information', + receiptInfo: 'Only team owner and team admin can subscribe and view billing information', }, plans: { sandbox: { diff --git a/web/i18n/lang/billing.pt.ts b/web/i18n/lang/billing.pt.ts index 4fba031789..9f38a0eaca 100644 --- a/web/i18n/lang/billing.pt.ts +++ b/web/i18n/lang/billing.pt.ts @@ -20,7 +20,7 @@ const translation = { save: 'Save ', free: 'Free', currentPlan: 'Current Plan', - contractOwner: 'Contact your workspace owner', + contractOwner: 'Contact team manager', startForFree: 'Start for free', getStartedWith: 'Get started with ', contactSales: 'Contact Sales', @@ -68,6 +68,7 @@ const translation = { tooltip: 'Manual editing and annotation of responses provides customizable high-quality question-answering abilities for apps. (Applicable only in chat apps)', }, ragAPIRequestTooltip: 'Refers to the number of API calls invoking only the knowledge base processing capabilities of Dify.', + receiptInfo: 'Somente proprietários e administradores de equipe podem se inscrever e visualizar informações de cobrança', }, plans: { sandbox: { diff --git a/web/i18n/lang/billing.zh.ts b/web/i18n/lang/billing.zh.ts index 4d9728b8d7..00c41e7340 100644 --- a/web/i18n/lang/billing.zh.ts +++ b/web/i18n/lang/billing.zh.ts @@ -19,7 +19,7 @@ const translation = { year: '年', save: '节省', currentPlan: '当前计划', - contractOwner: '联系您的工作区所有者', + contractOwner: '联系团队管理员', free: '免费', startForFree: '免费开始', getStartedWith: '开始使用', @@ -68,7 +68,7 @@ const translation = { tooltip: '标注回复功能通过人工编辑标注为应用提供了可定制的高质量问答回复能力', }, ragAPIRequestTooltip: '指单独调用 Dify 知识库数据处理能力的 API。', - receiptInfo: '只有团队所有者才能订阅和查看账单信息', + receiptInfo: '只有团队所有者和团队管理员才能订阅和查看账单信息', }, plans: { sandbox: { diff --git a/web/i18n/lang/common.en.ts b/web/i18n/lang/common.en.ts index a31c2d1510..c9d4c122e9 100644 --- a/web/i18n/lang/common.en.ts +++ b/web/i18n/lang/common.en.ts @@ -303,6 +303,7 @@ const translation = { model: 'Model', featureSupported: '{{feature}} supported', callTimes: 'Call times', + credits: 'Message Credits', buyQuota: 'Buy Quota', getFreeTokens: 'Get free Tokens', priorityUsing: 'Prioritize using', diff --git a/web/i18n/lang/common.zh.ts b/web/i18n/lang/common.zh.ts index 772eafe530..7c741b4bd5 100644 --- a/web/i18n/lang/common.zh.ts +++ b/web/i18n/lang/common.zh.ts @@ -303,6 +303,7 @@ const translation = { model: '模型', featureSupported: '支持 {{feature}} 功能', callTimes: '调用次数', + credits: '消息额度', buyQuota: '购买额度', getFreeTokens: '获得免费 Tokens', priorityUsing: '优先使用',