Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add missing permission guard (#19927)
ecmadao3ea923592f54
diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.goindex 7d38bbade7..7d1a41d6af 100644--- a/backend/api/v1/user_service.go+++ b/backend/api/v1/user_service.go@@ -256,6 +256,10 @@ func (s *UserService) CreateUser(ctx context.Context, request *connect.Request[vreturn nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to generate password hash"))}+ if err := s.preAddUserGuard(ctx, workspaceID); err != nil {+ return nil, err+ }+user, err := s.store.CreateUser(ctx, &store.UserMessage{Email: email,Name: request.Msg.User.Title,@@ -628,6 +632,10 @@ func (s *UserService) UndeleteUser(ctx context.Context, request *connect.Requestreturn nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("user %q is already active", email))}+ if err := s.preAddUserGuard(ctx, workspaceID); err != nil {+ return nil, err+ }+user, err = s.store.UpdateUser(ctx, user, &store.UpdateUserMessage{Delete: &undeletePatch})if err != nil {return nil, connect.NewError(connect.CodeInternal, err)@@ -883,8 +891,9 @@ func countUsersInIamPolicy(ctx context.Context, s *store.Store, workspaceID strireturn len(emails), nil}-// userCountGuard checks the seat limit against an IAM policy. If policy is nil,-// reads the current workspace IAM policy.+// userCountGuard checks seat limits before adding a new IAM member (e.g. SSO login).+// Uses >= because the new user has not been counted yet.+// If policy is nil, reads the current workspace IAM policy.func userCountGuard(ctx context.Context, s *store.Store, licenseService *enterprise.LicenseService, workspaceID string, policy *storepb.IamPolicy, saas bool) error {if policy == nil {p, err := s.GetWorkspaceIamPolicy(ctx, workspaceID)@@ -898,12 +907,37 @@ func userCountGuard(ctx context.Context, s *store.Store, licenseService *enterprif err != nil {return connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to count users in IAM policy"))}- if count > userLimit {- return connect.NewError(connect.CodeResourceExhausted, errors.Errorf("workspace has %d users, exceeding the limit of %d", count, userLimit))+ if count >= userLimit {+ return connect.NewError(connect.CodeResourceExhausted, errors.Errorf("workspace has %d users, reaching the limit of %d", count, userLimit))}return nil}+// preAddUserGuard checks seat limits before creating or undeleting a principal.+// Only enforces when the IAM policy contains allUsers, because without allUsers+// a new principal does not occupy a seat until explicitly added to IAM.+func (s *UserService) preAddUserGuard(ctx context.Context, workspaceID string) error {+ p, err := s.store.GetWorkspaceIamPolicy(ctx, workspaceID)+ if err != nil {+ return connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to get workspace IAM policy"))+ }+ if !policyContainsAllUsers(p.Policy) {+ return nil+ }+ return userCountGuard(ctx, s.store, s.licenseService, workspaceID, p.Policy, s.profile.SaaS)+}++func policyContainsAllUsers(policy *storepb.IamPolicy) bool {+ for _, binding := range policy.Bindings {+ for _, member := range binding.Members {+ if member == common.AllUsers {+ return true+ }+ }+ }+ return false+}+func isUserWorkspaceAdmin(ctx context.Context, stores *store.Store, user *store.UserMessage, workspaceID string) (bool, error) {workspacePolicy, err := stores.GetWorkspaceIamPolicy(ctx, workspaceID)if err != nil {diff --git a/backend/api/v1/workspace_service.go b/backend/api/v1/workspace_service.goindex fce9e61a13..7e19472dc7 100644--- a/backend/api/v1/workspace_service.go+++ b/backend/api/v1/workspace_service.go@@ -229,8 +229,20 @@ func (s *WorkspaceService) SetIamPolicy(ctx context.Context, req *connect.Reques}// Guard: count members in the new policy BEFORE saving.- if err := userCountGuard(ctx, s.store, s.licenseService, workspaceID, iamPolicy, s.profile.SaaS); err != nil {- return nil, err+ // Allow over-limit workspaces to reduce seats incrementally (e.g. after license downgrade).+ userLimit := s.licenseService.GetUserLimit(ctx, workspaceID)+ newCount, err := countUsersInIamPolicy(ctx, s.store, workspaceID, iamPolicy, s.profile.SaaS)+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to count users in IAM policy"))+ }+ if newCount > userLimit {+ oldCount, err := countUsersInIamPolicy(ctx, s.store, workspaceID, policyMessage.Policy, s.profile.SaaS)+ if err != nil {+ return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to count users in current IAM policy"))+ }+ if newCount >= oldCount {+ return nil, connect.NewError(connect.CodeResourceExhausted, errors.Errorf("workspace has %d users, exceeding the limit of %d", newCount, userLimit))+ }}payloadBytes, err := protojson.Marshal(iamPolicy)diff --git a/backend/store/group.go b/backend/store/group.goindex bb7f93ec63..7550b71d29 100644--- a/backend/store/group.go+++ b/backend/store/group.go@@ -316,12 +316,12 @@ func (s *Store) DeleteGroup(ctx context.Context, workspace string, id string) erreturn err}- group := &GroupMessage{ID: id}+ group := &GroupMessage{ID: id, Workspace: workspace}if email.Valid {group.Email = email.String}s.groupCache.Remove(getGroupCacheKey(workspace, group))- s.removeGroupMembersCache(group.Workspace, group)+ s.removeGroupMembersCache(workspace, group)return nil}diff --git a/docs/plans/2026-04-08-react-migration-playbook.md b/docs/plans/2026-04-08-react-migration-playbook.mdindex e0d5dad5ba..e10eb2e8ee 100644--- a/docs/plans/2026-04-08-react-migration-playbook.md+++ b/docs/plans/2026-04-08-react-migration-playbook.md@@ -235,6 +235,8 @@ Renders a user avatar with color-coded initials.### Permission & Feature Guards+**IMPORTANT**: When migrating Vue pages to React, always check the Vue 3.16.1 source for `FeatureBadge`, `FeatureAttention`, `PermissionGuardWrapper`, and `ComponentPermissionGuard` usage. React pages must have feature parity — never just `disabled={!canX}` without the guard wrapper.+| Component | Purpose | Usage ||-----------|---------|-------|| `FeatureBadge` | Sparkles icon + tooltip for plan-gated features | Next to labels; inside buttons with `clickable={false} className="mr-1 text-white inline-flex"` |@@ -242,6 +244,33 @@ Renders a user avatar with color-coded initials.| `PermissionGuard` | Tooltip wrapper for missing permissions | Inline (buttons): default; Block (sections): `display="block"` || `ComponentPermissionGuard` | Error alert for gated components | Replaces content with permission error |+**PermissionGuard** supports two patterns:++```tsx+// 1. Static children — use usePermissionCheck for disabled state+const [canEdit] = usePermissionCheck(["bb.settings.set"]);+<PermissionGuard permissions={["bb.settings.set"]}>+ <Button disabled={!canEdit}>Edit</Button>+</PermissionGuard>++// 2. Render-prop children — like Vue PermissionGuardWrapper slot props+<PermissionGuard permissions={["bb.projects.update"]} project={project}>+ {({ disabled }) => <Button disabled={disabled}>Save</Button>}+</PermissionGuard>+```++**ComponentPermissionGuard** replaces entire sections when permissions are missing:++```tsx+<ComponentPermissionGuard+ permissions={["bb.accessGrants.list"]}+ project={project}+ className="mx-4"+>+ <AccessGrantsTable />+</ComponentPermissionGuard>+```+### Input HeightsAll inputs and buttons in the same row: **`h-9`**.diff --git a/frontend/src/react/components/AuditLogTable.tsx b/frontend/src/react/components/AuditLogTable.tsxindex 75fc88023e..b5d915cb56 100644--- a/frontend/src/react/components/AuditLogTable.tsx+++ b/frontend/src/react/components/AuditLogTable.tsx@@ -4,8 +4,6 @@ import { AnySchema } from "@bufbuild/protobuf/wkt";import dayjs from "dayjs";import utc from "dayjs/plugin/utc";import {- ArrowRight,- Calendar,ChevronDown,Download,ExternalLink,@@ -22,8 +20,8 @@ import {type SearchParams,} from "@/react/components/AdvancedSearch";import { FeatureAttention } from "@/react/components/FeatureAttention";+import { TimeRangePicker } from "@/react/components/TimeRangePicker";import { Button } from "@/react/components/ui/button";-import { Input } from "@/react/components/ui/input";import { PagedTableFooter } from "@/react/hooks/usePagedData";import {getPageSizeOptions,@@ -234,116 +232,6 @@ function JSONStringView({ jsonString }: { jsonString: string }) {);}-// ============================================================-// TimeRangePicker-// ============================================================--function TimeRangePicker({- params,- onParamsChange,-}: {- params: SearchParams;- onParamsChange: (params: SearchParams) => void;-}) {- const { t } = useTranslation();- const [showPicker, setShowPicker] = useState(false);- const containerRef = useRef<HTMLDivElement>(null);-- useEffect(() => {- const handler = (e: MouseEvent) => {- if (- containerRef.current &&- !containerRef.current.contains(e.target as Node)- ) {- setShowPicker(false);- }- };- document.addEventListener("mousedown", handler);- return () => document.removeEventListener("mousedown", handler);- }, []);-- const createdScope = params.scopes.find((s) => s.id === "created");- const [fromTs, toTs] = useMemo(() => {- if (!createdScope) return [undefined, undefined];- const parts = createdScope.value.split(",");- if (parts.length !== 2) return [undefined, undefined];- return [parseInt(parts[0], 10), parseInt(parts[1], 10)];- }, [createdScope]);-- const fromDatetime = fromTs- ? dayjs(fromTs).format("YYYY-MM-DDTHH:mm:ss")- : "";- const toDatetime = toTs ? dayjs(toTs).format("YYYY-MM-DDTHH:mm:ss") : "";-- const displayFrom = fromTs ? dayjs(fromTs).format("YYYY-MM-DD HH:mm:ss") : "";- const displayTo = toTs ? dayjs(toTs).format("YYYY-MM-DD HH:mm:ss") : "";-- const updateRange = useCallback(- (from: string, to: string) => {- const fromVal = from ? dayjs(from).valueOf() : undefined;- const toVal = to ? dayjs(to).valueOf() : undefined;- const scopes = params.scopes.filter((s) => s.id !== "created");- if (fromVal !== undefined && toVal !== undefined) {- scopes.push({- id: "created",- value: `${fromVal},${toVal}`,- readonly: true,- });- }- onParamsChange({ ...params, scopes });- },- [params, onParamsChange]- );-- return (- <div ref={containerRef} className="relative shrink-0">- <button- className="h-9 flex items-center gap-x-2 border border-control-border rounded-xs px-3 text-sm hover:bg-control-bg whitespace-nowrap"- onClick={() => setShowPicker(!showPicker)}- >- {displayFrom && displayTo ? (- <>- <span>{displayFrom}</span>- <ArrowRight className="w-3.5 h-3.5 text-control-light shrink-0" />- <span>{displayTo}</span>- </>- ) : (- <span className="text-control-placeholder">{t("common.select")}</span>- )}- <Calendar className="w-4 h-4 text-control-light ml-1 shrink-0" />- </button>- {showPicker && (- <div className="absolute right-0 top-[42px] bg-white border border-control-border rounded-sm shadow-lg z-50 p-3 flex flex-col gap-y-2 min-w-[300px]">- <div className="flex items-center gap-x-2">- <label className="text-sm text-control-light whitespace-nowrap w-10">- {t("common.from")}- </label>- <Input- type="datetime-local"- step="1"- className="flex-1"- value={fromDatetime}- onChange={(e) => updateRange(e.target.value, toDatetime)}- />- </div>- <div className="flex items-center gap-x-2">- <label className="text-sm text-control-light whitespace-nowrap w-10">- {t("common.to")}- </label>- <Input- type="datetime-local"- step="1"- className="flex-1"- value={toDatetime}- onChange={(e) => updateRange(fromDatetime, e.target.value)}- />- </div>- </div>- )}- </div>- );-}-// ============================================================// ExportDropdown// ============================================================diff --git a/frontend/src/react/components/IssueTable.tsx b/frontend/src/react/components/IssueTable.tsxindex 80f65f1f31..76f4fb3b3e 100644--- a/frontend/src/react/components/IssueTable.tsx+++ b/frontend/src/react/components/IssueTable.tsx@@ -1,6 +1,5 @@import { create } from "@bufbuild/protobuf";-import dayjs from "dayjs";-import { ArrowUpDown, Calendar, Check, Loader2, X } from "lucide-react";+import { ArrowUpDown, Check, Loader2, X } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { issueServiceClientConnect } from "@/connect";@@ -11,8 +10,8 @@ import {type ValueOption,} from "@/react/components/AdvancedSearch";import { HumanizeTs } from "@/react/components/HumanizeTs";+import { TimeRangePicker } from "@/react/components/TimeRangePicker";import { Button } from "@/react/components/ui/button";-import { Input } from "@/react/components/ui/input";import { Tooltip } from "@/react/components/ui/tooltip";import { useClickOutside } from "@/react/hooks/useClickOutside";import { useEscapeKey } from "@/react/hooks/useEscapeKey";@@ -47,7 +46,6 @@ import {extractProjectResourceName,getHighlightHTMLByRegExp,getIssueRoute,- getTsRangeFromSearchParams,getValueFromSearchParams,getValuesFromSearchParams,projectOfIssue,@@ -88,126 +86,6 @@ export function IssueSearchBar({);}-// ===========================================================================-// TimeRangePicker-// ===========================================================================--function TimeRangePicker({- params,- onParamsChange,-}: {- params: SearchParams;- onParamsChange: (p: SearchParams) => void;-}) {- const { t } = useTranslation();- const [from, setFrom] = useState("");- const [to, setTo] = useState("");- const [open, setOpen] = useState(false);- const containerRef = useRef<HTMLDivElement>(null);- useClickOutside(containerRef, open, () => setOpen(false));-- const timeRange = useMemo(- () => getTsRangeFromSearchParams(params as VueSearchParams, "created"),- [params]- );-- const hasRange = !!timeRange;-- useEffect(() => {- if (timeRange) {- setFrom(dayjs(timeRange[0]).format("YYYY-MM-DD"));- setTo(dayjs(timeRange[1]).format("YYYY-MM-DD"));- } else {- setFrom("");- setTo("");- }- }, [timeRange]);-- const applyRange = useCallback(() => {- const fromTs = from ? dayjs(from).startOf("day").valueOf() : null;- const toTs = to ? dayjs(to).endOf("day").valueOf() : null;- const updated = upsertScope({- params: params as VueSearchParams,- scopes: {- id: "created",- value: fromTs && toTs ? `${fromTs},${toTs}` : "",- },- });- onParamsChange({- query: updated.query,- scopes: updated.scopes.map((s) => ({- id: s.id,- value: s.value,- readonly: (s as VueSearchScope & { readonly?: boolean }).readonly,- })),- });- setOpen(false);- }, [from, to, params, onParamsChange]);-- const clearRange = useCallback(() => {- const updated = upsertScope({- params: params as VueSearchParams,- scopes: { id: "created", value: "" },- });- onParamsChange({- query: updated.query,- scopes: updated.scopes.map((s) => ({- id: s.id,- value: s.value,- readonly: (s as VueSearchScope & { readonly?: boolean }).readonly,- })),- });- setOpen(false);- }, [params, onParamsChange]);-- return (- <div ref={containerRef} className="relative">- <Button- variant="ghost"- size="sm"- className={cn(- hasRange- ? "text-accent! hover:text-accent"- : "text-control-placeholder hover:text-control"- )}- onClick={() => setOpen(!open)}- >- <Calendar className="w-4 h-4" />- </Button>- {open && (- <div className="absolute right-0 top-full mt-1 z-50 bg-white border border-gray-200 rounded-sm shadow-lg p-3 flex flex-col gap-2 min-w-[240px]">- <label className="text-xs text-control-light">- {t("common.from")}- </label>- <Input- type="date"- value={from}- max={dayjs().format("YYYY-MM-DD")}- onChange={(e) => setFrom(e.target.value)}- />- <label className="text-xs text-control-light">{t("common.to")}</label>- <Input- type="date"- value={to}- max={dayjs().format("YYYY-MM-DD")}- onChange={(e) => setTo(e.target.value)}- />- <div className="flex items-center gap-x-2 mt-1">- <Button size="sm" onClick={applyRange} disabled={!from || !to}>- {t("common.confirm")}- </Button>- {hasRange && (- <Button variant="ghost" size="sm" onClick={clearRange}>- {t("common.clear")}- </Button>- )}- </div>- </div>- )}- </div>- );-}-// ===========================================================================// IssueSortDropdown// ===========================================================================diff --git a/frontend/src/react/components/PermissionGuard.tsx b/frontend/src/react/components/PermissionGuard.tsxindex f3df81eb80..e1f52cff6a 100644--- a/frontend/src/react/components/PermissionGuard.tsx+++ b/frontend/src/react/components/PermissionGuard.tsx@@ -30,25 +30,39 @@ export function usePermissionCheck(];}+interface PermissionGuardRenderProps {+ disabled: boolean;+}+interface PermissionGuardProps {readonly permissions: Permission[];readonly project?: Project;- readonly children: ReactNode;+ /** Either a ReactNode or a render function receiving `{ disabled }`. */+ readonly children:+ | ReactNode+ | ((props: PermissionGuardRenderProps) => 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+ * PermissionGuard wraps content with a styled tooltip showing missing* permissions. The tooltip only renders when the user lacks permission.*- * Usage:+ * Supports two patterns:+ *+ * 1. Static children (use `usePermissionCheck` separately for disabled state):* ```tsx* const [canEdit] = usePermissionCheck(["bb.settings.setWorkspaceProfile"]);* <PermissionGuard permissions={["bb.settings.setWorkspaceProfile"]}>- * <div>- * <input disabled={!canEdit} />- * </div>+ * <Button disabled={!canEdit}>Edit</Button>+ * </PermissionGuard>+ * ```+ *+ * 2. Render-prop children (like Vue PermissionGuardWrapper slot props):+ * ```tsx+ * <PermissionGuard permissions={["bb.projects.update"]} project={project}>+ * {({ disabled }) => <Button disabled={disabled}>Save</Button>}* </PermissionGuard>* ```*/@@ -63,24 +77,28 @@ export function PermissionGuard({? permissions.filter((p) => !hasProjectPermissionV2(project, p)): permissions.filter((p) => !hasWorkspacePermissionV2(p));- const tooltip =- missed.length > 0 ? (- <div className="flex flex-col gap-1">- {project- ? t("common.missing-required-permission-for-resource", {- resource: project.name,- })- : t("common.missing-required-permission", { permissions: "" })}- <ul className="list-disc pl-4">- {missed.map((p) => (- <li key={p}>{p}</li>- ))}- </ul>- </div>- ) : undefined;+ const disabled = missed.length > 0;++ const tooltip = disabled ? (+ <div className="flex flex-col gap-1">+ {project+ ? t("common.missing-required-permission-for-resource", {+ resource: project.name,+ })+ : t("common.missing-required-permission", { permissions: "" })}+ <ul className="list-disc pl-4">+ {missed.map((p) => (+ <li key={p}>{p}</li>+ ))}+ </ul>+ </div>+ ) : undefined;++ const content =+ typeof children === "function" ? children({ disabled }) : children;if (display === "block") {- return <BlockTooltip content={tooltip}>{children}</BlockTooltip>;+ return <BlockTooltip content={tooltip}>{content}</BlockTooltip>;}- return <Tooltip content={tooltip}>{children}</Tooltip>;+ return <Tooltip content={tooltip}>{content}</Tooltip>;}diff --git a/frontend/src/react/components/TimeRangePicker.tsx b/frontend/src/react/components/TimeRangePicker.tsxnew file mode 100644index 0000000000..137bab8862--- /dev/null+++ b/frontend/src/react/components/TimeRangePicker.tsx@@ -0,0 +1,154 @@+import dayjs from "dayjs";+import { ArrowRight, Calendar } from "lucide-react";+import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { useTranslation } from "react-i18next";+import type { SearchParams } from "./AdvancedSearch";+import { Button } from "./ui/button";+import { Input } from "./ui/input";++interface TimeRangePickerProps {+ params: SearchParams;+ onParamsChange: (p: SearchParams) => void;+}++export function TimeRangePicker({+ params,+ onParamsChange,+}: TimeRangePickerProps) {+ const { t } = useTranslation();+ const [showPicker, setShowPicker] = useState(false);+ const containerRef = useRef<HTMLDivElement>(null);++ const createdScope = params.scopes.find((s) => s.id === "created");+ const [fromTs, toTs] = useMemo(() => {+ if (!createdScope) return [undefined, undefined];+ const parts = createdScope.value.split(",");+ if (parts.length !== 2) return [undefined, undefined];+ return [parseInt(parts[0], 10), parseInt(parts[1], 10)];+ }, [createdScope]);++ const hasRange = fromTs !== undefined && toTs !== undefined;++ // Local draft state for the inputs inside the dropdown.+ const [draftFrom, setDraftFrom] = useState("");+ const [draftTo, setDraftTo] = useState("");++ // Sync drafts when the dropdown opens or the external range changes.+ useEffect(() => {+ if (fromTs) {+ setDraftFrom(dayjs(fromTs).format("YYYY-MM-DDTHH:mm:ss"));+ } else {+ setDraftFrom("");+ }+ if (toTs) {+ setDraftTo(dayjs(toTs).format("YYYY-MM-DDTHH:mm:ss"));+ } else {+ setDraftTo("");+ }+ }, [fromTs, toTs]);++ const displayFrom = fromTs ? dayjs(fromTs).format("YYYY-MM-DD HH:mm:ss") : "";+ const displayTo = toTs ? dayjs(toTs).format("YYYY-MM-DD HH:mm:ss") : "";++ const applyRange = useCallback(() => {+ const fromVal = draftFrom ? dayjs(draftFrom).valueOf() : undefined;+ const toVal = draftTo ? dayjs(draftTo).valueOf() : undefined;+ const scopes = params.scopes.filter((s) => s.id !== "created");+ if (fromVal !== undefined && toVal !== undefined) {+ scopes.push({+ id: "created",+ value: `${fromVal},${toVal}`,+ readonly: true,+ });+ }+ onParamsChange({ ...params, scopes });+ setShowPicker(false);+ }, [draftFrom, draftTo, params, onParamsChange]);++ const clearRange = useCallback(() => {+ const scopes = params.scopes.filter((s) => s.id !== "created");+ onParamsChange({ ...params, scopes });+ setDraftFrom("");+ setDraftTo("");+ setShowPicker(false);+ }, [params, onParamsChange]);++ // Close on click outside.+ useEffect(() => {+ if (!showPicker) return;+ const handler = (e: MouseEvent) => {+ if (+ containerRef.current &&+ !containerRef.current.contains(e.target as Node) &&+ !containerRef.current.contains(document.activeElement)+ ) {+ setShowPicker(false);+ }+ };+ document.addEventListener("mousedown", handler);+ return () => document.removeEventListener("mousedown", handler);+ }, [showPicker]);++ return (+ <div ref={containerRef} className="relative shrink-0">+ <button+ type="button"+ className="h-9 flex items-center gap-x-2 border border-control-border rounded-xs px-3 text-sm hover:bg-control-bg whitespace-nowrap"+ onClick={() => setShowPicker(!showPicker)}+ >+ {displayFrom && displayTo ? (+ <>+ <span>{displayFrom}</span>+ <ArrowRight className="w-3.5 h-3.5 text-control-light shrink-0" />+ <span>{displayTo}</span>+ </>+ ) : (+ <span className="text-control-placeholder">{t("common.select")}</span>+ )}+ <Calendar className="w-4 h-4 text-control-light ml-1 shrink-0" />+ </button>+ {showPicker && (+ <div className="absolute right-0 top-[42px] bg-white border border-control-border rounded-sm shadow-lg z-50 p-3 flex flex-col gap-y-2 min-w-[300px]">+ <div className="flex items-center gap-x-2">+ <label className="text-sm text-control-light whitespace-nowrap w-10">+ {t("common.from")}+ </label>+ <Input+ type="datetime-local"+ step="1"+ className="flex-1"+ value={draftFrom}+ onChange={(e) => setDraftFrom(e.target.value)}+ />+ </div>+ <div className="flex items-center gap-x-2">+ <label className="text-sm text-control-light whitespace-nowrap w-10">+ {t("common.to")}+ </label>+ <Input+ type="datetime-local"+ step="1"+ className="flex-1"+ value={draftTo}+ onChange={(e) => setDraftTo(e.target.value)}+ />+ </div>+ <div className="flex items-center gap-x-2 mt-1">+ <Button+ size="sm"+ onClick={applyRange}+ disabled={!draftFrom || !draftTo}+ >+ {t("common.confirm")}+ </Button>+ {hasRange && (+ <Button variant="ghost" size="sm" onClick={clearRange}>+ {t("common.clear")}+ </Button>+ )}+ </div>+ </div>+ )}+ </div>+ );+}diff --git a/frontend/src/react/components/instance/InstanceFormBody.tsx b/frontend/src/react/components/instance/InstanceFormBody.tsxindex c7065aa19b..4e93010509 100644--- a/frontend/src/react/components/instance/InstanceFormBody.tsx+++ b/frontend/src/react/components/instance/InstanceFormBody.tsx@@ -11,6 +11,7 @@ import {import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { EnvironmentSelect } from "@/react/components/EnvironmentSelect";+import { FeatureBadge } from "@/react/components/FeatureBadge";import { LabelListEditor } from "@/react/components/LabelListEditor";import { Alert } from "@/react/components/ui/alert";import { Button } from "@/react/components/ui/button";@@ -35,7 +36,10 @@ import {DataSource_RedisType,DataSourceType,} 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,extractInstanceResourceName,@@ -579,6 +583,7 @@ function ScanIntervalInput({<div className="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2"><div className="flex items-center gap-x-2"><label className="textlabel">{t("instance.scan-interval.self")}</label>+ <FeatureBadge feature={PlanFeature.FEATURE_CUSTOM_INSTANCE_SYNC_TIME} /></div><div className="textinfolabel">{t("instance.scan-interval.description")}diff --git a/frontend/src/react/components/ui/button.tsx b/frontend/src/react/components/ui/button.tsxindex 3738dc2e70..d737a04b31 100644--- a/frontend/src/react/components/ui/button.tsx+++ b/frontend/src/react/components/ui/button.tsx@@ -17,6 +17,7 @@ const buttonVariants = cva(},size: {default: "h-9 px-4 py-2",+ xs: "h-7 px-2 text-xs",sm: "h-8 px-3 text-xs",md: "h-9 px-4 text-sm",lg: "h-10 px-6",diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.jsonindex 3afc59b0e6..c4d67c0781 100644--- a/frontend/src/react/locales/en-US.json+++ b/frontend/src/react/locales/en-US.json@@ -146,7 +146,6 @@"clear-filters": "Clear filters","close": "Close","closed": "Closed",- "columns": "Columns","comment": "Comment","configure": "Configure","configure-now": "Configure now",@@ -1890,7 +1889,6 @@},"sql-editor": {"access-grants": "Access Grants",- "access-grants-redirect-hint": "Go to {link} to view and manage your own access grants.","activate-access": "Activate","activate-confirm": "Are you sure you want to activate this access grant?","expired": "Expired",diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.jsonindex fc7d3c109b..971a01304d 100644--- a/frontend/src/react/locales/es-ES.json+++ b/frontend/src/react/locales/es-ES.json@@ -146,7 +146,6 @@"clear-filters": "Limpiar filtros","close": "Cerrar","closed": "Cerrado",- "columns": "Columnas","comment": "Comentario","configure": "Configurar","configure-now": "Configurar ahora",@@ -1890,7 +1889,6 @@},"sql-editor": {"access-grants": "Access Grants",- "access-grants-redirect-hint": "Go to {link} to view and manage your own access grants.","activate-access": "Activate","activate-confirm": "Are you sure you want to activate this access grant?","expired": "Expired",diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.jsonindex 03ae98ffc8..f895f0580d 100644--- a/frontend/src/react/locales/ja-JP.json+++ b/frontend/src/react/locales/ja-JP.json@@ -146,7 +146,6 @@"clear-filters": "フィルタをクリア","close": "閉じる","closed": "閉まっている",- "columns": "カラム","comment": "コメント","configure": "設定","configure-now": "今すぐ設定する",@@ -1890,7 +1889,6 @@},"sql-editor": {"access-grants": "Access Grants",- "access-grants-redirect-hint": "Go to {link} to view and manage your own access grants.","activate-access": "Activate","activate-confirm": "Are you sure you want to activate this access grant?","expired": "Expired",diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.jsonindex 477084a6bc..edaa87930e 100644--- a/frontend/src/react/locales/vi-VN.json+++ b/frontend/src/react/locales/vi-VN.json@@ -146,7 +146,6 @@"clear-filters": "Xóa bộ lọc","close": "Đóng","closed": "Đã đóng",- "columns": "Cột","comment": "Bình luận","configure": "Cấu hình","configure-now": "Cấu hình ngay",@@ -1890,7 +1889,6 @@},"sql-editor": {"access-grants": "Access Grants",- "access-grants-redirect-hint": "Go to {link} to view and manage your own access grants.","activate-access": "Activate","activate-confirm": "Are you sure you want to activate this access grant?","expired": "Expired",diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.jsonindex 52935645a7..a452b3e42a 100644--- a/frontend/src/react/locales/zh-CN.json+++ b/frontend/src/react/locales/zh-CN.json@@ -146,7 +146,6 @@"clear-filters": "清除过滤","close": "关闭","closed": "已关闭",- "columns": "列","comment": "评论","configure": "配置","configure-now": "现在配置",@@ -1890,7 +1889,6 @@},"sql-editor": {"access-grants": "访问授权",- "access-grants-redirect-hint": "前往 {link} 查看和管理您自己的访问授权。","activate-access": "激活","activate-confirm": "确定要激活此访问授权吗?","expired": "已过期",diff --git a/frontend/src/react/pages/project/ProjectAccessGrantsPage.tsx b/frontend/src/react/pages/project/ProjectAccessGrantsPage.tsxindex 69df57c549..68f4535fc7 100644--- a/frontend/src/react/pages/project/ProjectAccessGrantsPage.tsx+++ b/frontend/src/react/pages/project/ProjectAccessGrantsPage.tsx@@ -1,4 +1,4 @@-import { ArrowDown, ArrowUp, ArrowUpDown, ShieldAlert } from "lucide-react";+import { ArrowDown, ArrowUp, ArrowUpDown } from "lucide-react";import { useCallback, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { EngineIconPath } from "@/components/InstanceForm/constants";@@ -9,7 +9,9 @@ import {type SearchParams,type ValueOption,} from "@/react/components/AdvancedSearch";+import { ComponentPermissionGuard } from "@/react/components/ComponentPermissionGuard";import { FeatureAttention } from "@/react/components/FeatureAttention";+import { TimeRangePicker } from "@/react/components/TimeRangePicker";import { Badge } from "@/react/components/ui/badge";import { Button } from "@/react/components/ui/button";import {@@ -17,7 +19,6 @@ import {DialogContent,DialogTitle,} from "@/react/components/ui/dialog";-import { Input } from "@/react/components/ui/input";import { Tooltip } from "@/react/components/ui/tooltip";import { PagedTableFooter, usePagedData } from "@/react/hooks/usePagedData";import { useVueState } from "@/react/hooks/useVueState";@@ -136,10 +137,6 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {const [searchParams, setSearchParams] =useState<SearchParams>(emptySearchParams);- // --- Created-time range state ---- const [createdAfter, setCreatedAfter] = useState("");- const [createdBefore, setCreatedBefore] = useState("");-// --- Sort state ---const [sortKey, setSortKey] = useState<SortKey | "">("");const [sortDir, setSortDir] = useState<SortDir>("desc");@@ -312,22 +309,13 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {if (query) {filter.statement = query;}- if (createdAfter) {- const [y, m, d] = createdAfter.split("-").map(Number);- filter.createdTsAfter = new Date(y, m - 1, d).getTime();- }- if (createdBefore) {- const [y, m, d] = createdBefore.split("-").map(Number);- // End of the selected day (23:59:59.999)- filter.createdTsBefore = new Date(- y,- m - 1,- d,- 23,- 59,- 59,- 999- ).getTime();+ const createdScope = searchParams.scopes.find((s) => s.id === "created");+ if (createdScope) {+ const parts = createdScope.value.split(",");+ if (parts.length === 2) {+ filter.createdTsAfter = parseInt(parts[0], 10);+ filter.createdTsBefore = parseInt(parts[1], 10);+ }}const response = await accessGrantStore.listAccessGrants({parent: projectName,@@ -341,14 +329,7 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {nextPageToken: response.nextPageToken,};},- [- projectName,- accessGrantStore,- searchParams,- orderBy,- createdAfter,- createdBefore,- ]+ [projectName, accessGrantStore, searchParams, orderBy]);const paged = usePagedData<AccessGrant>({@@ -385,7 +366,11 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {<FeatureAttention feature={PlanFeature.FEATURE_JIT} /></div>- {canList ? (+ <ComponentPermissionGuard+ permissions={["bb.accessGrants.list"]}+ project={project}+ className="mx-4"+ ><><div className="px-4 pb-2 flex items-center gap-x-2"><AdvancedSearch@@ -394,23 +379,10 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {scopeOptions={scopeOptions}placeholder={t("issue.advanced-search.filter")}/>- <div className="flex items-center gap-x-1 shrink-0">- <Input- type="date"- className="w-36 text-xs"- value={createdAfter}- onChange={(e) => setCreatedAfter(e.target.value)}- title={t("common.from")}- />- <span className="text-control-light text-xs">–</span>- <Input- type="date"- className="w-36 text-xs"- value={createdBefore}- onChange={(e) => setCreatedBefore(e.target.value)}- title={t("common.to")}- />- </div>+ <TimeRangePicker+ params={searchParams}+ onParamsChange={setSearchParams}+ /></div>{!hasJITFeature ? (@@ -497,59 +469,7 @@ export function ProjectAccessGrantsPage({ projectId }: { projectId: string }) {</div>)}</>- ) : (- <div className="mx-4 mt-2 flex flex-col gap-y-3">- {/* Permission guard fallback */}- <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">- <li>bb.accessGrants.list</li>- </ul>- </div>- </div>- </div>-- {/* Redirect hint */}- <div className="flex items-start gap-3 rounded-xs border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-700">- <span>- {t("sql-editor.access-grants-redirect-hint")- .split("{link}")- .map((part, i) =>- i === 0 ? (- <span key={i}>{part}</span>- ) : (- <span key={i}>- <a- className="normal-link"- href="#"- onClick={(e) => {- e.preventDefault();- router.push({- name: "sql-editor.project",- params: { project: projectId },- query: { panel: "access" },- });- }}- >- {t("sql-editor.self")}- </a>- {part}- </span>- )- )}- </span>- </div>- </div>- )}+ </ComponentPermissionGuard>{/* Activate / Revoke confirmation dialog */}<Dialogdiff --git a/frontend/src/react/pages/project/ProjectAuditLogPage.tsx b/frontend/src/react/pages/project/ProjectAuditLogPage.tsxindex 4c50bbeaaa..36a41f3532 100644--- a/frontend/src/react/pages/project/ProjectAuditLogPage.tsx+++ b/frontend/src/react/pages/project/ProjectAuditLogPage.tsx@@ -1,8 +1,10 @@import { useMemo } from "react";import { AuditLogTable } from "@/react/components/AuditLogTable";+import { FeatureAttention } from "@/react/components/FeatureAttention";import { useVueState } from "@/react/hooks/useVueState";import { useProjectV1Store } from "@/store";import { projectNamePrefix } from "@/store/modules/v1/common";+import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import { hasProjectPermissionV2 } from "@/utils";export function ProjectAuditLogPage({ projectId }: { projectId: string }) {@@ -20,10 +22,15 @@ export function ProjectAuditLogPage({ projectId }: { projectId: string }) {);return (- <AuditLogTable- parent={projectName}- canExport={canExport}- readonlyScopes={readonlyScopes}- />+ <div className="flex flex-col">+ <div className="mx-4 mb-2">+ <FeatureAttention feature={PlanFeature.FEATURE_AUDIT_LOG} />+ </div>+ <AuditLogTable+ parent={projectName}+ canExport={canExport}+ readonlyScopes={readonlyScopes}+ />+ </div>);}diff --git a/frontend/src/react/pages/project/ProjectDatabaseGroupDetailPage.tsx b/frontend/src/react/pages/project/ProjectDatabaseGroupDetailPage.tsxindex f283c273b6..6b62c7e932 100644--- a/frontend/src/react/pages/project/ProjectDatabaseGroupDetailPage.tsx+++ b/frontend/src/react/pages/project/ProjectDatabaseGroupDetailPage.tsx@@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next";import { preCreateIssue } from "@/components/Plan/logic/issue";import { DatabaseGroupForm } from "@/react/components/DatabaseGroupForm";import { FeatureAttention } from "@/react/components/FeatureAttention";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import {Dialog,@@ -108,23 +109,33 @@ export function ProjectDatabaseGroupDetailPage({{hasDatabaseGroupFeature && !editing && (<div className="flex flex-row justify-end items-center flex-wrap shrink gap-x-2 gap-y-2">- <Button- variant="outline"- disabled={!canChangeDatabase || !hasMatchedDatabases}- onClick={() => preCreateIssue(project.name, [resourceName])}- title={- !hasMatchedDatabases- ? t("database-group.no-matched-databases")- : undefined- }+ <PermissionGuard+ permissions={["bb.plans.create", "bb.sheets.create"]}+ project={project}>- {t("database.change-database")}- </Button>+ <Button+ variant="outline"+ disabled={!canChangeDatabase || !hasMatchedDatabases}+ onClick={() => preCreateIssue(project.name, [resourceName])}+ title={+ !hasMatchedDatabases+ ? t("database-group.no-matched-databases")+ : undefined+ }+ >+ {t("database.change-database")}+ </Button>+ </PermissionGuard>- <Button disabled={!canUpdate} onClick={() => setEditing(true)}>- <Edit className="w-4 h-4 mr-1" />- {t("common.configure")}- </Button>+ <PermissionGuard+ permissions={["bb.databaseGroups.update"]}+ project={project}+ >+ <Button disabled={!canUpdate} onClick={() => setEditing(true)}>+ <Edit className="w-4 h-4 mr-1" />+ {t("common.configure")}+ </Button>+ </PermissionGuard>{canDelete && (<div className="relative">diff --git a/frontend/src/react/pages/project/ProjectDatabasesPage.tsx b/frontend/src/react/pages/project/ProjectDatabasesPage.tsxindex 872feb7d52..45cc30f822 100644--- a/frontend/src/react/pages/project/ProjectDatabasesPage.tsx+++ b/frontend/src/react/pages/project/ProjectDatabasesPage.tsx@@ -17,6 +17,7 @@ import {LabelEditorDrawer,} from "@/react/components/database";import { EditEnvironmentDrawer } from "@/react/components/EditEnvironmentDrawer";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { useVueState } from "@/react/hooks/useVueState";import {@@ -355,16 +356,27 @@ export function ProjectDatabasesPage({ projectId }: { projectId: string }) {placeholder={t("database.filter-database")}scopeOptions={scopeOptions}/>- <Button- disabled={- !hasProjectPermission("bb.instances.list") ||- !PERMISSIONS_FOR_DATABASE_CREATE_ISSUE.every(hasProjectPermission)- }- onClick={() => setShowCreateDrawer(true)}+ <PermissionGuard+ permissions={[+ "bb.instances.list",+ "bb.plans.create",+ "bb.sheets.create",+ ]}+ project={project}>- <Plus className="h-4 w-4 mr-1" />- {t("common.create")}- </Button>+ <Button+ disabled={+ !hasProjectPermission("bb.instances.list") ||+ !PERMISSIONS_FOR_DATABASE_CREATE_ISSUE.every(+ hasProjectPermission+ )+ }+ onClick={() => setShowCreateDrawer(true)}+ >+ <Plus className="h-4 w-4 mr-1" />+ {t("common.create")}+ </Button>+ </PermissionGuard></div></div>diff --git a/frontend/src/react/pages/project/ProjectGitOpsPage.tsx b/frontend/src/react/pages/project/ProjectGitOpsPage.tsxindex 7c2d7cb994..63157f8a1b 100644--- a/frontend/src/react/pages/project/ProjectGitOpsPage.tsx+++ b/frontend/src/react/pages/project/ProjectGitOpsPage.tsx@@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import gitopsWorkflowImage from "@/assets/gitops-workflow.svg";import { CreateWorkloadIdentityDrawer } from "@/react/components/CreateWorkloadIdentityDrawer";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Alert } from "@/react/components/ui/alert";import { Button } from "@/react/components/ui/button";import { Combobox, type ComboboxOption } from "@/react/components/ui/combobox";@@ -13,7 +14,6 @@ import {TabsPanel,TabsTrigger,} from "@/react/components/ui/tabs";-import { Tooltip } from "@/react/components/ui/tooltip";import { useVueState } from "@/react/hooks/useVueState";import { cn } from "@/react/lib/utils";import { router } from "@/router";@@ -390,14 +390,9 @@ export function ProjectGitOpsPage({ projectId }: { projectId: string }) {onSearch={setWiSearch}className="max-w-lg"/>- <Tooltip- content={- canCreateWorkloadIdentity- ? undefined- : t("common.missing-required-permission", {- permissions: "bb.workloadIdentities.create",- })- }+ <PermissionGuard+ permissions={["bb.workloadIdentities.create"]}+ project={project}><Buttonvariant="outline"@@ -406,7 +401,7 @@ export function ProjectGitOpsPage({ projectId }: { projectId: string }) {>{t("common.create")}</Button>- </Tooltip>+ </PermissionGuard></div>{repoUrl && (<adiff --git a/frontend/src/react/pages/project/ProjectMaskingExemptionPage.tsx b/frontend/src/react/pages/project/ProjectMaskingExemptionPage.tsxindex 3792377a31..2936c3dc78 100644--- a/frontend/src/react/pages/project/ProjectMaskingExemptionPage.tsx+++ b/frontend/src/react/pages/project/ProjectMaskingExemptionPage.tsx@@ -32,7 +32,7 @@ import {DialogContent,DialogTitle,} from "@/react/components/ui/dialog";-import { Tooltip } from "@/react/components/ui/tooltip";+import { Tabs, TabsList, TabsTrigger } from "@/react/components/ui/tabs";import { useVueState } from "@/react/hooks/useVueState";import { cn } from "@/react/lib/utils";import { router } from "@/router";@@ -406,24 +406,20 @@ export function ProjectMaskingExemptionPage({</div>{/* Preset tabs */}- <div className="shrink-0">- <div className="flex border-b border-gray-200">+ <Tabs+ value={activePreset}+ onValueChange={(v) => {+ if (typeof v === "string") selectPreset(v);+ }}+ >+ <TabsList>{presets.map((preset) => (- <button- key={preset.id}- className={cn(- "px-3 py-1.5 text-sm font-medium border-b-2 -mb-px transition-colors",- activePreset === preset.id- ? "border-accent text-accent"- : "border-transparent text-control-light hover:text-control hover:border-gray-300"- )}- onClick={() => selectPreset(preset.id)}- >+ <TabsTrigger key={preset.id} value={preset.id}>{preset.label}- </button>+ </TabsTrigger>))}- </div>- </div>+ </TabsList>+ </Tabs></div>{/* Wide view: side-by-side */}@@ -1203,8 +1199,6 @@ function ExemptionGrantSection({// ExemptionResourceTable// ============================================================-const COLUMN_VISIBLE_LIMIT = 3;-function ExemptionResourceTable({databaseResources,classificationLevel,@@ -1218,13 +1212,6 @@ function ExemptionResourceTable({const isSentinel = (value: string): boolean => value === "";- const displayInstance = (resource: DatabaseResource): string => {- const { instanceName } = extractDatabaseResourceName(- resource.databaseFullName- );- return isSentinel(instanceName) ? t("database.all") : instanceName;- };-const handleDatabaseClick = (resource: DatabaseResource) => {const path = resource.databaseFullName.startsWith("/")? resource.databaseFullName@@ -1234,40 +1221,32 @@ function ExemptionResourceTable({return (<div className="overflow-x-auto">- <table className="w-full text-sm table-fixed min-w-[600px]">- <colgroup>- <col style={{ width: "16%" }} />- <col style={{ width: "16%" }} />- <col style={{ width: "14%" }} />- <col style={{ width: "18%" }} />- <col style={{ width: "20%" }} />- <col style={{ width: "16%" }} />- </colgroup>+ <table className="w-full text-sm"><thead><tr className="border-b border-gray-200">- <th className="textinfolabel font-medium uppercase text-xs tracking-wider py-2 px-2 text-left">+ <th className="textinfolabel font-medium text-xs py-2 px-2 text-left whitespace-nowrap">{t("common.instance")}</th>- <th className="textinfolabel font-medium uppercase text-xs tracking-wider py-2 px-2 text-left">+ <th className="textinfolabel font-medium text-xs py-2 px-2 text-left whitespace-nowrap">{t("common.database")}</th>- <th className="textinfolabel font-medium uppercase text-xs tracking-wider py-2 px-2 text-left">+ <th className="textinfolabel font-medium text-xs py-2 px-2 text-left whitespace-nowrap">{t("common.schema")}</th>- <th className="textinfolabel font-medium uppercase text-xs tracking-wider py-2 px-2 text-left">+ <th className="textinfolabel font-medium text-xs py-2 px-2 text-left whitespace-nowrap">{t("common.table")}</th>- <th className="textinfolabel font-medium uppercase text-xs tracking-wider py-2 px-2 text-left">- {t("common.columns")}+ <th className="textinfolabel font-medium text-xs py-2 px-2 text-left whitespace-nowrap">+ {t("database.columns")}</th>- <th className="textinfolabel font-medium uppercase text-xs tracking-wider py-2 px-2 text-left">+ <th className="textinfolabel font-medium text-xs py-2 px-2 text-left whitespace-nowrap">{t("common.classification-level")}</th></tr></thead><tbody>{databaseResources.map((resource, idx) => {- const { databaseName } = extractDatabaseResourceName(+ const { instanceName, databaseName } = extractDatabaseResourceName(resource.databaseFullName);return (@@ -1275,55 +1254,35 @@ function ExemptionResourceTable({key={idx}className="border-b border-gray-200 last:border-b-0">- <td className="py-2 px-2 text-control-light">- <Tooltip content={displayInstance(resource)}>- <span className="block truncate">- {displayInstance(resource)}- </span>- </Tooltip>+ <td className="py-2 px-2 text-control-light whitespace-nowrap">+ {isSentinel(instanceName) ? t("database.all") : instanceName}</td>- <td className="py-2 px-2">+ <td className="py-2 px-2 whitespace-nowrap">{isSentinel(databaseName) ? (<span className="text-control-placeholder">{t("database.all")}</span>) : showDatabaseLink ? (- <Tooltip content={databaseName}>- <span- className="block truncate normal-link cursor-pointer"- onClick={() => handleDatabaseClick(resource)}- >- {databaseName}- </span>- </Tooltip>+ <span+ className="normal-link cursor-pointer"+ onClick={() => handleDatabaseClick(resource)}+ >+ {databaseName}+ </span>) : (- <Tooltip content={databaseName}>- <span className="block truncate text-control-light">- {databaseName}- </span>- </Tooltip>+ <span className="text-control-light">{databaseName}</span>)}</td>- <td className="py-2 px-2 text-control-light">- {resource.schema ? (- <Tooltip content={resource.schema}>- <span className="block truncate">{resource.schema}</span>- </Tooltip>- ) : (- <span>-</span>- )}+ <td className="py-2 px-2 text-control-light whitespace-nowrap">+ {resource.schema || "-"}</td>- <td className="py-2 px-2 text-control-light">- {resource.table ? (- <Tooltip content={resource.table}>- <span className="block truncate">{resource.table}</span>- </Tooltip>- ) : (- <span>-</span>- )}+ <td className="py-2 px-2 text-control-light whitespace-nowrap">+ {resource.table || "-"}</td><td className="py-2 px-2">- <ColumnCell columns={resource.columns} />+ {resource.columns && resource.columns.length > 0+ ? resource.columns.join(", ")+ : "-"}</td><td className="py-2 px-2"><LevelBadge@@ -1341,45 +1300,6 @@ function ExemptionResourceTable({);}-// ============================================================-// ColumnCell-// ============================================================--function ColumnCell({ columns }: { columns?: string[] }) {- const { t } = useTranslation();-- if (!columns || columns.length === 0) {- return <span className="text-control-placeholder">-</span>;- }-- const visible = columns.slice(0, COLUMN_VISIBLE_LIMIT);- const rest = columns.length - visible.length;- const text = visible.join(", ");-- if (rest <= 0) {- return <span className="text-control-light">{text}</span>;- }-- return (- <Tooltip- content={- <div className="flex flex-col gap-y-0.5">- {columns.map((col) => (- <span key={col}>{col}</span>- ))}- </div>- }- >- <span className="text-control-light">- {text}- <span className="text-control-placeholder ml-1">- {t("common.n-more", { n: rest })}- </span>- </span>- </Tooltip>- );-}-// ============================================================// ExemptionLevelCard// ============================================================diff --git a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsxindex e0400ccd0b..715de85898 100644--- a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx+++ b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx@@ -20,6 +20,10 @@ import {type ValueOption,} from "@/react/components/AdvancedSearch";import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";+import {+ PermissionGuard,+ usePermissionCheck,+} from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { SearchInput } from "@/react/components/ui/search-input";import { Tooltip } from "@/react/components/ui/tooltip";@@ -80,7 +84,6 @@ import {generatePlanTitle,getDatabaseEnvironment,getInstanceResource,- hasProjectPermissionV2,humanizeTs,type SearchParams as VueSearchParams,} from "@/utils";@@ -193,11 +196,7 @@ export function ProjectPlanDashboardPage({ projectId }: { projectId: string }) {[t, userStore, me]);- // Permission check- const canCreate = useMemo(() => {- if (!project) return false;- return hasProjectPermissionV2(project, "bb.plans.create");- }, [project]);+ const [canCreate] = usePermissionCheck(["bb.plans.create"], project);// Build plan filterconst planFilter = useMemo(() => {@@ -304,14 +303,9 @@ export function ProjectPlanDashboardPage({ projectId }: { projectId: string }) {onParamsChange={setSearchParams}scopeOptions={scopeOptions}/>- <Tooltip- content={- !canCreate- ? t("common.missing-required-permission", {- permissions: "bb.plans.create",- })- : undefined- }+ <PermissionGuard+ permissions={["bb.plans.create"]}+ project={project}><Buttondisabled={!canCreate}@@ -320,7 +314,7 @@ export function ProjectPlanDashboardPage({ projectId }: { projectId: string }) {<Plus className="w-4 h-4 mr-1" />{t("plan.new-plan")}</Button>- </Tooltip>+ </PermissionGuard></div></div></div>diff --git a/frontend/src/react/pages/project/ProjectSettingsPage.tsx b/frontend/src/react/pages/project/ProjectSettingsPage.tsxindex 6374d5373f..c759f02664 100644--- a/frontend/src/react/pages/project/ProjectSettingsPage.tsx+++ b/frontend/src/react/pages/project/ProjectSettingsPage.tsx@@ -5,6 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { FeatureBadge } from "@/react/components/FeatureBadge";import { LabelListEditor } from "@/react/components/LabelListEditor";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import {Dialog,@@ -643,43 +644,49 @@ export function ProjectSettingsPage() {<h1 className="text-2xl font-bold">{t("common.general")}</h1></div><div className="flex-1 mt-4 lg:px-4 lg:mt-0">- <form className="w-full flex flex-col gap-y-4">- <div>- <div className="font-medium">- {t("common.name")} <span className="text-error">*</span>- </div>- <Input- className="mt-1"- value={title}- onChange={(e) => setTitle(e.target.value)}- disabled={- !canUpdateProject ||- isDefault ||- project.state !== State.ACTIVE- }- required- />- <div className="mt-1 text-sm text-control-light">- {t("common.id")}: {extractProjectResourceName(project.name)}+ <PermissionGuard+ permissions={["bb.projects.update"]}+ project={project}+ display="block"+ >+ <form className="w-full flex flex-col gap-y-4">+ <div>+ <div className="font-medium">+ {t("common.name")} <span className="text-error">*</span>+ </div>+ <Input+ className="mt-1"+ value={title}+ onChange={(e) => setTitle(e.target.value)}+ disabled={+ !canUpdateProject ||+ isDefault ||+ project.state !== State.ACTIVE+ }+ required+ />+ <div className="mt-1 text-sm text-control-light">+ {t("common.id")}: {extractProjectResourceName(project.name)}+ </div></div>- </div>- {/* Project Labels */}- <div>- <div className="font-medium">- {t("project.settings.project-labels.self")}- </div>- <div className="text-sm text-gray-500 mb-3">- {t("project.settings.project-labels.description")}+ {/* Project Labels */}+ <div>+ <div className="font-medium">+ {t("project.settings.project-labels.self")}+ </div>+ <div className="text-sm text-gray-500 mb-3">+ {t("project.settings.project-labels.description")}+ </div>+ <LabelListEditor+ kvList={labelKVList}+ onChange={setLabelKVList}+ readonly={!canUpdateProject}+ onErrorsChange={setLabelErrors}+ /></div>- <LabelListEditor- kvList={labelKVList}- onChange={setLabelKVList}- readonly={!canUpdateProject}- onErrorsChange={setLabelErrors}- />- </div>- </form>+ </form>+ </PermissionGuard></div></div>diff --git a/frontend/src/react/pages/project/ProjectWebhooksPage.tsx b/frontend/src/react/pages/project/ProjectWebhooksPage.tsxindex 229eb2c040..30882be548 100644--- a/frontend/src/react/pages/project/ProjectWebhooksPage.tsx+++ b/frontend/src/react/pages/project/ProjectWebhooksPage.tsx@@ -1,6 +1,7 @@import { EllipsisVertical, Plus } from "lucide-react";import { useCallback, useMemo, useState } from "react";import { useTranslation } from "react-i18next";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import {Dialog,@@ -93,10 +94,12 @@ export function ProjectWebhooksPage({ projectId }: { projectId: string }) {return (<div className="py-4 flex flex-col"><div className="px-4 pb-2 flex items-center justify-end">- <Button disabled={!allowEdit} onClick={handleAdd}>- <Plus className="w-4 h-4 mr-1" />- {t("common.create")}- </Button>+ <PermissionGuard permissions={["bb.projects.update"]} project={project}>+ <Button disabled={!allowEdit} onClick={handleAdd}>+ <Plus className="w-4 h-4 mr-1" />+ {t("common.create")}+ </Button>+ </PermissionGuard></div><WebhookTablediff --git a/frontend/src/react/pages/project/database-detail/DatabaseDetailActions.tsx b/frontend/src/react/pages/project/database-detail/DatabaseDetailActions.tsxindex 0514cee32d..567c43a3a9 100644--- a/frontend/src/react/pages/project/database-detail/DatabaseDetailActions.tsx+++ b/frontend/src/react/pages/project/database-detail/DatabaseDetailActions.tsx@@ -2,6 +2,7 @@ import { ArrowRightLeft, Pencil } from "lucide-react";import { useMemo } from "react";import { useTranslation } from "react-i18next";import { preCreateIssue } from "@/components/Plan/logic/issue";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { useVueState } from "@/react/hooks/useVueState";import { usePermissionStore, useProjectV1Store } from "@/store";@@ -65,32 +66,49 @@ export function DatabaseDetailActions({return (<><div className="flex shrink-0 flex-wrap items-center justify-start gap-x-2 gap-y-2">- <DatabaseSyncButton database={database} disabled={!canSync} />- <DatabaseExportSchemaButton- database={database}- disabled={!canExportSchema}- />+ <PermissionGuard permissions={["bb.databases.sync"]} project={project}>+ <DatabaseSyncButton database={database} disabled={!canSync} />+ </PermissionGuard>+ <PermissionGuard+ permissions={["bb.databases.getSchema"]}+ project={project}+ >+ <DatabaseExportSchemaButton+ database={database}+ disabled={!canExportSchema}+ />+ </PermissionGuard>{!isDefaultProject && (- <Button- variant="outline"- disabled={!canUpdate}- onClick={onOpenTransferProject}+ <PermissionGuard+ permissions={["bb.databases.update"]}+ project={project}>- <ArrowRightLeft className="h-4 w-4" />- {t("database.transfer-project")}- </Button>+ <Button+ variant="outline"+ disabled={!canUpdate}+ onClick={onOpenTransferProject}+ >+ <ArrowRightLeft className="h-4 w-4" />+ {t("database.transfer-project")}+ </Button>+ </PermissionGuard>)}{!isDefaultProject && (- <Button- variant="outline"- disabled={!canChangeDatabase}- onClick={() =>- void preCreateIssue(database.project, [database.name])- }+ <PermissionGuard+ permissions={["bb.plans.create", "bb.sheets.create"]}+ project={project}>- <Pencil className="h-4 w-4" />- {t("database.change-database")}- </Button>+ <Button+ variant="outline"+ disabled={!canChangeDatabase}+ onClick={() =>+ void preCreateIssue(database.project, [database.name])+ }+ >+ <Pencil className="h-4 w-4" />+ {t("database.change-database")}+ </Button>+ </PermissionGuard>)}</div></>diff --git a/frontend/src/react/pages/project/database-detail/panels/DatabaseSettingsPanel.tsx b/frontend/src/react/pages/project/database-detail/panels/DatabaseSettingsPanel.tsxindex 68db2d6d85..925ee7b3b7 100644--- a/frontend/src/react/pages/project/database-detail/panels/DatabaseSettingsPanel.tsx+++ b/frontend/src/react/pages/project/database-detail/panels/DatabaseSettingsPanel.tsx@@ -5,6 +5,7 @@ import { useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { EnvironmentSelect } from "@/react/components/EnvironmentSelect";import { LabelListEditor } from "@/react/components/LabelListEditor";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { Button } from "@/react/components/ui/button";import { pushNotification, useDatabaseV1Store } from "@/store";import type { Database } from "@/types/proto-es/v1/database_service_pb";@@ -119,20 +120,25 @@ export function DatabaseSettingsPanel({ database }: { database: Database }) {<p className="text-lg font-medium leading-7 text-main">{t("common.environment")}</p>- <EnvironmentSelect- className="mt-1 max-w-md"- value={database.effectiveEnvironment || ""}- clearable={allowClearEnvironment}- disabled={!allowUpdateDatabase}- renderSuffix={(environment) =>- instanceEnvironment === environment.name ? (- <span className="text-xs text-control-placeholder">- ({t("common.default")})- </span>- ) : null- }- onChange={handleSelectEnvironment}- />+ <PermissionGuard+ permissions={["bb.databases.update"]}+ project={getDatabaseProject(database)}+ >+ <EnvironmentSelect+ className="mt-1 max-w-md"+ value={database.effectiveEnvironment || ""}+ clearable={allowClearEnvironment}+ disabled={!allowUpdateDatabase}+ renderSuffix={(environment) =>+ instanceEnvironment === environment.name ? (+ <span className="text-xs text-control-placeholder">+ ({t("common.default")})+ </span>+ ) : null+ }+ onChange={handleSelectEnvironment}+ />+ </PermissionGuard></div></div><div className="flex flex-col gap-y-4 pt-7">@@ -159,9 +165,14 @@ export function DatabaseSettingsPanel({ database }: { database: Database }) {<Button variant="outline" onClick={handleCancel}>{t("common.revert")}</Button>- <Button disabled={!allowSave} onClick={() => void handleSave()}>- {t("common.save")}- </Button>+ <PermissionGuard+ permissions={["bb.databases.update"]}+ project={getDatabaseProject(database)}+ >+ <Button disabled={!allowSave} onClick={() => void handleSave()}>+ {t("common.save")}+ </Button>+ </PermissionGuard></div>)}</div>diff --git a/frontend/src/react/pages/settings/EnvironmentsPage.tsx b/frontend/src/react/pages/settings/EnvironmentsPage.tsxindex 43bf9e239d..5fbe5e6ef0 100644--- a/frontend/src/react/pages/settings/EnvironmentsPage.tsx+++ b/frontend/src/react/pages/settings/EnvironmentsPage.tsx@@ -304,82 +304,86 @@ function RolloutPolicyConfig({return (<div className="flex flex-col items-start gap-y-2">- <div className="flex flex-col gap-y-2">- {/* Role select */}- <div className="flex flex-wrap items-center gap-2">- {rolloutPolicy.roles.map((role) => (- <span- key={role}- className="inline-flex items-center gap-x-1 rounded-xs bg-gray-100 px-2 py-1 text-sm"- >- {displayRoleTitle(role)}- {canUpdatePolicy && (- <button- type="button"- className="text-gray-400 hover:text-gray-600"- onClick={() => removeRole(role)}- >- <X className="w-3.5 h-3.5" />- </button>- )}- </span>- ))}- {canUpdatePolicy && (- <div className="relative" ref={dropdownRef}>- <Button- variant="outline"- size="sm"- onClick={() => setShowRoleDropdown(!showRoleDropdown)}+ <PermissionGuard permissions={["bb.policies.update"]} display="block">+ <div className="flex flex-col gap-y-2">+ {/* Role select */}+ <div className="flex flex-wrap items-center gap-2">+ {rolloutPolicy.roles.map((role) => (+ <span+ key={role}+ className="inline-flex items-center gap-x-1 rounded-xs bg-gray-100 px-2 py-1 text-sm">- <Plus className="w-3.5 h-3.5 mr-1" />- {t("common.add")}- </Button>- {showRoleDropdown && (- <div className="absolute z-50 mt-1 w-64 max-h-60 overflow-auto rounded-sm 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">- {group.label}+ {displayRoleTitle(role)}+ {canUpdatePolicy && (+ <button+ type="button"+ className="text-gray-400 hover:text-gray-600"+ onClick={() => removeRole(role)}+ >+ <X className="w-3.5 h-3.5" />+ </button>+ )}+ </span>+ ))}+ {canUpdatePolicy && (+ <div className="relative" ref={dropdownRef}>+ <Button+ variant="outline"+ size="xs"+ onClick={() => setShowRoleDropdown(!showRoleDropdown)}+ >+ <Plus className="w-3.5 h-3.5 mr-1" />+ {t("common.add")}+ </Button>+ {showRoleDropdown && (+ <div className="absolute z-50 mt-1 w-64 max-h-60 overflow-auto rounded-sm 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">+ {group.label}+ </div>+ {group.roles.map((role) => (+ <button+ key={role.name}+ type="button"+ className="w-full text-left px-3 py-1.5 text-sm hover:bg-control-bg cursor-pointer"+ onClick={() => {+ addRole(role.name);+ setShowRoleDropdown(false);+ }}+ >+ {role.title}+ </button>+ ))}</div>- {group.roles.map((role) => (- <button- key={role.name}- type="button"- className="w-full text-left px-3 py-1.5 text-sm hover:bg-control-bg cursor-pointer"- onClick={() => {- addRole(role.name);- setShowRoleDropdown(false);- }}- >- {role.title}- </button>- ))}- </div>- ))}- {availableRoles.length === 0 && (- <div className="px-3 py-2 text-sm text-gray-400">- {t("common.no-data")}- </div>- )}- </div>- )}- </div>- )}- </div>+ ))}+ {availableRoles.length === 0 && (+ <div className="px-3 py-2 text-sm text-gray-400">+ {t("common.no-data")}+ </div>+ )}+ </div>+ )}+ </div>+ )}+ </div>- {/* Auto rollout toggle */}- <div className="w-full inline-flex items-start gap-x-2">- <ToggleSwitch- checked={rolloutPolicy.automatic}- disabled={!canUpdatePolicy}- onChange={toggleAutomatic}- />- <div className="flex flex-col">- <span className="textlabel">{t("policy.rollout.auto")}</span>- <div className="textinfolabel">{t("policy.rollout.auto-info")}</div>+ {/* Auto rollout toggle */}+ <div className="w-full inline-flex items-start gap-x-2">+ <ToggleSwitch+ checked={rolloutPolicy.automatic}+ disabled={!canUpdatePolicy}+ onChange={toggleAutomatic}+ />+ <div className="flex flex-col">+ <span className="textlabel">{t("policy.rollout.auto")}</span>+ <div className="textinfolabel">+ {t("policy.rollout.auto-info")}+ </div>+ </div></div></div>- </div>+ </PermissionGuard></div>);}@@ -1452,19 +1456,17 @@ export function EnvironmentsPage() {onValueChange={(v) => selectTab(v as string)}className="flex-1 flex flex-col overflow-hidden">- <div className="flex items-center border-b border-control-border">- <TabsList className="flex-1 overflow-x-auto overflow-y-hidden gap-x-0 border-none">- {environmentList.map((env, index) => (- <TabsTrigger key={env.id} value={env.id} className="px-4 pt-1">- <span className="text-opacity-60 mr-1">{index + 1}.</span>- <EnvironmentName environment={env} />- </TabsTrigger>- ))}- </TabsList>-+ <TabsList className="flex-wrap">+ {environmentList.map((env, index) => (+ <TabsTrigger key={env.id} value={env.id} className="px-4">+ <span className="opacity-60 mr-1">{index + 1}.</span>+ <EnvironmentName environment={env} />+ </TabsTrigger>+ ))}+ <div className="flex-1" />{/* Toolbar */}<PermissionGuard permissions={["bb.settings.setEnvironment"]}>- <div className="flex items-center justify-end gap-x-2 px-2 pb-1 shrink-0">+ <div className="flex items-center gap-x-2 pb-2 mr-2 shrink-0"><Buttonvariant="outline"disabled={!canEdit || environmentList.length <= 1}@@ -1479,14 +1481,14 @@ export function EnvironmentsPage() {</Button></div></PermissionGuard>- </div>+ </TabsList>{/* Tab content */}{environmentList.map((env) => (<TabsPanelkey={env.id}value={env.id}- className="flex-1 overflow-auto mt-0"+ className="flex-1 overflow-auto"keepMounted={false}><EnvironmentDetaildiff --git a/frontend/src/react/pages/settings/IDPDetailPage.tsx b/frontend/src/react/pages/settings/IDPDetailPage.tsxindex 0bb4646700..b65ad769fd 100644--- a/frontend/src/react/pages/settings/IDPDetailPage.tsx+++ b/frontend/src/react/pages/settings/IDPDetailPage.tsx@@ -5,6 +5,7 @@ import { ArrowRight, Database, Info, Key, ShieldCheck, X } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { identityProviderServiceClientConnect } from "@/connect";+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";@@ -1606,27 +1607,31 @@ export function IDPDetailPage() {{/* Actions Section */}<div className="py-6"><div className="flex flex-row justify-between items-center">- <Button- variant="destructive"- onClick={() => setShowDeleteConfirm(true)}- disabled={- !hasWorkspacePermissionV2("bb.identityProviders.delete")- }- >- {t("settings.sso.delete")}- </Button>+ <PermissionGuard permissions={["bb.identityProviders.delete"]}>+ <Button+ variant="destructive"+ onClick={() => setShowDeleteConfirm(true)}+ disabled={+ !hasWorkspacePermissionV2("bb.identityProviders.delete")+ }+ >+ {t("settings.sso.delete")}+ </Button>+ </PermissionGuard><div className="gap-x-2 flex flex-row justify-end items-center">{hasChanges && (<Button variant="outline" onClick={handleDiscard}>{t("common.discard-changes")}</Button>)}- <Button- disabled={!canUpdate || isUpdating}- onClick={handleUpdate}- >- {t("common.update")}- </Button>+ <PermissionGuard permissions={["bb.identityProviders.update"]}>+ <Button+ disabled={!canUpdate || isUpdating}+ onClick={handleUpdate}+ >+ {t("common.update")}+ </Button>+ </PermissionGuard></div></div></div>diff --git a/frontend/src/react/pages/settings/MembersPage.tsx b/frontend/src/react/pages/settings/MembersPage.tsxindex a1db185b90..e5051b5d27 100644--- a/frontend/src/react/pages/settings/MembersPage.tsx+++ b/frontend/src/react/pages/settings/MembersPage.tsx@@ -28,6 +28,7 @@ import {import { AccountMultiSelect } from "@/react/components/AccountMultiSelect";import { DatabaseResourceSelector as DatabaseResourceSelectorComponent } from "@/react/components/DatabaseResourceSelector";import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { RoleSelect } from "@/react/components/RoleSelect";import { UserAvatar } from "@/react/components/UserAvatar";import {@@ -1783,27 +1784,29 @@ export function MembersPage({ projectId }: { projectId?: string }) {value={memberSearchText}onChange={(e) => setMemberSearchText(e.target.value)}/>- <div className="flex items-center gap-x-2">- {memberViewTab === "MEMBERS" && (+ <PermissionGuard permissions={["bb.workspaces.setIamPolicy"]}>+ <div className="flex items-center gap-x-2">+ {memberViewTab === "MEMBERS" && (+ <Button+ variant="outline"+ disabled={!canSetIamPolicy || selectedMembers.length === 0}+ onClick={handleRevokeSelected}+ >+ {t("settings.members.revoke-access")}+ </Button>+ )}<Button- variant="outline"- disabled={!canSetIamPolicy || selectedMembers.length === 0}- onClick={handleRevokeSelected}+ disabled={!canSetIamPolicy}+ onClick={() => {+ setEditingMember(undefined);+ setShowEditMemberDrawer(true);+ }}>- {t("settings.members.revoke-access")}+ <Plus className="h-4 w-4 mr-1" />+ {t("settings.members.grant-access")}</Button>- )}- <Button- disabled={!canSetIamPolicy}- onClick={() => {- setEditingMember(undefined);- setShowEditMemberDrawer(true);- }}- >- <Plus className="h-4 w-4 mr-1" />- {t("settings.members.grant-access")}- </Button>- </div>+ </div>+ </PermissionGuard></div><Tabsdiff --git a/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx b/frontend/src/react/pages/settings/SQLReviewDetailPage.tsxindex 37bc6d0b7a..7d007e762f 100644--- a/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx+++ b/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx@@ -2,6 +2,7 @@ import { Trash2 } from "lucide-react";import { useCallback, useEffect, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { rulesToTemplate } from "@/components/SQLReview/components/utils";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { AttachResourcesPanel } from "@/react/components/sql-review/Panels";import { ResourceLink } from "@/react/components/sql-review/ResourceLink";import { ReviewCreation } from "@/react/components/sql-review/ReviewCreation";@@ -257,36 +258,42 @@ export function SQLReviewDetailPage({</h1>)}<div className="flex gap-x-2">- {reviewPolicy.enforce ? (+ <PermissionGuard permissions={["bb.reviewConfigs.update"]}>+ {reviewPolicy.enforce ? (+ <Button+ variant="outline"+ disabled={!hasUpdatePermission}+ onClick={() => setShowDisableModal(true)}+ >+ {t("common.disable")}+ </Button>+ ) : (+ <Button+ variant="outline"+ disabled={!hasUpdatePermission}+ onClick={() => setShowEnableModal(true)}+ >+ {t("common.enable")}+ </Button>+ )}+ </PermissionGuard>+ <PermissionGuard permissions={["bb.policies.update"]}><Buttonvariant="outline"- disabled={!hasUpdatePermission}- onClick={() => setShowDisableModal(true)}+ disabled={!hasWorkspacePermissionV2("bb.policies.update")}+ onClick={() => setShowResourcePanel(true)}>- {t("common.disable")}+ {t("sql-review.attach-resource.change-resources")}</Button>- ) : (+ </PermissionGuard>+ <PermissionGuard permissions={["bb.reviewConfigs.update"]}><Button- variant="outline"disabled={!hasUpdatePermission}- onClick={() => setShowEnableModal(true)}+ onClick={() => setEditMode(true)}>- {t("common.enable")}+ {t("sql-review.create.configure-rule.change-template")}</Button>- )}- <Button- variant="outline"- disabled={!hasWorkspacePermissionV2("bb.policies.update")}- onClick={() => setShowResourcePanel(true)}- >- {t("sql-review.attach-resource.change-resources")}- </Button>- <Button- disabled={!hasUpdatePermission}- onClick={() => setEditMode(true)}- >- {t("sql-review.create.configure-rule.change-template")}- </Button>+ </PermissionGuard></div></div>@@ -341,14 +348,16 @@ export function SQLReviewDetailPage({{/* Delete button */}<hr className="my-6" />- <Button- variant="destructive"- disabled={!hasDeletePermission}- onClick={() => setShowDeleteConfirm(true)}- >- <Trash2 className="w-4 h-4 mr-1" />- {t("sql-review.delete")}- </Button>+ <PermissionGuard permissions={["bb.reviewConfigs.delete"]}>+ <Button+ variant="destructive"+ disabled={!hasDeletePermission}+ onClick={() => setShowDeleteConfirm(true)}+ >+ <Trash2 className="w-4 h-4 mr-1" />+ {t("sql-review.delete")}+ </Button>+ </PermissionGuard>{/* Sticky save bar when rules changed */}{rulesUpdated && (diff --git a/frontend/src/react/pages/settings/ServiceAccountsPage.tsx b/frontend/src/react/pages/settings/ServiceAccountsPage.tsxindex ed94fa4f2c..e6ba8edd5a 100644--- a/frontend/src/react/pages/settings/ServiceAccountsPage.tsx+++ b/frontend/src/react/pages/settings/ServiceAccountsPage.tsx@@ -3,6 +3,7 @@ import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";import { Copy, KeyRound, Pencil, Plus, Trash2, Undo2, X } from "lucide-react";import { useCallback, useState } from "react";import { useTranslation } from "react-i18next";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { RoleSelect } from "@/react/components/RoleSelect";import { UserAvatar } from "@/react/components/UserAvatar";import { Badge } from "@/react/components/ui/badge";@@ -702,21 +703,26 @@ export function ServiceAccountsPage({ projectId }: { projectId?: string }) {<h2 className="text-lg font-medium leading-7 text-main">{t("settings.members.service-accounts")}</h2>- <Button- disabled={- project- ? project.state !== State.ACTIVE ||- !hasProjectPermissionV2(project, "bb.serviceAccounts.create")- : !hasWorkspacePermissionV2("bb.serviceAccounts.create")- }- onClick={() => {- setEditingSa(undefined);- setShowDrawer(true);- }}+ <PermissionGuard+ permissions={["bb.serviceAccounts.create"]}+ project={project}>- <Plus className="h-4 w-4 mr-1" />- {t("common.create")}- </Button>+ <Button+ disabled={+ project+ ? project.state !== State.ACTIVE ||+ !hasProjectPermissionV2(project, "bb.serviceAccounts.create")+ : !hasWorkspacePermissionV2("bb.serviceAccounts.create")+ }+ onClick={() => {+ setEditingSa(undefined);+ setShowDrawer(true);+ }}+ >+ <Plus className="h-4 w-4 mr-1" />+ {t("common.create")}+ </Button>+ </PermissionGuard></div><div className="flex flex-col gap-y-4">diff --git a/frontend/src/react/pages/settings/WorkloadIdentitiesPage.tsx b/frontend/src/react/pages/settings/WorkloadIdentitiesPage.tsxindex a8e85c79ad..545944829c 100644--- a/frontend/src/react/pages/settings/WorkloadIdentitiesPage.tsx+++ b/frontend/src/react/pages/settings/WorkloadIdentitiesPage.tsx@@ -2,6 +2,7 @@ import { Pencil, Plus, Trash2, Undo2 } from "lucide-react";import { useCallback, useState } from "react";import { useTranslation } from "react-i18next";import { CreateWorkloadIdentityDrawer } from "@/react/components/CreateWorkloadIdentityDrawer";+import { PermissionGuard } from "@/react/components/PermissionGuard";import { UserAvatar } from "@/react/components/UserAvatar";import { Button } from "@/react/components/ui/button";import { Tooltip } from "@/react/components/ui/tooltip";@@ -320,21 +321,29 @@ export function WorkloadIdentitiesPage({ projectId }: { projectId?: string }) {<p className="text-lg font-medium leading-7 text-main">{t("settings.members.workload-identities")}</p>- <Button- disabled={- project- ? project.state !== State.ACTIVE ||- !hasProjectPermissionV2(project, "bb.workloadIdentities.create")- : !hasWorkspacePermissionV2("bb.workloadIdentities.create")- }- onClick={() => {- setEditingWI(undefined);- setShowDrawer(true);- }}+ <PermissionGuard+ permissions={["bb.workloadIdentities.create"]}+ project={project}>- <Plus className="h-4 w-4 mr-1" />- {t("common.create")}- </Button>+ <Button+ disabled={+ project+ ? project.state !== State.ACTIVE ||+ !hasProjectPermissionV2(+ project,+ "bb.workloadIdentities.create"+ )+ : !hasWorkspacePermissionV2("bb.workloadIdentities.create")+ }+ onClick={() => {+ setEditingWI(undefined);+ setShowDrawer(true);+ }}+ >+ <Plus className="h-4 w-4 mr-1" />+ {t("common.create")}+ </Button>+ </PermissionGuard></div><div className="flex flex-col gap-y-4">