Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: react ui miss feature/permission guard (#19805)
ecmadao78e388b76175
diff --git a/frontend/scripts/check-react-i18n.mjs b/frontend/scripts/check-react-i18n.mjsindex 8d75553165..b27fb8bbda 100644--- a/frontend/scripts/check-react-i18n.mjs+++ b/frontend/scripts/check-react-i18n.mjs@@ -18,6 +18,7 @@ const DYNAMIC_PREFIXES = ["dynamic.settings.sensitive-data.semantic-types.template.","subscription.plan.","settings.sensitive-data.algorithms.",+ "instance.selected-n-instances","settings.sidebar.",];diff --git a/frontend/src/assets/css/tailwind.css b/frontend/src/assets/css/tailwind.cssindex 3598a6f370..539150a5ff 100644--- a/frontend/src/assets/css/tailwind.css+++ b/frontend/src/assets/css/tailwind.css@@ -22,6 +22,14 @@::file-selector-button {border-color: var(--color-gray-200, currentcolor);}++ /* All disabled form elements should show not-allowed cursor */+ input:disabled,+ select:disabled,+ textarea:disabled,+ button:disabled {+ cursor: not-allowed;+ }}@utility hide-scrollbar {diff --git a/frontend/src/react/components/AdvancedSearch.tsx b/frontend/src/react/components/AdvancedSearch.tsxindex 7c4fc427f5..474156dcde 100644--- a/frontend/src/react/components/AdvancedSearch.tsx+++ b/frontend/src/react/components/AdvancedSearch.tsx@@ -473,7 +473,7 @@ export function AdvancedSearch({{/* Dropdown menu */}{showMenu && (<div- className="absolute top-[38px] w-full bg-gray-100 shadow-xl origin-top-left rounded-[3px] overflow-hidden z-50"+ className="absolute top-[38px] w-full bg-gray-100 shadow-xl origin-top-left rounded-xs overflow-hidden z-50"onMouseDown={(e) => e.preventDefault()}>{/* Scope menu */}diff --git a/frontend/src/react/components/ComponentPermissionGuard.tsx b/frontend/src/react/components/ComponentPermissionGuard.tsxnew file mode 100644index 0000000000..7afe51c67f--- /dev/null+++ b/frontend/src/react/components/ComponentPermissionGuard.tsx@@ -0,0 +1,55 @@+import { ShieldAlert } from "lucide-react";+import type { ReactNode } from "react";+import { useTranslation } from "react-i18next";+import type { Permission } from "@/types";+import { hasWorkspacePermissionV2 } from "@/utils";++interface ComponentPermissionGuardProps {+ readonly permissions: Permission[];+ readonly children: ReactNode;+ readonly className?: string;+}++/**+ * ComponentPermissionGuard gates an entire component behind a permission check.+ *+ * - If the user has all required permissions, children are rendered normally.+ * - If the user is missing permissions, an error alert is shown listing the+ * missing permissions — matching the Vue `ComponentPermissionGuard` behavior.+ */+export function ComponentPermissionGuard({+ permissions,+ children,+ className,+}: ComponentPermissionGuardProps) {+ const { t } = useTranslation();+ const missed = permissions.filter((p) => !hasWorkspacePermissionV2(p));++ if (missed.length === 0) {+ return <>{children}</>;+ }++ return (+ <div className={className}>+ <div+ role="alert"+ className="relative w-full rounded-xs border border-error/30 bg-error/5 text-error px-4 py-3 text-sm flex gap-x-3"+ >+ <ShieldAlert className="h-5 w-5 shrink-0 mt-0.5" />+ <div className="flex flex-col gap-2">+ <h5 className="font-medium leading-tight">+ {t("common.missing-required-permission", { permissions: "" })}+ </h5>+ <div>+ {t("common.required-permission")}+ <ul className="list-disc pl-4">+ {missed.map((p) => (+ <li key={p}>{p}</li>+ ))}+ </ul>+ </div>+ </div>+ </div>+ </div>+ );+}diff --git a/frontend/src/react/components/ExprEditor.tsx b/frontend/src/react/components/ExprEditor.tsxindex e320c11426..ee6a37e280 100644--- a/frontend/src/react/components/ExprEditor.tsx+++ b/frontend/src/react/components/ExprEditor.tsx@@ -205,7 +205,7 @@ function SearchableSelect({<div ref={containerRef} className="relative min-w-28"><buttontype="button"- className="h-8 px-2 text-sm rounded border border-control-border bg-white w-full text-left disabled:opacity-50 truncate"+ className="h-8 px-2 text-sm rounded-xs border border-control-border bg-white w-full text-left disabled:opacity-50 truncate"disabled={disabled}onClick={handleOpen}>@@ -214,11 +214,11 @@ function SearchableSelect({)}</button>{open && (- <div className="absolute z-50 mt-1 w-56 bg-white border border-control-border rounded shadow-md">+ <div className="absolute z-50 mt-1 w-56 bg-white border border-control-border rounded-xs shadow-md"><div className="p-1 border-b border-control-border"><inputautoFocus- className="w-full h-8 px-2 text-sm rounded border border-control-border outline-none"+ className="w-full h-8 px-2 text-sm rounded-xs border border-control-border outline-none"placeholder={t("common.filter-by-name")}value={search}onChange={(e) => handleSearchChange(e.target.value)}@@ -384,7 +384,7 @@ function MultiSearchableSelect({return (<div ref={containerRef} className="relative min-w-32 max-w-xs"><div- className="min-h-8 px-2 py-0.5 text-sm rounded border border-control-border bg-white flex flex-wrap gap-1 cursor-pointer"+ className="min-h-8 px-2 py-0.5 text-sm rounded-xs border border-control-border bg-white flex flex-wrap gap-1 cursor-pointer"onClick={disabled ? undefined : handleOpen}>{value.length === 0 && (@@ -414,11 +414,11 @@ function MultiSearchableSelect({))}</div>{open && (- <div className="absolute z-50 mt-1 w-56 bg-white border border-control-border rounded shadow-md">+ <div className="absolute z-50 mt-1 w-56 bg-white border border-control-border rounded-xs shadow-md"><div className="p-1 border-b border-control-border"><inputautoFocus- className="w-full h-8 px-2 text-sm rounded border border-control-border outline-none"+ className="w-full h-8 px-2 text-sm rounded-xs border border-control-border outline-none"placeholder={t("common.filter-by-name")}value={search}onChange={(e) => handleSearchChange(e.target.value)}@@ -501,7 +501,7 @@ function TagInput({};return (- <div className="flex flex-wrap items-center gap-1 min-h-8 px-2 py-0.5 rounded border border-control-border bg-white min-w-64 max-w-xs">+ <div className="flex flex-wrap items-center gap-1 min-h-8 px-2 py-0.5 rounded-xs border border-control-border bg-white min-w-64 max-w-xs">{value.map((tag) => (<spankey={tag}@@ -593,7 +593,7 @@ function MultiCheckSelect({<div ref={containerRef} className="relative min-w-32"><buttontype="button"- className="inline-flex items-center gap-1 min-h-8 w-full px-2 py-0.5 text-sm rounded-md border border-control-border bg-white text-left hover:bg-control-bg disabled:pointer-events-none disabled:opacity-50 flex-wrap"+ className="inline-flex items-center gap-1 min-h-8 w-full px-2 py-0.5 text-sm rounded-xs border border-control-border bg-white text-left hover:bg-control-bg disabled:pointer-events-none disabled:opacity-50 flex-wrap"disabled={disabled}onClick={() => setOpen(!open)}>@@ -894,7 +894,7 @@ function ValueInput({return (<inputtype="number"- className="h-8 px-2 text-sm rounded border border-control-border bg-white disabled:opacity-50 max-w-20"+ className="h-8 px-2 text-sm rounded-xs border border-control-border bg-white disabled:opacity-50 max-w-20"value={getNumberValue()}disabled={readonly}onChange={(e) => setNumberValue(Number(e.target.value))}@@ -1012,7 +1012,7 @@ function ConditionRow({{!readonly && (<buttontype="button"- className="shrink-0 w-7 h-7 flex items-center justify-center rounded text-control-placeholder hover:text-control hover:bg-gray-100"+ className="shrink-0 w-7 h-7 flex items-center justify-center rounded-xs text-control-placeholder hover:text-control hover:bg-gray-100"onClick={onRemove}><X className="w-4 h-4" />@@ -1040,7 +1040,7 @@ function RawStringEditor({return (<div className="w-full flex items-start gap-x-1"><textarea- className="flex-1 min-h-16 max-h-24 px-2 py-1 text-sm rounded border border-control-border bg-white resize-y disabled:opacity-50"+ className="flex-1 min-h-16 max-h-24 px-2 py-1 text-sm rounded-xs border border-control-border bg-white resize-y disabled:opacity-50"placeholder="Enter raw CEL expression"value={expr.content}disabled={readonly}@@ -1053,7 +1053,7 @@ function RawStringEditor({{!readonly && (<buttontype="button"- className="shrink-0 w-7 h-7 flex items-center justify-center rounded text-control-placeholder hover:text-control hover:bg-gray-100"+ className="shrink-0 w-7 h-7 flex items-center justify-center rounded-xs text-control-placeholder hover:text-control hover:bg-gray-100"onClick={onRemove}><X className="w-4 h-4" />@@ -1144,7 +1144,7 @@ function ConditionGroup({return (<divclassName={`w-full flex flex-col gap-y-2 py-0.5 ${- root ? "" : "border rounded-[3px] bg-gray-50"+ root ? "" : "border rounded-xs bg-gray-50"}`}>{!root && (@@ -1171,7 +1171,7 @@ function ConditionGroup({<div className="flex items-center justify-end"><buttontype="button"- className="w-[22px] h-[22px] flex items-center justify-center rounded hover:bg-gray-100"+ className="w-[22px] h-[22px] flex items-center justify-center rounded-xs hover:bg-gray-100"onClick={onRemove}><X className="w-3.5 h-3.5" />@@ -1253,7 +1253,7 @@ function ConditionGroup({<div className="pl-1.5 pb-1 flex gap-x-1"><buttontype="button"- className="inline-flex items-center gap-1 text-sm text-gray-500 px-1.5 py-0.5 rounded hover:bg-gray-100 disabled:opacity-50"+ className="inline-flex items-center gap-1 text-sm text-gray-500 px-1.5 py-0.5 rounded-xs hover:bg-gray-100 disabled:opacity-50"disabled={readonly}onClick={addCondition}>@@ -1262,7 +1262,7 @@ function ConditionGroup({</button><buttontype="button"- className="inline-flex items-center gap-1 text-sm text-gray-500 px-1.5 py-0.5 rounded hover:bg-gray-100 disabled:opacity-50"+ className="inline-flex items-center gap-1 text-sm text-gray-500 px-1.5 py-0.5 rounded-xs hover:bg-gray-100 disabled:opacity-50"disabled={readonly}onClick={addRawString}>@@ -1276,7 +1276,7 @@ function ConditionGroup({<div className="flex gap-x-1"><buttontype="button"- className="inline-flex items-center gap-1 text-sm px-1.5 py-0.5 rounded hover:bg-gray-100 disabled:opacity-50"+ className="inline-flex items-center gap-1 text-sm px-1.5 py-0.5 rounded-xs hover:bg-gray-100 disabled:opacity-50"disabled={readonly}onClick={addCondition}>@@ -1285,7 +1285,7 @@ function ConditionGroup({</button><buttontype="button"- className="inline-flex items-center gap-1 text-sm px-1.5 py-0.5 rounded hover:bg-gray-100 disabled:opacity-50"+ className="inline-flex items-center gap-1 text-sm px-1.5 py-0.5 rounded-xs hover:bg-gray-100 disabled:opacity-50"disabled={readonly}onClick={addConditionGroup}>@@ -1295,7 +1295,7 @@ function ConditionGroup({{enableRawExpression && (<buttontype="button"- className="inline-flex items-center gap-1 text-sm px-1.5 py-0.5 rounded hover:bg-gray-100 disabled:opacity-50"+ className="inline-flex items-center gap-1 text-sm px-1.5 py-0.5 rounded-xs hover:bg-gray-100 disabled:opacity-50"disabled={readonly}onClick={addRawString}>diff --git a/frontend/src/react/components/FeatureAttention.tsx b/frontend/src/react/components/FeatureAttention.tsxindex b86c1cda46..fec9aa1719 100644--- a/frontend/src/react/components/FeatureAttention.tsx+++ b/frontend/src/react/components/FeatureAttention.tsx@@ -99,7 +99,7 @@ export function FeatureAttention({return (<div- className={`flex items-start gap-3 rounded-md border px-4 py-3 ${+ className={`flex items-start gap-3 rounded-xs border px-4 py-3 ${isWarning? "border-yellow-300 bg-yellow-50": "border-blue-200 bg-blue-50"@@ -110,7 +110,7 @@ export function FeatureAttention({isWarning ? "text-yellow-600" : "text-blue-600"}`}/>- <div className="flex-1 flex flex-col md:flex-row md:items-center md:justify-between gap-3">+ <div className="flex-1 flex flex-col gap-3"><div><pclassName={`font-medium text-sm ${@@ -128,14 +128,16 @@ export function FeatureAttention({</p></div>{actionText && (- <Button- variant="outline"- size="sm"- className="shrink-0 whitespace-nowrap"- onClick={onAction}- >- {actionText}- </Button>+ <div className="flex justify-end">+ <Button+ variant="outline"+ size="sm"+ className="shrink-0 whitespace-nowrap"+ onClick={onAction}+ >+ {actionText}+ </Button>+ </div>)}</div></div>diff --git a/frontend/src/react/components/FeatureBadge.tsx b/frontend/src/react/components/FeatureBadge.tsxnew file mode 100644index 0000000000..42cbe3496c--- /dev/null+++ b/frontend/src/react/components/FeatureBadge.tsx@@ -0,0 +1,99 @@+import { Lock, Sparkles } from "lucide-react";+import { useTranslation } from "react-i18next";+import { useVueState } from "@/react/hooks/useVueState";+import { useSubscriptionV1Store } from "@/store";+import type {+ Instance,+ InstanceResource,+} from "@/types/proto-es/v1/instance_service_pb";+import {+ PlanFeature,+ PlanType,+} from "@/types/proto-es/v1/subscription_service_pb";+import { Tooltip } from "./ui/tooltip";++interface FeatureBadgeProps {+ readonly feature: PlanFeature;+ readonly instance?: Instance | InstanceResource;+ readonly clickable?: boolean;+ readonly className?: string;+}++const planLabel: Record<number, string> = {+ [PlanType.FREE]: "free",+ [PlanType.TEAM]: "team",+ [PlanType.ENTERPRISE]: "enterprise",+};++/**+ * FeatureBadge shows a sparkles icon with tooltip when the user's plan+ * doesn't include the required feature, or a lock icon when the instance+ * is missing a license assignment.+ *+ * Renders nothing if the feature is available.+ */+export function FeatureBadge({+ feature,+ instance,+ clickable = true,+ className,+}: FeatureBadgeProps) {+ const { t } = useTranslation();+ const subscriptionStore = useSubscriptionV1Store();++ const hasFeature = useVueState(() =>+ subscriptionStore.hasInstanceFeature(feature, instance)+ );+ const instanceMissingLicense = useVueState(() =>+ subscriptionStore.instanceMissingLicense(feature, instance)+ );+ const minimumPlan = useVueState(() =>+ subscriptionStore.getMinimumRequiredPlan(feature)+ );++ if (instanceMissingLicense) {+ return (+ <Tooltip+ content={t(+ "subscription.instance-assignment.missing-license-attention"+ )}+ >+ <span className={className ?? "text-accent inline-flex"}>+ <Lock className="w-5 h-5" />+ </span>+ </Tooltip>+ );+ }++ if (hasFeature) {+ return null;+ }++ const requiredPlanLabel = t(+ `subscription.plan.${planLabel[minimumPlan] ?? "enterprise"}.title`+ );+ const tooltip = t("subscription.require-subscription", {+ requiredPlan: requiredPlanLabel,+ });++ if (clickable) {+ return (+ <Tooltip content={tooltip}>+ <a+ href="/setting/subscription"+ className={className ?? "text-accent inline-flex"}+ >+ <Sparkles className="w-5 h-5" />+ </a>+ </Tooltip>+ );+ }++ return (+ <Tooltip content={tooltip}>+ <span className={className ?? "text-accent inline-flex"}>+ <Sparkles className="w-5 h-5" />+ </span>+ </Tooltip>+ );+}diff --git a/frontend/src/react/components/PermissionGuard.tsx b/frontend/src/react/components/PermissionGuard.tsxnew file mode 100644index 0000000000..43e8ba6c2c--- /dev/null+++ b/frontend/src/react/components/PermissionGuard.tsx@@ -0,0 +1,70 @@+import type { ReactNode } from "react";+import { useTranslation } from "react-i18next";+import type { Permission } from "@/types";+import { hasWorkspacePermissionV2 } from "@/utils";+import { BlockTooltip, Tooltip } from "./ui/tooltip";++/**+ * usePermissionCheck returns whether the user has all the required permissions+ * and a tooltip message listing missing ones.+ */+export function usePermissionCheck(+ permissions: Permission[]+): [boolean, string | undefined] {+ const { t } = useTranslation();+ const missed = permissions.filter((p) => !hasWorkspacePermissionV2(p));+ if (missed.length === 0) return [true, undefined];+ return [+ false,+ t("common.missing-required-permission", {+ permissions: missed.join(", "),+ }),+ ];+}++interface PermissionGuardProps {+ readonly permissions: Permission[];+ readonly children: ReactNode;+ /** Use "block" when wrapping section-level block content (e.g. form areas). */+ readonly display?: "inline" | "block";+}++/**+ * PermissionGuard wraps block content with a styled tooltip showing missing+ * permissions. The tooltip only renders when the user lacks permission.+ *+ * Usage:+ * ```tsx+ * const [canEdit] = usePermissionCheck(["bb.settings.setWorkspaceProfile"]);+ * <PermissionGuard permissions={["bb.settings.setWorkspaceProfile"]}>+ * <div>+ * <input disabled={!canEdit} />+ * </div>+ * </PermissionGuard>+ * ```+ */+export function PermissionGuard({+ permissions,+ children,+ display = "inline",+}: PermissionGuardProps) {+ const { t } = useTranslation();+ const missed = permissions.filter((p) => !hasWorkspacePermissionV2(p));++ const tooltip =+ missed.length > 0 ? (+ <div className="flex flex-col gap-1">+ {t("common.missing-required-permission", { permissions: "" })}+ <ul className="list-disc pl-4">+ {missed.map((p) => (+ <li key={p}>{p}</li>+ ))}+ </ul>+ </div>+ ) : undefined;++ if (display === "block") {+ return <BlockTooltip content={tooltip}>{children}</BlockTooltip>;+ }+ return <Tooltip content={tooltip}>{children}</Tooltip>;+}diff --git a/frontend/src/react/components/ui/button.tsx b/frontend/src/react/components/ui/button.tsxindex c0f3cdeffb..b614371c13 100644--- a/frontend/src/react/components/ui/button.tsx+++ b/frontend/src/react/components/ui/button.tsx@@ -4,7 +4,7 @@ import type { ComponentProps } from "react";import { cn } from "@/react/lib/utils";const buttonVariants = cva(- "inline-flex items-center justify-center gap-2 rounded-xs text-sm font-medium whitespace-nowrap cursor-pointer transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",+ "inline-flex items-center justify-center gap-2 rounded-xs text-sm font-medium whitespace-nowrap cursor-pointer transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",{variants: {variant: {diff --git a/frontend/src/react/components/ui/tooltip.tsx b/frontend/src/react/components/ui/tooltip.tsxnew file mode 100644index 0000000000..6485adc1ed--- /dev/null+++ b/frontend/src/react/components/ui/tooltip.tsx@@ -0,0 +1,72 @@+import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";+import type { ReactNode } from "react";++interface TooltipProps {+ readonly content: ReactNode;+ readonly children: ReactNode;+ readonly side?: "top" | "bottom" | "left" | "right";+ readonly delayDuration?: number;+}++export function Tooltip({+ content,+ children,+ side = "top",+ delayDuration = 100,+}: TooltipProps) {+ if (!content) {+ return <>{children}</>;+ }++ return (+ <BaseTooltip.Provider delay={delayDuration}>+ <BaseTooltip.Root>+ <BaseTooltip.Trigger render={<span className="inline-flex" />}>+ {children}+ </BaseTooltip.Trigger>+ <BaseTooltip.Portal>+ <BaseTooltip.Positioner side={side} sideOffset={4}>+ <BaseTooltip.Popup className="z-50 rounded-xs bg-gray-900 px-2.5 py-1.5 text-xs text-white shadow-md max-w-56">+ {content}+ <BaseTooltip.Arrow className="fill-gray-900" />+ </BaseTooltip.Popup>+ </BaseTooltip.Positioner>+ </BaseTooltip.Portal>+ </BaseTooltip.Root>+ </BaseTooltip.Provider>+ );+}++/**+ * BlockTooltip is the same as Tooltip but renders the trigger as a block-level+ * div instead of an inline span. Use this when wrapping block content like+ * form sections.+ */+export function BlockTooltip({+ content,+ children,+ side = "top",+ delayDuration = 100,+}: TooltipProps) {+ if (!content) {+ return <>{children}</>;+ }++ return (+ <BaseTooltip.Provider delay={delayDuration}>+ <BaseTooltip.Root>+ <BaseTooltip.Trigger render={<div className="flex-1 min-w-0" />}>+ {children}+ </BaseTooltip.Trigger>+ <BaseTooltip.Portal>+ <BaseTooltip.Positioner side={side} sideOffset={4}>+ <BaseTooltip.Popup className="z-50 rounded-xs bg-gray-900 px-2.5 py-1.5 text-xs text-white shadow-md max-w-56">+ {content}+ <BaseTooltip.Arrow className="fill-gray-900" />+ </BaseTooltip.Popup>+ </BaseTooltip.Positioner>+ </BaseTooltip.Portal>+ </BaseTooltip.Root>+ </BaseTooltip.Provider>+ );+}diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.jsonindex cd13a6dd62..da0a808b52 100644--- a/frontend/src/react/locales/en-US.json+++ b/frontend/src/react/locales/en-US.json@@ -55,6 +55,7 @@"added": "Added","description": "Description","missing-required-permission": "Missing required permissions {{permissions}}",+ "required-permission": "Required permissions","required-workspace-permission": "Following permissions are required to initialize the workspace UX","add-permissions": "Add permissions","system": "System",diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.jsonindex 439ede1fc5..aaca4f2913 100644--- a/frontend/src/react/locales/es-ES.json+++ b/frontend/src/react/locales/es-ES.json@@ -55,6 +55,7 @@"added": "Agregado","description": "Descripción","missing-required-permission": "Faltan permisos requeridos {{permissions}}",+ "required-permission": "Permisos necesarios","required-workspace-permission": "Se requieren los siguientes permisos para inicializar el espacio de trabajo UX","add-permissions": "Agregar permisos","system": "Sistema",diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.jsonindex 116dfd7a07..6289a66d04 100644--- a/frontend/src/react/locales/ja-JP.json+++ b/frontend/src/react/locales/ja-JP.json@@ -55,6 +55,7 @@"added": "作成した","description": "説明","missing-required-permission": "必要な権限がありません {{permissions}}",+ "required-permission": "必要な権限","required-workspace-permission": "ワークスペース UX の初期化には以下の権限が必要です","add-permissions": "権限を追加","system": "システム",diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.jsonindex dd2adb36c8..6cc099c6f6 100644--- a/frontend/src/react/locales/vi-VN.json+++ b/frontend/src/react/locales/vi-VN.json@@ -55,6 +55,7 @@"added": "Đã thêm","description": "Mô tả","missing-required-permission": "Thiếu quyền cần thiết {{permissions}}",+ "required-permission": "Quyền hạn cần thiết","required-workspace-permission": "Các quyền sau đây cần thiết để khởi tạo không gian làm việc UX","add-permissions": "Thêm quyền","system": "Hệ thống",diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.jsonindex bed69564f6..f3ad2fe684 100644--- a/frontend/src/react/locales/zh-CN.json+++ b/frontend/src/react/locales/zh-CN.json@@ -55,6 +55,7 @@"added": "已创建","description": "描述","missing-required-permission": "缺少必需的权限 {{permissions}}",+ "required-permission": "所需权限","required-workspace-permission": "初始化工作空间 UX 需要以下权限","add-permissions": "添加权限","system": "系统",diff --git a/frontend/src/react/pages/settings/DataClassificationPage.tsx b/frontend/src/react/pages/settings/DataClassificationPage.tsxindex a4ba21627d..e38b354b59 100644--- a/frontend/src/react/pages/settings/DataClassificationPage.tsx+++ b/frontend/src/react/pages/settings/DataClassificationPage.tsx@@ -228,7 +228,7 @@ function LevelBadge({if (!levelObj) return null;const color = bgColorList[level - 1] ?? "bg-gray-200";return (- <span className={`ml-1 px-1 py-0.5 rounded text-xs ${color}`}>+ <span className={`ml-1 px-1 py-0.5 rounded-xs text-xs ${color}`}>{levelObj.title}</span>);@@ -290,7 +290,7 @@ function ClassificationTreeNode({return (<div><div- className="flex items-center gap-1 py-1 px-1 rounded hover:bg-control-bg cursor-pointer select-none"+ className="flex items-center gap-1 py-1 px-1 rounded-xs hover:bg-control-bg cursor-pointer select-none"onClick={() => hasChildren && setExpanded(!expanded)}>{hasChildren ? (diff --git a/frontend/src/react/pages/settings/EnvironmentsPage.tsx b/frontend/src/react/pages/settings/EnvironmentsPage.tsxindex 1ec5b0cdf5..e5514bd81f 100644--- a/frontend/src/react/pages/settings/EnvironmentsPage.tsx+++ b/frontend/src/react/pages/settings/EnvironmentsPage.tsx@@ -1,6 +1,6 @@import { create } from "@bufbuild/protobuf";import { cloneDeep, isEqual } from "lodash-es";-import { GripVertical, ListOrdered, Plus, X } from "lucide-react";+import { GripVertical, ListOrdered, Plus, ShieldAlert, X } from "lucide-react";import {forwardRef,useCallback,@@ -11,8 +11,8 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";-import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";import { FeatureAttention } from "@/react/components/FeatureAttention";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { ResourceIdField } from "@/react/components/ResourceIdField";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";@@ -57,6 +57,7 @@ import type { Environment } from "@/types/v1/environment";import {displayRoleTitle,hasWorkspacePermissionV2,+ hexToRgb,sqlReviewPolicySlug,} from "@/utils";@@ -85,6 +86,60 @@ function useEscapeKey(onEscape: () => void) {}, [onEscape]);}+// ============================================================+// EnvironmentName - displays env name with color badge+// ============================================================+function EnvironmentName({+ environment,+ link = false,+}: {+ environment: Environment;+ link?: boolean;+}) {+ const subscriptionStore = useSubscriptionV1Store();+ const hasEnvTierFeature = useVueState(() =>+ subscriptionStore.hasInstanceFeature(PlanFeature.FEATURE_ENVIRONMENT_TIERS)+ );+ const color = environment.color || "#4f46e5";+ const rgbValues = hexToRgb(color);+ const rgbStr = rgbValues.join(", ");+ const showProductionIcon =+ hasEnvTierFeature && environment.tags?.protected === "protected";++ const content = (+ <span+ className="inline-flex items-center gap-x-1 px-1.5 rounded-xs select-none truncate"+ style={{+ backgroundColor: `rgba(${rgbStr}, 0.1)`,+ color: `rgb(${rgbStr})`,+ }}+ >+ <span className="truncate">{environment.title}</span>+ {showProductionIcon && (+ <ShieldAlert className="w-3.5 h-3.5 shrink-0 text-control" />+ )}+ </span>+ );++ if (link) {+ return (+ <a+ href={`/${formatEnvironmentName(environment.id)}`}+ onClick={(e) => {+ e.preventDefault();+ e.stopPropagation();+ router.push({ path: `/${formatEnvironmentName(environment.id)}` });+ }}+ className="hover:underline"+ >+ {content}+ </a>+ );+ }++ return content;+}+// ============================================================// Toggle switch// ============================================================@@ -245,7 +300,7 @@ function RolloutPolicyConfig({{rolloutPolicy.roles.map((role) => (<spankey={role}- className="inline-flex items-center gap-x-1 rounded-md bg-gray-100 px-2 py-1 text-sm"+ className="inline-flex items-center gap-x-1 rounded-xs bg-gray-100 px-2 py-1 text-sm">{displayRoleTitle(role)}{canUpdatePolicy && (@@ -270,7 +325,7 @@ function RolloutPolicyConfig({{t("common.add")}</Button>{showRoleDropdown && (- <div className="absolute z-50 mt-1 w-64 max-h-60 overflow-auto rounded-md border border-control-border bg-white py-1 shadow-md">+ <div className="absolute z-50 mt-1 w-64 max-h-60 overflow-auto rounded-xs border border-control-border bg-white py-1 shadow-md">{availableRoles.map((group) => (<div key={group.label}><div className="px-2 py-1 text-xs font-semibold text-gray-500 uppercase">@@ -483,7 +538,7 @@ function SQLReviewSectionInner({t("sql-review.configure-policy")}</Button>{showSelectPanel && (- <div className="absolute z-50 mt-1 w-80 max-h-60 overflow-auto rounded-md border border-control-border bg-white py-1 shadow-md">+ <div className="absolute z-50 mt-1 w-80 max-h-60 overflow-auto rounded-xs border border-control-border bg-white py-1 shadow-md">{reviewPolicyList.length === 0 ? (<div className="px-3 py-2 text-sm text-gray-400">{t("common.no-data")}@@ -782,7 +837,7 @@ function EnvironmentDetail({checked={editProtected}disabled={!canEdit}onChange={(e) => setEditProtected(e.target.checked)}- className="rounded border-gray-300"+ className="rounded-xs border-gray-300"/><span className="text-sm">{t("policy.environment-tier.mark-env-as-production")}@@ -869,7 +924,7 @@ function EnvironmentDetail({onClick={() => setShowDeleteConfirm(false)}/><div className="fixed inset-0 z-50 flex items-center justify-center">- <div className="bg-white rounded-md shadow-xl p-6 max-w-md w-full mx-4">+ <div className="bg-white rounded-sm shadow-xl p-6 max-w-md w-full mx-4"><h3 className="text-lg font-medium mb-2">{t("environment.delete")} '{editTitle}'?</h3>@@ -880,7 +935,7 @@ function EnvironmentDetail({type="checkbox"checked={confirmDelete}onChange={(e) => setConfirmDelete(e.target.checked)}- className="mt-0.5 rounded border-gray-300"+ className="mt-0.5 rounded-xs border-gray-300"/><span className="text-sm text-gray-600">{t("environment.delete-description")}@@ -1068,7 +1123,7 @@ function CreateDrawer({type="checkbox"checked={isProtected}onChange={(e) => setIsProtected(e.target.checked)}- className="rounded border-gray-300"+ className="rounded-xs border-gray-300"/><span className="text-sm">{t("policy.environment-tier.mark-env-as-production")}@@ -1177,7 +1232,7 @@ function ReorderDrawer({><div className="flex items-center gap-x-2"><span className="textinfo">{index + 1}.</span>- <EnvironmentLabel environment={env} />+ <EnvironmentName environment={env} /></div><GripVertical className="w-5 h-5 text-gray-500" /></div>@@ -1382,29 +1437,33 @@ export function EnvironmentsPage() {onClick={() => selectTab(env.id)}><span className="text-opacity-60">{index + 1}.</span>- <EnvironmentLabel environment={env} />+ <EnvironmentName environment={env} /></button>))}</div>{/* Toolbar */}- {canEdit && (+ <PermissionGuard permissions={["bb.settings.setEnvironment"]}><div className="flex items-center justify-end gap-x-2 px-2 pb-1 shrink-0"><Buttonvariant="outline"size="sm"- disabled={environmentList.length <= 1}+ disabled={!canEdit || environmentList.length <= 1}onClick={() => setShowReorder(true)}><ListOrdered className="h-4 w-4 mr-1" />{t("common.reorder")}</Button>- <Button size="sm" onClick={() => setShowCreate(true)}>+ <Button+ size="sm"+ disabled={!canEdit}+ onClick={() => setShowCreate(true)}+ ><Plus className="h-4 w-4 mr-1" />{t("environment.create")}</Button></div>- )}+ </PermissionGuard></div>{/* Tab content */}diff --git a/frontend/src/react/pages/settings/GlobalMaskingPage.tsx b/frontend/src/react/pages/settings/GlobalMaskingPage.tsxindex ae683aba50..33869169b3 100644--- a/frontend/src/react/pages/settings/GlobalMaskingPage.tsx+++ b/frontend/src/react/pages/settings/GlobalMaskingPage.tsx@@ -342,7 +342,7 @@ function MaskingRuleConfig({{t("common.confirm")}</Button>{errorMessages.length > 0 && (- <div className="absolute bottom-full mb-1 right-0 bg-gray-800 text-white text-xs rounded px-2 py-1 hidden group-hover:block whitespace-nowrap z-10">+ <div className="absolute bottom-full mb-1 right-0 bg-gray-800 text-white text-xs rounded-xs px-2 py-1 hidden group-hover:block whitespace-nowrap z-10"><ul className="list-disc pl-4">{errorMessages.map((msg, i) => (<li key={i}>{msg}</li>@@ -563,7 +563,7 @@ export function GlobalMaskingPage() {<div className="w-full px-4 py-4 flex flex-col gap-y-4"><FeatureAttention feature={PlanFeature.FEATURE_DATA_MASKING} />{hasSensitiveDataFeature && (- <div className="rounded-md border border-blue-200 bg-blue-50 text-blue-800 px-4 py-3 text-sm">+ <div className="rounded-xs border border-blue-200 bg-blue-50 text-blue-800 px-4 py-3 text-sm">{t("custom-approval.rule.first-match-wins")}</div>)}@@ -654,7 +654,7 @@ export function GlobalMaskingPage() {{index > 0 && (<buttontype="button"- className="w-6 h-6 flex items-center justify-center rounded hover:bg-gray-100"+ className="w-6 h-6 flex items-center justify-center rounded-xs hover:bg-gray-100"onClick={() => onReorder(item, -1)}><ChevronUp className="w-4 h-4" />@@ -663,7 +663,7 @@ export function GlobalMaskingPage() {{index !== items.length - 1 && (<buttontype="button"- className="w-6 h-6 flex items-center justify-center rounded hover:bg-gray-100"+ className="w-6 h-6 flex items-center justify-center rounded-xs hover:bg-gray-100"onClick={() => onReorder(item, 1)}><ChevronDown className="w-4 h-4" />@@ -674,7 +674,7 @@ export function GlobalMaskingPage() {<div className="pt-2"><buttontype="button"- className="w-6 h-6 flex items-center justify-center rounded hover:bg-gray-100"+ className="w-6 h-6 flex items-center justify-center rounded-xs hover:bg-gray-100"onClick={() => onEdit(index)}><Pencil className="w-4 h-4" />diff --git a/frontend/src/react/pages/settings/IDPDetailPage.tsx b/frontend/src/react/pages/settings/IDPDetailPage.tsxindex 51fe0851b7..2484231b66 100644--- a/frontend/src/react/pages/settings/IDPDetailPage.tsx+++ b/frontend/src/react/pages/settings/IDPDetailPage.tsx@@ -82,7 +82,7 @@ function TestConnectionResultDialog({if (e.target === e.currentTarget) onClose();}}>- <div className="bg-white rounded-md shadow-lg w-[32rem] max-h-[80vh] overflow-auto p-6">+ <div className="bg-white rounded-sm shadow-lg w-[32rem] max-h-[80vh] overflow-auto p-6"><div className="flex items-center justify-between mb-4"><div className="flex items-center gap-x-2"><div className="w-6 h-6 text-green-500">✓</div>@@ -99,7 +99,7 @@ function TestConnectionResultDialog({<p className="text-sm text-control-light">{t("identity-provider.userinfo-description")}</p>- <div className="bg-gray-50 rounded-md p-4">+ <div className="bg-gray-50 rounded-xs p-4"><div className="flex flex-col gap-y-1">{Object.entries(response.userInfo).map(([key, value]) => (<div@@ -126,7 +126,7 @@ function TestConnectionResultDialog({<p className="text-sm text-control-light">{t("identity-provider.claims-description")}</p>- <div className="bg-gray-50 rounded-md p-4">+ <div className="bg-gray-50 rounded-xs p-4">{Object.keys(response.claims).length === 0 ? (<div className="text-sm text-control-light italic">{t("identity-provider.no-claims")}@@ -345,7 +345,7 @@ function DeleteConfirmDialog({if (e.target === e.currentTarget) onCancel();}}>- <div className="bg-white rounded-md shadow-lg w-96 p-6">+ <div className="bg-white rounded-sm shadow-lg w-96 p-6"><h3 className="text-lg font-medium mb-2">{t("settings.sso.delete")}</h3><p className="text-sm text-gray-600 mb-6">{t("identity-provider.delete-warning")}@@ -765,7 +765,7 @@ function ProviderConfigForm({min={1}max={65535}placeholder="389"- className="flex h-9 w-full rounded-md border border-control-border bg-transparent px-3 py-1 text-sm"+ className="flex h-9 w-full rounded-xs border border-control-border bg-transparent px-3 py-1 text-sm"/></div></div>@@ -1502,7 +1502,7 @@ export function IDPDetailPage() {<p className="text-base font-semibold text-gray-800 mb-2">{t("common.type")}</p>- <div className="flex items-center gap-x-3 p-3 bg-gray-50 rounded-md">+ <div className="flex items-center gap-x-3 p-3 bg-gray-50 rounded-xs"><ProviderIcon className="w-5 h-5 text-gray-600" /><span className="text-base font-medium text-gray-800">{identityProviderTypeToString(localIdp.type)}diff --git a/frontend/src/react/pages/settings/IDPsPage.tsx b/frontend/src/react/pages/settings/IDPsPage.tsxindex 48c35e4d83..61b7cfbcbd 100644--- a/frontend/src/react/pages/settings/IDPsPage.tsx+++ b/frontend/src/react/pages/settings/IDPsPage.tsx@@ -17,6 +17,8 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { identityProviderServiceClientConnect } from "@/connect";import { FeatureAttention } from "@/react/components/FeatureAttention";+import { FeatureBadge } from "@/react/components/FeatureBadge";+import { PermissionGuard } from "@/react/components/PermissionGuard";import {ResourceIdField,type ResourceIdFieldRef,@@ -143,7 +145,7 @@ function ExternalURLInfo({ type }: { type: IdentityProviderType }) {};return (- <div className="p-4 rounded-md border border-gray-200 bg-gray-50">+ <div className="p-4 rounded-sm border border-gray-200 bg-gray-50"><div className="flex items-start gap-x-3"><Info className="w-5 h-5 text-blue-500 mt-0.5 shrink-0" /><div className="flex-1 min-w-0">@@ -195,7 +197,7 @@ function TestConnectionResultDialog({if (e.target === e.currentTarget) onClose();}}>- <div className="bg-white rounded-md shadow-lg w-[32rem] max-h-[80vh] overflow-auto p-6">+ <div className="bg-white rounded-sm shadow-lg w-[32rem] max-h-[80vh] overflow-auto p-6"><div className="flex items-center justify-between mb-4"><div className="flex items-center gap-x-2"><div className="w-6 h-6 text-green-500">✓</div>@@ -212,7 +214,7 @@ function TestConnectionResultDialog({<p className="text-sm text-control-light">{t("identity-provider.userinfo-description")}</p>- <div className="bg-gray-50 rounded-md p-4">+ <div className="bg-gray-50 rounded-xs p-4"><div className="flex flex-col gap-y-1">{Object.entries(response.userInfo).map(([key, value]) => (<div@@ -239,7 +241,7 @@ function TestConnectionResultDialog({<p className="text-sm text-control-light">{t("identity-provider.claims-description")}</p>- <div className="bg-gray-50 rounded-md p-4">+ <div className="bg-gray-50 rounded-xs p-4">{Object.keys(response.claims).length === 0 ? (<div className="text-sm text-control-light italic">{t("identity-provider.no-claims")}@@ -836,7 +838,7 @@ function ProviderConfigForm({min={1}max={65535}placeholder="389"- className="flex h-9 w-full rounded-md border border-control-border bg-transparent px-3 py-1 text-sm"+ className="flex h-9 w-full rounded-xs border border-control-border bg-transparent px-3 py-1 text-sm"/></div></div>@@ -1691,7 +1693,7 @@ function CreateWizardDrawer({</div>{/* Step content */}- <div className="bg-white rounded-md border border-gray-200 px-6 pt-6 pb-10">+ <div className="bg-white rounded-sm border border-gray-200 px-6 pt-6 pb-10">{/* Step 1: Select provider type */}{currentStep === 1 && (<div className="flex flex-col gap-y-6">@@ -1712,7 +1714,7 @@ function CreateWizardDrawer({return (<labelkey={item.type}- className={`block border rounded-md mb-4 p-4 transition-colors cursor-pointer ${+ className={`block border rounded-sm mb-4 p-4 transition-colors cursor-pointer ${selectedType === item.type? "border-blue-500 bg-blue-50": "border-gray-200 hover:border-gray-300"@@ -1769,7 +1771,7 @@ function CreateWizardDrawer({return (<labelkey={tmpl.title}- className={`block border rounded-md p-4 transition-colors cursor-pointer ${+ className={`block border rounded-xs p-4 transition-colors cursor-pointer ${selectedTemplate?.title === tmpl.title? "border-blue-500 bg-blue-50": "border-gray-200 hover:border-gray-300"@@ -2032,10 +2034,17 @@ export function IDPsPage() {</div><div className="w-full flex justify-end">- <Button disabled={!canCreate} onClick={handleCreateSSO}>- <Plus className="h-4 w-4 mr-1" />- {t("settings.sso.create")}- </Button>+ <PermissionGuard permissions={["bb.identityProviders.create"]}>+ <Button disabled={!canCreate} onClick={handleCreateSSO}>+ <FeatureBadge+ feature={PlanFeature.FEATURE_GOOGLE_AND_GITHUB_SSO}+ clickable={false}+ className="mr-1 text-white inline-flex"+ />+ <Plus className="h-4 w-4 mr-1" />+ {t("settings.sso.create")}+ </Button>+ </PermissionGuard></div>{ready ? (diff --git a/frontend/src/react/pages/settings/IMPage.tsx b/frontend/src/react/pages/settings/IMPage.tsxindex 5fc0ab849a..0900b36c97 100644--- a/frontend/src/react/pages/settings/IMPage.tsx+++ b/frontend/src/react/pages/settings/IMPage.tsx@@ -9,6 +9,7 @@ import feishuIcon from "@/assets/im/feishu.webp";import slackIcon from "@/assets/im/slack.png";import teamsIcon from "@/assets/im/teams.svg";import wecomIcon from "@/assets/im/wecom.png";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import { useVueState } from "@/react/hooks/useVueState";@@ -389,11 +390,16 @@ export function IMPage() {<Description /><div className="py-12 border rounded-sm flex flex-col items-center justify-center gap-y-4 text-control-light"><span>{t("common.no-data")}</span>- {availableTypes.length > 0 && allowEdit && (- <Button onClick={() => handleAdd(availableTypes[0].type)}>- <Plus className="h-4 w-4 mr-1" />- {t("settings.im.add-im-integration")}- </Button>+ {availableTypes.length > 0 && (+ <PermissionGuard permissions={["bb.settings.set"]}>+ <Button+ disabled={!allowEdit}+ onClick={() => handleAdd(availableTypes[0].type)}+ >+ <Plus className="h-4 w-4 mr-1" />+ {t("settings.im.add-im-integration")}+ </Button>+ </PermissionGuard>)}</div></div>@@ -411,7 +417,7 @@ export function IMPage() {) : (<selectvalue={item.type}- className="flex h-9 w-full max-w-xs rounded-md border border-control-border bg-transparent px-3 py-1 text-sm cursor-pointer"+ className="flex h-9 w-full max-w-xs rounded-xs border border-control-border bg-transparent px-3 py-1 text-sm cursor-pointer"onChange={(e) => handleChangeType(i, e.target.value)}><option value={item.type}>{item.typeLabel}</option>@@ -476,15 +482,18 @@ export function IMPage() {</div>))}- {availableTypes.length > 0 && allowEdit && (+ {availableTypes.length > 0 && (<div className="flex justify-end">- <Button- variant="outline"- onClick={() => handleAdd(availableTypes[0].type)}- >- <Plus className="h-4 w-4 mr-1" />- {t("settings.im.add-another-im")}- </Button>+ <PermissionGuard permissions={["bb.settings.set"]}>+ <Button+ variant="outline"+ disabled={!allowEdit}+ onClick={() => handleAdd(availableTypes[0].type)}+ >+ <Plus className="h-4 w-4 mr-1" />+ {t("settings.im.add-another-im")}+ </Button>+ </PermissionGuard></div>)}</div>diff --git a/frontend/src/react/pages/settings/InstancesPage.tsx b/frontend/src/react/pages/settings/InstancesPage.tsxindex 5bead4de48..78458a78df 100644--- a/frontend/src/react/pages/settings/InstancesPage.tsx+++ b/frontend/src/react/pages/settings/InstancesPage.tsx@@ -9,7 +9,6 @@ import {Plus,RefreshCw,SquareStack,- X,} from "lucide-react";import type { RefObject } from "react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";@@ -21,13 +20,14 @@ import {type ScopeOption,type SearchParams,} from "@/react/components/AdvancedSearch";-import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { useVueState } from "@/react/hooks/useVueState";import { cn } from "@/react/lib/utils";import { router } from "@/router";import { INSTANCE_ROUTE_CREATE } from "@/router/dashboard/instance";import {+ featureToRef,pushNotification,useActuatorV1Store,useCurrentUserV1,@@ -40,17 +40,22 @@ import { environmentNamePrefix } from "@/store/modules/v1/common";import type { InstanceFilter } from "@/store/modules/v1/instance";import {isValidInstanceName,+ NULL_ENVIRONMENT_NAME,UNKNOWN_ENVIRONMENT_NAME,unknownEnvironment,} from "@/types";import { Engine, State } from "@/types/proto-es/v1/common_pb";import type { Instance } from "@/types/proto-es/v1/instance_service_pb";import { UpdateInstanceRequestSchema } from "@/types/proto-es/v1/instance_service_pb";-import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";+import {+ PlanFeature,+ PlanType,+} from "@/types/proto-es/v1/subscription_service_pb";import {engineNameV1,getDefaultPagination,hasWorkspacePermissionV2,+ hexToRgb,hostPortOfDataSource,hostPortOfInstanceV1,supportedEngineV1List,@@ -177,7 +182,7 @@ function ConfirmDialog({<div className="fixed inset-0 bg-black/50" onClick={onCancel} /><divclassName={cn(- "relative bg-white rounded-md shadow-lg max-w-lg w-full mx-4 border-t-4",+ "relative bg-white rounded-sm shadow-lg max-w-lg w-full mx-4 border-t-4",borderColor)}>@@ -192,7 +197,7 @@ function ConfirmDialog({</Button><buttonclassName={cn(- "inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium",+ "inline-flex items-center justify-center rounded-xs px-4 py-2 text-sm font-medium",okBg)}onClick={onOk}@@ -205,6 +210,71 @@ function ConfirmDialog({);}+// ============================================================+// EnvironmentName+// ============================================================++function EnvironmentName({ environmentName }: { environmentName: string }) {+ const { t } = useTranslation();+ const environmentStore = useEnvironmentV1Store();+ const environment = useVueState(() =>+ environmentStore.getEnvironmentByName(+ environmentName || NULL_ENVIRONMENT_NAME+ )+ );++ const isUnset =+ environment.name === UNKNOWN_ENVIRONMENT_NAME ||+ environment.name === NULL_ENVIRONMENT_NAME;++ const hasEnvTierFeature = useVueState(+ () => featureToRef(PlanFeature.FEATURE_ENVIRONMENT_TIERS).value+ );+ const isProtected =+ hasEnvTierFeature && environment.tags?.protected === "protected";++ const bgColorRgb = environment.color ? hexToRgb(environment.color) : null;++ return (+ <span+ className="inline-flex items-center gap-x-1"+ style={+ bgColorRgb && !isUnset+ ? {+ backgroundColor: `rgba(${bgColorRgb.join(", ")}, 0.1)`,+ color: `rgb(${bgColorRgb.join(", ")})`,+ padding: "0 6px",+ borderRadius: "4px",+ }+ : undefined+ }+ >+ <span className="truncate">+ {isUnset ? (+ <span className="text-control-light italic">+ {t("common.unassigned")}+ </span>+ ) : (+ environment.title+ )}+ </span>+ {isProtected && !isUnset && (+ <svg+ className="w-4 h-4 shrink-0 text-current"+ viewBox="0 0 20 20"+ fill="currentColor"+ >+ <path+ fillRule="evenodd"+ d="M10 1.944A11.954 11.954 0 012.166 5C2.056 5.649 2 6.319 2 7c0 5.225 3.34 9.67 8 11.317C14.66 16.67 18 12.225 18 7c0-.682-.057-1.351-.166-2.001A11.954 11.954 0 0110 1.944zM11 14a1 1 0 11-2 0 1 1 0 012 0zm0-7a1 1 0 10-2 0v3a1 1 0 102 0V7z"+ clipRule="evenodd"+ />+ </svg>+ )}+ </span>+ );+}+// ============================================================// InstanceActionDropdown// ============================================================@@ -370,7 +440,7 @@ function InstanceActionDropdown({type="checkbox"checked={forceArchive}onChange={(e) => setForceArchive(e.target.checked)}- className="rounded border-control-border"+ className="rounded-xs border-control-border"/>{t("instance.force-archive-description")}</label>@@ -406,7 +476,7 @@ function LabelsDisplay({ labels }: { labels: { [key: string]: string } }) {return (<div className="flex items-center gap-x-1">{displayEntries.map(([key, value]) => (- <span key={key} className="rounded-md bg-gray-100 py-0.5 px-2 text-sm">+ <span key={key} className="rounded-xs bg-gray-100 py-0.5 px-2 text-sm">{key}:{value}</span>))}@@ -434,13 +504,9 @@ function EditEnvironmentDrawer({() => environmentStore.environmentList ?? []);const [selected, setSelected] = useState("");- const [updating, setUpdating] = useState(false);useEscapeKey(open, onClose);useEffect(() => {- if (open) {- setSelected("");- setUpdating(false);- }+ if (open) setSelected("");}, [open]);if (!open) return null;@@ -454,16 +520,16 @@ function EditEnvironmentDrawer({{t("database.edit-environment")}</h2><button className="p-1 hover:bg-control-bg rounded" onClick={onClose}>- <X className="w-4 h-4" />+ ×</button></div><div className="flex-1 overflow-y-auto p-6">- <div className="flex flex-col gap-y-1">+ <div className="flex flex-col gap-y-2">{environments.map((env) => (<labelkey={env.name}className={cn(- "flex items-center gap-x-3 px-3 py-2.5 rounded-lg cursor-pointer border transition-colors",+ "flex items-center gap-x-3 px-3 py-2 rounded-xs cursor-pointer border",selected === env.name? "border-accent bg-accent/5": "border-transparent hover:bg-gray-50"@@ -476,7 +542,15 @@ function EditEnvironmentDrawer({onChange={() => setSelected(env.name)}className="accent-accent"/>- <EnvironmentLabel environment={env} />+ <div className="flex items-center gap-x-2">+ {env.color && (+ <span+ className="inline-block w-3 h-3 rounded-full"+ style={{ backgroundColor: env.color }}+ />+ )}+ <span>{env.title}</span>+ </div></label>))}</div>@@ -486,15 +560,10 @@ function EditEnvironmentDrawer({{t("common.cancel")}</Button><Button- disabled={!selected || updating}+ disabled={!selected}onClick={async () => {- setUpdating(true);- try {- await onUpdate(selected);- onClose();- } finally {- setUpdating(false);- }+ await onUpdate(selected);+ onClose();}}>{t("common.confirm")}@@ -1062,7 +1131,7 @@ export function InstancesPage() {<div className="py-4 flex flex-col">{/* Instance count warning */}{quotaExhausted && (- <div className="mx-4 mb-2 p-3 rounded-md border border-warning bg-warning/5">+ <div className="mx-4 mb-2 p-3 rounded-xs border border-warning bg-warning/5"><p className="text-sm font-medium text-warning">{t("subscription.usage.instance-count.title")}</p>@@ -1082,12 +1151,12 @@ export function InstancesPage() {placeholder={t("instance.filter-instance-name")}onParamsChange={setSearchParams}/>- {canCreate && (- <Button onClick={navigateToCreate}>+ <PermissionGuard permissions={["bb.instances.create"]}>+ <Button disabled={!canCreate} onClick={navigateToCreate}><Plus className="h-4 w-4 mr-1" />{t("quick-action.add-instance")}</Button>- )}+ </PermissionGuard></div>{/* Batch operations */}@@ -1116,7 +1185,7 @@ export function InstancesPage() {type="checkbox"checked={allSelected}onChange={toggleSelectAll}- className="rounded border-control-border"+ className="rounded-xs border-control-border"/></th><th@@ -1192,7 +1261,7 @@ export function InstancesPage() {checked={isSelected}onChange={() => toggleSelection(instance.name)}onClick={(e) => e.stopPropagation()}- className="rounded border-control-border"+ className="rounded-xs border-control-border"/></td><td className="px-4 py-2">@@ -1206,7 +1275,7 @@ export function InstancesPage() {</div></td><td className="px-4 py-2">- <EnvironmentLabel+ <EnvironmentNameenvironmentName={instance.environment ?? ""}/></td>@@ -1221,7 +1290,7 @@ export function InstancesPage() {</span>{hasMultipleDS && (<button- className="p-0.5 hover:bg-control-bg rounded shrink-0"+ className="p-0.5 hover:bg-control-bg rounded-xs shrink-0"onClick={(e) => {e.stopPropagation();toggleDataSource(instance.name);diff --git a/frontend/src/react/pages/settings/LandingPage.tsx b/frontend/src/react/pages/settings/LandingPage.tsxindex f98e6b4005..7d54f6d045 100644--- a/frontend/src/react/pages/settings/LandingPage.tsx+++ b/frontend/src/react/pages/settings/LandingPage.tsx@@ -505,7 +505,7 @@ export function LandingPage({{t("landing.quick-link.self")}</div><button- className="p-1 rounded hover:bg-gray-100"+ className="p-1 rounded-xs hover:bg-gray-100"onClick={() => setShowConfigDrawer(true)}><Settings className="w-4 h-4 text-gray-500" />diff --git a/frontend/src/react/pages/settings/ProjectsPage.tsx b/frontend/src/react/pages/settings/ProjectsPage.tsxindex 8bfc6b4beb..ca7b3915b3 100644--- a/frontend/src/react/pages/settings/ProjectsPage.tsx+++ b/frontend/src/react/pages/settings/ProjectsPage.tsx@@ -17,6 +17,7 @@ import {type ScopeOption,type SearchParams,} from "@/react/components/AdvancedSearch";+import { PermissionGuard } from "@/react/components/PermissionGuard";import {ResourceIdField,type ResourceIdFieldRef,@@ -167,7 +168,7 @@ function ConfirmDialog({<div className="fixed inset-0 bg-black/50" onClick={onCancel} /><divclassName={cn(- "relative bg-white rounded-md shadow-lg max-w-lg w-full mx-4 border-t-4",+ "relative bg-white rounded-sm shadow-lg max-w-lg w-full mx-4 border-t-4",borderColor)}>@@ -182,7 +183,7 @@ function ConfirmDialog({</Button><buttonclassName={cn(- "inline-flex items-center justify-center rounded-md px-4 py-2 text-sm font-medium",+ "inline-flex items-center justify-center rounded-xs px-4 py-2 text-sm font-medium",okBg)}onClick={onOk}@@ -549,7 +550,7 @@ function BatchOperationsBar({projects={selectedProjects}iconColor="text-red-600"/>- <div className="rounded-md border border-error bg-error/5 p-3">+ <div className="rounded-xs border border-error bg-error/5 p-3"><p className="text-sm font-medium text-error">{t("common.cannot-undo-this-action")}</p>@@ -1046,12 +1047,15 @@ export function ProjectsPage() {placeholder={t("project.filter-projects")}onParamsChange={setSearchParams}/>- {canCreate && (- <Button onClick={() => setShowCreateDrawer(true)}>+ <PermissionGuard permissions={["bb.projects.create"]}>+ <Button+ disabled={!canCreate}+ onClick={() => setShowCreateDrawer(true)}+ ><Plus className="h-4 w-4 mr-1" />{t("quick-action.new-project")}</Button>- )}+ </PermissionGuard></div>{/* Batch operations */}@@ -1073,7 +1077,7 @@ export function ProjectsPage() {type="checkbox"checked={allSelected}onChange={toggleSelectAll}- className="rounded border-control-border"+ className="rounded-xs border-control-border"/></th>)}@@ -1140,7 +1144,7 @@ export function ProjectsPage() {disabled={isDefault}onChange={() => toggleSelection(project.name)}onClick={(e) => e.stopPropagation()}- className="rounded border-control-border disabled:opacity-50"+ className="rounded-xs border-control-border disabled:opacity-50"/></td>)}@@ -1232,7 +1236,7 @@ function LabelsDisplay({ labels }: { labels: { [key: string]: string } }) {return (<div className="flex items-center gap-x-1">{displayEntries.map(([key, value]) => (- <span key={key} className="rounded-md bg-gray-100 py-0.5 px-2 text-sm">+ <span key={key} className="rounded-xs bg-gray-100 py-0.5 px-2 text-sm">{key}:{value}</span>))}diff --git a/frontend/src/react/pages/settings/PurchaseSection.tsx b/frontend/src/react/pages/settings/PurchaseSection.tsxindex 21678a99cb..969e25985f 100644--- a/frontend/src/react/pages/settings/PurchaseSection.tsx+++ b/frontend/src/react/pages/settings/PurchaseSection.tsx@@ -461,7 +461,7 @@ export function PurchaseSection({ onRequireEnterprise }: PurchaseSectionProps) {<span className="text-main">{t("subscription.purchase.seats")}</span>- <div className="ml-auto flex items-center h-7 rounded-md bg-gray-200 text-gray-600">+ <div className="ml-auto flex items-center h-7 rounded-xs bg-gray-200 text-gray-600"><buttontype="button"className="px-2 h-full rounded-l hover:bg-gray-300 disabled:opacity-50 cursor-pointer"@@ -600,7 +600,7 @@ function PlanCard({}) {return (<div- className={`h-full flex flex-col rounded-md p-5 border-2 ${highlighted ? "shadow-lg border-accent" : "border-block-border"}`}+ className={`h-full flex flex-col rounded-sm p-5 border-2 ${highlighted ? "shadow-lg border-accent" : "border-block-border"}`}><h3 className="text-3xl font-semibold text-main">{title}</h3><p className="text-control-placeholder mt-1 text-sm">{description}</p>diff --git a/frontend/src/react/pages/settings/RolesPage.tsx b/frontend/src/react/pages/settings/RolesPage.tsxindex a2d0abbe5d..c00251ccf5 100644--- a/frontend/src/react/pages/settings/RolesPage.tsx+++ b/frontend/src/react/pages/settings/RolesPage.tsx@@ -5,6 +5,8 @@ import { Pencil, Plus, Search, Trash2, X } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { FeatureAttention } from "@/react/components/FeatureAttention";+import { FeatureBadge } from "@/react/components/FeatureBadge";+import { PermissionGuard } from "@/react/components/PermissionGuard";import {ResourceIdField,type ResourceIdFieldRef,@@ -117,7 +119,7 @@ function PermissionTransfer({};return (- <div className="flex h-[28rem] border rounded-md overflow-hidden">+ <div className="flex h-[28rem] border rounded-sm overflow-hidden">{/* Source */}<div className="flex-1 flex flex-col border-r min-w-0"><div className="flex items-center gap-x-2 px-3 py-2 border-b">@@ -226,7 +228,7 @@ function ImportPermissionModal({if (e.target === e.currentTarget) onCancel();}}>- <div className="bg-white rounded-md shadow-lg w-[28rem] p-6">+ <div className="bg-white rounded-sm shadow-lg w-[28rem] p-6"><div className="flex items-center justify-between mb-4"><h3 className="text-lg font-medium">{t("role.import-from-role")}</h3><Button variant="ghost" size="icon" onClick={onCancel}>@@ -242,7 +244,7 @@ function ImportPermissionModal({<selectvalue={selectedRoleName}onChange={(e) => setSelectedRoleName(e.target.value)}- className="flex h-9 w-full rounded-md border border-control-border bg-transparent px-3 py-1 text-sm"+ className="flex h-9 w-full rounded-xs border border-control-border bg-transparent px-3 py-1 text-sm"><option value="">--</option>{roleList.map((role) => (@@ -316,7 +318,7 @@ function DeleteConfirmModal({if (e.target === e.currentTarget) onCancel();}}>- <div className="bg-white rounded-md shadow-lg w-[28rem] p-6">+ <div className="bg-white rounded-sm shadow-lg w-[28rem] p-6"><h3 className="text-lg font-medium mb-4">{t("common.delete")} - {displayRoleTitle(roleName)}</h3>@@ -818,10 +820,17 @@ export function RolesPage() {</div><div className="w-full flex justify-end">- <Button disabled={!canCreate} onClick={addRole}>- <Plus className="h-4 w-4 mr-1" />- {t("common.add")}- </Button>+ <PermissionGuard permissions={["bb.roles.create"]}>+ <Button disabled={!canCreate} onClick={addRole}>+ <FeatureBadge+ feature={PlanFeature.FEATURE_CUSTOM_ROLES}+ clickable={false}+ className="mr-1 text-white inline-flex"+ />+ <Plus className="h-4 w-4 mr-1" />+ {t("common.add")}+ </Button>+ </PermissionGuard></div>{/* Roles Table */}diff --git a/frontend/src/react/pages/settings/SemanticTypesPage.tsx b/frontend/src/react/pages/settings/SemanticTypesPage.tsxindex d3bff7709e..973fa30aec 100644--- a/frontend/src/react/pages/settings/SemanticTypesPage.tsx+++ b/frontend/src/react/pages/settings/SemanticTypesPage.tsx@@ -686,7 +686,7 @@ function MaskingAlgorithmDrawer({: t("settings.sensitive-data.algorithms.add")}</h2><button- className="p-1 rounded hover:bg-gray-200 text-gray-500"+ className="p-1 rounded-xs hover:bg-gray-200 text-gray-500"onClick={onDismiss}><X className="w-5 h-5" />@@ -704,7 +704,7 @@ function MaskingAlgorithmDrawer({{maskingTypeOptions.map((opt) => (<buttonkey={opt.value}- className={`px-3 py-2 text-sm border rounded-md transition-colors ${+ className={`px-3 py-2 text-sm border rounded-sm transition-colors ${maskingType === opt.value? "border-accent bg-accent/10 text-accent": "border-control-border hover:bg-gray-50"@@ -802,7 +802,7 @@ function MaskingAlgorithmDrawer({/></div><button- className="p-1 rounded hover:bg-red-100 text-red-500 mb-0.5"+ className="p-1 rounded-xs hover:bg-red-100 text-red-500 mb-0.5"onClick={() =>setRangeMaskSlices((prev) =>prev.filter((_, idx) => idx !== i)@@ -1015,7 +1015,7 @@ function SemanticTemplateDrawer({{t("settings.sensitive-data.semantic-types.add-from-template")}</h2><button- className="p-1 rounded hover:bg-gray-200 text-gray-500"+ className="p-1 rounded-xs hover:bg-gray-200 text-gray-500"onClick={onDismiss}><X className="w-5 h-5" />@@ -1218,7 +1218,7 @@ function SemanticTypeRow({)}{!isItemReadonly && (<button- className="p-1 rounded hover:bg-gray-200 text-gray-500"+ className="p-1 rounded-xs hover:bg-gray-200 text-gray-500"onClick={() => {const algo = getMaskingType(row.item.algorithm)? row.item.algorithm@@ -1247,7 +1247,7 @@ function SemanticTypeRow({<>{isEditing && (<button- className="p-1 rounded hover:bg-gray-200 text-gray-500"+ className="p-1 rounded-xs hover:bg-gray-200 text-gray-500"onClick={() => onCancel(index)}><Undo2 className="w-4 h-4" />@@ -1265,7 +1265,7 @@ function SemanticTypeRow({)}{isEditing && (<button- className="p-1 rounded hover:bg-accent/10 text-accent disabled:opacity-50 disabled:cursor-not-allowed"+ className="p-1 rounded-xs hover:bg-accent/10 text-accent disabled:opacity-50 disabled:cursor-not-allowed"disabled={isConfirmDisabled(row)}onClick={() => onConfirm(index)}>@@ -1274,7 +1274,7 @@ function SemanticTypeRow({)}{row.mode === "NORMAL" && (<button- className="p-1 rounded hover:bg-gray-200 text-gray-500"+ className="p-1 rounded-xs hover:bg-gray-200 text-gray-500"onClick={() => onStartEdit(index)}><Pencil className="w-4 h-4" />@@ -1332,7 +1332,7 @@ function IconPicker({ value, onChange }: IconPickerProps) {<div className="flex items-center gap-1"><img src={value} className="w-6 h-6 object-contain" alt="" /><button- className="p-0.5 rounded hover:bg-gray-200 text-gray-500"+ className="p-0.5 rounded-xs hover:bg-gray-200 text-gray-500"onClick={handleOpen}><Pencil className="w-3 h-3" />@@ -1340,7 +1340,7 @@ function IconPicker({ value, onChange }: IconPickerProps) {</div>) : (<button- className="p-1 rounded hover:bg-gray-200 text-gray-500"+ className="p-1 rounded-xs hover:bg-gray-200 text-gray-500"onClick={handleOpen}><Pencil className="w-4 h-4" />@@ -1354,7 +1354,7 @@ function IconPicker({ value, onChange }: IconPickerProps) {>{tempValue ? (<div- className="w-1/3 h-1/3 bg-no-repeat bg-contain bg-center rounded-md"+ className="w-1/3 h-1/3 bg-no-repeat bg-contain bg-center rounded-sm"style={{ backgroundImage: `url(${tempValue})` }}/>) : (@@ -1420,7 +1420,7 @@ function DeleteConfirmButton({return (<div className="relative" ref={popoverRef}><button- className="p-1 rounded hover:bg-red-100 text-red-500"+ className="p-1 rounded-xs hover:bg-red-100 text-red-500"onClick={() => onShowChange(!show)}><Trash2 className="w-4 h-4" />diff --git a/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx b/frontend/src/react/pages/settings/general/AIAugmentationSection.tsxindex c0c05f4297..c4ba972801 100644--- a/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx+++ b/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx@@ -9,6 +9,8 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";+import { ComponentPermissionGuard } from "@/react/components/ComponentPermissionGuard";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Alert } from "@/react/components/ui/alert";import { Input } from "@/react/components/ui/input";import { useVueState } from "@/react/hooks/useVueState";@@ -85,7 +87,6 @@ export const AIAugmentationSection = forwardRef<const actuatorStore = useActuatorV1Store();const isSaaSMode = useVueState(() => actuatorStore.isSaaSMode);- const canView = hasWorkspacePermissionV2("bb.settings.get");const canEdit = hasWorkspacePermissionV2("bb.settings.set") && !isSaaSMode;const aiSetting = useVueState(() => {@@ -209,10 +210,6 @@ export const AIAugmentationSection = forwardRef<});};- if (!canView) {- return null;- }-return (<div id="ai" ref={containerRef} className="py-6 lg:flex"><div className="text-left lg:w-1/4">@@ -220,185 +217,194 @@ export const AIAugmentationSection = forwardRef<<h1 className="text-2xl font-bold">{title}</h1></div></div>- <div className="flex-1 lg:px-4">- {isSaaSMode ? (- <Alert variant="info">- {t("settings.general.workspace.ai-assistant.enabled-in-saas")}- </Alert>- ) : (- <div className="mt-4 lg:mt-0 flex flex-col gap-y-4">- {/* Enable toggle */}- <div>- <div className="flex items-center gap-x-2">- <input- type="checkbox"- checked={state.enabled}- disabled={!canEdit}- onChange={(e) => toggleEnabled(e.target.checked)}- />- <span className="font-medium">- {t(- "settings.general.workspace.ai-assistant.enable-ai-assistant"- )}- </span>- </div>- <div className="mt-1 mb-3 text-sm text-gray-400">- {t("settings.general.workspace.ai-assistant.description")}{" "}- <a- href="https://docs.bytebase.com/ai-assistant?source=console"- target="_blank"- rel="noopener noreferrer"- className="text-accent hover:underline text-sm ml-1"- >- {t("common.learn-more")}- </a>- </div>- </div>-- {/* Collapsible fields when enabled */}- {state.enabled && (- <>- {/* Provider */}+ <ComponentPermissionGuard+ permissions={["bb.settings.get"]}+ className="flex-1 lg:px-4"+ >+ <PermissionGuard permissions={["bb.settings.set"]} display="block">+ <div className="flex-1 lg:px-4">+ {isSaaSMode ? (+ <Alert variant="info">+ {t("settings.general.workspace.ai-assistant.enabled-in-saas")}+ </Alert>+ ) : (+ <div className="mt-4 lg:mt-0 flex flex-col gap-y-4">+ {/* Enable toggle */}<div>- <label className="flex items-center gap-x-2 mb-2">+ <div className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={state.enabled}+ disabled={!canEdit}+ onChange={(e) => toggleEnabled(e.target.checked)}+ /><span className="font-medium">{t(- "settings.general.workspace.ai-assistant.provider.self"+ "settings.general.workspace.ai-assistant.enable-ai-assistant")}</span>- </label>- <select- className="w-48 border border-control-border rounded-xs px-3 py-1.5 text-sm bg-white disabled:opacity-50"- value={state.provider}- disabled={!canEdit}- onChange={(e) =>- onProviderChange(- Number(e.target.value) as AISetting_Provider- )- }- >- {PROVIDER_OPTIONS.map((provider) => (- <option key={provider} value={provider}>- {provider === AISetting_Provider.OPEN_AI &&- t(- "settings.general.workspace.ai-assistant.provider.open_ai"- )}- {provider === AISetting_Provider.AZURE_OPENAI &&- t(- "settings.general.workspace.ai-assistant.provider.azure_open_ai"- )}- {provider === AISetting_Provider.GEMINI &&- t(- "settings.general.workspace.ai-assistant.provider.gemini"- )}- {provider === AISetting_Provider.CLAUDE &&- t(- "settings.general.workspace.ai-assistant.provider.claude"- )}- </option>- ))}- </select>+ </div>+ <div className="mt-1 mb-3 text-sm text-gray-400">+ {t("settings.general.workspace.ai-assistant.description")}{" "}+ <a+ href="https://docs.bytebase.com/ai-assistant?source=console"+ target="_blank"+ rel="noopener noreferrer"+ className="text-accent hover:underline text-sm ml-1"+ >+ {t("common.learn-more")}+ </a>+ </div></div>- {/* API Key */}- <div>- <label className="flex items-center gap-x-2">- <span className="font-medium">- {t(- "settings.general.workspace.ai-assistant.api-key.self"- )}- </span>- </label>- <div className="mb-3 text-sm text-gray-400">- {t(- "settings.general.workspace.ai-assistant.api-key.description",- {- viewDoc: "__LINK__",- interpolation: { escapeValue: false },- }- )- .split("__LINK__")- .map((part, i) => (- <span key={i}>- {part}- {i === 0 && (- <a- href={providerDefault.apiKeyDoc}- className="normal-link"- target="_blank"- rel="noopener noreferrer"- >- {t(- "settings.general.workspace.ai-assistant.api-key.find-my-key"+ {/* Collapsible fields when enabled */}+ {state.enabled && (+ <>+ {/* Provider */}+ <div>+ <label className="flex items-center gap-x-2 mb-2">+ <span className="font-medium">+ {t(+ "settings.general.workspace.ai-assistant.provider.self"+ )}+ </span>+ </label>+ <select+ className="w-48 border border-control-border rounded-xs px-3 py-1.5 text-sm bg-white disabled:opacity-50"+ value={state.provider}+ disabled={!canEdit}+ onChange={(e) =>+ onProviderChange(+ Number(e.target.value) as AISetting_Provider+ )+ }+ >+ {PROVIDER_OPTIONS.map((provider) => (+ <option key={provider} value={provider}>+ {provider === AISetting_Provider.OPEN_AI &&+ t(+ "settings.general.workspace.ai-assistant.provider.open_ai"+ )}+ {provider === AISetting_Provider.AZURE_OPENAI &&+ t(+ "settings.general.workspace.ai-assistant.provider.azure_open_ai"+ )}+ {provider === AISetting_Provider.GEMINI &&+ t(+ "settings.general.workspace.ai-assistant.provider.gemini")}- </a>+ {provider === AISetting_Provider.CLAUDE &&+ t(+ "settings.general.workspace.ai-assistant.provider.claude"+ )}+ </option>+ ))}+ </select>+ </div>++ {/* API Key */}+ <div>+ <label className="flex items-center gap-x-2">+ <span className="font-medium">+ {t(+ "settings.general.workspace.ai-assistant.api-key.self")}</span>- ))}- </div>- <Input- value={state.apiKey}- disabled={!canEdit}- placeholder={t(- "settings.general.workspace.ai-assistant.api-key.placeholder"- )}- onChange={(e) =>- setState((s) => ({ ...s, apiKey: e.target.value }))- }- />- </div>+ </label>+ <div className="mb-3 text-sm text-gray-400">+ {t(+ "settings.general.workspace.ai-assistant.api-key.description",+ {+ viewDoc: "__LINK__",+ interpolation: { escapeValue: false },+ }+ )+ .split("__LINK__")+ .map((part, i) => (+ <span key={i}>+ {part}+ {i === 0 && (+ <a+ href={providerDefault.apiKeyDoc}+ className="normal-link"+ target="_blank"+ rel="noopener noreferrer"+ >+ {t(+ "settings.general.workspace.ai-assistant.api-key.find-my-key"+ )}+ </a>+ )}+ </span>+ ))}+ </div>+ <Input+ value={state.apiKey}+ disabled={!canEdit}+ placeholder={t(+ "settings.general.workspace.ai-assistant.api-key.placeholder"+ )}+ onChange={(e) =>+ setState((s) => ({ ...s, apiKey: e.target.value }))+ }+ />+ </div>- {/* Endpoint */}- <div>- <label className="flex items-center gap-x-2">- <span className="font-medium">- {t(- "settings.general.workspace.ai-assistant.endpoint.self"- )}- </span>- </label>- <div className="mb-3 text-sm text-gray-400">- {t(- "settings.general.workspace.ai-assistant.endpoint.description"- )}- </div>- <Input- value={state.endpoint}- required- disabled={!canEdit}- placeholder={providerDefault.endpoint}- onChange={(e) =>- setState((s) => ({ ...s, endpoint: e.target.value }))- }- />- </div>+ {/* Endpoint */}+ <div>+ <label className="flex items-center gap-x-2">+ <span className="font-medium">+ {t(+ "settings.general.workspace.ai-assistant.endpoint.self"+ )}+ </span>+ </label>+ <div className="mb-3 text-sm text-gray-400">+ {t(+ "settings.general.workspace.ai-assistant.endpoint.description"+ )}+ </div>+ <Input+ value={state.endpoint}+ required+ disabled={!canEdit}+ placeholder={providerDefault.endpoint}+ onChange={(e) =>+ setState((s) => ({ ...s, endpoint: e.target.value }))+ }+ />+ </div>- {/* Model */}- <div>- <label className="flex items-center gap-x-2">- <span className="font-medium">- {t("settings.general.workspace.ai-assistant.model.self")}- </span>- </label>- <div className="mb-3 text-sm text-gray-400">- {t(- "settings.general.workspace.ai-assistant.model.description"- )}- </div>- <Input- value={state.model}- required- disabled={!canEdit}- onChange={(e) =>- setState((s) => ({ ...s, model: e.target.value }))- }- />- </div>- </>+ {/* Model */}+ <div>+ <label className="flex items-center gap-x-2">+ <span className="font-medium">+ {t(+ "settings.general.workspace.ai-assistant.model.self"+ )}+ </span>+ </label>+ <div className="mb-3 text-sm text-gray-400">+ {t(+ "settings.general.workspace.ai-assistant.model.description"+ )}+ </div>+ <Input+ value={state.model}+ required+ disabled={!canEdit}+ onChange={(e) =>+ setState((s) => ({ ...s, model: e.target.value }))+ }+ />+ </div>+ </>+ )}+ </div>)}</div>- )}- </div>+ </PermissionGuard>+ </ComponentPermissionGuard></div>);});diff --git a/frontend/src/react/pages/settings/general/AccountSection.tsx b/frontend/src/react/pages/settings/general/AccountSection.tsxindex 7ed3a78df0..3dd81ef1b8 100644--- a/frontend/src/react/pages/settings/general/AccountSection.tsx+++ b/frontend/src/react/pages/settings/general/AccountSection.tsx@@ -12,6 +12,11 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";+import { FeatureBadge } from "@/react/components/FeatureBadge";+import {+ PermissionGuard,+ usePermissionCheck,+} from "@/react/components/PermissionGuard";import { useVueState } from "@/react/hooks/useVueState";import {useActuatorV1Store,@@ -26,7 +31,6 @@ import {import type { WorkspaceProfileSetting_PasswordRestriction } from "@/types/proto-es/v1/setting_service_pb";import { WorkspaceProfileSetting_PasswordRestrictionSchema } from "@/types/proto-es/v1/setting_service_pb";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";-import { hasWorkspacePermissionV2 } from "@/utils";import type { SectionHandle } from "./useSettingSection";const DEFAULT_MIN_LENGTH = 8;@@ -82,9 +86,7 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>());- const allowEdit = hasWorkspacePermissionV2(- "bb.settings.setWorkspaceProfile"- );+ const [allowEdit] = usePermissionCheck(["bb.settings.setWorkspaceProfile"]);const existActiveIdentityProvider = useVueState(() => idpStore.identityProviderList.length > 0@@ -365,459 +367,495 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(<div className="text-left lg:w-1/4"><h1 className="text-2xl font-bold">{title}</h1></div>- <div className="flex-1 lg:px-4">- {/* Sub-section 1: Disallow signup (non-SaaS only) */}- {!isSaaSMode && (- <>- <div className="mb-7 mt-4 lg:mt-0">- <div className="flex items-center gap-x-2">+ <PermissionGuard+ permissions={["bb.settings.setWorkspaceProfile"]}+ display="block"+ >+ <div className="flex-1 lg:px-4">+ {/* Sub-section 1: Disallow signup (non-SaaS only) */}+ {!isSaaSMode && (+ <>+ <div className="mt-4 lg:mt-0">+ <div className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={toggleState.disallowSignup}+ disabled={disabled || !hasDisallowSignupFeature}+ onChange={(e) =>+ setToggleState((s) => ({+ ...s,+ disallowSignup: e.target.checked,+ }))+ }+ />+ <span className="font-medium">+ {t("settings.general.workspace.disallow-signup.enable")}+ </span>+ <FeatureBadge+ feature={PlanFeature.FEATURE_DISALLOW_SELF_SERVICE_SIGNUP}+ />+ </div>+ <div className="mt-1 mb-3 text-sm text-gray-400">+ {t(+ "settings.general.workspace.disallow-signup.description"+ )}+ </div>+ </div>+ <hr className="my-6" />+ </>+ )}++ {/* Sub-section 2: Password Restriction */}+ <div className="mt-4 lg:mt-0">+ <p className="font-medium flex flex-row justify-start items-center mb-2 gap-x-2">+ {t("settings.general.workspace.password-restriction.self")}+ <FeatureBadge+ feature={PlanFeature.FEATURE_PASSWORD_RESTRICTIONS}+ />+ </p>+ <div className="flex flex-col gap-y-3">+ <div className="flex items-center">+ <input+ type="number"+ className="w-24 mr-2 rounded-xs border border-control-border px-2 py-1 text-sm"+ value={passwordState.minLength || DEFAULT_MIN_LENGTH}+ min={DEFAULT_MIN_LENGTH}+ disabled={disabled || !hasPasswordFeature}+ onChange={(e) => {+ const val = parseInt(e.target.value, 10);+ updatePasswordField({+ minLength: Math.max(+ Number.isNaN(val) ? DEFAULT_MIN_LENGTH : val,+ DEFAULT_MIN_LENGTH+ ),+ });+ }}+ />+ <span>+ {t(+ "settings.general.workspace.password-restriction.min-length",+ {+ min: passwordState.minLength || DEFAULT_MIN_LENGTH,+ }+ )}+ </span>+ </div>+ <label className="flex items-center gap-x-2"><inputtype="checkbox"- checked={toggleState.disallowSignup}- disabled={disabled || !hasDisallowSignupFeature}+ checked={passwordState.requireNumber}+ disabled={disabled || !hasPasswordFeature}onChange={(e) =>- setToggleState((s) => ({- ...s,- disallowSignup: e.target.checked,- }))+ updatePasswordField({+ requireNumber: e.target.checked,+ })}/>- <span className="font-medium">- {t("settings.general.workspace.disallow-signup.enable")}- </span>- </div>- <div className="mt-1 mb-3 text-sm text-gray-400">- {t("settings.general.workspace.disallow-signup.description")}- </div>- </div>- <hr />- </>- )}-- {/* Sub-section 2: Password Restriction */}- <div className="mb-7 mt-4 lg:mt-0">- <p className="font-medium flex flex-row justify-start items-center mb-2 gap-x-2">- {t("settings.general.workspace.password-restriction.self")}- </p>- <div className="flex flex-col gap-y-3">- <div className="flex items-center">- <input- type="number"- className="w-24 mr-2 rounded-xs border border-control-border px-2 py-1 text-sm"- value={passwordState.minLength || DEFAULT_MIN_LENGTH}- min={DEFAULT_MIN_LENGTH}- disabled={disabled || !hasPasswordFeature}- onChange={(e) => {- const val = parseInt(e.target.value, 10);- updatePasswordField({- minLength: Math.max(- Number.isNaN(val) ? DEFAULT_MIN_LENGTH : val,- DEFAULT_MIN_LENGTH- ),- });- }}- />- <span>{t(- "settings.general.workspace.password-restriction.min-length",- {- min: passwordState.minLength || DEFAULT_MIN_LENGTH,+ "settings.general.workspace.password-restriction.require-number"+ )}+ </label>+ <label className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={passwordState.requireLetter}+ disabled={disabled || !hasPasswordFeature}+ onChange={(e) =>+ updatePasswordField({+ requireLetter: e.target.checked,+ })}+ />+ {t(+ "settings.general.workspace.password-restriction.require-letter")}- </span>- </div>- <label className="flex items-center gap-x-2">- <input- type="checkbox"- checked={passwordState.requireNumber}- disabled={disabled || !hasPasswordFeature}- onChange={(e) =>- updatePasswordField({- requireNumber: e.target.checked,- })- }- />- {t(- "settings.general.workspace.password-restriction.require-number"- )}- </label>- <label className="flex items-center gap-x-2">- <input- type="checkbox"- checked={passwordState.requireLetter}- disabled={disabled || !hasPasswordFeature}- onChange={(e) =>- updatePasswordField({- requireLetter: e.target.checked,- })- }- />- {t(- "settings.general.workspace.password-restriction.require-letter"- )}- </label>- <label className="flex items-center gap-x-2">- <input- type="checkbox"- checked={passwordState.requireUppercaseLetter}- disabled={disabled || !hasPasswordFeature}- onChange={(e) =>- updatePasswordField({- requireUppercaseLetter: e.target.checked,- })- }- />- {t(- "settings.general.workspace.password-restriction.require-uppercase-letter"- )}- </label>- <label className="flex items-center gap-x-2">- <input- type="checkbox"- checked={passwordState.requireSpecialCharacter}- disabled={disabled || !hasPasswordFeature}- onChange={(e) =>- updatePasswordField({- requireSpecialCharacter: e.target.checked,- })- }- />- {t(- "settings.general.workspace.password-restriction.require-special-character"- )}- </label>- <label className="flex items-center gap-x-2">- <input- type="checkbox"- checked={passwordState.requireResetPasswordForFirstLogin}- disabled={disabled || !hasPasswordFeature}- onChange={(e) =>- updatePasswordField({- requireResetPasswordForFirstLogin: e.target.checked,- })- }- />- {t(- "settings.general.workspace.password-restriction.require-reset-password-for-first-login"- )}- </label>- <label className="flex items-center gap-x-2">- <input- type="checkbox"- checked={!!passwordState.passwordRotation}- disabled={disabled || !hasPasswordFeature}- onChange={(e) => {- if (e.target.checked) {+ </label>+ <label className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={passwordState.requireUppercaseLetter}+ disabled={disabled || !hasPasswordFeature}+ onChange={(e) =>updatePasswordField({- passwordRotation: create(DurationSchema, {- seconds: BigInt(7 * 24 * 60 * 60),- nanos: 0,- }),- });- } else {- setPasswordState((prev) => ({- ...prev,- passwordRotation: undefined,- }));+ requireUppercaseLetter: e.target.checked,+ })}- }}- />- <span className="flex items-center gap-x-2">- {- t(- "settings.general.workspace.password-restriction.password-rotation"- ).split("{day}")[0]- }- {passwordState.passwordRotation ? (- <input- type="number"- className="w-24 mx-2 rounded-xs border border-control-border px-2 py-1 text-sm"- value={passwordRotationDays}- min={1}- disabled={disabled || !hasPasswordFeature}- onClick={(e) => e.stopPropagation()}- onChange={(e) => {- const val = parseInt(e.target.value, 10);+ />+ {t(+ "settings.general.workspace.password-restriction.require-uppercase-letter"+ )}+ </label>+ <label className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={passwordState.requireSpecialCharacter}+ disabled={disabled || !hasPasswordFeature}+ onChange={(e) =>+ updatePasswordField({+ requireSpecialCharacter: e.target.checked,+ })+ }+ />+ {t(+ "settings.general.workspace.password-restriction.require-special-character"+ )}+ </label>+ <label className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={passwordState.requireResetPasswordForFirstLogin}+ disabled={disabled || !hasPasswordFeature}+ onChange={(e) =>+ updatePasswordField({+ requireResetPasswordForFirstLogin: e.target.checked,+ })+ }+ />+ {t(+ "settings.general.workspace.password-restriction.require-reset-password-for-first-login"+ )}+ </label>+ <label className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={!!passwordState.passwordRotation}+ disabled={disabled || !hasPasswordFeature}+ onChange={(e) => {+ if (e.target.checked) {updatePasswordField({passwordRotation: create(DurationSchema, {- seconds: BigInt(- (Number.isNaN(val) || val < 1 ? 1 : val) *- 24 *- 60 *- 60- ),+ seconds: BigInt(7 * 24 * 60 * 60),nanos: 0,}),});- }}- />- ) : (- <span className="mx-1">N</span>- )}- {- t(- "settings.general.workspace.password-restriction.password-rotation"- ).split("{day}")[1]- }- </span>- </label>- </div>- </div>-- <hr />-- {/* Sub-section 3: Require 2FA */}- <div className="flex flex-col gap-y-7">- <div className="mt-4 lg:mt-0">- <div className="flex items-center gap-x-2">- <input- type="checkbox"- checked={toggleState.require2fa}- disabled={disabled || !has2FAFeature}- onChange={(e) =>- setToggleState((s) => ({- ...s,- require2fa: e.target.checked,- }))- }- />- <span className="font-medium">- {t("settings.general.workspace.require-2fa.enable")}- </span>- </div>- <div className="mt-1 text-sm text-gray-400">- {t("settings.general.workspace.require-2fa.description")}+ } else {+ setPasswordState((prev) => ({+ ...prev,+ passwordRotation: undefined,+ }));+ }+ }}+ />+ <span className="flex items-center gap-x-2">+ {+ t(+ "settings.general.workspace.password-restriction.password-rotation"+ ).split("{day}")[0]+ }+ {passwordState.passwordRotation ? (+ <input+ type="number"+ className="w-24 mx-2 rounded-xs border border-control-border px-2 py-1 text-sm"+ value={passwordRotationDays}+ min={1}+ disabled={disabled || !hasPasswordFeature}+ onClick={(e) => e.stopPropagation()}+ onChange={(e) => {+ const val = parseInt(e.target.value, 10);+ updatePasswordField({+ passwordRotation: create(DurationSchema, {+ seconds: BigInt(+ (Number.isNaN(val) || val < 1 ? 1 : val) *+ 24 *+ 60 *+ 60+ ),+ nanos: 0,+ }),+ });+ }}+ />+ ) : (+ <span className="mx-1">N</span>+ )}+ {+ t(+ "settings.general.workspace.password-restriction.password-rotation"+ ).split("{day}")[1]+ }+ </span>+ </label></div></div>- {/* Sub-section 4: Disallow password signin (non-SaaS only) */}- {!isSaaSMode && (- <div className="lg:mt-0">+ <hr className="my-6" />++ {/* Sub-section 3: Require 2FA */}+ <div className="flex flex-col gap-y-7">+ <div className="mt-4 lg:mt-0"><div className="flex items-center gap-x-2"><inputtype="checkbox"- checked={toggleState.disallowPasswordSignin}- disabled={- disabled ||- !hasDisallowPasswordSigninFeature ||- (!toggleState.disallowPasswordSignin &&- !existActiveIdentityProvider)- }+ checked={toggleState.require2fa}+ disabled={disabled || !has2FAFeature}onChange={(e) =>setToggleState((s) => ({...s,- disallowPasswordSignin: e.target.checked,+ require2fa: e.target.checked,}))}/>- <span className="font-medium flex items-center gap-x-2">- {t(- "settings.general.workspace.disallow-password-signin.enable"- )}- {hasDisallowPasswordSigninFeature &&- !toggleState.disallowPasswordSignin &&- !existActiveIdentityProvider && (- <span- title={t(- "settings.general.workspace.disallow-password-signin.require-sso-setup"- )}- >- <TriangleAlert className="w-4 text-warning" />- </span>- )}+ <span className="font-medium">+ {t("settings.general.workspace.require-2fa.enable")}</span>+ <FeatureBadge feature={PlanFeature.FEATURE_TWO_FA} /></div><div className="mt-1 text-sm text-gray-400">- {t(- "settings.general.workspace.disallow-password-signin.description"- )}+ {t("settings.general.workspace.require-2fa.description")}</div></div>- )}- </div>- <hr />-- {/* Sub-section 5: Token Duration */}- {/* Access Token Duration */}- <div className="mb-7 mt-4 lg:mt-0">- <p className="font-medium flex flex-row justify-start items-center">- <span className="mr-2">- {t("settings.general.workspace.access-token-duration.self")}- </span>- </p>- <p className="text-sm text-gray-400 mt-1">- {t(- "settings.general.workspace.access-token-duration.description"+ {/* Sub-section 4: Disallow password signin (non-SaaS only) */}+ {!isSaaSMode && (+ <div className="lg:mt-0">+ <div className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={toggleState.disallowPasswordSignin}+ disabled={+ disabled ||+ !hasDisallowPasswordSigninFeature ||+ (!toggleState.disallowPasswordSignin &&+ !existActiveIdentityProvider)+ }+ onChange={(e) =>+ setToggleState((s) => ({+ ...s,+ disallowPasswordSignin: e.target.checked,+ }))+ }+ />+ <span className="font-medium flex items-center gap-x-2">+ {t(+ "settings.general.workspace.disallow-password-signin.enable"+ )}+ <FeatureBadge+ feature={PlanFeature.FEATURE_DISALLOW_PASSWORD_SIGNIN}+ />+ {hasDisallowPasswordSigninFeature &&+ !toggleState.disallowPasswordSignin &&+ !existActiveIdentityProvider && (+ <span+ title={t(+ "settings.general.workspace.disallow-password-signin.require-sso-setup"+ )}+ >+ <TriangleAlert className="w-4 text-warning" />+ </span>+ )}+ </span>+ </div>+ <div className="mt-1 text-sm text-gray-400">+ {t(+ "settings.general.workspace.disallow-password-signin.description"+ )}+ </div>+ </div>)}- </p>- <div className="mt-3 flex flex-row justify-start items-center gap-x-4">- <input- type="number"- className="w-24 rounded-xs border border-control-border px-2 py-1 text-sm"- value={tokenState.accessTokenDuration}- min={1}- max={tokenState.accessTokenTimeFormat === "MINUTES" ? 59 : 23}- disabled={disabled || !hasSecureTokenFeature}- onChange={(e) => {- const val = parseInt(e.target.value, 10);- if (!Number.isNaN(val)) {- const max =- tokenState.accessTokenTimeFormat === "MINUTES" ? 59 : 23;- setTokenState((s) => ({- ...s,- accessTokenDuration: Math.max(1, Math.min(val, max)),- }));- }- }}- />- <label className="flex items-center gap-x-1">- <input- type="radio"- name="accessTokenTimeFormat"- value="MINUTES"- checked={tokenState.accessTokenTimeFormat === "MINUTES"}- disabled={disabled || !hasSecureTokenFeature}- onChange={() =>- setTokenState((s) => ({- ...s,- accessTokenTimeFormat: "MINUTES",- }))- }+ </div>++ <hr className="my-6" />++ {/* Sub-section 5: Token Duration */}+ {/* Access Token Duration */}+ <div className="mb-7 mt-4 lg:mt-0">+ <p className="font-medium flex flex-row justify-start items-center gap-x-2">+ <span>+ {t("settings.general.workspace.access-token-duration.self")}+ </span>+ <FeatureBadge+ feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}/>- {t("settings.general.workspace.access-token-duration.minutes")}- </label>- <label className="flex items-center gap-x-1">+ </p>+ <p className="text-sm text-gray-400 mt-1">+ {t(+ "settings.general.workspace.access-token-duration.description"+ )}+ </p>+ <div className="mt-3 flex flex-row justify-start items-center gap-x-4"><input- type="radio"- name="accessTokenTimeFormat"- value="HOURS"- checked={tokenState.accessTokenTimeFormat === "HOURS"}+ type="number"+ className="w-24 rounded-xs border border-control-border px-2 py-1 text-sm"+ value={tokenState.accessTokenDuration}+ min={1}+ max={tokenState.accessTokenTimeFormat === "MINUTES" ? 59 : 23}disabled={disabled || !hasSecureTokenFeature}- onChange={() =>- setTokenState((s) => ({- ...s,- accessTokenTimeFormat: "HOURS",- }))- }+ onChange={(e) => {+ const val = parseInt(e.target.value, 10);+ if (!Number.isNaN(val)) {+ const max =+ tokenState.accessTokenTimeFormat === "MINUTES"+ ? 59+ : 23;+ setTokenState((s) => ({+ ...s,+ accessTokenDuration: Math.max(1, Math.min(val, max)),+ }));+ }+ }}/>- {t("settings.general.workspace.access-token-duration.hours")}- </label>+ <label className="flex items-center gap-x-1">+ <input+ type="radio"+ name="accessTokenTimeFormat"+ value="MINUTES"+ checked={tokenState.accessTokenTimeFormat === "MINUTES"}+ disabled={disabled || !hasSecureTokenFeature}+ onChange={() =>+ setTokenState((s) => ({+ ...s,+ accessTokenTimeFormat: "MINUTES",+ }))+ }+ />+ {t(+ "settings.general.workspace.access-token-duration.minutes"+ )}+ </label>+ <label className="flex items-center gap-x-1">+ <input+ type="radio"+ name="accessTokenTimeFormat"+ value="HOURS"+ checked={tokenState.accessTokenTimeFormat === "HOURS"}+ disabled={disabled || !hasSecureTokenFeature}+ onChange={() =>+ setTokenState((s) => ({+ ...s,+ accessTokenTimeFormat: "HOURS",+ }))+ }+ />+ {t("settings.general.workspace.access-token-duration.hours")}+ </label>+ </div></div>- </div>- {/* Refresh Token Duration */}- <div className="mb-7 mt-4 lg:mt-0">- <p className="font-medium flex flex-row justify-start items-center">- <span className="mr-2">- {t("settings.general.workspace.refresh-token-duration.self")}- </span>- </p>- <p className="text-sm text-gray-400 mt-1">- {t(- "settings.general.workspace.refresh-token-duration.description"- )}- </p>- <div className="mt-3 flex flex-row justify-start items-center gap-x-4">- <input- type="number"- className="w-24 rounded-xs border border-control-border px-2 py-1 text-sm"- value={tokenState.refreshTokenDuration}- min={1}- max={- tokenState.refreshTokenTimeFormat === "HOURS" ? 23 : undefined- }- disabled={disabled || !hasSecureTokenFeature}- onChange={(e) => {- const val = parseInt(e.target.value, 10);- if (!Number.isNaN(val)) {- const max =- tokenState.refreshTokenTimeFormat === "HOURS"- ? 23- : undefined;- setTokenState((s) => ({- ...s,- refreshTokenDuration: Math.max(- 1,- max ? Math.min(val, max) : val- ),- }));- }- }}- />- <label className="flex items-center gap-x-1">- <input- type="radio"- name="refreshTokenTimeFormat"- value="HOURS"- checked={tokenState.refreshTokenTimeFormat === "HOURS"}- disabled={disabled || !hasSecureTokenFeature}- onChange={() =>- setTokenState((s) => ({- ...s,- refreshTokenTimeFormat: "HOURS",- }))- }+ {/* Refresh Token Duration */}+ <div className="mb-7 mt-4 lg:mt-0">+ <p className="font-medium flex flex-row justify-start items-center gap-x-2">+ <span>+ {t("settings.general.workspace.refresh-token-duration.self")}+ </span>+ <FeatureBadge+ feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}/>- {t("settings.general.workspace.refresh-token-duration.hours")}- </label>- <label className="flex items-center gap-x-1">+ </p>+ <p className="text-sm text-gray-400 mt-1">+ {t(+ "settings.general.workspace.refresh-token-duration.description"+ )}+ </p>+ <div className="mt-3 flex flex-row justify-start items-center gap-x-4"><input- type="radio"- name="refreshTokenTimeFormat"- value="DAYS"- checked={tokenState.refreshTokenTimeFormat === "DAYS"}- disabled={disabled || !hasSecureTokenFeature}- onChange={() =>- setTokenState((s) => ({- ...s,- refreshTokenTimeFormat: "DAYS",- }))+ type="number"+ className="w-24 rounded-xs border border-control-border px-2 py-1 text-sm"+ value={tokenState.refreshTokenDuration}+ min={1}+ max={+ tokenState.refreshTokenTimeFormat === "HOURS"+ ? 23+ : undefined}+ disabled={disabled || !hasSecureTokenFeature}+ onChange={(e) => {+ const val = parseInt(e.target.value, 10);+ if (!Number.isNaN(val)) {+ const max =+ tokenState.refreshTokenTimeFormat === "HOURS"+ ? 23+ : undefined;+ setTokenState((s) => ({+ ...s,+ refreshTokenDuration: Math.max(+ 1,+ max ? Math.min(val, max) : val+ ),+ }));+ }+ }}/>- {t("settings.general.workspace.refresh-token-duration.days")}- </label>+ <label className="flex items-center gap-x-1">+ <input+ type="radio"+ name="refreshTokenTimeFormat"+ value="HOURS"+ checked={tokenState.refreshTokenTimeFormat === "HOURS"}+ disabled={disabled || !hasSecureTokenFeature}+ onChange={() =>+ setTokenState((s) => ({+ ...s,+ refreshTokenTimeFormat: "HOURS",+ }))+ }+ />+ {t("settings.general.workspace.refresh-token-duration.hours")}+ </label>+ <label className="flex items-center gap-x-1">+ <input+ type="radio"+ name="refreshTokenTimeFormat"+ value="DAYS"+ checked={tokenState.refreshTokenTimeFormat === "DAYS"}+ disabled={disabled || !hasSecureTokenFeature}+ onChange={() =>+ setTokenState((s) => ({+ ...s,+ refreshTokenTimeFormat: "DAYS",+ }))+ }+ />+ {t("settings.general.workspace.refresh-token-duration.days")}+ </label>+ </div></div>- </div>- {/* Inactive Session Timeout */}- <div className="mb-7 mt-4 lg:mt-0">- <p className="font-medium flex flex-row justify-start items-center">- <span className="mr-2">- {t("settings.general.workspace.inactive-session-timeout.self")}- </span>- </p>- <p className="text-sm text-gray-400 mt-1">- {t(- "settings.general.workspace.inactive-session-timeout.description"- )}{" "}- <span className="font-semibold">- {t("settings.general.workspace.no-limit")}- </span>- </p>- <div className="mt-3 flex flex-row justify-start items-center gap-x-4">- <input- type="number"- className="w-24 rounded-xs border border-control-border px-2 py-1 text-sm"- value={tokenState.inactiveTimeout}- min={-1}- disabled={disabled || !hasSecureTokenFeature}- onChange={(e) => {- const val = parseInt(e.target.value, 10);- if (!Number.isNaN(val)) {- setTokenState((s) => ({- ...s,- inactiveTimeout: Math.max(-1, val),- }));- }- }}- />- <span className="text-sm text-gray-500">- {t("settings.general.workspace.inactive-session-timeout.hours")}- </span>+ {/* Inactive Session Timeout */}+ <div className="mt-4 lg:mt-0">+ <p className="font-medium flex flex-row justify-start items-center gap-x-2">+ <span>+ {t(+ "settings.general.workspace.inactive-session-timeout.self"+ )}+ </span>+ <FeatureBadge+ feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}+ />+ </p>+ <p className="text-sm text-gray-400 mt-1">+ {t(+ "settings.general.workspace.inactive-session-timeout.description"+ )}{" "}+ <span className="font-semibold">+ {t("settings.general.workspace.no-limit")}+ </span>+ </p>+ <div className="mt-3 flex flex-row justify-start items-center gap-x-4">+ <input+ type="number"+ className="w-24 rounded-xs border border-control-border px-2 py-1 text-sm"+ value={tokenState.inactiveTimeout}+ min={-1}+ disabled={disabled || !hasSecureTokenFeature}+ onChange={(e) => {+ const val = parseInt(e.target.value, 10);+ if (!Number.isNaN(val)) {+ setTokenState((s) => ({+ ...s,+ inactiveTimeout: Math.max(-1, val),+ }));+ }+ }}+ />+ <span className="text-sm text-gray-500">+ {t(+ "settings.general.workspace.inactive-session-timeout.hours"+ )}+ </span>+ </div></div></div>- </div>+ </PermissionGuard></div>);}diff --git a/frontend/src/react/pages/settings/general/AnnouncementSection.tsx b/frontend/src/react/pages/settings/general/AnnouncementSection.tsxindex d3340020c0..7f9fd8a179 100644--- a/frontend/src/react/pages/settings/general/AnnouncementSection.tsx+++ b/frontend/src/react/pages/settings/general/AnnouncementSection.tsx@@ -1,7 +1,6 @@import { create } from "@bufbuild/protobuf";import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";import { cloneDeep, isEqual } from "lodash-es";-import { SparklesIcon } from "lucide-react";import {forwardRef,useCallback,@@ -10,6 +9,11 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";+import { FeatureBadge } from "@/react/components/FeatureBadge";+import {+ PermissionGuard,+ usePermissionCheck,+} from "@/react/components/PermissionGuard";import { Input } from "@/react/components/ui/input";import { useVueState } from "@/react/hooks/useVueState";import { useSubscriptionV1Store } from "@/store";@@ -18,11 +22,7 @@ import {Announcement_AlertLevel,AnnouncementSchema,} from "@/types/proto-es/v1/setting_service_pb";-import {- PlanFeature,- PlanType,-} from "@/types/proto-es/v1/subscription_service_pb";-import { hasWorkspacePermissionV2 } from "@/utils";+import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import type { SectionHandle } from "./useSettingSection";interface AnnouncementSectionProps {@@ -54,7 +54,7 @@ export const AnnouncementSection = forwardRef<subscriptionStore.hasFeature(PlanFeature.FEATURE_DASHBOARD_ANNOUNCEMENT));- const canEdit = hasWorkspacePermissionV2("bb.settings.setWorkspaceProfile");+ const [canEdit] = usePermissionCheck(["bb.settings.setWorkspaceProfile"]);const getRawAnnouncement = useCallback((): AnnouncementState => {const announcement = settingV1Store.workspaceProfile.announcement;@@ -104,107 +104,103 @@ export const AnnouncementSection = forwardRef<const disabled = !canEdit || !hasFeature;- const minimumPlan = useVueState(() =>- subscriptionStore.getMinimumRequiredPlan(- PlanFeature.FEATURE_DASHBOARD_ANNOUNCEMENT- )- );-return (<div id="announcement" className="py-6 lg:flex"><div className="text-left lg:w-1/4"><div className="flex items-center gap-x-2"><h1 className="text-2xl font-bold">{title}</h1>- {!hasFeature && (- <a- href="/setting/subscription"- className="text-accent"- title={t("subscription.require-subscription", {- requiredPlan: t(- `subscription.plan.${PlanType[minimumPlan].toLowerCase()}.title`- ),- })}- >- <SparklesIcon className="w-5 h-5" />- </a>- )}+ <FeatureBadge+ feature={PlanFeature.FEATURE_DASHBOARD_ANNOUNCEMENT}+ clickable+ /></div></div>- <div className="flex-1 lg:px-5">- <div className="mt-5 lg:mt-0">- {/* Alert level radio */}- <label className="flex items-center gap-x-2">- <span className="font-medium">- {t(- "settings.general.workspace.announcement-alert-level.description"+ <PermissionGuard+ permissions={["bb.settings.setWorkspaceProfile"]}+ display="block"+ >+ <div className="flex-1 lg:px-5">+ <div className="mt-5 lg:mt-0">+ {/* Alert level radio */}+ <label className="flex items-center gap-x-2">+ <span className="font-medium">+ {t(+ "settings.general.workspace.announcement-alert-level.description"+ )}+ </span>+ </label>+ <div className="flex flex-wrap py-2 gap-4">+ {ALERT_LEVELS.map((level) => (+ <label+ key={level}+ className="flex items-center gap-x-2 cursor-pointer"+ >+ <input+ type="radio"+ name="announcementLevel"+ disabled={disabled}+ checked={state.level === level}+ onChange={() => setState((s) => ({ ...s, level }))}+ />+ <span>+ {level === Announcement_AlertLevel.INFO &&+ t(+ "settings.general.workspace.announcement-alert-level.field.info"+ )}+ {level === Announcement_AlertLevel.WARNING &&+ t(+ "settings.general.workspace.announcement-alert-level.field.warning"+ )}+ {level === Announcement_AlertLevel.CRITICAL &&+ t(+ "settings.general.workspace.announcement-alert-level.field.critical"+ )}+ </span>+ </label>+ ))}+ </div>++ {/* Announcement text */}+ <label className="flex items-center mt-2 gap-x-2">+ <span className="font-medium">+ {t("settings.general.workspace.announcement-text.self")}+ </span>+ </label>+ <div className="mb-3 text-sm text-gray-400">+ {t("settings.general.workspace.announcement-text.description")}+ </div>+ <Input+ value={state.text}+ className="mb-3 w-full"+ placeholder={t(+ "settings.general.workspace.announcement-text.placeholder")}- </span>- </label>- <div className="flex flex-wrap py-2 gap-4">- {ALERT_LEVELS.map((level) => (- <label- key={level}- className="flex items-center gap-x-2 cursor-pointer"- >- <input- type="radio"- name="announcementLevel"- disabled={disabled}- checked={state.level === level}- onChange={() => setState((s) => ({ ...s, level }))}- />- <span>- {level === Announcement_AlertLevel.INFO &&- t(- "settings.general.workspace.announcement-alert-level.field.info"- )}- {level === Announcement_AlertLevel.WARNING &&- t(- "settings.general.workspace.announcement-alert-level.field.warning"- )}- {level === Announcement_AlertLevel.CRITICAL &&- t(- "settings.general.workspace.announcement-alert-level.field.critical"- )}- </span>- </label>- ))}- </div>-- {/* Announcement text */}- <label className="flex items-center mt-2 gap-x-2">- <span className="font-medium">- {t("settings.general.workspace.announcement-text.self")}- </span>- </label>- <div className="mb-3 text-sm text-gray-400">- {t("settings.general.workspace.announcement-text.description")}+ disabled={disabled}+ onChange={(e) =>+ setState((s) => ({ ...s, text: e.target.value }))+ }+ />++ {/* Extra link */}+ <label className="flex items-center py-2 gap-x-2">+ <span className="font-medium">+ {t("settings.general.workspace.extra-link.self")}+ </span>+ </label>+ <Input+ value={state.link}+ className="mb-5 w-full"+ placeholder={t(+ "settings.general.workspace.extra-link.placeholder"+ )}+ disabled={disabled}+ onChange={(e) =>+ setState((s) => ({ ...s, link: e.target.value }))+ }+ /></div>- <Input- value={state.text}- className="mb-3 w-full"- placeholder={t(- "settings.general.workspace.announcement-text.placeholder"- )}- disabled={disabled}- onChange={(e) => setState((s) => ({ ...s, text: e.target.value }))}- />-- {/* Extra link */}- <label className="flex items-center py-2 gap-x-2">- <span className="font-medium">- {t("settings.general.workspace.extra-link.self")}- </span>- </label>- <Input- value={state.link}- className="mb-5 w-full"- placeholder={t("settings.general.workspace.extra-link.placeholder")}- disabled={disabled}- onChange={(e) => setState((s) => ({ ...s, link: e.target.value }))}- /></div>- </div>+ </PermissionGuard></div>);});diff --git a/frontend/src/react/pages/settings/general/AuditLogSection.tsx b/frontend/src/react/pages/settings/general/AuditLogSection.tsxindex 12a3c4e8ee..6fb9e8c106 100644--- a/frontend/src/react/pages/settings/general/AuditLogSection.tsx+++ b/frontend/src/react/pages/settings/general/AuditLogSection.tsx@@ -9,6 +9,7 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";+import { FeatureBadge } from "@/react/components/FeatureBadge";import { useVueState } from "@/react/hooks/useVueState";import { useSettingV1Store, useSubscriptionV1Store } from "@/store";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";@@ -80,7 +81,10 @@ export const AuditLogSection = forwardRef<SectionHandle, AuditLogSectionProps>(return (<div id="audit-log-stdout" className="py-6 lg:flex"><div className="text-left lg:w-1/4">- <h1 className="text-2xl font-bold">{title}</h1>+ <div className="flex items-center gap-x-2">+ <h1 className="text-2xl font-bold">{title}</h1>+ <FeatureBadge feature={PlanFeature.FEATURE_AUDIT_LOG} />+ </div></div><div className="flex-1 lg:px-4 flex flex-col gap-y-6">{/* Audit log stdout toggle */}diff --git a/frontend/src/react/pages/settings/general/BrandingSection.tsx b/frontend/src/react/pages/settings/general/BrandingSection.tsxindex ccadaae69c..bf63346ba5 100644--- a/frontend/src/react/pages/settings/general/BrandingSection.tsx+++ b/frontend/src/react/pages/settings/general/BrandingSection.tsx@@ -10,6 +10,11 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";+import { FeatureBadge } from "@/react/components/FeatureBadge";+import {+ PermissionGuard,+ usePermissionCheck,+} from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import { useVueState } from "@/react/hooks/useVueState";@@ -20,7 +25,6 @@ import {} from "@/store";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import { WorkspaceSchema } from "@/types/proto-es/v1/workspace_service_pb";-import { hasWorkspacePermissionV2 } from "@/utils";import type { SectionHandle } from "./useSettingSection";const MAX_FILE_SIZE_MIB = 2;@@ -49,7 +53,7 @@ export const BrandingSection = forwardRef<SectionHandle, BrandingSectionProps>(useSubscriptionV1Store().hasFeature(PlanFeature.FEATURE_CUSTOM_LOGO));- const canEdit = hasWorkspacePermissionV2("bb.workspaces.update");+ const [canEdit] = usePermissionCheck(["bb.workspaces.update"]);const [localTitle, setLocalTitle] = useState(workspace?.title ?? "");const [logoUrl, setLogoUrl] = useState(workspace?.logo ?? "");@@ -177,105 +181,111 @@ export const BrandingSection = forwardRef<SectionHandle, BrandingSectionProps>(<div className="text-left lg:w-1/4"><h1 className="text-2xl font-bold">{title}</h1></div>- <div className="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">- {/* Workspace ID */}- <div>- <label className="font-medium">- {t("settings.general.workspace.id")}- </label>- <Input value={workspaceID} disabled className="mt-1" />- </div>+ <PermissionGuard permissions={["bb.workspaces.update"]} display="block">+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">+ {/* Workspace ID */}+ <div>+ <label className="font-medium">+ {t("settings.general.workspace.id")}+ </label>+ <Input value={workspaceID} disabled className="mt-1" />+ </div>- {/* Workspace Title */}- <div>- <label className="font-medium">- {t("settings.general.workspace.title")}- </label>- <Input- value={localTitle}- onChange={(e) => setLocalTitle(e.target.value)}- disabled={!canEdit}- className="mt-1"- />- </div>+ {/* Workspace Title */}+ <div>+ <label className="font-medium">+ {t("settings.general.workspace.title")}+ </label>+ <Input+ value={localTitle}+ onChange={(e) => setLocalTitle(e.target.value)}+ disabled={!canEdit}+ className="mt-1"+ />+ </div>- {/* Logo */}- <div>- <div className="mb-4 mt-4 lg:mt-0">- <div className="flex items-center gap-x-2 font-medium">- {t("settings.general.workspace.logo")}- </div>- <p className="mb-3 text-sm text-gray-400">- {t("settings.general.workspace.logo-aspect")}- </p>- <div- className={`flex justify-center border-2 border-gray-300 border-dashed rounded-xs relative h-48 transition-all ${- dropActive ? "bg-gray-300 opacity-100" : ""- } ${uploadDisabled ? "cursor-not-allowed" : "cursor-pointer hover:bg-gray-100"}`}- onClick={() => {- if (!uploadDisabled) fileInputRef.current?.click();- }}- onDrop={handleDrop}- onDragOver={(e) => e.preventDefault()}- onDragEnter={() => setDropActive(true)}- onDragLeave={() => setDropActive(false)}- >- {/* Logo preview */}+ {/* Logo */}+ <div>+ <div className="mb-4 mt-4 lg:mt-0">+ <div className="flex items-center gap-x-2 font-medium">+ {t("settings.general.workspace.logo")}+ <FeatureBadge+ feature={PlanFeature.FEATURE_CUSTOM_LOGO}+ clickable+ />+ </div>+ <p className="mb-3 text-sm text-gray-400">+ {t("settings.general.workspace.logo-aspect")}+ </p><div- className="w-full bg-no-repeat bg-contain bg-center rounded-md pointer-events-none m-4"- style={{- backgroundImage: logoUrl ? `url(${logoUrl})` : undefined,+ className={`flex justify-center border-2 border-gray-300 border-dashed rounded-xs relative h-48 transition-all ${+ dropActive ? "bg-gray-300 opacity-100" : ""+ } ${uploadDisabled ? "cursor-not-allowed" : "cursor-pointer hover:bg-gray-100"}`}+ onClick={() => {+ if (!uploadDisabled) fileInputRef.current?.click();}}- />- {/* Upload overlay */}- <div- className={`flex flex-col gap-y-1 text-center justify-center items-center absolute top-0 bottom-0 left-0 right-0 ${- logoUrl ? "opacity-0 hover:opacity-90" : ""- }`}+ onDrop={handleDrop}+ onDragOver={(e) => e.preventDefault()}+ onDragEnter={() => setDropActive(true)}+ onDragLeave={() => setDropActive(false)}>- {!logoUrl && (- <div className="py-4 text-gray-500">- {t("common.no-data")}+ {/* Logo preview */}+ <div+ className="w-full bg-no-repeat bg-contain bg-center rounded-sm pointer-events-none m-4"+ style={{+ backgroundImage: logoUrl ? `url(${logoUrl})` : undefined,+ }}+ />+ {/* Upload overlay */}+ <div+ className={`flex flex-col gap-y-1 text-center justify-center items-center absolute top-0 bottom-0 left-0 right-0 ${+ logoUrl ? "opacity-0 hover:opacity-90" : ""+ }`}+ >+ {!logoUrl && (+ <div className="py-4 text-gray-500">+ {t("common.no-data")}+ </div>+ )}+ <div className="text-sm text-gray-600 inline-flex pointer-events-none">+ <span className="relative cursor-pointer rounded-xs font-medium text-indigo-600 hover:text-indigo-500">+ {t("settings.general.workspace.select-logo")}+ </span>+ <p className="pl-1">+ {t("settings.general.workspace.drag-logo")}+ </p></div>- )}- <div className="text-sm text-gray-600 inline-flex pointer-events-none">- <span className="relative cursor-pointer rounded-md font-medium text-indigo-600 hover:text-indigo-500">- {t("settings.general.workspace.select-logo")}- </span>- <p className="pl-1">- {t("settings.general.workspace.drag-logo")}+ <p className="text-xs text-gray-500 pointer-events-none">+ {t("settings.general.workspace.logo-upload-tip", {+ extension: SUPPORT_IMAGE_EXTENSIONS.join(", "),+ size: MAX_FILE_SIZE_MIB,+ })}</p></div>- <p className="text-xs text-gray-500 pointer-events-none">- {t("settings.general.workspace.logo-upload-tip", {- extension: SUPPORT_IMAGE_EXTENSIONS.join(", "),- size: MAX_FILE_SIZE_MIB,- })}- </p>+ <input+ ref={fileInputRef}+ type="file"+ accept={SUPPORT_IMAGE_EXTENSIONS.join(",")}+ className="sr-only hidden"+ disabled={uploadDisabled}+ onChange={handleFileInput}+ /></div>- <input- ref={fileInputRef}- type="file"- accept={SUPPORT_IMAGE_EXTENSIONS.join(",")}- className="sr-only hidden"- disabled={uploadDisabled}- onChange={handleFileInput}- /></div>+ {logoUrl && (+ <div className="flex justify-end gap-x-3">+ <Button+ variant="destructive"+ disabled={!canEdit}+ onClick={() => setLogoUrl("")}+ >+ {t("common.delete")}+ </Button>+ </div>+ )}</div>- {logoUrl && (- <div className="flex justify-end gap-x-3">- <Button- variant="destructive"- disabled={!canEdit}- onClick={() => setLogoUrl("")}- >- {t("common.delete")}- </Button>- </div>- )}</div>- </div>+ </PermissionGuard></div>);}diff --git a/frontend/src/react/pages/settings/general/GeneralPage.tsx b/frontend/src/react/pages/settings/general/GeneralPage.tsxindex c21180419c..4300f63deb 100644--- a/frontend/src/react/pages/settings/general/GeneralPage.tsx+++ b/frontend/src/react/pages/settings/general/GeneralPage.tsx@@ -1,5 +1,7 @@import { useCallback, useEffect, useRef, useState } from "react";import { useTranslation } from "react-i18next";+import { t as vueT } from "@/plugins/i18n";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { useVueState } from "@/react/hooks/useVueState";import { router } from "@/router";@@ -142,7 +144,7 @@ export function GeneralPage() {const removeGuard = router.beforeEach((_to, _from, next) => {if (allRefs.some((ref) => ref.current?.isDirty())) {- if (!window.confirm(t("common.leave-without-saving"))) {+ if (!window.confirm(vueT("common.leave-without-saving"))) {next(false);return;}@@ -201,18 +203,28 @@ export function GeneralPage() {onDirtyChange={onDirtyChange}/>{!isSaaSMode && (- <ProductImprovementSection- ref={productImprovementRef}- allowEdit={canEditProfile}- onDirtyChange={onDirtyChange}- />+ <PermissionGuard+ permissions={["bb.settings.setWorkspaceProfile"]}+ display="block"+ >+ <ProductImprovementSection+ ref={productImprovementRef}+ allowEdit={canEditProfile}+ onDirtyChange={onDirtyChange}+ />+ </PermissionGuard>)}{!isSaaSMode && (- <AuditLogSection- ref={auditLogRef}- allowEdit={canEditProfile}- onDirtyChange={onDirtyChange}- />+ <PermissionGuard+ permissions={["bb.settings.setWorkspaceProfile"]}+ display="block"+ >+ <AuditLogSection+ ref={auditLogRef}+ allowEdit={canEditProfile}+ onDirtyChange={onDirtyChange}+ />+ </PermissionGuard>)}{isDirty && (diff --git a/frontend/src/react/pages/settings/general/GeneralSection.tsx b/frontend/src/react/pages/settings/general/GeneralSection.tsxindex 573a22c67c..bc7cb85500 100644--- a/frontend/src/react/pages/settings/general/GeneralSection.tsx+++ b/frontend/src/react/pages/settings/general/GeneralSection.tsx@@ -9,6 +9,10 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";+import {+ PermissionGuard,+ usePermissionCheck,+} from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import { useVueState } from "@/react/hooks/useVueState";@@ -16,7 +20,6 @@ import { router } from "@/router";import { SQL_EDITOR_HOME_MODULE } from "@/router/sqlEditor";import { useActuatorV1Store, useSettingV1Store } from "@/store";import { DatabaseChangeMode } from "@/types/proto-es/v1/setting_service_pb";-import { hasWorkspacePermissionV2 } from "@/utils";import type { SectionHandle } from "./useSettingSection";interface GeneralSectionProps {@@ -40,7 +43,7 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(() => actuatorV1Store.serverInfo?.externalUrlFromFlag ?? false);- const canEdit = hasWorkspacePermissionV2("bb.settings.setWorkspaceProfile");+ const [canEdit] = usePermissionCheck(["bb.settings.setWorkspaceProfile"]);const getInitialState = useCallback((): LocalState => {const mode = settingV1Store.workspaceProfile.databaseChangeMode;@@ -119,107 +122,114 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(<h1 className="text-2xl font-bold">{title}</h1></div></div>- <div className="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">- {/* Database change mode */}- <div>- <div className="mb-4 font-medium">- {t("settings.general.workspace.default-landing-page.self")}- </div>- <div className="w-full flex flex-col gap-8">- <label className="flex items-start gap-x-3 cursor-pointer">- <input- type="radio"- name="databaseChangeMode"- className="mt-1"- disabled={!canEdit}- checked={- state.databaseChangeMode === DatabaseChangeMode.PIPELINE- }- onChange={() =>- setState((s) => ({- ...s,- databaseChangeMode: DatabaseChangeMode.PIPELINE,- }))- }- />- <div className="flex flex-col gap-1">- <div className="textinfo">- {t(- "settings.general.workspace.default-landing-page.workspace.self"- )}- </div>- <div className="textinfolabel">- {t(- "settings.general.workspace.default-landing-page.workspace.description"- )}- </div>- </div>- </label>- <label className="flex items-start gap-x-3 cursor-pointer">- <input- type="radio"- name="databaseChangeMode"- className="mt-1"- disabled={!canEdit}- checked={- state.databaseChangeMode === DatabaseChangeMode.EDITOR- }- onChange={() =>- setState((s) => ({- ...s,- databaseChangeMode: DatabaseChangeMode.EDITOR,- }))- }- />- <div className="flex flex-col gap-1">- <div className="textinfo">- {t(- "settings.general.workspace.default-landing-page.sql-editor.self"- )}+ <PermissionGuard+ permissions={["bb.settings.setWorkspaceProfile"]}+ display="block"+ >+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">+ {/* Database change mode */}+ <div>+ <div className="mb-4 font-medium">+ {t("settings.general.workspace.default-landing-page.self")}+ </div>+ <div className="w-full flex flex-col gap-8">+ <label className="flex items-start gap-x-3 cursor-pointer">+ <input+ type="radio"+ name="databaseChangeMode"+ className="mt-1"+ disabled={!canEdit}+ checked={+ state.databaseChangeMode === DatabaseChangeMode.PIPELINE+ }+ onChange={() =>+ setState((s) => ({+ ...s,+ databaseChangeMode: DatabaseChangeMode.PIPELINE,+ }))+ }+ />+ <div className="flex flex-col gap-1">+ <div className="textinfo">+ {t(+ "settings.general.workspace.default-landing-page.workspace.self"+ )}+ </div>+ <div className="textinfolabel">+ {t(+ "settings.general.workspace.default-landing-page.workspace.description"+ )}+ </div></div>- <div className="textinfolabel">- {t(- "settings.general.workspace.default-landing-page.sql-editor.description"- )}+ </label>+ <label className="flex items-start gap-x-3 cursor-pointer">+ <input+ type="radio"+ name="databaseChangeMode"+ className="mt-1"+ disabled={!canEdit}+ checked={+ state.databaseChangeMode === DatabaseChangeMode.EDITOR+ }+ onChange={() =>+ setState((s) => ({+ ...s,+ databaseChangeMode: DatabaseChangeMode.EDITOR,+ }))+ }+ />+ <div className="flex flex-col gap-1">+ <div className="textinfo">+ {t(+ "settings.general.workspace.default-landing-page.sql-editor.self"+ )}+ </div>+ <div className="textinfolabel">+ {t(+ "settings.general.workspace.default-landing-page.sql-editor.description"+ )}+ </div></div>- </div>- </label>+ </label>+ </div></div>- </div>- {/* External URL */}- <div>- <label className="flex items-center gap-x-2">- <span className="font-medium">- {t("settings.general.workspace.external-url.self")}- </span>- </label>- <div className="mb-3 text-sm text-gray-400">- {t("settings.general.workspace.external-url.description")}{" "}- <a- href="https://docs.bytebase.com/get-started/self-host/external-url?source=console"- target="_blank"- rel="noopener noreferrer"- className="text-accent hover:underline"- >- {t("common.learn-more")}- </a>- </div>- {externalUrlFromFlag && !isSaaSMode && (- <div className="mb-3 p-3 bg-blue-50 text-blue-700 text-sm rounded-xs">- {t("settings.general.workspace.external-url.cannot-edit-flag")}+ {/* External URL */}+ <div>+ <label className="flex items-center gap-x-2">+ <span className="font-medium">+ {t("settings.general.workspace.external-url.self")}+ </span>+ </label>+ <div className="mb-3 text-sm text-gray-400">+ {t("settings.general.workspace.external-url.description")}{" "}+ <a+ href="https://docs.bytebase.com/get-started/self-host/external-url?source=console"+ target="_blank"+ rel="noopener noreferrer"+ className="text-accent hover:underline"+ >+ {t("common.learn-more")}+ </a></div>- )}- <Input- value={state.externalUrl}- className="mb-4 w-full"- disabled={!canEdit || isSaaSMode || externalUrlFromFlag}- onChange={(e) =>- setState((s) => ({ ...s, externalUrl: e.target.value }))- }- />+ {externalUrlFromFlag && !isSaaSMode && (+ <div className="mb-3 p-3 bg-blue-50 text-blue-700 text-sm rounded-xs">+ {t(+ "settings.general.workspace.external-url.cannot-edit-flag"+ )}+ </div>+ )}+ <Input+ value={state.externalUrl}+ className="mb-4 w-full"+ disabled={!canEdit || isSaaSMode || externalUrlFromFlag}+ onChange={(e) =>+ setState((s) => ({ ...s, externalUrl: e.target.value }))+ }+ />+ </div></div>- </div>+ </PermissionGuard>{/* Modal after switching to Editor mode */}{showModal && (@@ -228,7 +238,7 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(className="fixed inset-0 bg-black/40"onClick={() => setShowModal(false)}/>- <div className="relative bg-white rounded-md shadow-lg p-6 max-w-md w-full mx-4 flex flex-col gap-2">+ <div className="relative bg-white rounded-sm shadow-lg p-6 max-w-md w-full mx-4 flex flex-col gap-2"><h2 className="text-lg font-semibold">{t("settings.general.workspace.config-updated")}</h2>diff --git a/frontend/src/react/pages/settings/general/SQLEditorSection.tsx b/frontend/src/react/pages/settings/general/SQLEditorSection.tsxindex 9a4edd265a..114828037d 100644--- a/frontend/src/react/pages/settings/general/SQLEditorSection.tsx+++ b/frontend/src/react/pages/settings/general/SQLEditorSection.tsx@@ -1,7 +1,6 @@import { create } from "@bufbuild/protobuf";import { DurationSchema, FieldMaskSchema } from "@bufbuild/protobuf/wkt";import { isEqual } from "lodash-es";-import { Sparkles } from "lucide-react";import {type ChangeEvent,forwardRef,@@ -12,6 +11,8 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";+import { FeatureBadge } from "@/react/components/FeatureBadge";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { useVueState } from "@/react/hooks/useVueState";import {DEFAULT_MAX_RESULT_SIZE_IN_MB,@@ -43,17 +44,6 @@ interface LocalState {maxQueryTimeInSeconds: number;}-function FeatureBadge({ feature }: { feature: PlanFeature }) {- const subscriptionStore = useSubscriptionV1Store();- const hasFeature = useVueState(() => subscriptionStore.hasFeature(feature));- if (hasFeature) return null;- return (- <span className="text-accent">- <Sparkles className="w-5 h-5" />- </span>- );-}-export const SQLEditorSection = forwardRef<SectionHandle,SQLEditorSectionProps@@ -121,6 +111,15 @@ export const SQLEditorSection = forwardRef<const [state, setState] = useState<LocalState>(getInitialState);+ // Re-sync state when underlying data loads (e.g. after policy fetch on mount).+ const prevPolicyRef = useRef(policyPayload);+ useEffect(() => {+ if (prevPolicyRef.current !== policyPayload) {+ prevPolicyRef.current = policyPayload;+ setState(getInitialState());+ }+ }, [policyPayload, getInitialState]);+const isDirty = useCallback(() => !isEqual(state, getInitialState()),[state, getInitialState]@@ -216,162 +215,184 @@ export const SQLEditorSection = forwardRef<</div><div className="flex-1 lg:px-4 flex flex-col gap-y-6">{/* Data Export toggle */}- <div className="w-full inline-flex items-center gap-x-2">- <input- type="checkbox"- checked={!state.disableExport}- disabled={!canUpdatePolicy || !hasQueryPolicyFeature}- onChange={(e) => handleToggle("disableExport", !e.target.checked)}- className="h-4 w-4"- />- <span className="font-medium">- {t("settings.general.workspace.data-export")}- </span>- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />- </div>+ <PermissionGuard permissions={["bb.policies.update"]} display="block">+ <div className="w-full inline-flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={!state.disableExport}+ disabled={!canUpdatePolicy || !hasQueryPolicyFeature}+ onChange={(e) => handleToggle("disableExport", !e.target.checked)}+ className="h-4 w-4"+ />+ <span className="font-medium">+ {t("settings.general.workspace.data-export")}+ </span>+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />+ </div>+ </PermissionGuard>{/* Data Copy toggle */}- <div className="w-full inline-flex items-center gap-x-2">- <input- type="checkbox"- checked={!state.disableCopyData}- disabled={!canUpdatePolicy || !hasRestrictCopyingDataFeature}- onChange={(e) => handleToggle("disableCopyData", !e.target.checked)}- className="h-4 w-4"- />- <span className="font-medium">- {t("settings.general.workspace.data-copy")}- </span>- <FeatureBadge feature={PlanFeature.FEATURE_RESTRICT_COPYING_DATA} />- </div>-- {/* Allow Admin Data Source toggle */}- <div>+ <PermissionGuard permissions={["bb.policies.update"]} display="block"><div className="w-full inline-flex items-center gap-x-2"><inputtype="checkbox"- checked={state.allowAdminDataSource}- disabled={!canUpdatePolicy || !hasQueryPolicyFeature}+ checked={!state.disableCopyData}+ disabled={!canUpdatePolicy || !hasRestrictCopyingDataFeature}onChange={(e) =>- handleToggle("allowAdminDataSource", e.target.checked)+ handleToggle("disableCopyData", !e.target.checked)}className="h-4 w-4"/><span className="font-medium">- {t("settings.general.workspace.allow-admin-data-source.self")}+ {t("settings.general.workspace.data-copy")}+ </span>+ <FeatureBadge feature={PlanFeature.FEATURE_RESTRICT_COPYING_DATA} />+ </div>+ </PermissionGuard>++ {/* Allow Admin Data Source toggle */}+ <PermissionGuard permissions={["bb.policies.update"]} display="block">+ <div>+ <div className="w-full inline-flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={state.allowAdminDataSource}+ disabled={!canUpdatePolicy || !hasQueryPolicyFeature}+ onChange={(e) =>+ handleToggle("allowAdminDataSource", e.target.checked)+ }+ className="h-4 w-4"+ />+ <span className="font-medium">+ {t("settings.general.workspace.allow-admin-data-source.self")}+ </span>+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />+ </div>+ <span className="mt-1 text-sm text-gray-400">+ {t(+ "settings.general.workspace.allow-admin-data-source.description"+ )}</span>- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} /></div>- <span className="mt-1 text-sm text-gray-400">- {t(- "settings.general.workspace.allow-admin-data-source.description"- )}- </span>- </div>+ </PermissionGuard>{/* Maximum SQL Result Size (MB) */}{canGetWorkspaceProfile && (+ <PermissionGuard+ permissions={["bb.settings.setWorkspaceProfile"]}+ display="block"+ >+ <div>+ <p className="font-medium flex flex-row justify-start items-center">+ <span className="mr-2">+ {t("settings.general.workspace.maximum-sql-result.size.self")}+ </span>+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />+ </p>+ <p className="text-sm text-gray-400 mt-1">+ {t(+ "settings.general.workspace.maximum-sql-result.size.description"+ )}{" "}+ <span className="font-semibold! textinfolabel">+ {t(+ "settings.general.workspace.maximum-sql-result.size.default",+ { limit: DEFAULT_MAX_RESULT_SIZE_IN_MB }+ )}+ </span>+ </p>+ <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">+ <div className="relative w-60">+ <input+ type="number"+ value={state.maximumResultSize}+ min={1}+ disabled={!hasQueryPolicyFeature || !canSetWorkspaceProfile}+ onChange={(e) => handleNumberInput("maximumResultSize", e)}+ className="w-full rounded-xs border border-control-border px-3 py-1.5 pr-12 text-sm disabled:opacity-50"+ />+ <span className="absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500">+ MB+ </span>+ </div>+ </div>+ </div>+ </PermissionGuard>+ )}++ {/* Maximum SQL Result Rows */}+ <PermissionGuard permissions={["bb.policies.update"]} display="block"><div><p className="font-medium flex flex-row justify-start items-center"><span className="mr-2">- {t("settings.general.workspace.maximum-sql-result.size.self")}+ {t("settings.general.workspace.maximum-sql-result.rows.self")}</span><FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} /></p><p className="text-sm text-gray-400 mt-1">{t(- "settings.general.workspace.maximum-sql-result.size.description"+ "settings.general.workspace.maximum-sql-result.rows.description")}{" "}<span className="font-semibold! textinfolabel">- {t(- "settings.general.workspace.maximum-sql-result.size.default",- { limit: DEFAULT_MAX_RESULT_SIZE_IN_MB }- )}+ {t("settings.general.workspace.no-limit")}</span></p><div className="mt-3 w-full flex flex-row justify-start items-center gap-4"><div className="relative w-60"><inputtype="number"- value={state.maximumResultSize}- min={1}- disabled={!hasQueryPolicyFeature || !canSetWorkspaceProfile}- onChange={(e) => handleNumberInput("maximumResultSize", e)}- className="w-full rounded-xs border border-control-border px-3 py-1.5 pr-12 text-sm disabled:opacity-50"+ value={state.maximumResultRows}+ min={0}+ disabled={!hasQueryPolicyFeature || !canUpdatePolicy}+ onChange={(e) => handleNumberInput("maximumResultRows", e)}+ className="w-full rounded-xs border border-control-border px-3 py-1.5 pr-16 text-sm disabled:opacity-50"/><span className="absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500">- MB+ {t("settings.general.workspace.maximum-sql-result.rows.rows")}</span></div></div></div>- )}-- {/* Maximum SQL Result Rows */}- <div>- <p className="font-medium flex flex-row justify-start items-center">- <span className="mr-2">- {t("settings.general.workspace.maximum-sql-result.rows.self")}- </span>- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />- </p>- <p className="text-sm text-gray-400 mt-1">- {t(- "settings.general.workspace.maximum-sql-result.rows.description"- )}{" "}- <span className="font-semibold! textinfolabel">- {t("settings.general.workspace.no-limit")}- </span>- </p>- <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">- <div className="relative w-60">- <input- type="number"- value={state.maximumResultRows}- min={0}- disabled={!hasQueryPolicyFeature || !canUpdatePolicy}- onChange={(e) => handleNumberInput("maximumResultRows", e)}- className="w-full rounded-xs border border-control-border px-3 py-1.5 pr-16 text-sm disabled:opacity-50"- />- <span className="absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500">- {t("settings.general.workspace.maximum-sql-result.rows.rows")}- </span>- </div>- </div>- </div>+ </PermissionGuard>{/* Query Timeout (seconds) */}- <div>- <p className="font-medium flex flex-row justify-start items-center">- <span className="mr-2">- {t("settings.general.workspace.query-data-policy.timeout.self")}- </span>- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />- </p>- <p className="text-sm text-gray-400 mt-1">- {t(- "settings.general.workspace.query-data-policy.timeout.description"- )}{" "}- <span className="font-semibold! textinfolabel">- {t("settings.general.workspace.no-limit")}- </span>- </p>- <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">- <div className="relative w-60">- <input- type="number"- value={state.maxQueryTimeInSeconds}- min={0}- disabled={!hasQueryPolicyFeature || !canSetWorkspaceProfile}- onChange={(e) => handleNumberInput("maxQueryTimeInSeconds", e)}- className="w-full rounded-xs border border-control-border px-3 py-1.5 pr-20 text-sm disabled:opacity-50"- />- <span className="absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500">- {t("settings.general.workspace.query-data-policy.seconds")}+ <PermissionGuard+ permissions={["bb.settings.setWorkspaceProfile"]}+ display="block"+ >+ <div>+ <p className="font-medium flex flex-row justify-start items-center">+ <span className="mr-2">+ {t("settings.general.workspace.query-data-policy.timeout.self")}+ </span>+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />+ </p>+ <p className="text-sm text-gray-400 mt-1">+ {t(+ "settings.general.workspace.query-data-policy.timeout.description"+ )}{" "}+ <span className="font-semibold! textinfolabel">+ {t("settings.general.workspace.no-limit")}</span>+ </p>+ <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">+ <div className="relative w-60">+ <input+ type="number"+ value={state.maxQueryTimeInSeconds}+ min={0}+ disabled={!hasQueryPolicyFeature || !canSetWorkspaceProfile}+ onChange={(e) =>+ handleNumberInput("maxQueryTimeInSeconds", e)+ }+ className="w-full rounded-xs border border-control-border px-3 py-1.5 pr-20 text-sm disabled:opacity-50"+ />+ <span className="absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500">+ {t("settings.general.workspace.query-data-policy.seconds")}+ </span>+ </div></div></div>- </div>+ </PermissionGuard></div></div>);diff --git a/frontend/src/react/pages/settings/general/SecuritySection.tsx b/frontend/src/react/pages/settings/general/SecuritySection.tsxindex 4555a10ecb..b9fa9e949a 100644--- a/frontend/src/react/pages/settings/general/SecuritySection.tsx+++ b/frontend/src/react/pages/settings/general/SecuritySection.tsx@@ -11,11 +11,15 @@ import {useState,} from "react";import { useTranslation } from "react-i18next";+import { FeatureBadge } from "@/react/components/FeatureBadge";+import {+ PermissionGuard,+ usePermissionCheck,+} from "@/react/components/PermissionGuard";import { useVueState } from "@/react/hooks/useVueState";import { useSubscriptionV1Store } from "@/store";import { useSettingV1Store } from "@/store/modules/v1/setting";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";-import { hasWorkspacePermissionV2 } from "@/utils";import type { SectionHandle } from "./useSettingSection";const DEFAULT_EXPIRATION_DAYS = 90;@@ -47,7 +51,7 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(PlanFeature.FEATURE_USER_EMAIL_DOMAIN_RESTRICTION));- const canEdit = hasWorkspacePermissionV2("bb.settings.setWorkspaceProfile");+ const [canEdit] = usePermissionCheck(["bb.settings.setWorkspaceProfile"]);const getInitialState = useCallback((): SecurityState => {const profile = settingV1Store.workspaceProfile;@@ -207,172 +211,183 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(<div className="text-left lg:w-1/4"><h1 className="text-2xl font-bold">{title}</h1></div>- <div className="flex-1 lg:px-4 flex flex-col gap-y-6">- {/* Watermark */}- <div>- <div className="flex items-center gap-x-2">- <input- type="checkbox"- checked={state.enableWatermark}- disabled={!canEdit || !hasWatermarkFeature}- onChange={(e) =>- setState((prev) => ({- ...prev,- enableWatermark: e.target.checked,- }))- }- />- <span className="font-medium">- {t("settings.general.workspace.watermark.enable")}- </span>- </div>- <div className="mt-1 text-sm text-gray-400">- {t("settings.general.workspace.watermark.description")}+ <PermissionGuard+ permissions={["bb.settings.setWorkspaceProfile"]}+ display="block"+ >+ <div className="flex-1 lg:px-4 flex flex-col gap-y-6">+ {/* Watermark */}+ <div>+ <div className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={state.enableWatermark}+ disabled={!canEdit || !hasWatermarkFeature}+ onChange={(e) =>+ setState((prev) => ({+ ...prev,+ enableWatermark: e.target.checked,+ }))+ }+ />+ <span className="font-medium">+ {t("settings.general.workspace.watermark.enable")}+ </span>+ <FeatureBadge feature={PlanFeature.FEATURE_WATERMARK} />+ </div>+ <div className="mt-1 text-sm text-gray-400">+ {t("settings.general.workspace.watermark.description")}+ </div></div>- </div>- {/* Maximum Role Expiration */}- <div>- <p className="font-medium flex flex-row justify-start items-center">- <span className="mr-2">- {t("settings.general.workspace.maximum-role-expiration.self")}- </span>- </p>- <p className="text-sm text-gray-400 mt-1">- {t(- "settings.general.workspace.maximum-role-expiration.description"- )}- </p>- <div className="mt-3 w-full flex flex-row">- <div className="flex items-center gap-4">- <div className="relative w-60">- <input- type="number"- className="w-full rounded-xs border border-control-border px-3 py-1.5 pr-14 text-sm disabled:opacity-50"- value={state.inputValue}- min={1}- step={1}- disabled={!canEdit || state.neverExpire}- onChange={(e) => {- const val = Math.max(- 1,- Math.floor(Number(e.target.value))- );- if (!Number.isNaN(val)) {- setState((prev) => ({ ...prev, inputValue: val }));+ {/* Maximum Role Expiration */}+ <div>+ <p className="font-medium flex flex-row justify-start items-center">+ <span className="mr-2">+ {t("settings.general.workspace.maximum-role-expiration.self")}+ </span>+ </p>+ <p className="text-sm text-gray-400 mt-1">+ {t(+ "settings.general.workspace.maximum-role-expiration.description"+ )}+ </p>+ <div className="mt-3 w-full flex flex-row">+ <div className="flex items-center gap-4">+ <div className="relative w-60">+ <input+ type="number"+ className="w-full rounded-xs border border-control-border px-3 py-1.5 pr-14 text-sm disabled:opacity-50"+ value={state.inputValue}+ min={1}+ step={1}+ disabled={!canEdit || state.neverExpire}+ onChange={(e) => {+ const val = Math.max(+ 1,+ Math.floor(Number(e.target.value))+ );+ if (!Number.isNaN(val)) {+ setState((prev) => ({ ...prev, inputValue: val }));+ }+ }}+ />+ <span className="absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500 pointer-events-none">+ {t(+ "settings.general.workspace.maximum-role-expiration.days"+ )}+ </span>+ </div>+ <label className="flex items-center gap-x-2">+ <input+ type="checkbox"+ checked={state.neverExpire}+ disabled={!canEdit}+ onChange={(e) =>+ setState((prev) => ({+ ...prev,+ neverExpire: e.target.checked,+ }))}- }}- />- <span className="absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500 pointer-events-none">- {t(- "settings.general.workspace.maximum-role-expiration.days"- )}- </span>+ />+ <span>+ {t(+ "settings.general.workspace.maximum-role-expiration.never-expires"+ )}+ </span>+ </label></div>- <label className="flex items-center gap-x-2">- <input- type="checkbox"- checked={state.neverExpire}- disabled={!canEdit}- onChange={(e) =>- setState((prev) => ({- ...prev,- neverExpire: e.target.checked,- }))- }- />- <span>- {t(- "settings.general.workspace.maximum-role-expiration.never-expires"- )}- </span>- </label></div></div>- </div>- {/* Domain Restriction */}- <div>- <h3- id="domain-restriction"- className="font-medium flex flex-row justify-start items-center"- >- <span className="mr-2">- {t("settings.general.workspace.domain-restriction.self")}- </span>- </h3>- <p className="text-sm text-gray-400 mt-1">- {t("settings.general.workspace.domain-restriction.description")}- </p>- <div className="w-full flex flex-col gap-2 mt-2">- {/* Domain tags + input */}- <div className="flex flex-wrap items-center gap-2">- {state.domains.map((domain, index) => (- <span- key={index}- className="inline-flex items-center gap-1 rounded-xs bg-gray-100 px-2 py-1.5 text-sm"- >- {domain}- <button- type="button"- className="text-gray-500 hover:text-gray-700 disabled:opacity-50"- disabled={!canEdit}- onClick={() => removeDomain(index)}+ {/* Domain Restriction */}+ <div>+ <h3+ id="domain-restriction"+ className="font-medium flex flex-row justify-start items-center"+ >+ <span className="mr-2">+ {t("settings.general.workspace.domain-restriction.self")}+ </span>+ </h3>+ <p className="text-sm text-gray-400 mt-1">+ {t("settings.general.workspace.domain-restriction.description")}+ </p>+ <div className="w-full flex flex-col gap-2 mt-2">+ {/* Domain tags + input */}+ <div className="flex flex-wrap items-center gap-2">+ {state.domains.map((domain, index) => (+ <span+ key={index}+ className="inline-flex items-center gap-1 rounded-xs bg-gray-100 px-2 py-1.5 text-sm">- <X className="h-3.5 w-3.5" />- </button>- </span>- ))}- <input- type="text"- className="min-w-[20rem] rounded-xs border border-control-border px-3 py-1.5 text-sm disabled:opacity-50"- placeholder={t(- "settings.general.workspace.domain-restriction.domain-input-placeholder"- )}- value={domainInput}- disabled={!canEdit}- onChange={(e) => setDomainInput(e.target.value)}- onKeyDown={handleDomainKeyDown}- onBlur={addDomain}- />- </div>-- {/* Enforce restriction checkbox */}- <div className="w-full flex flex-row justify-between items-center">- <label className="flex items-start gap-x-2">+ {domain}+ <button+ type="button"+ className="text-gray-500 hover:text-gray-700 disabled:opacity-50"+ disabled={!canEdit}+ onClick={() => removeDomain(index)}+ >+ <X className="h-3.5 w-3.5" />+ </button>+ </span>+ ))}<input- type="checkbox"- className="mt-1"- checked={state.enableRestriction}- disabled={- !canEdit ||- validDomains.length === 0 ||- !hasDomainRestrictionFeature- }- onChange={(e) =>- setState((prev) => ({- ...prev,- enableRestriction: e.target.checked,- }))- }+ type="text"+ className="min-w-[20rem] rounded-xs border border-control-border px-3 py-1.5 text-sm disabled:opacity-50"+ placeholder={t(+ "settings.general.workspace.domain-restriction.domain-input-placeholder"+ )}+ value={domainInput}+ disabled={!canEdit}+ onChange={(e) => setDomainInput(e.target.value)}+ onKeyDown={handleDomainKeyDown}+ onBlur={addDomain}/>- <div>- <div className="font-medium">- {t(- "settings.general.workspace.domain-restriction.members-restriction.self"- )}+ </div>++ {/* Enforce restriction checkbox */}+ <div className="w-full flex flex-row justify-between items-center">+ <label className="flex items-start gap-x-2">+ <input+ type="checkbox"+ className="mt-1"+ checked={state.enableRestriction}+ disabled={+ !canEdit ||+ validDomains.length === 0 ||+ !hasDomainRestrictionFeature+ }+ onChange={(e) =>+ setState((prev) => ({+ ...prev,+ enableRestriction: e.target.checked,+ }))+ }+ />+ <div>+ <div className="font-medium flex items-center gap-x-2">+ {t(+ "settings.general.workspace.domain-restriction.members-restriction.self"+ )}+ <FeatureBadge+ feature={+ PlanFeature.FEATURE_USER_EMAIL_DOMAIN_RESTRICTION+ }+ />+ </div>+ <p className="text-sm text-gray-400 leading-tight">+ {t(+ "settings.general.workspace.domain-restriction.members-restriction.description"+ )}+ </p></div>- <p className="text-sm text-gray-400 leading-tight">- {t(- "settings.general.workspace.domain-restriction.members-restriction.description"- )}- </p>- </div>- </label>+ </label>+ </div></div></div></div>- </div>+ </PermissionGuard></div>);}