diff --git a/web/app/components/base/premium-badge/index.tsx b/web/app/components/base/premium-badge/index.tsx index bdae8a0cba..7bf85cdcc3 100644 --- a/web/app/components/base/premium-badge/index.tsx +++ b/web/app/components/base/premium-badge/index.tsx @@ -12,6 +12,7 @@ const PremiumBadgeVariants = cva( size: { s: 'premium-badge-s', m: 'premium-badge-m', + custom: '', }, color: { blue: 'premium-badge-blue', @@ -33,7 +34,7 @@ const PremiumBadgeVariants = cva( ) type PremiumBadgeProps = { - size?: 's' | 'm' + size?: 's' | 'm' | 'custom' color?: 'blue' | 'indigo' | 'gray' | 'orange' allowHover?: boolean styleCss?: CSSProperties diff --git a/web/app/components/billing/plan-upgrade-modal/index.tsx b/web/app/components/billing/plan-upgrade-modal/index.tsx index 79f354333c..4f5d1ed3a6 100644 --- a/web/app/components/billing/plan-upgrade-modal/index.tsx +++ b/web/app/components/billing/plan-upgrade-modal/index.tsx @@ -72,9 +72,10 @@ const PlanUpgradeModal: FC = ({ {t('billing.triggerLimitModal.dismiss')} diff --git a/web/app/components/billing/upgrade-btn/index.tsx b/web/app/components/billing/upgrade-btn/index.tsx index d576e07f3e..b70daeb2e6 100644 --- a/web/app/components/billing/upgrade-btn/index.tsx +++ b/web/app/components/billing/upgrade-btn/index.tsx @@ -11,7 +11,7 @@ type Props = { className?: string style?: CSSProperties isFull?: boolean - size?: 'md' | 'lg' + size?: 's' | 'm' | 'custom' isPlain?: boolean isShort?: boolean onClick?: () => void @@ -21,6 +21,7 @@ type Props = { const UpgradeBtn: FC = ({ className, + size = 'm', style, isPlain = false, isShort = false, @@ -62,7 +63,7 @@ const UpgradeBtn: FC = ({ return ( = ({ embedding, }) => { const { t } = useTranslation() + const [isShowPlanUpgradeModal, { + setTrue: showPlanUpgradeModal, + setFalse: hidePlanUpgradeModal, + }] = useBoolean(false) + const { plan, enableBilling } = useProviderContext() + const { usage, total } = plan + const canAdd = enableBilling && (usage.vectorSpace < total.vectorSpace) + + const withNeedUpgradeCheck = useCallback((fn: () => void) => { + return () => { + if (!canAdd) { + showPlanUpgradeModal() + return + } + fn() + } + }, [canAdd, showPlanUpgradeModal]) const textColor = useMemo(() => { return embedding ? 'text-components-button-secondary-accent-text-disabled' @@ -90,7 +110,7 @@ const SegmentAdd: FC = ({ type='button' className={`inline-flex items-center rounded-l-lg border-r-[1px] border-r-divider-subtle px-2.5 py-2 hover:bg-state-base-hover disabled:cursor-not-allowed disabled:hover:bg-transparent`} - onClick={showNewSegmentModal} + onClick={withNeedUpgradeCheck(showNewSegmentModal)} disabled={embedding} > @@ -108,7 +128,7 @@ const SegmentAdd: FC = ({ @@ -116,7 +136,7 @@ const SegmentAdd: FC = ({ } btnElement={
- +
} btnClassName={open => cn( @@ -129,7 +149,16 @@ const SegmentAdd: FC = ({ className='h-fit min-w-[128px]' disabled={embedding} /> + {isShowPlanUpgradeModal && ( + + )} + ) } export default React.memo(SegmentAdd) diff --git a/web/i18n/en-US/billing.ts b/web/i18n/en-US/billing.ts index 9c88acf4d0..793e534e35 100644 --- a/web/i18n/en-US/billing.ts +++ b/web/i18n/en-US/billing.ts @@ -226,6 +226,10 @@ const translation = { title: 'Upgrade to upload multiple pages at once', description: 'You’ve reached the upload limit — only one page can be selected and uploaded at a time on your current plan.', }, + addChunks: { + title: 'Upgrade to continue adding chunks', + description: 'You’ve reached the limit of adding chunks for this plan. ', + }, }, } diff --git a/web/i18n/ja-JP/billing.ts b/web/i18n/ja-JP/billing.ts index 881e3797b6..a7dd695871 100644 --- a/web/i18n/ja-JP/billing.ts +++ b/web/i18n/ja-JP/billing.ts @@ -207,6 +207,10 @@ const translation = { title: '複数ページを一度にアップロードするにはアップグレード', description: '現在のプランではアップロード上限に達しています。1回の操作で選択・アップロードできるページは1つのみです。', }, + addChunks: { + title: 'アップグレードして、チャンクを引き続き追加できるようにしてください。', + description: 'このプランでは、チャンク追加の上限に達しています。 ', + }, }, } diff --git a/web/i18n/zh-Hans/billing.ts b/web/i18n/zh-Hans/billing.ts index dd319ef964..6e0c97de71 100644 --- a/web/i18n/zh-Hans/billing.ts +++ b/web/i18n/zh-Hans/billing.ts @@ -207,6 +207,10 @@ const translation = { title: '升级以一次性上传多个页面', description: '您已达到当前套餐的上传限制 —— 该套餐每次只能选择并上传 1 个页面。', }, + addChunks: { + title: '升级以继续添加分段', + description: '您已达到此计划的添加分段上限。', + }, }, }