Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: UI consistency (#20750)

ecmadao43d2d6eca77e
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 52c36cd6bf..4078c07d55 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1079,7 +1079,7 @@
"external-secret-gcp": "GCP Secret Manager",
"external-secret-vault": "Vault (KV v2)",
"google-iam": "Google Cloud SQL IAM",
- "password": "Password"
+ "password": "Plain Password"
},
"password-write-only": "YOUR_DB_PWD - write only",
"port": "Port",
@@ -1733,7 +1733,6 @@
"request-role": {
"disabled-reason": {
"allow-request-role-disabled": "Allow request role is disabled for this project.",
- "can-grant-access-directly": "You already have full access to this project, so you can grant access directly.",
"feature-unavailable": "Request role workflow is unavailable on the current plan."
},
"expiration-exceeds-max": "Expiration cannot exceed the workspace limit of {{days}} day(s).",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index b81846ba2a..aac946db36 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1733,7 +1733,6 @@
"request-role": {
"disabled-reason": {
"allow-request-role-disabled": "La solicitud de roles está deshabilitada para este proyecto.",
- "can-grant-access-directly": "Ya tienes acceso completo a este proyecto, así que puedes conceder acceso directamente.",
"feature-unavailable": "El flujo de solicitud de roles no está disponible en el plan actual."
},
"expiration-exceeds-max": "La expiración no puede exceder el límite del espacio de trabajo de {{days}} día(s).",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index ef9453ac11..605ff2de02 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1733,7 +1733,6 @@
"request-role": {
"disabled-reason": {
"allow-request-role-disabled": "このプロジェクトではロール申請が無効になっています。",
- "can-grant-access-directly": "このプロジェクトへのフルアクセス権を持っているため、直接アクセスを付与できます。",
"feature-unavailable": "現在のプランではロール申請ワークフローを利用できません。"
},
"expiration-exceeds-max": "有効期限はワークスペースの上限 {{days}} 日を超えることはできません。",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 3ab0c30bf1..6cfe61f363 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1733,7 +1733,6 @@
"request-role": {
"disabled-reason": {
"allow-request-role-disabled": "Dự án này đã tắt tính năng yêu cầu vai trò.",
- "can-grant-access-directly": "Bạn đã có toàn quyền truy cập dự án này, nên có thể cấp quyền truy cập trực tiếp.",
"feature-unavailable": "Quy trình yêu cầu vai trò không khả dụng trong gói hiện tại."
},
"expiration-exceeds-max": "Thời gian hết hạn không được vượt quá giới hạn {{days}} ngày của không gian làm việc.",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index bce30cb9ac..049237872c 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1733,7 +1733,6 @@
"request-role": {
"disabled-reason": {
"allow-request-role-disabled": "此项目未启用申请角色。",
- "can-grant-access-directly": "您已拥有该项目的完整访问权限,可以直接授予访问权限。",
"feature-unavailable": "当前套餐不支持申请角色工作流。"
},
"expiration-exceeds-max": "过期时间不能超过工作空间上限 {{days}} 天。",
diff --git a/frontend/src/react/components/AuditLogTable.tsx b/frontend/src/react/components/AuditLogTable.tsx
index e55656e09a..387c8a9baa 100644
--- a/frontend/src/react/components/AuditLogTable.tsx
+++ b/frontend/src/react/components/AuditLogTable.tsx
@@ -22,7 +22,12 @@ import {
DialogContent,
DialogTitle,
} from "@/react/components/ui/dialog";
-import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/react/components/ui/dropdown-menu";
import {
Table,
TableBody,
@@ -38,7 +43,6 @@ import {
getPageSizeOptions,
useSessionPageSize,
} from "@/react/hooks/useSessionPageSize";
-import { cn } from "@/react/lib/utils";
import { useAppStore } from "@/react/stores/app";
import { pushNotification } from "@/store";
import {
@@ -280,22 +284,6 @@ function ExportDropdown({
onExport: (format: ExportFormat) => void;
}) {
const { t } = useTranslation();
- const [open, setOpen] = useState(false);
- const containerRef = useRef<HTMLDivElement>(null);
-
- useEffect(() => {
- const handler = (e: MouseEvent) => {
- if (
- containerRef.current &&
- !containerRef.current.contains(e.target as Node)
- ) {
- setOpen(false);
- }
- };
- document.addEventListener("mousedown", handler);
- return () => document.removeEventListener("mousedown", handler);
- }, []);
-
const formats = [
{ format: ExportFormat.CSV, label: "CSV" },
{ format: ExportFormat.JSON, label: "JSON" },
@@ -303,37 +291,23 @@ function ExportDropdown({
];
return (
- <div ref={containerRef} className="relative shrink-0">
- <Button
- disabled={disabled}
- title={tooltip}
- onClick={() => setOpen(!open)}
- >
- <Download className="size-4 mr-1" />
- {t("common.export")}
- </Button>
- {open && !disabled && (
- <div
- className={cn(
- "absolute right-0 top-[42px] bg-background border border-control-border rounded-sm shadow-lg py-1 min-w-[100px]",
- LAYER_SURFACE_CLASS
- )}
- >
- {formats.map(({ format, label }) => (
- <button
- key={label}
- className="block w-full text-left px-3 py-1.5 text-sm hover:bg-control-bg"
- onClick={() => {
- onExport(format);
- setOpen(false);
- }}
- >
- {label}
- </button>
- ))}
- </div>
- )}
- </div>
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button disabled={disabled} title={tooltip}>
+ <Download className="size-4 mr-1" />
+ {t("common.export")}
+ </Button>
+ }
+ />
+ <DropdownMenuContent className="min-w-[100px]">
+ {formats.map(({ format, label }) => (
+ <DropdownMenuItem key={label} onClick={() => onExport(format)}>
+ {label}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
);
}
diff --git a/frontend/src/react/components/BannersWrapper.test.tsx b/frontend/src/react/components/BannersWrapper.test.tsx
index 86f77ad8e1..efd3a45b0f 100644
--- a/frontend/src/react/components/BannersWrapper.test.tsx
+++ b/frontend/src/react/components/BannersWrapper.test.tsx
@@ -261,8 +261,8 @@ describe("BannersWrapper", () => {
const banner = Array.from(container.querySelectorAll("div")).find((el) =>
el.textContent?.includes("Untheméd banner")
);
- // info preset background: "#2563eb", white text.
- expect(banner?.style.backgroundColor).toBe("rgb(37, 99, 235)");
+ // info preset background follows --color-accent (#4f46e5), white text.
+ expect(banner?.style.backgroundColor).toBe("rgb(79, 70, 229)");
expect(banner?.style.color).toBe("rgb(255, 255, 255)");
unmount();
});
diff --git a/frontend/src/react/components/CreateWorkloadIdentitySheet.test.tsx b/frontend/src/react/components/CreateWorkloadIdentitySheet.test.tsx
new file mode 100644
index 0000000000..e3f06bbc21
--- /dev/null
+++ b/frontend/src/react/components/CreateWorkloadIdentitySheet.test.tsx
@@ -0,0 +1,118 @@
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, describe, expect, test, vi } from "vitest";
+import { CreateWorkloadIdentitySheet } from "./CreateWorkloadIdentitySheet";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => {
+ const store = {
+ projectsByName: {},
+ getProjectIamPolicy: vi.fn(),
+ updateProjectIamPolicy: vi.fn(),
+ patchWorkspaceIamPolicy: vi.fn(),
+ createWorkloadIdentity: vi.fn(),
+ updateWorkloadIdentity: vi.fn(),
+ workspaceResourceName: () => "workspaces/default",
+ };
+ const useAppStore = vi.fn((selector: (state: typeof store) => unknown) =>
+ selector(store)
+ );
+ return {
+ store,
+ useAppStore: Object.assign(useAppStore, {
+ getState: () => store,
+ }),
+ };
+});
+
+vi.mock("react-i18next", () => ({
+ initReactI18next: { type: "3rdParty", init: () => undefined },
+ useTranslation: () => ({
+ t: (key: string) => key,
+ }),
+}));
+
+vi.mock("@/react/components/RoleSelect", () => ({
+ RoleSelect: () => <div data-testid="role-select" />,
+}));
+
+vi.mock("@/react/components/ui/sheet", () => ({
+ Sheet: ({ children, open }: { children: React.ReactNode; open: boolean }) =>
+ open ? <div>{children}</div> : null,
+ SheetBody: ({ children }: { children: React.ReactNode }) => (
+ <div>{children}</div>
+ ),
+ SheetContent: ({ children }: { children: React.ReactNode }) => (
+ <div>{children}</div>
+ ),
+ SheetFooter: ({ children }: { children: React.ReactNode }) => (
+ <div>{children}</div>
+ ),
+ SheetHeader: ({ children }: { children: React.ReactNode }) => (
+ <div>{children}</div>
+ ),
+ SheetTitle: ({ children }: { children: React.ReactNode }) => (
+ <h2>{children}</h2>
+ ),
+}));
+
+vi.mock("@/react/hooks/useProjectByName", () => ({
+ useProjectByName: () => undefined,
+}));
+
+vi.mock("@/react/stores/app", () => ({
+ useAppStore: mocks.useAppStore,
+}));
+
+vi.mock("@/store", () => ({
+ pushNotification: vi.fn(),
+}));
+
+vi.mock("@/utils", () => ({
+ getWorkloadIdentityProviderText: (provider: number) =>
+ provider === 1 ? "GitLab" : "GitHub Actions",
+ hasProjectPermissionV2: () => true,
+ hasWorkspacePermissionV2: () => true,
+ parseWorkloadIdentitySubjectPattern: () => undefined,
+}));
+
+describe("CreateWorkloadIdentitySheet", () => {
+ afterEach(() => {
+ document.body.innerHTML = "";
+ vi.clearAllMocks();
+ });
+
+ test("places role selection directly after email in create mode", () => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+
+ act(() => {
+ root.render(
+ <CreateWorkloadIdentitySheet
+ open
+ onClose={() => undefined}
+ onCreated={() => undefined}
+ />
+ );
+ });
+
+ const text = container.textContent ?? "";
+ const emailIndex = text.indexOf("common.email");
+ const rolesIndex = text.indexOf("settings.members.table.roles");
+ const platformIndex = text.indexOf(
+ "settings.members.workload-identity-platform"
+ );
+
+ expect(emailIndex).toBeGreaterThanOrEqual(0);
+ expect(rolesIndex).toBeGreaterThan(emailIndex);
+ expect(platformIndex).toBeGreaterThan(rolesIndex);
+
+ act(() => {
+ root.unmount();
+ });
+ });
+});
diff --git a/frontend/src/react/components/CreateWorkloadIdentitySheet.tsx b/frontend/src/react/components/CreateWorkloadIdentitySheet.tsx
index fb74770ee4..6bb4f5f944 100644
--- a/frontend/src/react/components/CreateWorkloadIdentitySheet.tsx
+++ b/frontend/src/react/components/CreateWorkloadIdentitySheet.tsx
@@ -5,6 +5,11 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { RoleSelect } from "@/react/components/RoleSelect";
import { Button } from "@/react/components/ui/button";
+import {
+ FormDescription,
+ FormField,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Sheet,
@@ -304,6 +309,9 @@ function WorkloadIdentityForm({
const hasPermission = projectEntity
? hasProjectPermissionV2(projectEntity, requiredPermission)
: hasWorkspacePermissionV2(requiredPermission);
+ const canSetRoles = projectEntity
+ ? hasProjectPermissionV2(projectEntity, "bb.projects.setIamPolicy")
+ : hasWorkspacePermissionV2("bb.workspaces.setIamPolicy");
const handleSubmit = async () => {
if (!allowConfirm || !hasPermission) return;
@@ -433,10 +441,8 @@ function WorkloadIdentityForm({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Title */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("common.name")}
- </label>
+ <FormField>
+ <FormLabel>{t("common.name")}</FormLabel>
<Input
value={title}
onChange={(e) => setTitle(e.target.value)}
@@ -444,14 +450,14 @@ function WorkloadIdentityForm({
maxLength={200}
autoComplete="off"
/>
- </div>
+ </FormField>
{/* Email */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.email")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
{isEditMode ? (
<Input value={workloadIdentity!.email} disabled />
) : (
@@ -468,14 +474,22 @@ function WorkloadIdentityForm({
</span>
</div>
)}
- </div>
+ </FormField>
+
+ {/* Roles (create mode only) */}
+ {!isEditMode && canSetRoles && (
+ <FormField>
+ <FormLabel>{t("settings.members.table.roles")}</FormLabel>
+ <RoleSelect value={roles} onChange={setRoles} disabled={false} />
+ </FormField>
+ )}
{/* Platform */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.workload-identity-platform")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
<select
value={providerType}
onChange={(e) =>
@@ -494,16 +508,16 @@ function WorkloadIdentityForm({
</option>
))}
</select>
- </div>
+ </FormField>
{/* Owner / Group */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{isGitLab
? t("settings.members.workload-identity-group")
: t("settings.members.workload-identity-owner")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
<Input
value={owner}
onChange={(e) => setOwner(e.target.value)}
@@ -511,15 +525,15 @@ function WorkloadIdentityForm({
maxLength={200}
autoComplete="off"
/>
- </div>
+ </FormField>
{/* Repository / Project */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{isGitLab
? t("settings.members.workload-identity-project")
: t("settings.members.workload-identity-repo")}
- </label>
+ </FormLabel>
<Input
value={repo}
onChange={(e) => setRepo(e.target.value)}
@@ -527,19 +541,19 @@ function WorkloadIdentityForm({
maxLength={200}
autoComplete="off"
/>
- <span className="text-xs text-control-light">
+ <FormDescription>
{isGitLab
? t("settings.members.workload-identity-project-hint")
: t("settings.members.workload-identity-repo-hint")}
- </span>
- </div>
+ </FormDescription>
+ </FormField>
{/* Allowed Branches/Tags (GitLab only) */}
{isGitLab && (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.workload-identity-allowed-branches-tags")}
- </label>
+ </FormLabel>
<select
value={refType}
onChange={(e) => setRefType(e.target.value as RefType)}
@@ -555,17 +569,17 @@ function WorkloadIdentityForm({
{t("settings.members.workload-identity-specific-tag")}
</option>
</select>
- </div>
+ </FormField>
)}
{/* Branch / Tag */}
{showBranchField && (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{isTagRefType
? t("settings.members.workload-identity-tag")
: t("settings.members.workload-identity-branch")}
- </label>
+ </FormLabel>
<Input
value={branch}
onChange={(e) => setBranch(e.target.value)}
@@ -573,24 +587,24 @@ function WorkloadIdentityForm({
maxLength={200}
autoComplete="off"
/>
- <span className="text-xs text-control-light">
+ <FormDescription>
{isTagRefType
? t("settings.members.workload-identity-tag-hint")
: t("settings.members.workload-identity-branch-hint")}
- </span>
- </div>
+ </FormDescription>
+ </FormField>
)}
{/* Advanced Settings */}
{showAdvanced && (
<div className="flex flex-col gap-y-6 pt-6 border-t">
{/* Issuer URL / GitLab URL */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{isGitLab
? t("settings.members.workload-identity-gitlab-url")
: t("settings.members.workload-identity-issuer")}
- </label>
+ </FormLabel>
<Input
value={issuerUrl}
onChange={(e) => setIssuerUrl(e.target.value)}
@@ -598,37 +612,37 @@ function WorkloadIdentityForm({
autoComplete="off"
/>
{isGitLab && (
- <span className="text-xs text-control-light">
+ <FormDescription>
{t("settings.members.workload-identity-gitlab-url-hint")}
- </span>
+ </FormDescription>
)}
- </div>
+ </FormField>
{/* Audience */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.workload-identity-audience")}
- </label>
+ </FormLabel>
<Input
value={audience}
onChange={(e) => setAudience(e.target.value)}
maxLength={500}
autoComplete="off"
/>
- </div>
+ </FormField>
{/* Subject Pattern */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.workload-identity-subject")}
- </label>
+ </FormLabel>
<Input
value={subjectPattern}
onChange={(e) => setSubjectPattern(e.target.value)}
maxLength={500}
autoComplete="off"
/>
- </div>
+ </FormField>
</div>
)}
@@ -645,26 +659,6 @@ function WorkloadIdentityForm({
<ChevronDown className="size-4" />
)}
</button>
-
- {/* Roles (create mode only) */}
- {!isEditMode &&
- (projectEntity
- ? hasProjectPermissionV2(
- projectEntity,
- "bb.projects.setIamPolicy"
- )
- : hasWorkspacePermissionV2("bb.workspaces.setIamPolicy")) && (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("settings.members.table.roles")}
- </label>
- <RoleSelect
- value={roles}
- onChange={setRoles}
- disabled={false}
- />
- </div>
- )}
</div>
</SheetBody>
diff --git a/frontend/src/react/components/DatabaseGroupForm.tsx b/frontend/src/react/components/DatabaseGroupForm.tsx
index 0a93c64671..707079e2e8 100644
--- a/frontend/src/react/components/DatabaseGroupForm.tsx
+++ b/frontend/src/react/components/DatabaseGroupForm.tsx
@@ -15,6 +15,7 @@ import { MatchedDatabaseView } from "@/react/components/MatchedDatabaseView";
import { ResourceIdField } from "@/react/components/ResourceIdField";
import { Button } from "@/react/components/ui/button";
import { Input } from "@/react/components/ui/input";
+import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
import {
FactorList,
getDatabaseGroupOptionConfigMap,
@@ -246,16 +247,19 @@ export function DatabaseGroupForm({
</div>
{!readonly && (
- <div className="sticky bottom-0 z-10">
- <div className="flex justify-end w-full pt-4 pb-2 px-4 border-t border-block-border bg-background gap-x-4">
+ <StickyActionFooter
+ className="pt-4 pb-2"
+ left={
<Button variant="outline" onClick={onDismiss}>
{t("common.cancel")}
</Button>
+ }
+ right={
<Button disabled={!allowConfirm} onClick={doConfirm}>
{isCreating ? t("common.create") : t("common.update")}
</Button>
- </div>
- </div>
+ }
+ />
)}
</div>
);
diff --git a/frontend/src/react/components/EditEnvironmentSheet.tsx b/frontend/src/react/components/EditEnvironmentSheet.tsx
index 388b9e98e1..64fe76dbb8 100644
--- a/frontend/src/react/components/EditEnvironmentSheet.tsx
+++ b/frontend/src/react/components/EditEnvironmentSheet.tsx
@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { EnvironmentLabel } from "@/react/components/EnvironmentLabel";
import { Button } from "@/react/components/ui/button";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
SheetBody,
@@ -41,10 +42,15 @@ export function EditEnvironmentSheet({
<SheetTitle>{t("database.edit-environment")}</SheetTitle>
</SheetHeader>
<SheetBody>
- <div className="flex flex-col gap-y-1">
+ <RadioGroup
+ className="flex-col items-stretch gap-y-1"
+ value={selected}
+ onValueChange={(value) => setSelected(value as string)}
+ >
{environments.map((env) => (
- <label
+ <RadioGroupItem
key={env.name}
+ value={env.name}
className={cn(
"flex items-center gap-x-3 px-3 py-2.5 rounded-sm cursor-pointer border transition-colors",
selected === env.name
@@ -52,17 +58,10 @@ export function EditEnvironmentSheet({
: "border-transparent hover:bg-control-bg"
)}
>
- <input
- type="radio"
- name="environment"
- checked={selected === env.name}
- onChange={() => setSelected(env.name)}
- className="accent-accent"
- />
<EnvironmentLabel environment={env} />
- </label>
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
</SheetBody>
<SheetFooter>
<Button variant="ghost" onClick={onClose}>
diff --git a/frontend/src/react/components/IssueTable.tsx b/frontend/src/react/components/IssueTable.tsx
index 1ac1e1a91f..79bb77a6e8 100644
--- a/frontend/src/react/components/IssueTable.tsx
+++ b/frontend/src/react/components/IssueTable.tsx
@@ -1,6 +1,6 @@
import { create } from "@bufbuild/protobuf";
import { ArrowUpDown, Check, Loader2 } from "lucide-react";
-import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { memo, useCallback, useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import { issueServiceClientConnect } from "@/connect";
import {
@@ -16,8 +16,14 @@ import { SelectionActionBar } from "@/react/components/SelectionActionBar";
import { TimeRangePicker } from "@/react/components/TimeRangePicker";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuTrigger,
+} from "@/react/components/ui/dropdown-menu";
import { EllipsisText } from "@/react/components/ui/ellipsis-text";
-import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";
import {
Sheet,
SheetBody,
@@ -28,7 +34,6 @@ import {
} from "@/react/components/ui/sheet";
import { Tooltip } from "@/react/components/ui/tooltip";
import { useCurrentUser } from "@/react/hooks/useAppState";
-import { useClickOutside } from "@/react/hooks/useClickOutside";
import { useEscapeKey } from "@/react/hooks/useEscapeKey";
import { displayRoleTitleFromList } from "@/react/lib/role";
import { cn } from "@/react/lib/utils";
@@ -110,9 +115,6 @@ function IssueSortDropdown({
onOrderByChange: (v: string) => void;
}) {
const { t } = useTranslation();
- const [open, setOpen] = useState(false);
- const containerRef = useRef<HTMLDivElement>(null);
- useClickOutside(containerRef, open, () => setOpen(false));
const sortOptions = useMemo(
() => [
@@ -136,57 +138,53 @@ function IssueSortDropdown({
const handleSelect = (key: string) => {
onOrderByChange(key === orderBy ? "" : key);
- setOpen(false);
};
return (
- <div ref={containerRef} className="relative">
- <Button
- variant="ghost"
- size="sm"
- className={cn(
- orderBy
- ? "text-accent! hover:text-accent"
- : "text-control-placeholder hover:text-control"
- )}
- onClick={() => setOpen(!open)}
- >
- <ArrowUpDown className="size-4" />
- <span className="hidden md:inline ml-1">{t("issue.sort.sort")}</span>
- </Button>
- {open && (
- <div
- className={cn(
- "absolute right-0 top-full mt-1 bg-background border border-block-border rounded-sm shadow-lg min-w-[180px] py-1",
- LAYER_SURFACE_CLASS
- )}
- >
- {sortOptions.map((group) => (
- <div key={group.label}>
- <div className="px-3 py-1.5 text-xs text-control-light font-medium">
- {group.label}
- </div>
- {group.children.map((opt) => (
- <button
- key={opt.key}
- type="button"
- className="w-full text-left px-3 py-1.5 text-sm hover:bg-control-bg flex items-center gap-x-2"
- onClick={() => handleSelect(opt.key)}
- >
- <Check
- className={cn(
- "size-3",
- orderBy === opt.key ? "text-accent" : "text-transparent"
- )}
- />
- {opt.label}
- </button>
- ))}
- </div>
- ))}
- </div>
- )}
- </div>
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="sm"
+ className={cn(
+ orderBy
+ ? "text-accent! hover:text-accent"
+ : "text-control-placeholder hover:text-control"
+ )}
+ >
+ <ArrowUpDown className="size-4" />
+ <span className="hidden md:inline ml-1">
+ {t("issue.sort.sort")}
+ </span>
+ </Button>
+ }
+ />
+ <DropdownMenuContent className="min-w-[180px]">
+ {sortOptions.map((group) => (
+ <div key={group.label}>
+ <DropdownMenuLabel className="px-3 font-medium">
+ {group.label}
+ </DropdownMenuLabel>
+ {group.children.map((opt) => (
+ <DropdownMenuItem
+ key={opt.key}
+ className="gap-x-2"
+ onClick={() => handleSelect(opt.key)}
+ >
+ <Check
+ className={cn(
+ "size-3",
+ orderBy === opt.key ? "text-accent" : "text-transparent"
+ )}
+ />
+ {opt.label}
+ </DropdownMenuItem>
+ ))}
+ </div>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
);
}
diff --git a/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx b/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx
index 4d46534a70..b7efaf8a3c 100644
--- a/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx
+++ b/frontend/src/react/components/SchemaEditorLite/Aside/AsideTree.tsx
@@ -14,10 +14,15 @@ import {
import { Fragment, useCallback, useMemo, useRef, useState } from "react";
import type { NodeRendererProps } from "react-arborist";
import { Tree } from "react-arborist";
-import { createPortal } from "react-dom";
import { useTranslation } from "react-i18next";
import { ColumnIcon } from "@/react/components/schema/icons";
import { Badge } from "@/react/components/ui/badge";
+import {
+ ContextMenu,
+ ContextMenuContent,
+ ContextMenuItem,
+ ContextMenuTrigger,
+} from "@/react/components/ui/context-menu";
import {
DropdownMenu,
DropdownMenuContent,
@@ -26,7 +31,6 @@ import {
DropdownMenuTrigger,
} from "@/react/components/ui/dropdown-menu";
import { ErrorBoundary } from "@/react/components/ui/error-boundary";
-import { getLayerRoot, LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";
import { SearchInput } from "@/react/components/ui/search-input";
import { cn } from "@/react/lib/utils";
import type {
@@ -522,6 +526,50 @@ export function AsideTree() {
return actions;
}, [readonly, targets, t, editStatus, tabs, rebuildTree]);
+ const treeSurface = (
+ <div ref={containerRef} className="flex-1 overflow-hidden">
+ {/* react-arborist hard-throws on malformed data (e.g. a falsy
+ node id) — contain that to this pane, same as the shared
+ ui/Tree primitive does. */}
+ <ErrorBoundary
+ resetKey={arboristData}
+ fallback={
+ <div className="px-2 py-1 text-sm text-control-light">
+ {t("common.render-failed")}
+ </div>
+ }
+ onError={(error) => {
+ console.error("[AsideTree] failed to render tree data:", error);
+ }}
+ >
+ <Tree
+ data={arboristData}
+ idAccessor="id"
+ searchTerm={searchPattern}
+ searchMatch={(node, term) =>
+ node.data.name.toLowerCase().includes(term.toLowerCase())
+ }
+ rowHeight={28}
+ indent={16}
+ openByDefault={false}
+ width="100%"
+ height={containerRef.current?.clientHeight ?? 400}
+ >
+ {(props) => (
+ <NodeRenderer
+ {...props}
+ nodeMap={nodeMap}
+ onNodeClick={handleNodeClick}
+ onContextMenu={readonly ? undefined : showMenu}
+ getNodeStatus={getNodeStatus}
+ selection={selection}
+ />
+ )}
+ </Tree>
+ </ErrorBoundary>
+ </div>
+ );
+
return (
<div className="flex size-full flex-col gap-y-2">
<div className="sticky top-0 flex items-center gap-x-1 px-1 pt-1">
@@ -553,79 +601,29 @@ export function AsideTree() {
</DropdownMenu>
)}
</div>
- <div ref={containerRef} className="flex-1 overflow-hidden">
- {/* react-arborist hard-throws on malformed data (e.g. a falsy
- node id) — contain that to this pane, same as the shared
- ui/Tree primitive does. */}
- <ErrorBoundary
- resetKey={arboristData}
- fallback={
- <div className="px-2 py-1 text-sm text-control-light">
- {t("common.render-failed")}
- </div>
- }
- onError={(error) => {
- console.error("[AsideTree] failed to render tree data:", error);
+ {readonly ? (
+ treeSurface
+ ) : (
+ <ContextMenu
+ onOpenChange={(open) => {
+ if (!open) hideMenu();
}}
>
- <Tree
- data={arboristData}
- idAccessor="id"
- searchTerm={searchPattern}
- searchMatch={(node, term) =>
- node.data.name.toLowerCase().includes(term.toLowerCase())
- }
- rowHeight={28}
- indent={16}
- openByDefault={false}
- width="100%"
- height={containerRef.current?.clientHeight ?? 400}
- >
- {(props) => (
- <NodeRenderer
- {...props}
- nodeMap={nodeMap}
- onNodeClick={handleNodeClick}
- onContextMenu={readonly ? undefined : showMenu}
- getNodeStatus={getNodeStatus}
- selection={selection}
- />
- )}
- </Tree>
- </ErrorBoundary>
- </div>
-
- {/* Context menu portal */}
- {menuState.show &&
- menuOptions.length > 0 &&
- createPortal(
- <div
- className="fixed inset-0"
- onClick={hideMenu}
- onContextMenu={(e) => {
- e.preventDefault();
- hideMenu();
- }}
- >
- <div
- className={`absolute rounded-sm border border-control-border bg-background py-1 shadow-md ${LAYER_SURFACE_CLASS}`}
- style={{ left: menuState.x, top: menuState.y }}
- onClick={(e) => e.stopPropagation()}
- >
+ <ContextMenuTrigger render={treeSurface} />
+ {menuState.show && menuOptions.length > 0 && (
+ <ContextMenuContent>
{menuOptions.map((opt) => (
- <button
+ <ContextMenuItem
key={opt.key}
- type="button"
- className="flex w-full items-center px-3 py-1.5 text-left text-sm hover:bg-control-bg-hover"
onClick={() => handleMenuSelect(opt.key)}
>
{opt.label}
- </button>
+ </ContextMenuItem>
))}
- </div>
- </div>,
- getLayerRoot("overlay")
- )}
+ </ContextMenuContent>
+ )}
+ </ContextMenu>
+ )}
{/* Modals */}
{tableNameModalCtx && (
diff --git a/frontend/src/react/components/SchemaEditorLite/Aside/useContextMenu.ts b/frontend/src/react/components/SchemaEditorLite/Aside/useContextMenu.ts
index 4528cc34a8..30f561c62d 100644
--- a/frontend/src/react/components/SchemaEditorLite/Aside/useContextMenu.ts
+++ b/frontend/src/react/components/SchemaEditorLite/Aside/useContextMenu.ts
@@ -151,8 +151,6 @@ export function useContextMenu(editStatus: EditStatusContext) {
}, [menuState, editStatus, t]);
const showMenu = useCallback((e: React.MouseEvent, node: TreeNode) => {
- e.preventDefault();
- e.stopPropagation();
setMenuState({ show: true, x: e.clientX, y: e.clientY, node });
}, []);
diff --git a/frontend/src/react/components/announcement-theme.ts b/frontend/src/react/components/announcement-theme.ts
index 6026587602..3b692f3dee 100644
--- a/frontend/src/react/components/announcement-theme.ts
+++ b/frontend/src/react/components/announcement-theme.ts
@@ -10,14 +10,14 @@ export type AnnouncementPresetKey = "info" | "warning" | "critical";
/**
* Built-in presets are a frontend-only concept that seed the two banner colors.
- * Each value is a #rrggbb hex color. The backgrounds match `--color-info` /
- * `--color-warning` / `--color-error`, all with white text.
+ * Each value is a #rrggbb hex color. The normal background matches
+ * `--color-accent`; warning and critical match their semantic tokens.
*/
export const ANNOUNCEMENT_PRESETS: Record<
AnnouncementPresetKey,
AnnouncementTheme
> = {
- info: { background: "#2563eb", text: "#ffffff" },
+ info: { background: "#4f46e5", text: "#ffffff" },
warning: { background: "#f59e0b", text: "#ffffff" },
critical: { background: "#dc2626", text: "#ffffff" },
};
diff --git a/frontend/src/react/components/database/TransferProjectSheet.tsx b/frontend/src/react/components/database/TransferProjectSheet.tsx
index 9d1beffbd5..73f7250c4c 100644
--- a/frontend/src/react/components/database/TransferProjectSheet.tsx
+++ b/frontend/src/react/components/database/TransferProjectSheet.tsx
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
import { DatabaseTableView } from "@/react/components/database";
import { ProjectSelect } from "@/react/components/ProjectSelect";
import { Button } from "@/react/components/ui/button";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
SheetBody,
@@ -62,30 +63,18 @@ export function TransferProjectSheet({
<DatabaseTableView databases={databases} />
</div>
- <div className="shrink-0 flex items-center gap-x-6">
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="transfer-mode"
- checked={mode === "project"}
- onChange={() => setMode("project")}
- className="accent-accent"
- />
- <span className="text-sm font-medium">{t("common.project")}</span>
- </label>
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="transfer-mode"
- checked={mode === "unassign"}
- onChange={() => setMode("unassign")}
- className="accent-accent"
- />
- <span className="text-sm font-medium">
- {t("database.unassign")}
- </span>
- </label>
- </div>
+ <RadioGroup
+ className="shrink-0 gap-x-6"
+ value={mode}
+ onValueChange={(value) => setMode(value as "project" | "unassign")}
+ >
+ <RadioGroupItem value="project" contentClassName="font-medium">
+ {t("common.project")}
+ </RadioGroupItem>
+ <RadioGroupItem value="unassign" contentClassName="font-medium">
+ {t("database.unassign")}
+ </RadioGroupItem>
+ </RadioGroup>
{mode === "project" && (
<div className="shrink-0">
diff --git a/frontend/src/react/components/header/ProfileMenuTrigger.tsx b/frontend/src/react/components/header/ProfileMenuTrigger.tsx
index d0dc5fb763..d6d3beb2e7 100644
--- a/frontend/src/react/components/header/ProfileMenuTrigger.tsx
+++ b/frontend/src/react/components/header/ProfileMenuTrigger.tsx
@@ -12,6 +12,7 @@ import {
DropdownMenuSubmenuTrigger,
DropdownMenuTrigger,
} from "@/react/components/ui/dropdown-menu";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
useAppFeature,
useOptionalCurrentUser,
@@ -53,6 +54,23 @@ export function ProfileMenuTrigger({
const resetQuickstartProgress = useQuickstartReset();
const hideQuickStart = useAppFeature("bb.feature.hide-quick-start");
const currentPlan = subscription?.plan ?? PlanType.FREE;
+ const devLicenseOptions = [
+ {
+ label: t("subscription.plan.free.title"),
+ value: "",
+ plan: PlanType.FREE,
+ },
+ {
+ label: t("subscription.plan.team.title"),
+ value: import.meta.env.BB_DEV_TEAM_LICENSE as string,
+ plan: PlanType.TEAM,
+ },
+ {
+ label: t("subscription.plan.enterprise.title"),
+ value: import.meta.env.BB_DEV_ENTERPRISE_LICENSE as string,
+ plan: PlanType.ENTERPRISE,
+ },
+ ];
const quickStartEnabled =
!hideQuickStart &&
Boolean(serverInfo?.enableSample) &&
@@ -144,27 +162,31 @@ export function ProfileMenuTrigger({
<ChevronRight className="h-4 w-4 text-control-light" />
</DropdownMenuSubmenuTrigger>
<DropdownMenuSubmenuContent className="w-48">
- {HEADER_LANGUAGE_OPTIONS.map((item) => (
- <DropdownMenuItem
- key={item.value}
- className={
- item.value === i18n.language ? "bg-control-bg" : ""
- }
- onClick={() => {
- setAppLocale(item.value);
- setOpen(false);
- }}
- >
- <span className="mr-2">
- <input
- type="radio"
- readOnly
- checked={item.value === i18n.language}
- />
- </span>
- {item.label}
- </DropdownMenuItem>
- ))}
+ <RadioGroup
+ className="flex-col items-stretch gap-0"
+ value={i18n.language}
+ onValueChange={(value) => {
+ setAppLocale(String(value));
+ setOpen(false);
+ }}
+ >
+ {HEADER_LANGUAGE_OPTIONS.map((item) => (
+ <DropdownMenuItem
+ key={item.value}
+ className={
+ item.value === i18n.language ? "bg-control-bg" : ""
+ }
+ onClick={() => {
+ setAppLocale(item.value);
+ setOpen(false);
+ }}
+ >
+ <RadioGroupItem value={item.value}>
+ {item.label}
+ </RadioGroupItem>
+ </DropdownMenuItem>
+ ))}
+ </RadioGroup>
</DropdownMenuSubmenuContent>
</DropdownMenuSubmenu>
@@ -175,38 +197,32 @@ export function ProfileMenuTrigger({
<ChevronRight className="h-4 w-4 text-control-light" />
</DropdownMenuSubmenuTrigger>
<DropdownMenuSubmenuContent className="w-48">
- {[
- {
- label: t("subscription.plan.free.title"),
- value: "",
- plan: PlanType.FREE,
- },
- {
- label: t("subscription.plan.team.title"),
- value: import.meta.env.BB_DEV_TEAM_LICENSE as string,
- plan: PlanType.TEAM,
- },
- {
- label: t("subscription.plan.enterprise.title"),
- value: import.meta.env.BB_DEV_ENTERPRISE_LICENSE as string,
- plan: PlanType.ENTERPRISE,
- },
- ].map((item) => (
- <DropdownMenuItem
- key={item.plan}
- className={item.plan === currentPlan ? "bg-control-bg" : ""}
- onClick={() => switchPlan(item.value)}
- >
- <span className="mr-2">
- <input
- type="radio"
- readOnly
- checked={item.plan === currentPlan}
- />
- </span>
- {item.label}
- </DropdownMenuItem>
- ))}
+ <RadioGroup
+ className="flex-col items-stretch gap-0"
+ value={String(currentPlan)}
+ onValueChange={(value) => {
+ const item = devLicenseOptions.find(
+ (item) => String(item.plan) === value
+ );
+ if (item) {
+ switchPlan(item.value);
+ }
+ }}
+ >
+ {devLicenseOptions.map((item) => (
+ <DropdownMenuItem
+ key={item.plan}
+ className={
+ item.plan === currentPlan ? "bg-control-bg" : ""
+ }
+ onClick={() => switchPlan(item.value)}
+ >
+ <RadioGroupItem value={String(item.plan)}>
+ {item.label}
+ </RadioGroupItem>
+ </DropdownMenuItem>
+ ))}
+ </RadioGroup>
</DropdownMenuSubmenuContent>
</DropdownMenuSubmenu>
) : null}
diff --git a/frontend/src/react/components/instance/CredentialSourceForm.tsx b/frontend/src/react/components/instance/CredentialSourceForm.tsx
index 1f7ea5ba25..d5e7cfb7bc 100644
--- a/frontend/src/react/components/instance/CredentialSourceForm.tsx
+++ b/frontend/src/react/components/instance/CredentialSourceForm.tsx
@@ -8,6 +8,7 @@ import {
} from "react";
import { Trans, useTranslation } from "react-i18next";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { Textarea } from "@/react/components/ui/textarea";
import { useServerState } from "@/react/hooks/useAppState";
import { Engine } from "@/types/proto-es/v1/common_pb";
@@ -213,11 +214,18 @@ function CredentialSourceForm({
<label htmlFor="credential-source" className="textlabel block">
{t("instance.iam-extension.credential-source")}
</label>
- <div className="textlabel mt-2 flex gap-x-4">
+ <RadioGroup
+ className="textlabel mt-2 gap-x-4"
+ value={credentialSource}
+ onValueChange={(value) =>
+ handleCredentialSourceChange(value as CredentialSource)
+ }
+ >
{options.map((option) => (
- <label
+ <RadioGroupItem
key={option.value}
- className="inline-flex items-center gap-x-1.5"
+ value={option.value}
+ disabled={!allowEdit || option.disabled}
title={
option.disabled
? t(
@@ -226,18 +234,10 @@ function CredentialSourceForm({
: undefined
}
>
- <input
- type="radio"
- name="credential-source"
- value={option.value}
- checked={credentialSource === option.value}
- disabled={!allowEdit || option.disabled}
- onChange={() => handleCredentialSourceChange(option.value)}
- />
- <span>{option.label}</span>
- </label>
+ {option.label}
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
{credentialSource === "specific-credential" && (
<>
@@ -353,23 +353,21 @@ function CloudSQLIPTypeField({
<label className="textlabel block">
{t("instance.cloud-sql-ip-type.label")}
</label>
- <div className="textlabel mt-2 flex gap-x-4">
+ <RadioGroup
+ className="textlabel mt-2 gap-x-4"
+ value={String(current)}
+ onValueChange={(next) => onChange(Number(next))}
+ >
{options.map((option) => (
- <label
+ <RadioGroupItem
key={option.value}
- className="inline-flex items-center gap-x-1.5"
+ value={String(option.value)}
+ disabled={!allowEdit}
>
- <input
- type="radio"
- name="cloud-sql-ip-type"
- checked={current === option.value}
- disabled={!allowEdit}
- onChange={() => onChange(option.value)}
- />
- <span>{option.label}</span>
- </label>
+ {option.label}
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
<p className="textinfolabel mt-1">
{t("instance.cloud-sql-ip-type.description")}
</p>
diff --git a/frontend/src/react/components/instance/DataSourceForm.tsx b/frontend/src/react/components/instance/DataSourceForm.tsx
index 20b2cdbac8..b37896894e 100644
--- a/frontend/src/react/components/instance/DataSourceForm.tsx
+++ b/frontend/src/react/components/instance/DataSourceForm.tsx
@@ -5,7 +5,16 @@ import { useTranslation } from "react-i18next";
import { LearnMoreLink } from "@/react/components/LearnMoreLink";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
+import {
+ FormControlAffix,
+ FormControlGroup,
+ FormControlRow,
+ FormDescription,
+ FormField,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { useAppStore } from "@/react/stores/app";
import { Engine } from "@/types/proto-es/v1/common_pb";
import {
@@ -551,27 +560,27 @@ export function DataSourceForm({
{showAuthTypeRadio && (
<div className="sm:col-span-3 sm:col-start-1">
<div className="flex items-center gap-x-2">
- <div className="textlabel flex items-center gap-x-4">
+ <RadioGroup
+ className="textlabel gap-x-4"
+ value={String(dataSource.authenticationType)}
+ onValueChange={(value) =>
+ update({
+ authenticationType: Number(
+ value
+ ) as DataSource_AuthenticationType,
+ })
+ }
+ >
{supportedAuthenticationTypes.map((item) => (
- <label
+ <RadioGroupItem
key={item.value}
- className="flex items-center gap-x-1.5 cursor-pointer"
+ value={String(item.value)}
+ disabled={!allowEdit}
>
- <input
- type="radio"
- name="authenticationType"
- checked={
- dataSource.authenticationType === item.value
- }
- disabled={!allowEdit}
- onChange={() =>
- update({ authenticationType: item.value })
- }
- />
{item.label}
- </label>
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
</div>
</div>
)}
@@ -590,38 +599,35 @@ export function DataSourceForm({
{/* Hive authentication */}
{basicInfo.engine === Engine.HIVE && (
<div className="sm:col-span-3 sm:col-start-1">
- <div className="textlabel flex items-center gap-x-4">
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={hiveAuthentication === "PASSWORD"}
- disabled={!allowEdit}
- onChange={() => onHiveAuthenticationChange("PASSWORD")}
- />
+ <RadioGroup
+ className="textlabel gap-x-4"
+ value={hiveAuthentication}
+ onValueChange={(value) =>
+ onHiveAuthenticationChange(
+ value as typeof hiveAuthentication
+ )
+ }
+ >
+ <RadioGroupItem value="PASSWORD" disabled={!allowEdit}>
Plain Password
- </label>
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={hiveAuthentication === "KERBEROS"}
- disabled={!allowEdit}
- onChange={() => onHiveAuthenticationChange("KERBEROS")}
- />
+ </RadioGroupItem>
+ <RadioGroupItem value="KERBEROS" disabled={!allowEdit}>
Kerberos
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
)}
{/* Kerberos config */}
{dataSource.saslConfig?.mechanism?.case === "krbConfig" && (
<>
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel block">
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>
Principal <span className="text-error">*</span>
- </label>
- <div className="mt-2 flex items-center gap-x-2">
+ </FormLabel>
+ <FormControlRow>
<Input
+ className="min-w-0 flex-1"
value={
dataSource.saslConfig.mechanism.value.primary ?? ""
}
@@ -638,8 +644,9 @@ export function DataSourceForm({
onDataSourceChange(updated);
}}
/>
- <span>/</span>
+ <FormControlAffix>/</FormControlAffix>
<Input
+ className="min-w-0 flex-1"
value={
dataSource.saslConfig.mechanism.value.instance ?? ""
}
@@ -656,8 +663,9 @@ export function DataSourceForm({
onDataSourceChange(updated);
}}
/>
- <span>@</span>
+ <FormControlAffix>@</FormControlAffix>
<Input
+ className="min-w-0 flex-1"
value={
dataSource.saslConfig.mechanism.value.realm ?? ""
}
@@ -674,43 +682,42 @@ export function DataSourceForm({
onDataSourceChange(updated);
}}
/>
- </div>
- </div>
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel block">
+ </FormControlRow>
+ </FormField>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>
KDC <span className="text-error">*</span>
- </label>
- <div className="flex items-center gap-x-2">
- <div className="w-fit textlabel flex gap-x-3">
+ </FormLabel>
+ <FormControlRow>
+ <RadioGroup
+ className="w-fit textlabel gap-x-3"
+ value={
+ dataSource.saslConfig?.mechanism?.value
+ ?.kdcTransportProtocol ?? ""
+ }
+ onValueChange={(proto) => {
+ const updated = { ...dataSource };
+ if (
+ updated.saslConfig?.mechanism?.case === "krbConfig"
+ ) {
+ updated.saslConfig.mechanism.value.kdcTransportProtocol =
+ String(proto);
+ }
+ onDataSourceChange(updated);
+ }}
+ >
{["tcp", "udp"].map((proto) => (
- <label
+ <RadioGroupItem
key={proto}
- className="flex items-center gap-x-1.5"
+ value={proto}
+ disabled={!allowEdit}
>
- <input
- type="radio"
- checked={
- dataSource.saslConfig?.mechanism?.value
- ?.kdcTransportProtocol === proto
- }
- disabled={!allowEdit}
- onChange={() => {
- const updated = { ...dataSource };
- if (
- updated.saslConfig?.mechanism?.case ===
- "krbConfig"
- ) {
- updated.saslConfig.mechanism.value.kdcTransportProtocol =
- proto;
- }
- onDataSourceChange(updated);
- }}
- />
{proto.toUpperCase()}
- </label>
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
<Input
+ className="min-w-0 flex-1"
value={
dataSource.saslConfig.mechanism.value.kdcHost ?? ""
}
@@ -727,8 +734,9 @@ export function DataSourceForm({
onDataSourceChange(updated);
}}
/>
- <span>:</span>
+ <FormControlAffix>:</FormControlAffix>
<Input
+ className="min-w-0 flex-1"
value={
dataSource.saslConfig.mechanism.value.kdcPort ?? ""
}
@@ -750,12 +758,12 @@ export function DataSourceForm({
onDataSourceChange(updated);
}}
/>
- </div>
- </div>
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel block">
+ </FormControlRow>
+ </FormField>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>
Keytab File <span className="text-error">*</span>
- </label>
+ </FormLabel>
<div className="mt-3 border-2 border-dashed rounded-lg p-6 text-center">
<input
type="file"
@@ -771,16 +779,16 @@ export function DataSourceForm({
Click or Drag your .keytab file here
</label>
</div>
- </div>
+ </FormField>
</>
)}
{/* Username field (non-Kerberos, non-Azure IAM) */}
{dataSource.saslConfig?.mechanism?.case !== "krbConfig" &&
!isAzureIAM && (
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel flex items-center gap-x-1">
- {t("common.username")}
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <div className="flex items-center gap-x-1">
+ <FormLabel>{t("common.username")}</FormLabel>
{onOpenInfoPanel && hasAuthenticationInfo && (
<button
type="button"
@@ -790,10 +798,10 @@ export function DataSourceForm({
<Info className="size-3.5" />
</button>
)}
- </label>
+ </div>
<Input
value={dataSource.username}
- className="mt-2 w-full max-w-[48rem]"
+ className="w-full max-w-[48rem]"
disabled={!allowEdit}
placeholder={
basicInfo.engine === Engine.CLICKHOUSE
@@ -802,7 +810,7 @@ export function DataSourceForm({
}
onChange={(e) => update({ username: e.target.value })}
/>
- </div>
+ </FormField>
)}
{/* IAM Credential Source Form */}
@@ -817,19 +825,19 @@ export function DataSourceForm({
{/* AWS Region */}
{isAwsIAM && (
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel block">
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>
{t("instance.database-region")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormLabel>
<Input
value={dataSource.region ?? ""}
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder="database region, for example, us-east-1"
onChange={(e) => update({ region: e.target.value })}
/>
- </div>
+ </FormField>
)}
{/* Password / External Secret */}
@@ -838,7 +846,17 @@ export function DataSourceForm({
<div className="sm:col-span-3 sm:col-start-1">
{!hideAdvancedFeatures && (
<div className="mb-4">
- <div className="textlabel flex flex-wrap gap-x-4 gap-y-2">
+ <RadioGroup
+ className="textlabel flex-wrap gap-x-4 gap-y-2"
+ value={String(passwordType)}
+ onValueChange={(value) =>
+ changeSecretType(
+ Number(
+ value
+ ) as DataSourceExternalSecret_SecretType
+ )
+ }
+ >
{[
{
value:
@@ -874,16 +892,12 @@ export function DataSourceForm({
),
},
].map((item) => (
- <label
+ <RadioGroupItem
key={item.value}
- className="flex items-center gap-x-1.5 cursor-pointer"
+ value={String(item.value)}
+ disabled={!allowEdit}
+ contentClassName="flex items-center gap-x-1.5"
>
- <input
- type="radio"
- checked={passwordType === item.value}
- disabled={!allowEdit}
- onChange={() => changeSecretType(item.value)}
- />
{item.label}
{item.value !==
DataSourceExternalSecret_SecretType.SECRET_TYPE_UNSPECIFIED &&
@@ -892,24 +906,22 @@ export function DataSourceForm({
Pro
</span>
)}
- </label>
+ </RadioGroupItem>
))}
<LearnMoreLink
href="https://docs.bytebase.com/get-started/connect/overview#secret-manager-integration"
className="text-sm text-accent"
/>
- </div>
+ </RadioGroup>
</div>
)}
{/* Plain password */}
{passwordType ===
DataSourceExternalSecret_SecretType.SECRET_TYPE_UNSPECIFIED && (
- <div>
- <label className="textlabel block">
- {t("common.password")}
- </label>
- <div className="mt-2">
+ <FormField>
+ <FormLabel>{t("common.password")}</FormLabel>
+ <div>
{!isCreating && allowUsingEmptyPassword && (
<label className="flex items-center gap-x-1.5 mb-2 text-sm cursor-pointer">
<Checkbox
@@ -946,7 +958,7 @@ export function DataSourceForm({
}
/>
</div>
- </div>
+ </FormField>
)}
{/* External secret fields */}
@@ -958,17 +970,17 @@ export function DataSourceForm({
{passwordType ===
DataSourceExternalSecret_SecretType.VAULT_KV_V2 && (
<div className="flex flex-col gap-y-4">
- <div>
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{t(
"instance.external-secret-vault.vault-url"
)}{" "}
<span className="text-error">*</span>
- </label>
+ </FormLabel>
<Input
value={dataSource.externalSecret.url ?? ""}
required
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={t(
"instance.external-secret-vault.vault-url"
@@ -982,50 +994,46 @@ export function DataSourceForm({
onDataSourceChange(ds);
}}
/>
- </div>
- <div className="flex flex-col gap-y-2">
- <label className="textlabel block">
+ </FormField>
+ <FormField>
+ <FormLabel>
{t(
"instance.external-secret-vault.vault-auth-type.self"
)}
- </label>
- <div className="textlabel flex gap-x-4">
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={
- dataSource.externalSecret.authType ===
- DataSourceExternalSecret_AuthType.TOKEN
- }
- onChange={() =>
- changeExternalSecretAuthType(
- DataSourceExternalSecret_AuthType.TOKEN
- )
- }
- />
+ </FormLabel>
+ <RadioGroup
+ className="textlabel gap-x-4"
+ value={String(
+ dataSource.externalSecret.authType
+ )}
+ onValueChange={(value) =>
+ changeExternalSecretAuthType(
+ Number(
+ value
+ ) as DataSourceExternalSecret_AuthType
+ )
+ }
+ >
+ <RadioGroupItem
+ value={String(
+ DataSourceExternalSecret_AuthType.TOKEN
+ )}
+ >
{t(
"instance.external-secret-vault.vault-auth-type.token.self"
)}
- </label>
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={
- dataSource.externalSecret.authType ===
- DataSourceExternalSecret_AuthType.VAULT_APP_ROLE
- }
- onChange={() =>
- changeExternalSecretAuthType(
- DataSourceExternalSecret_AuthType.VAULT_APP_ROLE
- )
- }
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(
+ DataSourceExternalSecret_AuthType.VAULT_APP_ROLE
+ )}
+ >
{t(
"instance.external-secret-vault.vault-auth-type.approle.self"
)}
- </label>
- </div>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
+ </FormField>
{/* Token input */}
{dataSource.externalSecret.authType ===
DataSourceExternalSecret_AuthType.TOKEN &&
@@ -1067,71 +1075,57 @@ export function DataSourceForm({
);
}
return (
- <div>
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{tokenLabel}{" "}
<span className="text-error">*</span>
- </label>
+ </FormLabel>
{/* Token source is host-backed for env/file,
which is disallowed in SaaS mode; only
plain is offered there. */}
{!isSaaSMode && (
- <div className="textlabel my-1 flex gap-x-4">
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={
- tokenType ===
- DataSourceExternalSecret_TokenType.PLAIN
- }
- disabled={!allowEdit}
- onChange={() =>
- changeTokenType(
- DataSourceExternalSecret_TokenType.PLAIN
- )
- }
- />
+ <RadioGroup
+ className="textlabel my-1 gap-x-4"
+ value={String(tokenType)}
+ onValueChange={(value) =>
+ changeTokenType(
+ Number(
+ value
+ ) as DataSourceExternalSecret_TokenType
+ )
+ }
+ >
+ <RadioGroupItem
+ value={String(
+ DataSourceExternalSecret_TokenType.PLAIN
+ )}
+ disabled={!allowEdit}
+ >
{t(
"instance.external-secret-vault.vault-auth-type.token.type-plain"
)}
- </label>
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={
- tokenType ===
- DataSourceExternalSecret_TokenType.ENVIRONMENT
- }
- disabled={!allowEdit}
- onChange={() =>
- changeTokenType(
- DataSourceExternalSecret_TokenType.ENVIRONMENT
- )
- }
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(
+ DataSourceExternalSecret_TokenType.ENVIRONMENT
+ )}
+ disabled={!allowEdit}
+ >
{t(
"instance.external-secret-vault.vault-auth-type.token.type-environment"
)}
- </label>
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={
- tokenType ===
- DataSourceExternalSecret_TokenType.FILE
- }
- disabled={!allowEdit}
- onChange={() =>
- changeTokenType(
- DataSourceExternalSecret_TokenType.FILE
- )
- }
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(
+ DataSourceExternalSecret_TokenType.FILE
+ )}
+ disabled={!allowEdit}
+ >
{t(
"instance.external-secret-vault.vault-auth-type.token.type-file"
)}
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
)}
<Input
value={
@@ -1141,7 +1135,7 @@ export function DataSourceForm({
.authOption.value as string)
: ""
}
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={tokenPlaceholder}
onChange={(e) => {
@@ -1156,26 +1150,26 @@ export function DataSourceForm({
onDataSourceChange(ds);
}}
/>
- </div>
+ </FormField>
);
})()}
{/* AppRole fields */}
{dataSource.externalSecret.authOption?.case ===
"appRole" && (
<div className="flex flex-col gap-y-4">
- <div>
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{t(
"instance.external-secret-vault.vault-auth-type.approle.role-id"
)}{" "}
<span className="text-error">*</span>
- </label>
+ </FormLabel>
<Input
value={
dataSource.externalSecret.authOption
.value.roleId ?? ""
}
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={`${t("instance.external-secret-vault.vault-auth-type.approle.role-id")} - ${t("common.write-only")}`}
onChange={(e) => {
@@ -1199,90 +1193,68 @@ export function DataSourceForm({
onDataSourceChange(ds);
}}
/>
- </div>
- <div>
- <label className="textlabel block">
+ </FormField>
+ <FormField>
+ <FormLabel>
{t(
"instance.external-secret-vault.vault-auth-type.approle.secret-id"
)}{" "}
<span className="text-error">*</span>
- </label>
+ </FormLabel>
{/* Environment secret id reads from the host,
which is disallowed in SaaS mode; only plain
is offered there. */}
{!isSaaSMode && (
- <div className="textlabel my-1 flex gap-x-4">
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={
- dataSource.externalSecret
- .authOption.value.type ===
- DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN
- }
- disabled={!allowEdit}
- onChange={() => {
- const ds = { ...dataSource };
- if (
- ds.externalSecret?.authOption
- ?.case === "appRole"
- ) {
- ds.externalSecret = {
- ...ds.externalSecret,
- authOption: {
- ...ds.externalSecret
- .authOption,
- value: {
- ...ds.externalSecret
- .authOption.value,
- type: DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN,
- },
- },
- };
- }
- onDataSourceChange(ds);
- }}
- />
+ <RadioGroup
+ className="textlabel my-1 gap-x-4"
+ value={String(
+ dataSource.externalSecret.authOption
+ .value.type
+ )}
+ onValueChange={(value) => {
+ const ds = { ...dataSource };
+ if (
+ ds.externalSecret?.authOption
+ ?.case === "appRole"
+ ) {
+ ds.externalSecret = {
+ ...ds.externalSecret,
+ authOption: {
+ ...ds.externalSecret.authOption,
+ value: {
+ ...ds.externalSecret
+ .authOption.value,
+ type: Number(
+ value
+ ) as DataSourceExternalSecret_AppRoleAuthOption_SecretType,
+ },
+ },
+ };
+ }
+ onDataSourceChange(ds);
+ }}
+ >
+ <RadioGroupItem
+ value={String(
+ DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN
+ )}
+ disabled={!allowEdit}
+ >
{t(
"instance.external-secret-vault.vault-auth-type.approle.secret-plain-text"
)}
- </label>
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={
- dataSource.externalSecret
- .authOption.value.type ===
- DataSourceExternalSecret_AppRoleAuthOption_SecretType.ENVIRONMENT
- }
- disabled={!allowEdit}
- onChange={() => {
- const ds = { ...dataSource };
- if (
- ds.externalSecret?.authOption
- ?.case === "appRole"
- ) {
- ds.externalSecret = {
- ...ds.externalSecret,
- authOption: {
- ...ds.externalSecret
- .authOption,
- value: {
- ...ds.externalSecret
- .authOption.value,
- type: DataSourceExternalSecret_AppRoleAuthOption_SecretType.ENVIRONMENT,
- },
- },
- };
- }
- onDataSourceChange(ds);
- }}
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(
+ DataSourceExternalSecret_AppRoleAuthOption_SecretType.ENVIRONMENT
+ )}
+ disabled={!allowEdit}
+ >
{t(
"instance.external-secret-vault.vault-auth-type.approle.secret-env-name"
)}
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
)}
<Input
value={
@@ -1312,16 +1284,16 @@ export function DataSourceForm({
onDataSourceChange(ds);
}}
/>
- </div>
+ </FormField>
</div>
)}
{/* Vault TLS config */}
- <div>
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{t(
"instance.external-secret-vault.vault-tls-config"
)}
- </label>
+ </FormLabel>
<SslCertificateForm
verify={
!dataSource.externalSecret
@@ -1365,26 +1337,26 @@ export function DataSourceForm({
disabled={!allowEdit}
showKeyAndCert
/>
- </div>
+ </FormField>
{/* Engine name */}
- <div>
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{t(
"instance.external-secret-vault.vault-secret-engine-name"
)}{" "}
<span className="text-error">*</span>
- </label>
- <div className="flex gap-x-2 text-sm textinfolabel">
+ </FormLabel>
+ <FormDescription>
{t(
"instance.external-secret-vault.vault-secret-engine-tips"
)}
- </div>
+ </FormDescription>
<Input
value={
dataSource.externalSecret.engineName ?? ""
}
required
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={t(
"instance.external-secret-vault.vault-secret-engine-name"
@@ -1398,27 +1370,27 @@ export function DataSourceForm({
onDataSourceChange(ds);
}}
/>
- </div>
+ </FormField>
</div>
)}
{/* Azure Key Vault URL */}
{passwordType ===
DataSourceExternalSecret_SecretType.AZURE_KEY_VAULT && (
- <div>
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{t("instance.external-secret-azure.vault-url")}{" "}
<span className="text-error">*</span>
- </label>
- <div className="flex gap-x-2 text-sm textinfolabel">
+ </FormLabel>
+ <FormDescription>
{t(
"instance.external-secret-azure.vault-url-tips"
)}
- </div>
+ </FormDescription>
<Input
value={dataSource.externalSecret.url ?? ""}
required
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={t(
"instance.external-secret-azure.vault-url"
@@ -1432,35 +1404,35 @@ export function DataSourceForm({
onDataSourceChange(ds);
}}
/>
- </div>
+ </FormField>
)}
{/* Secret name (common) */}
- <div>
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{secretNameLabel}{" "}
<span className="text-error">*</span>
- </label>
+ </FormLabel>
{passwordType ===
DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER && (
- <div className="flex gap-x-2 text-sm textinfolabel">
+ <FormDescription>
{t(
"instance.external-secret-gcp.secret-name-tips"
)}
- </div>
+ </FormDescription>
)}
{passwordType ===
DataSourceExternalSecret_SecretType.AZURE_KEY_VAULT && (
- <div className="flex gap-x-2 text-sm textinfolabel">
+ <FormDescription>
{t(
"instance.external-secret-azure.secret-name-tips"
)}
- </div>
+ </FormDescription>
)}
<Input
value={dataSource.externalSecret.secretName ?? ""}
required
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={secretNameLabel}
onChange={(e) => {
@@ -1472,25 +1444,25 @@ export function DataSourceForm({
onDataSourceChange(ds);
}}
/>
- </div>
+ </FormField>
{/* Secret key (not for GCP/Azure) */}
{passwordType !==
DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER &&
passwordType !==
DataSourceExternalSecret_SecretType.AZURE_KEY_VAULT && (
- <div>
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{secretKeyLabel}{" "}
<span className="text-error">*</span>
- </label>
+ </FormLabel>
<Input
value={
dataSource.externalSecret.passwordKeyName ??
""
}
required
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={secretKeyLabel}
onChange={(e) => {
@@ -1502,7 +1474,7 @@ export function DataSourceForm({
onDataSourceChange(ds);
}}
/>
- </div>
+ </FormField>
)}
</div>
)}
@@ -1512,35 +1484,33 @@ export function DataSourceForm({
dataSource.redisType ===
DataSource_RedisType.SENTINEL && (
<>
- <div className="mt-2">
- <label className="textlabel">
+ <FormField>
+ <FormLabel>
Master Name <span className="text-error">*</span>
- </label>
+ </FormLabel>
<Input
value={dataSource.masterName ?? ""}
- className="mt-1 w-full"
+ className="w-full"
disabled={!allowEdit}
onChange={(e) =>
update({ masterName: e.target.value })
}
/>
- </div>
- <div className="mt-2">
- <label className="textlabel">Master Username</label>
+ </FormField>
+ <FormField>
+ <FormLabel>Master Username</FormLabel>
<Input
value={dataSource.masterUsername ?? ""}
- className="mt-1 w-full"
+ className="w-full"
disabled={!allowEdit}
onChange={(e) =>
update({ masterUsername: e.target.value })
}
/>
- </div>
- <div className="mt-2">
- <label className="textlabel block">
- Master Password
- </label>
- <div className="mt-2">
+ </FormField>
+ <FormField>
+ <FormLabel>Master Password</FormLabel>
+ <div>
{!isCreating && allowUsingEmptyPassword && (
<label className="flex items-center gap-x-1.5 mb-2 text-sm cursor-pointer">
<Checkbox
@@ -1586,7 +1556,7 @@ export function DataSourceForm({
}
/>
</div>
- </div>
+ </FormField>
</>
)}
</div>
@@ -1598,24 +1568,27 @@ export function DataSourceForm({
{(basicInfo.engine === Engine.SPANNER ||
basicInfo.engine === Engine.BIGQUERY) && (
<>
- <div className="sm:col-span-3 sm:col-start-1 textlabel flex gap-x-4">
+ <RadioGroup
+ className="sm:col-span-3 sm:col-start-1 textlabel gap-x-4"
+ value={String(dataSource.authenticationType)}
+ onValueChange={(value) =>
+ update({
+ authenticationType: Number(
+ value
+ ) as DataSource_AuthenticationType,
+ })
+ }
+ >
{supportedAuthenticationTypes.map((item) => (
- <label
+ <RadioGroupItem
key={item.value}
- className="flex items-center gap-x-1.5 cursor-pointer"
+ value={String(item.value)}
+ disabled={!allowEdit}
>
- <input
- type="radio"
- checked={dataSource.authenticationType === item.value}
- disabled={!allowEdit}
- onChange={() =>
- update({ authenticationType: item.value })
- }
- />
{item.label}
- </label>
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
<CredentialSourceForm
dataSource={dataSource}
engine={basicInfo.engine}
@@ -1639,10 +1612,8 @@ export function DataSourceForm({
{/* Snowflake keypair */}
{basicInfo.engine === Engine.SNOWFLAKE && (
<>
- <div className="sm:col-span-3 sm:col-start-1">
- <div className="textlabel block">
- {t("data-source.ssh.private-key")}
- </div>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>{t("data-source.ssh.private-key")}</FormLabel>
<div className="flex gap-x-2 text-sm">
<span className="textinfolabel">
{t("data-source.snowflake-keypair-tip")}
@@ -1655,24 +1626,22 @@ export function DataSourceForm({
<textarea
value={dataSource.authenticationPrivateKey ?? ""}
disabled={!allowEdit}
- className="w-full h-32 mt-2 whitespace-pre-wrap rounded-sm border border-control-border p-2 text-sm font-mono"
+ className="w-full h-32 whitespace-pre-wrap rounded-sm border border-control-border p-2 text-sm font-mono"
placeholder={`-----BEGIN PRIVATE KEY-----\nMIIEvQ...\n-----END PRIVATE KEY-----`}
onChange={(e) =>
update({ authenticationPrivateKey: e.target.value })
}
/>
- </div>
- <div className="sm:col-span-3 sm:col-start-1">
- <div className="textlabel block">
- {t("data-source.private-key-passphrase")}
- </div>
- <div className="textinfolabel text-sm">
+ </FormField>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>{t("data-source.private-key-passphrase")}</FormLabel>
+ <FormDescription>
{t("data-source.private-key-passphrase-tip")}
- </div>
+ </FormDescription>
<Input
value={dataSource.authenticationPrivateKeyPassphrase ?? ""}
type="password"
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={t(
"data-source.private-key-passphrase-placeholder"
@@ -1683,32 +1652,31 @@ export function DataSourceForm({
})
}
/>
- </div>
+ </FormField>
</>
)}
{/* Databricks */}
{basicInfo.engine === Engine.DATABRICKS && (
<>
- <div>
- <div className="textlabel mt-2">
+ <FormField>
+ <FormLabel>
Warehouse ID <span className="text-error">*</span>
- </div>
+ </FormLabel>
<Input
value={dataSource.warehouseId ?? ""}
- className="mt-2"
disabled={!allowEdit}
onChange={(e) => update({ warehouseId: e.target.value })}
/>
- </div>
- <div>
- <div className="textlabel mt-2">
+ </FormField>
+ <FormField>
+ <FormLabel>
Token <span className="text-error">*</span>
- </div>
+ </FormLabel>
<Input
type="password"
value={dataSource.updatedToken}
- className="mt-2 w-full"
+ className="w-full"
autoComplete="off"
disabled={!allowEdit}
placeholder={
@@ -1720,18 +1688,16 @@ export function DataSourceForm({
update({ updatedToken: e.target.value.trim() })
}
/>
- </div>
+ </FormField>
</>
)}
{/* MongoDB authentication database */}
{showAuthenticationDatabase && (
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel block">
- {t("instance.authentication-database")}
- </label>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>{t("instance.authentication-database")}</FormLabel>
<Input
- className="mt-2 w-full"
+ className="w-full"
autoComplete="off"
placeholder="admin"
disabled={!allowEdit}
@@ -1740,7 +1706,7 @@ export function DataSourceForm({
update({ authenticationDatabase: e.target.value.trim() })
}
/>
- </div>
+ </FormField>
)}
{/* Read-only replica host/port */}
@@ -1748,26 +1714,22 @@ export function DataSourceForm({
(hasReadonlyReplicaHost || hasReadonlyReplicaPort) && (
<>
{hasReadonlyReplicaHost && (
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel block">
- {t("data-source.read-replica-host")}
- </label>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>{t("data-source.read-replica-host")}</FormLabel>
<Input
- className="mt-2 w-full"
+ className="w-full"
autoComplete="off"
value={dataSource.host}
disabled={!allowEdit}
onChange={(e) => handleHostInput(e.target.value)}
/>
- </div>
+ </FormField>
)}
{hasReadonlyReplicaPort && (
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel block">
- {t("data-source.read-replica-port")}
- </label>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>{t("data-source.read-replica-port")}</FormLabel>
<Input
- className="mt-2 w-full"
+ className="w-full"
autoComplete="off"
value={dataSource.port}
disabled={!allowEdit}
@@ -1777,23 +1739,23 @@ export function DataSourceForm({
handlePortInput(e.target.value);
}}
/>
- </div>
+ </FormField>
)}
</>
)}
{/* Database field */}
{showDatabase && (
- <div className="sm:col-span-3 sm:col-start-1">
- <label className="textlabel block">{t("common.database")}</label>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel>{t("common.database")}</FormLabel>
<Input
value={dataSource.database ?? ""}
- className="mt-2 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={t("common.database")}
onChange={(e) => update({ database: e.target.value })}
/>
- </div>
+ </FormField>
)}
</>
)}
@@ -1803,9 +1765,11 @@ export function DataSourceForm({
<>
{/* SSL */}
{showSSL && isPasswordAuth && (
- <div className="sm:col-span-3 sm:col-start-1">
- <div className="flex items-center justify-start gap-x-2 textlabel">
- {t("data-source.ssl.connection-security")}
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <div className="flex items-center justify-start gap-x-2">
+ <FormLabel>
+ {t("data-source.ssl.connection-security")}
+ </FormLabel>
{onOpenInfoPanel && hasSslInfo && (
<button
type="button"
@@ -1920,16 +1884,14 @@ export function DataSourceForm({
engineType={basicInfo.engine}
disabled={!allowEdit}
/>
- </div>
+ </FormField>
)}
{/* SSH */}
{!hideAdvancedFeatures && showSSH && isPasswordAuth && (
- <div className="sm:col-span-3 sm:col-start-1">
+ <FormField className="sm:col-span-3 sm:col-start-1">
<div className="flex flex-row items-center gap-x-1">
- <label className="textlabel block">
- {t("data-source.ssh-connection")}
- </label>
+ <FormLabel>{t("data-source.ssh-connection")}</FormLabel>
{onOpenInfoPanel && hasSshInfo && (
<button
type="button"
@@ -1946,86 +1908,86 @@ export function DataSourceForm({
disabled={!allowEdit}
onChange={handleSSHChange}
/>
- </div>
+ </FormField>
)}
{/* Extra connection parameters */}
{hasExtraParameters && (
- <div className="sm:col-span-3 sm:col-start-1">
+ <FormField className="sm:col-span-3 sm:col-start-1">
<div className="flex flex-row items-center justify-between">
- <label className="textlabel block">
- {t("data-source.extra-params.self")}
- </label>
+ <FormLabel>{t("data-source.extra-params.self")}</FormLabel>
</div>
- <div className="textinfolabel text-sm mt-1 mb-2">
+ <FormDescription>
{t("data-source.extra-params.description")}
- </div>
+ </FormDescription>
- {allowEdit && (
- <div className="flex mt-2 mb-2 gap-x-2 bg-control-bg p-3 rounded-sm">
- <Input
- value={newParamKey}
- className="w-full"
- placeholder={t("instance.parameter-name-placeholder")}
- onChange={(e) => setNewParamKey(e.target.value)}
- />
- <Input
- value={newParamValue}
- className="w-full"
- placeholder={t("instance.parameter-value-placeholder")}
- onChange={(e) => setNewParamValue(e.target.value)}
- />
- <Button
- variant="outline"
- size="sm"
- disabled={!newParamKey.trim()}
- onClick={addNewParameter}
- >
- Add
- </Button>
- </div>
- )}
-
- {extraConnectionParamsList.map((param, index) => (
- <div key={param.key} className="flex mt-2 gap-x-2">
- <Input
- className="w-full"
- value={param.key}
- disabled={!allowEdit}
- placeholder="Parameter name"
- onChange={(e) =>
- updateExtraConnectionParamKey(index, e.target.value)
- }
- />
- <Input
- className="w-full"
- value={param.value}
- disabled={!allowEdit}
- placeholder="Parameter value"
- onChange={(e) =>
- updateExtraConnectionParamValue(index, e.target.value)
- }
- />
- {allowEdit && (
+ <FormControlGroup className="mt-2">
+ {allowEdit && (
+ <FormControlRow>
+ <Input
+ value={newParamKey}
+ className="min-w-0 flex-1"
+ placeholder={t("instance.parameter-name-placeholder")}
+ onChange={(e) => setNewParamKey(e.target.value)}
+ />
+ <Input
+ value={newParamValue}
+ className="min-w-0 flex-1"
+ placeholder={t("instance.parameter-value-placeholder")}
+ onChange={(e) => setNewParamValue(e.target.value)}
+ />
<Button
- variant="destructive"
- size="sm"
- onClick={() => removeExtraConnectionParam(index)}
+ variant="outline"
+ className="shrink-0"
+ disabled={!newParamKey.trim()}
+ onClick={addNewParameter}
>
- Remove
+ Add
</Button>
- )}
- </div>
- ))}
+ </FormControlRow>
+ )}
+
+ {extraConnectionParamsList.map((param, index) => (
+ <FormControlRow key={param.key}>
+ <Input
+ className="min-w-0 flex-1"
+ value={param.key}
+ disabled={!allowEdit}
+ placeholder="Parameter name"
+ onChange={(e) =>
+ updateExtraConnectionParamKey(index, e.target.value)
+ }
+ />
+ <Input
+ className="min-w-0 flex-1"
+ value={param.value}
+ disabled={!allowEdit}
+ placeholder="Parameter value"
+ onChange={(e) =>
+ updateExtraConnectionParamValue(index, e.target.value)
+ }
+ />
+ {allowEdit && (
+ <Button
+ variant="destructive"
+ className="shrink-0"
+ onClick={() => removeExtraConnectionParam(index)}
+ >
+ Remove
+ </Button>
+ )}
+ </FormControlRow>
+ ))}
+ </FormControlGroup>
{extraConnectionParamsList.length === 0 && (
- <div className="textinfolabel text-sm italic">
+ <div className="textinfolabel text-sm italic mt-2">
{allowEdit
? t("instance.no-params-yet-add-above")
: t("instance.no-extra-params-configured")}
</div>
)}
- </div>
+ </FormField>
)}
</>
)}
@@ -2061,26 +2023,20 @@ function OracleSIDServiceNameInput({
return (
<div className="sm:col-span-3 sm:col-start-1">
- <div className="textlabel flex gap-x-4 mb-2">
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={mode === "sid"}
- onChange={() => handleModeChange("sid")}
- disabled={!allowEdit}
- />
+ <RadioGroup
+ className="textlabel mb-2 gap-x-4"
+ value={mode}
+ onValueChange={(value) =>
+ handleModeChange(value as "sid" | "serviceName")
+ }
+ >
+ <RadioGroupItem value="sid" disabled={!allowEdit}>
SID
- </label>
- <label className="flex items-center gap-x-1.5 cursor-pointer">
- <input
- type="radio"
- checked={mode === "serviceName"}
- onChange={() => handleModeChange("serviceName")}
- disabled={!allowEdit}
- />
+ </RadioGroupItem>
+ <RadioGroupItem value="serviceName" disabled={!allowEdit}>
Service Name
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
<Input
value={mode === "sid" ? sid : serviceName}
className="w-full"
diff --git a/frontend/src/react/components/instance/InstanceFormBody.tsx b/frontend/src/react/components/instance/InstanceFormBody.tsx
index f2cb1e1c4c..2e592ba2f0 100644
--- a/frontend/src/react/components/instance/InstanceFormBody.tsx
+++ b/frontend/src/react/components/instance/InstanceFormBody.tsx
@@ -20,7 +20,15 @@ import { RouterLink } from "@/react/components/RouterLink";
import { Alert } from "@/react/components/ui/alert";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
+import {
+ FormControlGroup,
+ FormControlRow,
+ FormDescription,
+ FormField,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { cn } from "@/react/lib/utils";
import { useAppStore } from "@/react/stores/app";
import { pushNotification } from "@/store";
@@ -111,16 +119,16 @@ function SpannerHostInput({
return (
<div className="grid grid-cols-2 gap-x-2 gap-y-1">
- <div>
- <label className="textlabel">
+ <FormField>
+ <FormLabel>
{t("instance.project-id")}
<span style={{ color: "red" }}> *</span>
- </label>
+ </FormLabel>
<Input
value={projectId}
required
placeholder="projectId"
- className={`mt-1 w-full ${dirty && !isValidProjectId ? "border-error" : ""}`}
+ className={`w-full ${dirty && !isValidProjectId ? "border-error" : ""}`}
disabled={!allowEdit}
onChange={(e) => {
const v = e.target.value;
@@ -128,17 +136,17 @@ function SpannerHostInput({
update(v, instanceId);
}}
/>
- </div>
- <div>
- <label className="textlabel">
+ </FormField>
+ <FormField>
+ <FormLabel>
{t("instance.instance-id")}
<span style={{ color: "red" }}> *</span>
- </label>
+ </FormLabel>
<Input
value={instanceId}
required
placeholder="instanceId"
- className={`mt-1 w-full ${dirty && !isValidInstanceId ? "border-error" : ""}`}
+ className={`w-full ${dirty && !isValidInstanceId ? "border-error" : ""}`}
disabled={!allowEdit}
onChange={(e) => {
const v = e.target.value;
@@ -146,8 +154,8 @@ function SpannerHostInput({
update(projectId, v);
}}
/>
- </div>
- <p className="col-span-2 textinfolabel">
+ </FormField>
+ <FormDescription className="col-span-2">
{t("instance.find-gcp-project-id-and-instance-id")}{" "}
<a
href="https://docs.bytebase.com/get-started/connect/gcp?source=console"
@@ -158,7 +166,7 @@ function SpannerHostInput({
{t("common.detailed-guide")}
<ExternalLink className="size-4 ml-1" />
</a>
- </p>
+ </FormDescription>
</div>
);
}
@@ -186,16 +194,16 @@ function BigQueryHostInput({
return (
<div className="grid grid-cols-2 gap-x-2 gap-y-1">
- <div>
- <label className="textlabel">
+ <FormField>
+ <FormLabel>
{t("instance.project-id")}
<span style={{ color: "red" }}> *</span>
- </label>
+ </FormLabel>
<Input
value={projectId}
required
placeholder="projectId"
- className={`mt-1 w-full ${dirty && !isValidProjectId ? "border-error" : ""}`}
+ className={`w-full ${dirty && !isValidProjectId ? "border-error" : ""}`}
disabled={!allowEdit}
onChange={(e) => {
const v = e.target.value;
@@ -208,8 +216,8 @@ function BigQueryHostInput({
}
}}
/>
- </div>
- <p className="col-span-2 textinfolabel">
+ </FormField>
+ <FormDescription className="col-span-2">
{t("instance.find-gcp-project-id")}{" "}
<a
href="https://docs.bytebase.com/get-started/connect/gcp?source=console"
@@ -220,7 +228,7 @@ function BigQueryHostInput({
{t("common.detailed-guide")}
<ExternalLink className="size-4 ml-1" />
</a>
- </p>
+ </FormDescription>
</div>
);
}
@@ -336,31 +344,23 @@ function ScanIntervalInput({
if (hideAdvancedFeatures) return null;
return (
- <div className="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2">
+ <FormField className="sm:col-span-4 sm:col-start-1">
<div className="flex items-center gap-x-2">
- <label className="textlabel">{t("instance.scan-interval.self")}</label>
+ <FormLabel>{t("instance.scan-interval.self")}</FormLabel>
<FeatureBadge feature={PlanFeature.FEATURE_CUSTOM_INSTANCE_SYNC_TIME} />
</div>
- <div className="textinfolabel">
+ <FormDescription>
{t("instance.scan-interval.description")}
- </div>
- <div className="flex items-center gap-x-6">
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- checked={mode === "DEFAULT"}
- disabled={!allowEdit}
- onChange={() => handleModeChange("DEFAULT")}
- />
+ </FormDescription>
+ <RadioGroup
+ className="gap-x-6"
+ value={mode}
+ onValueChange={(value) => handleModeChange(value as typeof mode)}
+ >
+ <RadioGroupItem value="DEFAULT" disabled={!allowEdit}>
{t("instance.scan-interval.default-never")}
- </label>
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- checked={mode === "CUSTOM"}
- disabled={!allowEdit}
- onChange={() => handleModeChange("CUSTOM")}
- />
+ </RadioGroupItem>
+ <RadioGroupItem value="CUSTOM" disabled={!allowEdit}>
<span>{t("common.custom")}</span>
<Input
type="number"
@@ -379,9 +379,9 @@ function ScanIntervalInput({
) : (
<span className="text-sm">{t("common.minutes")}</span>
)}
- </label>
- </div>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
+ </FormField>
);
}
@@ -484,17 +484,15 @@ function SyncDatabases({
};
return (
- <div className="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2">
+ <FormField className="sm:col-span-4 sm:col-start-1">
{showLabel && (
<div className="flex items-center gap-x-2">
- <label className="textlabel">
- {t("instance.sync-databases.self")}
- </label>
+ <FormLabel>{t("instance.sync-databases.self")}</FormLabel>
</div>
)}
- <div className="textinfolabel">
+ <FormDescription>
{t("instance.sync-databases.description")}
- </div>
+ </FormDescription>
<div className="flex flex-col gap-y-2">
<label className="flex items-center gap-x-2 cursor-pointer">
<Checkbox
@@ -553,7 +551,7 @@ function SyncDatabases({
</div>
)}
</div>
- </div>
+ </FormField>
);
}
@@ -1116,11 +1114,8 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
<div className="mt-3 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-4">
{/* Instance Name */}
- <div className="sm:col-span-2 sm:col-start-1">
- <label
- htmlFor="name"
- className="textlabel flex flex-row items-center"
- >
+ <FormField className="sm:col-span-2 sm:col-start-1">
+ <FormLabel htmlFor="name" className="flex flex-row items-center">
{t("instance.instance-name")}
<span className="ml-0.5 text-error">*</span>
{instance && (
@@ -1129,16 +1124,16 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
<span className="ml-1">{instance.engineVersion}</span>
</div>
)}
- </label>
+ </FormLabel>
<Input
value={basicInfo.title}
required
- className="mt-1 w-full max-w-[40rem]"
+ className="w-full max-w-[40rem]"
disabled={!allowEdit}
maxLength={200}
onChange={(e) => updateBasicInfo({ title: e.target.value })}
/>
- </div>
+ </FormField>
{/* Activation toggle */}
{currentPlan !== PlanType.FREE &&
@@ -1191,12 +1186,12 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
</div>
{/* Environment */}
- <div className="sm:col-span-2 sm:col-start-1">
- <label htmlFor="environment" className="textlabel">
+ <FormField className="sm:col-span-2 sm:col-start-1">
+ <FormLabel htmlFor="environment">
{t("common.environment")}
- </label>
+ </FormLabel>
<EnvironmentSelect
- className="mt-1 w-full max-w-[40rem]"
+ className="w-full max-w-[40rem]"
value={
isValidEnvironmentName(
`${environmentNamePrefix}${environment.id}`
@@ -1209,36 +1204,29 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
handleSelectEnvironment(value || undefined)
}
/>
- </div>
+ </FormField>
{/* Labels */}
- <div className="sm:col-span-3 sm:col-start-1">
- <label htmlFor="labels" className="textlabel">
- {t("common.labels")}
- </label>
- <div className="mt-1">
- <LabelListEditor
- kvList={labelKVList}
- onChange={setLabelKVList}
- readonly={!allowEdit}
- showErrors
- onErrorsChange={ctx.setLabelErrors}
- />
- </div>
- </div>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <FormLabel htmlFor="labels">{t("common.labels")}</FormLabel>
+ <LabelListEditor
+ kvList={labelKVList}
+ onChange={setLabelKVList}
+ readonly={!allowEdit}
+ showErrors
+ onErrorsChange={ctx.setLabelErrors}
+ />
+ </FormField>
{/* External link (edit mode only) */}
{!isCreating && (
- <div className="sm:col-span-3 sm:col-start-1">
- <label
- htmlFor="external-link"
- className="textlabel inline-flex"
- >
- <span>
+ <FormField className="sm:col-span-3 sm:col-start-1">
+ <div className="inline-flex items-center">
+ <FormLabel htmlFor="external-link">
{basicInfo.engine === Engine.SNOWFLAKE
? t("instance.snowflake-web-console")
: t("instance.external-link")}
- </span>
+ </FormLabel>
{(basicInfo.externalLink ?? "").trim().length > 0 && (
<button
className="ml-1 btn-icon"
@@ -1253,23 +1241,23 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
<ExternalLink className="size-4" />
</button>
)}
- </label>
+ </div>
{basicInfo.engine === Engine.SNOWFLAKE ? (
<Input
required
- className="mt-1 w-full"
+ className="w-full"
disabled
value={instanceLink}
/>
) : (
<>
- <div className="mt-1 textinfolabel">
+ <FormDescription>
{t("instance.sentence.console.snowflake")}
- </div>
+ </FormDescription>
<Input
value={basicInfo.externalLink ?? ""}
required
- className="mt-1 w-full"
+ className="w-full"
disabled={!allowEdit}
placeholder={SnowflakeExtraLinkPlaceHolder}
onChange={(e) =>
@@ -1278,7 +1266,7 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
/>
</>
)}
- </div>
+ </FormField>
)}
{/* Scan Interval (edit mode only) */}
@@ -1326,57 +1314,59 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
/>
) : (
<>
- <label htmlFor="host" className="textlabel block">
- {basicInfo.engine === Engine.SNOWFLAKE ? (
- <>
- {t("instance.account-locator")}
- <span className="mr-2 text-error"> *</span>
+ {basicInfo.engine === Engine.SNOWFLAKE ? (
+ <>
+ <div className="flex items-center gap-x-2">
+ <FormLabel htmlFor="host">
+ {t("instance.account-locator")}
+ <span className="text-error"> *</span>
+ </FormLabel>
<LearnMoreLink
href="https://docs.snowflake.com/en/user-guide/admin-account-identifier#using-an-account-locator-as-an-identifier"
className="text-sm normal-link"
/>
- </>
- ) : basicInfo.engine === Engine.COSMOSDB ? (
- <>
- {t("instance.endpoint")}
- <span className="text-error"> *</span>
- </>
- ) : adminDataSource.authenticationType ===
- DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM ? (
- <div>
- <span>
- {t(
- "instance.sentence.google-cloud-sql.instance-name"
- )}
- <span className="text-error"> *</span>
- </span>
- <div className="textinfolabel mb-1">
- {t(
- "instance.sentence.google-cloud-sql.instance-name-tips",
- {
- instance: "{project-id}:{region}:{instance-name}",
- }
- )}
- </div>
</div>
- ) : (
- <>
+ </>
+ ) : basicInfo.engine === Engine.COSMOSDB ? (
+ <FormLabel htmlFor="host">
+ {t("instance.endpoint")}
+ <span className="text-error"> *</span>
+ </FormLabel>
+ ) : adminDataSource.authenticationType ===
+ DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM ? (
+ <>
+ <FormLabel htmlFor="host">
+ {t("instance.sentence.google-cloud-sql.instance-name")}
+ <span className="text-error"> *</span>
+ </FormLabel>
+ <FormDescription>
+ {t(
+ "instance.sentence.google-cloud-sql.instance-name-tips",
+ {
+ instance: "{project-id}:{region}:{instance-name}",
+ }
+ )}
+ </FormDescription>
+ </>
+ ) : (
+ <div className="flex items-center gap-x-1">
+ <FormLabel htmlFor="host">
{t("instance.host-or-socket")}
{basicInfo.engine !== Engine.DYNAMODB && (
<span className="text-error"> *</span>
)}
- {onOpenInfoPanel && hasHostInfo && (
- <button
- type="button"
- className="ml-1 inline-flex items-center gap-x-0.5 text-accent text-xs"
- onClick={() => openInfoPanel("host")}
- >
- <Info className="size-3.5" />
- </button>
- )}
- </>
- )}
- </label>
+ </FormLabel>
+ {onOpenInfoPanel && hasHostInfo && (
+ <button
+ type="button"
+ className="inline-flex items-center gap-x-0.5 text-accent text-xs"
+ onClick={() => openInfoPanel("host")}
+ >
+ <Info className="size-3.5" />
+ </button>
+ )}
+ </div>
+ )}
<Input
value={adminDataSource.host}
required
@@ -1390,9 +1380,9 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
onChange={(e) => updateAdminDS({ host: e.target.value })}
/>
{basicInfo.engine === Engine.SNOWFLAKE && (
- <div className="mt-2 textinfolabel">
+ <FormDescription className="mt-2">
{t("instance.sentence.proxy.snowflake")}
- </div>
+ </FormDescription>
)}
</>
)}
@@ -1405,101 +1395,84 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
basicInfo.engine !== Engine.COSMOSDB &&
adminDataSource.authenticationType !==
DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM && (
- <div className="sm:col-span-1">
- <label htmlFor="port" className="textlabel block">
- {t("instance.port")}
- </label>
+ <FormField className="sm:col-span-1">
+ <FormLabel htmlFor="port">{t("instance.port")}</FormLabel>
<Input
value={adminDataSource.port}
- className="mt-1 w-full"
+ className="w-full"
placeholder={defaultPort}
disabled={!allowEdit || !allowEditPort}
onChange={handlePortChange}
/>
- </div>
+ </FormField>
)}
{/* MongoDB connection string schema */}
{basicInfo.engine === Engine.MONGODB && (
- <div className="sm:col-span-4 sm:col-start-1">
- <label
- htmlFor="connectionStringSchema"
- className="textlabel flex flex-row items-center"
- >
+ <FormField className="sm:col-span-4 sm:col-start-1">
+ <FormLabel htmlFor="connectionStringSchema">
{t("data-source.connection-string-schema")}
- </label>
- <div className="flex items-center gap-x-4 mt-1">
+ </FormLabel>
+ <RadioGroup
+ className="gap-x-4"
+ value={currentMongoDBConnectionSchema}
+ onValueChange={(value) =>
+ handleMongodbConnectionStringSchemaChange(value as string)
+ }
+ >
{MongoDBConnectionStringSchemaList.map((type) => (
- <label
- key={type}
- className="flex items-center gap-x-2 cursor-pointer"
- >
- <input
- type="radio"
- checked={currentMongoDBConnectionSchema === type}
- onChange={() =>
- handleMongodbConnectionStringSchemaChange(type)
- }
- />
+ <RadioGroupItem key={type} value={type}>
{type}
- </label>
+ </RadioGroupItem>
))}
- </div>
- </div>
+ </RadioGroup>
+ </FormField>
)}
{/* Redis connection type */}
{basicInfo.engine === Engine.REDIS && (
- <div className="sm:col-span-4 sm:col-start-1 flex flex-col gap-y-2">
- <label
- htmlFor="connectionStringSchema"
- className="textlabel flex flex-row items-center"
- >
+ <FormField className="sm:col-span-4 sm:col-start-1">
+ <FormLabel htmlFor="connectionStringSchema">
{t("data-source.connection-type")}
- </label>
- <div className="flex items-center gap-x-4">
+ </FormLabel>
+ <RadioGroup
+ className="gap-x-4"
+ value={currentRedisConnectionType}
+ onValueChange={(value) =>
+ handleRedisConnectionTypeChange(value as string)
+ }
+ >
{RedisConnectionType.map((type) => (
- <label
- key={type}
- className="flex items-center gap-x-2 cursor-pointer"
- >
- <input
- type="radio"
- checked={currentRedisConnectionType === type}
- onChange={() => handleRedisConnectionTypeChange(type)}
- />
+ <RadioGroupItem key={type} value={type}>
{type}
- </label>
+ </RadioGroupItem>
))}
- </div>
- </div>
+ </RadioGroup>
+ </FormField>
)}
{/* Additional addresses */}
{showAdditionalAddresses && (
- <div className="sm:col-span-4 sm:col-start-1">
- <label
- htmlFor="additionalAddresses"
- className="textlabel flex flex-row items-center"
- >
+ <FormField className="sm:col-span-4 sm:col-start-1">
+ <FormLabel htmlFor="additionalAddresses">
{t("data-source.additional-node-addresses")}
- </label>
- <div className="mt-1 grid grid-cols-1 gap-y-1 gap-x-4 sm:grid-cols-12">
+ </FormLabel>
+ <FormControlGroup className="mt-1">
{adminDataSource.additionalAddresses.map((addr, index) => (
- <div key={index} className="contents">
- <div className="sm:col-span-8 sm:col-start-1">
+ <FormControlRow key={index} className="items-end">
+ <FormField className="min-w-0 flex-1">
{index === 0 && (
- <label
+ <FormLabel
htmlFor="additionalAddressesHost"
- className="textlabel font-normal! flex flex-row items-center"
+ className="font-normal!"
>
{t("instance.host-or-socket")}
- </label>
+ </FormLabel>
)}
<Input
value={addr.host}
required
- className="mt-1 w-full"
+ className="w-full"
disabled={!allowEdit}
onChange={(e) =>
handleAdditionalAddressHostChange(
@@ -1508,19 +1481,19 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
)
}
/>
- </div>
- <div className="sm:col-span-3">
+ </FormField>
+ <FormField className="w-32 shrink-0">
{index === 0 && (
- <label
+ <FormLabel
htmlFor="additionalAddressesPort"
- className="textlabel font-normal! flex flex-row items-center"
+ className="font-normal!"
>
{t("instance.port")}
- </label>
+ </FormLabel>
)}
<Input
value={addr.port}
- className="mt-1 w-full"
+ className="w-full"
placeholder={defaultPort}
disabled={!allowEdit || !allowEditPort}
onChange={(e) =>
@@ -1530,24 +1503,22 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
)
}
/>
- </div>
- <div className="h-8.5 flex flex-row items-center self-end">
- <button
- type="button"
- className="p-1 text-control-light hover:text-error disabled:opacity-50"
- disabled={!allowEdit}
- onClick={() => removeDSAdditionalAddress(index)}
- >
- <Trash2 className="size-4" />
- </button>
- </div>
- </div>
+ </FormField>
+ <button
+ type="button"
+ className="flex h-8.5 w-8.5 shrink-0 items-center justify-center text-control-light hover:text-error disabled:opacity-50"
+ disabled={!allowEdit}
+ onClick={() => removeDSAdditionalAddress(index)}
+ >
+ <Trash2 className="size-4" />
+ </button>
+ </FormControlRow>
))}
- <div className="mt-1 sm:col-span-12 sm:col-start-1">
+ <div>
<Button
variant="outline"
size="sm"
- className="ml-auto w-12!"
+ className="w-12!"
onClick={(e) => {
e.preventDefault();
addDSAdditionalAddress();
@@ -1556,26 +1527,26 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
{t("common.add")}
</Button>
</div>
- </div>
- </div>
+ </FormControlGroup>
+ </FormField>
)}
{/* MongoDB replica set */}
{basicInfo.engine === Engine.MONGODB && !adminDataSource.srv && (
- <div className="sm:col-span-2 sm:col-start-1">
- <label htmlFor="replicaSet" className="textlabel">
+ <FormField className="sm:col-span-2 sm:col-start-1">
+ <FormLabel htmlFor="replicaSet">
{t("data-source.replica-set")}
- </label>
+ </FormLabel>
<Input
value={adminDataSource.replicaSet}
required
- className="mt-1 w-full"
+ className="w-full"
disabled={!allowEdit}
onChange={(e) =>
updateAdminDS({ replicaSet: e.target.value })
}
/>
- </div>
+ </FormField>
)}
{/* MongoDB direct connection */}
diff --git a/frontend/src/react/components/instance/InstanceFormButtons.tsx b/frontend/src/react/components/instance/InstanceFormButtons.tsx
index b6ceaacaaa..a705f74bef 100644
--- a/frontend/src/react/components/instance/InstanceFormButtons.tsx
+++ b/frontend/src/react/components/instance/InstanceFormButtons.tsx
@@ -25,6 +25,7 @@ import {
AlertDialogTitle,
} from "../ui/alert-dialog";
import { Button } from "../ui/button";
+import { StickyActionFooter } from "../ui/sticky-action-footer";
import type { EditDataSource } from "./common";
import {
calcDataSourceUpdateMask,
@@ -504,30 +505,30 @@ export function InstanceFormButtons({
return (
<>
{connectionFailureDialog}
- <div
- className={cn(
- "w-full py-4 border-t border-block-border flex justify-end items-center gap-x-4 bg-background",
- className
- )}
- >
- {allowCancel && (
+ <StickyActionFooter
+ className={className}
+ left={
+ allowCancel ? (
+ <Button
+ variant="outline"
+ disabled={state.isRequesting || state.isTestingConnection}
+ onClick={cancel}
+ >
+ {t("common.cancel")}
+ </Button>
+ ) : undefined
+ }
+ right={
<Button
- variant="outline"
- disabled={state.isRequesting || state.isTestingConnection}
- onClick={cancel}
+ disabled={
+ !allowCreate || state.isRequesting || state.isTestingConnection
+ }
+ onClick={tryCreate}
>
- {t("common.cancel")}
+ {state.isRequesting ? t("common.creating") : t("common.create")}
</Button>
- )}
- <Button
- disabled={
- !allowCreate || state.isRequesting || state.isTestingConnection
- }
- onClick={tryCreate}
- >
- {state.isRequesting ? t("common.creating") : t("common.create")}
- </Button>
- </div>
+ }
+ />
</>
);
}
@@ -538,37 +539,39 @@ export function InstanceFormButtons({
return (
<>
{connectionFailureDialog}
- <div
- className={cn(
- "w-full mt-4 py-4 border-t border-block-border flex justify-end items-center gap-x-4 bg-background",
- className
- )}
- >
- <Button
- variant="outline"
- disabled={state.isTestingConnection}
- onClick={resetChanges}
- >
- {t("common.cancel")}
- </Button>
- <Button
- variant="ghost"
- disabled={!allowUpdate || state.isRequesting || !allowEdit}
- onClick={testConnectionForCurrentEditingDS}
- >
- {state.isTestingConnection
- ? t("instance.testing-connection")
- : t("instance.test-connection")}
- </Button>
- <Button
- disabled={
- !allowUpdate || state.isRequesting || state.isTestingConnection
- }
- onClick={doUpdate}
- >
- {state.isRequesting ? t("common.updating") : t("common.update")}
- </Button>
- </div>
+ <StickyActionFooter
+ className={cn("mt-4", className)}
+ left={
+ <Button
+ variant="outline"
+ disabled={state.isTestingConnection}
+ onClick={resetChanges}
+ >
+ {t("common.cancel")}
+ </Button>
+ }
+ right={
+ <>
+ <Button
+ variant="ghost"
+ disabled={!allowUpdate || state.isRequesting || !allowEdit}
+ onClick={testConnectionForCurrentEditingDS}
+ >
+ {state.isTestingConnection
+ ? t("instance.testing-connection")
+ : t("instance.test-connection")}
+ </Button>
+ <Button
+ disabled={
+ !allowUpdate || state.isRequesting || state.isTestingConnection
+ }
+ onClick={doUpdate}
+ >
+ {state.isRequesting ? t("common.updating") : t("common.update")}
+ </Button>
+ </>
+ }
+ />
</>
);
}
diff --git a/frontend/src/react/components/instance/SshConnectionForm.tsx b/frontend/src/react/components/instance/SshConnectionForm.tsx
index 72e152e5be..ab962dddef 100644
--- a/frontend/src/react/components/instance/SshConnectionForm.tsx
+++ b/frontend/src/react/components/instance/SshConnectionForm.tsx
@@ -1,6 +1,7 @@
-import { type DragEvent, useCallback, useEffect, useId, useState } from "react";
+import { type DragEvent, useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import type { Instance } from "@/types/proto-es/v1/instance_service_pb";
const SSH_TYPES = ["NONE", "TUNNEL+PK"] as const;
@@ -41,7 +42,6 @@ export function SshConnectionForm({
onChange,
}: SshConnectionFormProps) {
const { t } = useTranslation();
- const radioGroupId = useId();
const [sshType, setSshType] = useState<SshType>(() => guessSshType(value));
// Sync type from props when value changes externally.
@@ -95,30 +95,22 @@ export function SshConnectionForm({
return (
<>
{/* SSH type radio buttons */}
- <div className="flex flex-row items-center gap-x-4 mt-2">
- {SSH_TYPES.map((type) => {
- const id = `${radioGroupId}-${type}`;
- return (
- <label
- key={type}
- htmlFor={id}
- className="flex items-center gap-x-1.5 cursor-pointer text-sm text-main"
- >
- <input
- id={id}
- type="radio"
- name={radioGroupId}
- value={type}
- checked={sshType === type}
- disabled={disabled}
- onChange={() => handleSelectType(type)}
- className="accent-accent"
- />
- {getSshTypeLabel(type)}
- </label>
- );
- })}
- </div>
+ <RadioGroup
+ className="gap-x-4 mt-2"
+ value={sshType}
+ onValueChange={(value) => handleSelectType(value as SshType)}
+ >
+ {SSH_TYPES.map((type) => (
+ <RadioGroupItem
+ key={type}
+ value={type}
+ disabled={disabled}
+ className="text-main"
+ >
+ {getSshTypeLabel(type)}
+ </RadioGroupItem>
+ ))}
+ </RadioGroup>
{sshType !== "NONE" && (
<>
diff --git a/frontend/src/react/components/instance/SslCertificateForm.test.tsx b/frontend/src/react/components/instance/SslCertificateForm.test.tsx
index 1a7cea466e..24ab28eb64 100644
--- a/frontend/src/react/components/instance/SslCertificateForm.test.tsx
+++ b/frontend/src/react/components/instance/SslCertificateForm.test.tsx
@@ -1,7 +1,9 @@
+import * as stylex from "@stylexjs/stylex";
import type { ReactNode } from "react";
import { act } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, test, vi } from "vitest";
+import { controlMinHeightStyle } from "@/react/components/ui/styles.stylex";
import { Engine } from "@/types/proto-es/v1/common_pb";
import { SslCertificateForm } from "./SslCertificateForm";
@@ -108,6 +110,9 @@ describe("SslCertificateForm", () => {
/^z-\d+$/.test(className)
)
).toBe(false);
+ expect(selectedPostureLabel?.className).toContain(
+ stylex.props(controlMinHeightStyle("sm")).className
+ );
expect(
selectedPostureLabel?.classList.contains("focus-within:ring-inset")
).toBe(true);
@@ -168,6 +173,18 @@ describe("SslCertificateForm", () => {
"data-source.ssl.client-cert-placeholder",
"data-source.ssl.client-key-placeholder",
]);
+ const segmentSizeClassName =
+ stylex.props(controlMinHeightStyle("sm")).className ?? "";
+ for (const ariaLabel of [
+ "data-source.ssl.posture.self",
+ "data-source.ssl.ca-source.self",
+ "data-source.ssl.client-cert-source.self",
+ ]) {
+ const firstSegment = container
+ .querySelector(`[aria-label="${ariaLabel}"] [aria-checked]`)
+ ?.closest("label");
+ expect(firstSegment?.className).toContain(segmentSizeClassName);
+ }
act(() => {
root.unmount();
diff --git a/frontend/src/react/components/instance/SslCertificateForm.tsx b/frontend/src/react/components/instance/SslCertificateForm.tsx
index 3141a193bb..ab28995a31 100644
--- a/frontend/src/react/components/instance/SslCertificateForm.tsx
+++ b/frontend/src/react/components/instance/SslCertificateForm.tsx
@@ -2,6 +2,7 @@ import { Info } from "lucide-react";
import { type DragEvent, useCallback } from "react";
import { useTranslation } from "react-i18next";
import { Badge } from "@/react/components/ui/badge";
+import { FormField, FormLabel } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
SegmentedControl,
@@ -158,6 +159,7 @@ function CaSourceSelector({
options={options}
disabled={disabled}
className="mt-2"
+ size="sm"
/>
);
}
@@ -207,6 +209,7 @@ function ClientCertSourceSelector({
options={options}
disabled={disabled}
className="mt-2"
+ size="sm"
/>
);
}
@@ -355,7 +358,7 @@ export function SslCertificateForm({
visibleValue: string
) => (
<div className="flex items-center gap-x-2">
- <label className="textlabel block">{label}</label>
+ <FormLabel>{label}</FormLabel>
{showConfiguredBadge(hasStoredValue, visibleValue) && (
<Badge data-testid="tls-configured-badge" variant="success">
{resolvedConfiguredLabel}
@@ -391,6 +394,7 @@ export function SslCertificateForm({
ariaLabel={t("data-source.ssl.posture.self")}
options={options}
disabled={disabled}
+ size="sm"
/>
</div>
);
@@ -403,7 +407,7 @@ export function SslCertificateForm({
if (resolvedCaSource === LOCAL_TLS_CA_SOURCE_FILE_PATH) {
return (
- <div className="flex flex-col gap-y-1">
+ <FormField>
{renderLabel(resolvedCaPathLabel, hasCaPath, caPath)}
<Input
data-testid="tls-ca-path-input"
@@ -412,12 +416,12 @@ export function SslCertificateForm({
disabled={disabled || isSaaSMode}
placeholder={resolvedCaPathLabel}
/>
- </div>
+ </FormField>
);
}
return (
- <div className="flex flex-col gap-y-1">
+ <FormField>
{renderLabel(resolvedCaLabel, hasCa, ca)}
<DroppableTextarea
value={ca}
@@ -425,7 +429,7 @@ export function SslCertificateForm({
disabled={disabled}
placeholder={resolvedCaPlaceholder}
/>
- </div>
+ </FormField>
);
};
@@ -439,7 +443,7 @@ export function SslCertificateForm({
if (source === LOCAL_TLS_CLIENT_CERT_SOURCE_FILE_PATH) {
return (
<div className="flex flex-col gap-y-2">
- <div className="flex flex-col gap-y-1">
+ <FormField>
{renderLabel(resolvedCertPathLabel, hasCertPath, certPath)}
<Input
data-testid="tls-cert-path-input"
@@ -448,8 +452,8 @@ export function SslCertificateForm({
disabled={disabled || isSaaSMode}
placeholder={resolvedCertPathLabel}
/>
- </div>
- <div className="flex flex-col gap-y-1">
+ </FormField>
+ <FormField>
{renderLabel(resolvedKeyPathLabel, hasKeyPath, keyPath)}
<Input
data-testid="tls-key-path-input"
@@ -458,14 +462,14 @@ export function SslCertificateForm({
disabled={disabled || isSaaSMode}
placeholder={resolvedKeyPathLabel}
/>
- </div>
+ </FormField>
</div>
);
}
return (
<div className="flex flex-col gap-y-2">
- <div className="flex flex-col gap-y-1">
+ <FormField>
{renderLabel(resolvedCertLabel, hasCert, cert)}
<DroppableTextarea
value={cert}
@@ -473,8 +477,8 @@ export function SslCertificateForm({
disabled={disabled}
placeholder={resolvedCertPlaceholder}
/>
- </div>
- <div className="flex flex-col gap-y-1">
+ </FormField>
+ <FormField>
{renderLabel(resolvedKeyLabel, hasKey, sslKey)}
<DroppableTextarea
value={sslKey}
@@ -482,7 +486,7 @@ export function SslCertificateForm({
disabled={disabled}
placeholder={resolvedKeyPlaceholder}
/>
- </div>
+ </FormField>
</div>
);
};
@@ -491,7 +495,7 @@ export function SslCertificateForm({
if (resolvedCaSource === LOCAL_TLS_CA_SOURCE_FILE_PATH) {
return (
<div className="flex flex-col gap-y-2">
- <div className="flex flex-col gap-y-1">
+ <FormField>
{renderLabel(resolvedCaPathLabel, hasCaPath, caPath)}
<Input
data-testid="tls-ca-path-input"
@@ -500,9 +504,9 @@ export function SslCertificateForm({
disabled={disabled || isSaaSMode}
placeholder={resolvedCaPathLabel}
/>
- </div>
+ </FormField>
{showKeyAndCertFields && (
- <div className="flex flex-col gap-y-1">
+ <FormField>
{renderLabel(resolvedCertPathLabel, hasCertPath, certPath)}
<Input
data-testid="tls-cert-path-input"
@@ -511,10 +515,10 @@ export function SslCertificateForm({
disabled={disabled || isSaaSMode}
placeholder={resolvedCertPathLabel}
/>
- </div>
+ </FormField>
)}
{showKeyAndCertFields && (
- <div className="flex flex-col gap-y-1">
+ <FormField>
{renderLabel(resolvedKeyPathLabel, hasKeyPath, keyPath)}
<Input
data-testid="tls-key-path-input"
@@ -523,7 +527,7 @@ export function SslCertificateForm({
disabled={disabled || isSaaSMode}
placeholder={resolvedKeyPathLabel}
/>
- </div>
+ </FormField>
)}
</div>
);
@@ -611,7 +615,7 @@ export function SslCertificateForm({
onCheckedChange={(val) => onVerifyChange?.(val)}
disabled={disabled}
/>
- <label className="textlabel block">{resolvedVerifyLabel}</label>
+ <FormLabel>{resolvedVerifyLabel}</FormLabel>
{showTooltip && (
<Tooltip
content={t("data-source.ssl.verify-certificate-tooltip")}
@@ -648,17 +652,15 @@ export function SslCertificateForm({
)}
<div className="flex flex-col gap-y-2">
{showCaSourceUi && (
- <div className="flex flex-col gap-y-1">
- <label className="textlabel block">
- {t("data-source.ssl.ca-source.self")}
- </label>
+ <FormField>
+ <FormLabel>{t("data-source.ssl.ca-source.self")}</FormLabel>
<CaSourceSelector
value={resolvedCaSource}
onChange={onCaSourceChange!}
disabled={disabled}
isSaaSMode={isSaaSMode}
/>
- </div>
+ </FormField>
)}
{renderCaMaterial()}
</div>
@@ -671,17 +673,17 @@ export function SslCertificateForm({
</legend>
<div className="flex flex-col gap-y-2">
{showClientCertSourceUi && (
- <div className="flex flex-col gap-y-1">
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{t("data-source.ssl.client-cert-source.self")}
- </label>
+ </FormLabel>
<ClientCertSourceSelector
value={clientIdentitySource}
onChange={onClientCertSourceChange!}
disabled={disabled}
isSaaSMode={isSaaSMode}
/>
- </div>
+ </FormField>
)}
{renderClientCertMaterial(clientIdentitySource)}
</div>
@@ -707,9 +709,7 @@ export function SslCertificateForm({
onCheckedChange={(val) => onUseSslChange?.(val)}
disabled={disabled}
/>
- <label className="textlabel block">
- {t("data-source.ssl-connection")}
- </label>
+ <FormLabel>{t("data-source.ssl-connection")}</FormLabel>
</div>
)}
@@ -723,17 +723,15 @@ export function SslCertificateForm({
<>
<div className="flex flex-col gap-y-2">
{showCaSourceUi && (
- <div className="flex flex-col gap-y-1">
- <label className="textlabel block">
- {t("data-source.ssl.ca-source.self")}
- </label>
+ <FormField>
+ <FormLabel>{t("data-source.ssl.ca-source.self")}</FormLabel>
<CaSourceSelector
value={resolvedCaSource}
onChange={onCaSourceChange!}
disabled={disabled}
isSaaSMode={isSaaSMode}
/>
- </div>
+ </FormField>
)}
{renderCaMaterial()}
</div>
@@ -741,10 +739,10 @@ export function SslCertificateForm({
{showKeyAndCertFields && (
<div className="flex flex-col gap-y-2">
{showClientCertSourceUi && (
- <div className="flex flex-col gap-y-1">
- <label className="textlabel block">
+ <FormField>
+ <FormLabel>
{t("data-source.ssl.client-cert-source.self")}
- </label>
+ </FormLabel>
<ClientCertSourceSelector
value={resolvedClientCertSource}
onChange={onClientCertSourceChange!}
@@ -752,7 +750,7 @@ export function SslCertificateForm({
isSaaSMode={isSaaSMode}
allowNone
/>
- </div>
+ </FormField>
)}
{renderClientCertMaterial()}
</div>
diff --git a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
index 2862b2da16..0eeeeb98d6 100644
--- a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
+++ b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
@@ -19,6 +19,12 @@ import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
import { Combobox } from "@/react/components/ui/combobox";
import { ExpirationPicker } from "@/react/components/ui/expiration-picker";
+import {
+ FormDescription,
+ FormError,
+ FormField,
+ FormLabel,
+} from "@/react/components/ui/form";
import {
Sheet,
SheetBody,
@@ -295,25 +301,25 @@ function AccessGrantRequestDrawerInner({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Databases */}
- <div className="flex flex-col gap-y-2">
- <div className="text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.databases")}
<span className="text-error ml-0.5">*</span>
- </div>
+ </FormLabel>
<DatabaseSelect
multiple
value={targets}
onChange={setTargets}
projectName={project as string}
/>
- </div>
+ </FormField>
{/* Statement */}
- <div className="flex flex-col gap-y-2">
- <div className="text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.statement")}
<span className="text-error ml-0.5">*</span>
- </div>
+ </FormLabel>
<Alert
variant="info"
description={t("sql-editor.only-select-allowed")}
@@ -338,13 +344,11 @@ function AccessGrantRequestDrawerInner({
onChange={setQuery}
options={monacoOptions}
/>
- </div>
+ </FormField>
{/* Unmask */}
- <div className="flex flex-col gap-y-2">
- <div className="text-sm font-medium text-control">
- {t("sql-editor.grant-type-unmask")}
- </div>
+ <FormField>
+ <FormLabel>{t("sql-editor.grant-type-unmask")}</FormLabel>
<label className="flex items-center gap-2 cursor-pointer">
<Checkbox
checked={unmask}
@@ -352,13 +356,11 @@ function AccessGrantRequestDrawerInner({
/>
<span>{t("sql-editor.access-type-unmask")}</span>
</label>
- </div>
+ </FormField>
{/* Export */}
- <div className="flex flex-col gap-y-2">
- <div className="text-sm font-medium text-control">
- {t("sql-editor.grant-type-export")}
- </div>
+ <FormField>
+ <FormLabel>{t("sql-editor.grant-type-export")}</FormLabel>
<label className="flex items-center gap-2 cursor-pointer">
<Checkbox
checked={exportResult}
@@ -366,14 +368,14 @@ function AccessGrantRequestDrawerInner({
/>
<span>{t("sql-editor.access-type-export")}</span>
</label>
- </div>
+ </FormField>
{/* Expiration */}
- <div className="flex flex-col gap-y-2">
- <div className="text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.expiration")}
<span className="text-error ml-0.5">*</span>
- </div>
+ </FormLabel>
<Combobox
value={String(duration)}
onChange={(val) => setDuration(Number(val))}
@@ -389,39 +391,39 @@ function AccessGrantRequestDrawerInner({
/>
)}
{maximumExpirationDays !== undefined && (
- <p className="text-xs text-control-light">
+ <FormDescription>
{t("project.members.request-role.max-expiration-hint", {
days: maximumExpirationDays,
})}
- </p>
+ </FormDescription>
)}
{expirationIsInPast && (
- <p className="text-xs text-error">
+ <FormError>
{t("project.members.request-role.expiration-must-be-future")}
- </p>
+ </FormError>
)}
{expirationExceedsMax && maximumExpirationDays !== undefined && (
- <p className="text-xs text-error">
+ <FormError>
{t("project.members.request-role.expiration-exceeds-max", {
days: maximumExpirationDays,
})}
- </p>
+ </FormError>
)}
- </div>
+ </FormField>
{/* Reason */}
- <div className="flex flex-col gap-y-2">
- <div className="text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.reason")}
<span className="text-error ml-0.5">*</span>
- </div>
+ </FormLabel>
<Textarea
value={reason}
onChange={(e) => setReason(e.target.value)}
rows={3}
placeholder=""
/>
- </div>
+ </FormField>
</div>
</SheetBody>
<SheetFooter>
diff --git a/frontend/src/react/components/sql-editor/QueryContextSettingPopover.test.tsx b/frontend/src/react/components/sql-editor/QueryContextSettingPopover.test.tsx
index 8a8ff9c747..194f2654f6 100644
--- a/frontend/src/react/components/sql-editor/QueryContextSettingPopover.test.tsx
+++ b/frontend/src/react/components/sql-editor/QueryContextSettingPopover.test.tsx
@@ -154,6 +154,13 @@ const setTabMode = (mode: string) => {
};
};
+const getRedisRadios = (content: Element | null) =>
+ Array.from(
+ content?.querySelectorAll<HTMLElement>('[role="radio"]') ?? []
+ ).filter((radio) =>
+ radio.parentElement?.textContent?.includes("sql-editor.redis-command")
+ );
+
beforeEach(async () => {
vi.clearAllMocks();
@@ -215,8 +222,8 @@ describe("QueryContextSettingPopover", () => {
);
render();
const content = container.querySelector("[data-testid='popover-content']");
- // Should have radio inputs for each data source + automatic
- const radios = content?.querySelectorAll("input[type='radio']") ?? [];
+ // Should have radio options for each data source + automatic.
+ const radios = content?.querySelectorAll('[role="radio"]') ?? [];
// automatic + 2 data sources = 3
expect(radios.length).toBeGreaterThanOrEqual(3);
unmount();
@@ -246,8 +253,7 @@ describe("QueryContextSettingPopover", () => {
);
render();
const content = container.querySelector("[data-testid='popover-content']");
- const redisRadios =
- content?.querySelectorAll("input[name='redis-command']") ?? [];
+ const redisRadios = getRedisRadios(content);
expect(redisRadios.length).toBe(0);
unmount();
});
@@ -263,8 +269,7 @@ describe("QueryContextSettingPopover", () => {
);
render();
const content = container.querySelector("[data-testid='popover-content']");
- const redisRadios =
- content?.querySelectorAll("input[name='redis-command']") ?? [];
+ const redisRadios = getRedisRadios(content);
expect(redisRadios.length).toBe(2);
unmount();
});
diff --git a/frontend/src/react/components/sql-editor/QueryContextSettingPopover.tsx b/frontend/src/react/components/sql-editor/QueryContextSettingPopover.tsx
index a7f3290901..95c26cb5bd 100644
--- a/frontend/src/react/components/sql-editor/QueryContextSettingPopover.tsx
+++ b/frontend/src/react/components/sql-editor/QueryContextSettingPopover.tsx
@@ -9,6 +9,7 @@ import {
PopoverContent,
PopoverTrigger,
} from "@/react/components/ui/popover";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { Tooltip } from "@/react/components/ui/tooltip";
import {
useConnectionOfCurrentSQLEditorTab,
@@ -133,34 +134,29 @@ export function QueryContextSettingPopover({ disabled = false }: Props) {
<p className="mb-1 textinfolabel">
{t("data-source.select-query-data-source")}
</p>
- <div className="max-w-44 flex flex-col gap-1">
- <label className="flex items-center gap-2 cursor-pointer">
- <input
- type="radio"
- name="data-source"
- checked={selectedDataSourceId === ""}
- onChange={() => onDataSourceSelected("")}
- />
- <span>{t("data-source.automatic-query-data-source")}</span>
- </label>
+ <RadioGroup
+ className="max-w-44 flex-col items-stretch gap-1"
+ value={selectedDataSourceId}
+ onValueChange={(value) => onDataSourceSelected(String(value))}
+ >
+ <RadioGroupItem value="">
+ {t("data-source.automatic-query-data-source")}
+ </RadioGroupItem>
{dataSources.map((ds) => {
const reason = dataSourceUnaccessibleReason(ds);
const radio = (
- <label className="flex items-center gap-2 cursor-pointer">
- <input
- type="radio"
- name="data-source"
- checked={selectedDataSourceId === ds.id}
- disabled={Boolean(reason)}
- onChange={() => onDataSourceSelected(ds.id)}
- />
+ <RadioGroupItem
+ value={ds.id}
+ disabled={Boolean(reason)}
+ contentClassName="min-w-0"
+ >
<div className="max-w-36 flex items-center">
<span className="text-xs opacity-60 shrink-0">
{readableDataSourceType(ds.type)}
</span>
<span className="ml-1 truncate">{ds.username}</span>
</div>
- </label>
+ </RadioGroupItem>
);
return (
<Tooltip key={ds.id} content={reason} side="right">
@@ -168,7 +164,7 @@ export function QueryContextSettingPopover({ disabled = false }: Props) {
</Tooltip>
);
})}
- </div>
+ </RadioGroup>
</div>
{/* Redis cluster config */}
@@ -185,54 +181,38 @@ export function QueryContextSettingPopover({ disabled = false }: Props) {
<p className="mb-1 textinfolabel">
{t("sql-editor.redis-command.self")}
</p>
- <div
- className="max-w-44 flex flex-col gap-1"
+ <RadioGroup
+ className="max-w-44 flex-col items-stretch gap-1"
+ value={String(redisCommandOption)}
+ onValueChange={(value) => {
+ getSQLEditorEditorState().setRedisCommandOption(
+ Number(value) as QueryOption_RedisRunCommandsOn
+ );
+ }}
aria-disabled={
selectedDataSource?.redisType !==
DataSource_RedisType.CLUSTER
}
>
- <label className="flex items-center gap-2 cursor-pointer">
- <input
- type="radio"
- name="redis-command"
- disabled={
- selectedDataSource?.redisType !==
- DataSource_RedisType.CLUSTER
- }
- checked={
- redisCommandOption ===
- QueryOption_RedisRunCommandsOn.SINGLE_NODE
- }
- onChange={() => {
- getSQLEditorEditorState().setRedisCommandOption(
- QueryOption_RedisRunCommandsOn.SINGLE_NODE
- );
- }}
- />
- <span>{t("sql-editor.redis-command.single-node")}</span>
- </label>
- <label className="flex items-center gap-2 cursor-pointer">
- <input
- type="radio"
- name="redis-command"
- disabled={
- selectedDataSource?.redisType !==
- DataSource_RedisType.CLUSTER
- }
- checked={
- redisCommandOption ===
- QueryOption_RedisRunCommandsOn.ALL_NODES
- }
- onChange={() => {
- getSQLEditorEditorState().setRedisCommandOption(
- QueryOption_RedisRunCommandsOn.ALL_NODES
- );
- }}
- />
- <span>{t("sql-editor.redis-command.all-nodes")}</span>
- </label>
- </div>
+ <RadioGroupItem
+ value={String(QueryOption_RedisRunCommandsOn.SINGLE_NODE)}
+ disabled={
+ selectedDataSource?.redisType !==
+ DataSource_RedisType.CLUSTER
+ }
+ >
+ {t("sql-editor.redis-command.single-node")}
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(QueryOption_RedisRunCommandsOn.ALL_NODES)}
+ disabled={
+ selectedDataSource?.redisType !==
+ DataSource_RedisType.CLUSTER
+ }
+ >
+ {t("sql-editor.redis-command.all-nodes")}
+ </RadioGroupItem>
+ </RadioGroup>
</div>
</Tooltip>
)}
diff --git a/frontend/src/react/components/sql-review/ReviewCreation.tsx b/frontend/src/react/components/sql-review/ReviewCreation.tsx
index 87feb0729b..dbcbd05c40 100644
--- a/frontend/src/react/components/sql-review/ReviewCreation.tsx
+++ b/frontend/src/react/components/sql-review/ReviewCreation.tsx
@@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next";
import { ResourceIdField } from "@/react/components/ResourceIdField";
import { Button } from "@/react/components/ui/button";
import { Input } from "@/react/components/ui/input";
+import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
import { useUnsavedChangesGuard } from "@/react/hooks/useUnsavedChangesGuard";
import {
getRuleKey,
@@ -457,46 +458,50 @@ export function ReviewCreation({
</div>
{/* Footer navigation */}
- <div className="sticky bottom-0 z-10 border-t bg-background px-4 py-4 flex justify-between">
- <div>
- {currentStep === STEP_BASIC_INFO && (
- <Button variant="outline" onClick={() => handleCancel()}>
- {t("common.cancel")}
- </Button>
- )}
- {currentStep > STEP_BASIC_INFO && (
- <Button
- variant="outline"
- onClick={() => changeStep(currentStep - 1)}
- >
- {t("common.previous")}
- </Button>
- )}
- </div>
- <div className="flex gap-x-2">
- {currentStep === STEP_CONFIGURE_RULES && (
- <Button
- variant="outline"
- onClick={() => setShowRuleSelectPanel(true)}
- >
- {t("sql-review.add-or-remove-rules")}
- </Button>
- )}
- {currentStep < STEP_CONFIGURE_RULES && (
- <Button
- disabled={!allowNext}
- onClick={() => changeStep(currentStep + 1)}
- >
- {t("common.next")}
- </Button>
- )}
- {currentStep === STEP_CONFIGURE_RULES && (
- <Button disabled={!allowNext} onClick={tryFinishSetup}>
- {finishTitle}
- </Button>
- )}
- </div>
- </div>
+ <StickyActionFooter
+ left={
+ <>
+ {currentStep === STEP_BASIC_INFO && (
+ <Button variant="outline" onClick={() => handleCancel()}>
+ {t("common.cancel")}
+ </Button>
+ )}
+ {currentStep > STEP_BASIC_INFO && (
+ <Button
+ variant="outline"
+ onClick={() => changeStep(currentStep - 1)}
+ >
+ {t("common.previous")}
+ </Button>
+ )}
+ </>
+ }
+ right={
+ <>
+ {currentStep === STEP_CONFIGURE_RULES && (
+ <Button
+ variant="outline"
+ onClick={() => setShowRuleSelectPanel(true)}
+ >
+ {t("sql-review.add-or-remove-rules")}
+ </Button>
+ )}
+ {currentStep < STEP_CONFIGURE_RULES && (
+ <Button
+ disabled={!allowNext}
+ onClick={() => changeStep(currentStep + 1)}
+ >
+ {t("common.next")}
+ </Button>
+ )}
+ {currentStep === STEP_CONFIGURE_RULES && (
+ <Button disabled={!allowNext} onClick={tryFinishSetup}>
+ {finishTitle}
+ </Button>
+ )}
+ </>
+ }
+ />
</div>
);
}
diff --git a/frontend/src/react/components/ui/combobox.test.tsx b/frontend/src/react/components/ui/combobox.test.tsx
index 487374d309..1e7de6c936 100644
--- a/frontend/src/react/components/ui/combobox.test.tsx
+++ b/frontend/src/react/components/ui/combobox.test.tsx
@@ -4,6 +4,7 @@ import { afterEach, describe, expect, test } from "vitest";
import { Combobox } from "./combobox";
import { Dialog, DialogContent } from "./dialog";
import { LAYER_BACKDROP_CLASS, LAYER_SURFACE_CLASS } from "./layer";
+import { overlaySurfaceClassName } from "./styles.stylex";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
@@ -53,11 +54,16 @@ describe("Combobox", () => {
expect(overlayRoot?.innerHTML).toContain(LAYER_BACKDROP_CLASS);
- const dropdown = overlayRoot?.querySelector(
- "div.bg-background.border.border-control-border.rounded-sm.shadow-lg.overflow-hidden"
- ) as HTMLDivElement | null;
+ const dropdown = Array.from(
+ overlayRoot?.querySelectorAll("div") ?? []
+ ).find(
+ (element) =>
+ element.className.includes(overlaySurfaceClassName) &&
+ element.textContent?.includes("Alpha")
+ ) as HTMLDivElement | undefined;
expect(dropdown).toBeInstanceOf(HTMLDivElement);
expect(dropdown?.textContent).toContain("Alpha");
+ expect(dropdown?.className).toContain(overlaySurfaceClassName);
expect(dropdown?.className).toContain(LAYER_SURFACE_CLASS);
expect(overlayRoot?.lastElementChild).toBe(dropdown);
expect(dropdown?.querySelector("input")?.style.paddingInlineStart).toBe(
diff --git a/frontend/src/react/components/ui/combobox.tsx b/frontend/src/react/components/ui/combobox.tsx
index 70a26a52a0..7c6fb33a5b 100644
--- a/frontend/src/react/components/ui/combobox.tsx
+++ b/frontend/src/react/components/ui/combobox.tsx
@@ -23,6 +23,7 @@ import {
controlMinHeightStyle,
menuRowStateClassName,
menuRowStyle,
+ overlaySurfaceClassName,
} from "./styles.stylex";
export interface ComboboxOption {
@@ -391,9 +392,9 @@ export function Combobox(props: ComboboxProps) {
ref={dropdownRef}
style={portal ? dropdownStyle : undefined}
className={cn(
- "bg-background border border-control-border rounded-sm shadow-lg overflow-hidden",
- portal && LAYER_SURFACE_CLASS,
- !portal && "absolute z-50 mt-1 min-w-full w-max"
+ overlaySurfaceClassName,
+ LAYER_SURFACE_CLASS,
+ !portal && "absolute mt-1 min-w-full w-max"
)}
>
<SearchInput
@@ -403,7 +404,7 @@ export function Combobox(props: ComboboxProps) {
wrapperClassName="m-2"
className="h-7"
/>
- <div className="max-h-60 overflow-y-auto px-2 pb-2">
+ <div className="px-2 pb-2">
{filteredGroups.every((g) => g.options.length === 0) ? (
noResultsContent !== undefined ? (
<div className="p-3">{noResultsContent}</div>
diff --git a/frontend/src/react/components/ui/context-menu.test.tsx b/frontend/src/react/components/ui/context-menu.test.tsx
index e2beb42610..4fbdb84b3c 100644
--- a/frontend/src/react/components/ui/context-menu.test.tsx
+++ b/frontend/src/react/components/ui/context-menu.test.tsx
@@ -10,7 +10,11 @@ import {
ContextMenuSeparator,
ContextMenuTrigger,
} from "./context-menu";
-import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
+import {
+ menuRowStateClassName,
+ menuRowStyle,
+ overlaySurfaceClassName,
+} from "./styles.stylex";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
@@ -305,6 +309,8 @@ describe("ContextMenu", () => {
const item = Array.from(
document.querySelectorAll("[role='menuitem']")
).find((el) => el.textContent === "Action");
+ const surface = item?.parentElement;
+ expect(surface?.className).toContain(overlaySurfaceClassName);
expect(item?.className).toContain(
stylex.props(menuRowStyle("sm")).className ?? ""
);
diff --git a/frontend/src/react/components/ui/context-menu.tsx b/frontend/src/react/components/ui/context-menu.tsx
index a5ff64b26b..8b651fed2a 100644
--- a/frontend/src/react/components/ui/context-menu.tsx
+++ b/frontend/src/react/components/ui/context-menu.tsx
@@ -7,7 +7,11 @@ import {
LAYER_SURFACE_CLASS,
usePreserveHigherLayerAccess,
} from "./layer";
-import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
+import {
+ menuRowStateClassName,
+ menuRowStyle,
+ overlaySurfaceClassName,
+} from "./styles.stylex";
// ---- Root ----
// Wraps BaseContextMenu.Root. ContextMenu has no `modal` prop (it is omitted
@@ -32,11 +36,7 @@ function ContextMenuContent({
<BaseContextMenu.Positioner className={LAYER_SURFACE_CLASS}>
<BaseContextMenu.Popup
ref={ref}
- className={cn(
- "min-w-[10rem] overflow-hidden rounded-sm border border-control-border bg-background py-1 shadow-md",
- "focus:outline-hidden",
- className
- )}
+ className={cn("min-w-[10rem]", overlaySurfaceClassName, className)}
{...props}
>
{children}
diff --git a/frontend/src/react/components/ui/dropdown-menu.test.tsx b/frontend/src/react/components/ui/dropdown-menu.test.tsx
index ed2c2f2a0e..251e084448 100644
--- a/frontend/src/react/components/ui/dropdown-menu.test.tsx
+++ b/frontend/src/react/components/ui/dropdown-menu.test.tsx
@@ -9,7 +9,11 @@ import {
DropdownMenuLabel,
DropdownMenuTrigger,
} from "./dropdown-menu";
-import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
+import {
+ menuRowStateClassName,
+ menuRowStyle,
+ overlaySurfaceClassName,
+} from "./styles.stylex";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
@@ -55,6 +59,8 @@ describe("DropdownMenu", () => {
const item = Array.from(
document.querySelectorAll("[role='menuitem']")
).find((el) => el.textContent === "Action");
+ const surface = item?.parentElement;
+ expect(surface?.className).toContain(overlaySurfaceClassName);
expect(item?.className).toContain(
stylex.props(menuRowStyle("sm")).className ?? ""
);
diff --git a/frontend/src/react/components/ui/dropdown-menu.tsx b/frontend/src/react/components/ui/dropdown-menu.tsx
index d3bad4ea6d..f393b5eed2 100644
--- a/frontend/src/react/components/ui/dropdown-menu.tsx
+++ b/frontend/src/react/components/ui/dropdown-menu.tsx
@@ -3,7 +3,11 @@ import * as stylex from "@stylexjs/stylex";
import type { ComponentProps } from "react";
import { cn } from "@/react/lib/utils";
import { getLayerRoot, LAYER_SURFACE_CLASS } from "./layer";
-import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
+import {
+ menuRowStateClassName,
+ menuRowStyle,
+ overlaySurfaceClassName,
+} from "./styles.stylex";
// ---- Root ----
// Default to non-modal: row action menus should let users click through to
@@ -49,11 +53,7 @@ function DropdownMenuContent({
>
<BaseMenu.Popup
ref={ref}
- className={cn(
- "min-w-[10rem] overflow-hidden rounded-sm border border-control-border bg-background py-1 shadow-md",
- "focus:outline-hidden",
- className
- )}
+ className={cn("min-w-[10rem]", overlaySurfaceClassName, className)}
{...props}
>
{children}
@@ -84,11 +84,7 @@ function DropdownMenuSubmenuContent({
>
<BaseMenu.Popup
ref={ref}
- className={cn(
- "min-w-[10rem] overflow-hidden rounded-sm border border-control-border bg-background py-1 shadow-md",
- "focus:outline-hidden",
- className
- )}
+ className={cn("min-w-[10rem]", overlaySurfaceClassName, className)}
{...props}
>
{children}
diff --git a/frontend/src/react/components/ui/select.test.tsx b/frontend/src/react/components/ui/select.test.tsx
index 9db6c2f221..094349e6be 100644
--- a/frontend/src/react/components/ui/select.test.tsx
+++ b/frontend/src/react/components/ui/select.test.tsx
@@ -3,7 +3,11 @@ import { act, type CSSProperties, type ReactNode } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, test, vi } from "vitest";
import { Select, SelectContent, SelectItem, SelectTrigger } from "./select";
-import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
+import {
+ menuRowStateClassName,
+ menuRowStyle,
+ overlaySurfaceClassName,
+} from "./styles.stylex";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
@@ -34,7 +38,13 @@ vi.mock("@base-ui/react/select", () => ({
selectMocks.positionerProps.push(props);
return <div>{children}</div>;
},
- Popup: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ Popup: ({
+ children,
+ ...props
+ }: {
+ children: ReactNode;
+ className?: string;
+ }) => <div {...props}>{children}</div>,
Item: ({
children,
...props
@@ -118,6 +128,31 @@ describe("SelectContent", () => {
root.unmount();
});
});
+
+ test("uses the shared overlay surface contract", async () => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+
+ await act(async () => {
+ root.render(
+ <Select>
+ <SelectContent>Role options</SelectContent>
+ </Select>
+ );
+ });
+
+ const popup = Array.from(container.querySelectorAll("div")).find(
+ (element) =>
+ element.textContent === "Role options" &&
+ element.className.includes("min-w-")
+ );
+ expect(popup?.className).toContain(overlaySurfaceClassName);
+
+ await act(async () => {
+ root.unmount();
+ });
+ });
});
describe("SelectTrigger", () => {
diff --git a/frontend/src/react/components/ui/select.tsx b/frontend/src/react/components/ui/select.tsx
index fd637fa496..02cb90ae80 100644
--- a/frontend/src/react/components/ui/select.tsx
+++ b/frontend/src/react/components/ui/select.tsx
@@ -10,6 +10,7 @@ import {
controlSizeStyle,
menuRowStateClassName,
menuRowStyle,
+ overlaySurfaceClassName,
} from "./styles.stylex";
// ---- Root ----
@@ -91,7 +92,8 @@ function SelectContent({
<BaseSelect.Popup
ref={ref}
className={cn(
- "min-w-(--anchor-width) max-h-60 overflow-auto rounded-sm border border-control-border bg-background py-1 shadow-md",
+ "min-w-(--anchor-width)",
+ overlaySurfaceClassName,
className
)}
{...props}
diff --git a/frontend/src/react/components/ui/sticky-action-footer.test.tsx b/frontend/src/react/components/ui/sticky-action-footer.test.tsx
index 9b09167603..78e421ec6c 100644
--- a/frontend/src/react/components/ui/sticky-action-footer.test.tsx
+++ b/frontend/src/react/components/ui/sticky-action-footer.test.tsx
@@ -4,6 +4,7 @@ import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, test } from "vitest";
import { StickyActionFooter } from "./sticky-action-footer";
import {
+ stickyActionFooterContentStyle,
stickyActionFooterRightStyle,
stickyActionFooterSideStyle,
stickyActionFooterStyle,
@@ -55,14 +56,23 @@ describe("StickyActionFooter", () => {
const right = container.querySelector(
'[data-slot="sticky-action-footer-right"]'
);
+ const content = container.querySelector(
+ '[data-slot="sticky-action-footer-content"]'
+ );
expect(footer?.className).toContain("sticky");
expect(footer?.className).toContain("bottom-0");
expect(footer?.className).toContain(
stylex.props(stickyActionFooterStyle()).className ?? ""
);
- expect(footer?.firstElementChild).toBe(left);
- expect(footer?.lastElementChild).toBe(right);
+ expect(footer?.firstElementChild).toBe(content);
+ expect(content?.className).toContain("px-4");
+ expect(content?.className).toContain("sm:px-6");
+ expect(content?.className).toContain(
+ stylex.props(stickyActionFooterContentStyle()).className ?? ""
+ );
+ expect(content?.firstElementChild).toBe(left);
+ expect(content?.lastElementChild).toBe(right);
expect(left?.textContent).toBe("Cancel");
expect(left?.className).toContain(
stylex.props(stickyActionFooterSideStyle()).className ?? ""
diff --git a/frontend/src/react/components/ui/sticky-action-footer.tsx b/frontend/src/react/components/ui/sticky-action-footer.tsx
index 480de91339..5444f21aa5 100644
--- a/frontend/src/react/components/ui/sticky-action-footer.tsx
+++ b/frontend/src/react/components/ui/sticky-action-footer.tsx
@@ -2,6 +2,7 @@ import * as stylex from "@stylexjs/stylex";
import type { ComponentProps, ReactNode } from "react";
import { cn } from "@/react/lib/utils";
import {
+ stickyActionFooterContentStyle,
stickyActionFooterRightStyle,
stickyActionFooterSideStyle,
stickyActionFooterStyle,
@@ -27,6 +28,7 @@ function StickyActionFooter({
...props
}: StickyActionFooterProps) {
const rootStylexProps = stylex.props(stickyActionFooterStyle());
+ const contentStylexProps = stylex.props(stickyActionFooterContentStyle());
const leftStylexProps = stylex.props(stickyActionFooterSideStyle());
const rightStylexProps = stylex.props(
stickyActionFooterSideStyle(),
@@ -46,18 +48,24 @@ function StickyActionFooter({
{...props}
>
<div
- data-slot="sticky-action-footer-left"
- className={cn(leftStylexProps.className, leftClassName)}
- style={leftStylexProps.style}
+ data-slot="sticky-action-footer-content"
+ className={cn("px-4 sm:px-6", contentStylexProps.className)}
+ style={contentStylexProps.style}
>
- {left}
- </div>
- <div
- data-slot="sticky-action-footer-right"
- className={cn("gap-x-2", rightStylexProps.className, rightClassName)}
- style={rightStylexProps.style}
- >
- {right}
+ <div
+ data-slot="sticky-action-footer-left"
+ className={cn(leftStylexProps.className, leftClassName)}
+ style={leftStylexProps.style}
+ >
+ {left}
+ </div>
+ <div
+ data-slot="sticky-action-footer-right"
+ className={cn("gap-x-2", rightStylexProps.className, rightClassName)}
+ style={rightStylexProps.style}
+ >
+ {right}
+ </div>
</div>
</div>
);
diff --git a/frontend/src/react/components/ui/styles.stylex.test.tsx b/frontend/src/react/components/ui/styles.stylex.test.tsx
index 4ab976d1ee..5d63f4a487 100644
--- a/frontend/src/react/components/ui/styles.stylex.test.tsx
+++ b/frontend/src/react/components/ui/styles.stylex.test.tsx
@@ -37,9 +37,15 @@ import {
formLabelStyle,
formMessageStyle,
interactiveRowStyle,
+ listRowIconStyle,
+ listRowPrimaryTextStyle,
+ listRowSecondaryTextStyle,
+ listRowStateClassName,
listRowStyle,
menuRowStateClassName,
menuRowStyle,
+ overlaySurfaceClassName,
+ stickyActionFooterContentStyle,
stickyActionFooterRightStyle,
stickyActionFooterSideStyle,
stickyActionFooterStyle,
@@ -104,13 +110,30 @@ describe("StyleX common UI style contracts", () => {
expectStyleXClass(stylex.props(formMessageStyle()).className);
expectStyleXClass(stylex.props(menuRowStyle("md")).className);
expectStyleXClass(stylex.props(listRowStyle("sm")).className);
+ expectStyleXClass(stylex.props(listRowIconStyle()).className);
+ expectStyleXClass(stylex.props(listRowPrimaryTextStyle()).className);
+ expectStyleXClass(stylex.props(listRowSecondaryTextStyle()).className);
expectClasses(
menuRowStateClassName,
"data-highlighted:bg-control-bg data-disabled:pointer-events-none data-disabled:opacity-50 data-selected:bg-accent/5 aria-selected:bg-accent/5 aria-disabled:pointer-events-none aria-disabled:opacity-50"
);
expectStyleXClass(stylex.props(stickyActionFooterStyle()).className);
+ expectStyleXClass(stylex.props(stickyActionFooterContentStyle()).className);
expectStyleXClass(stylex.props(stickyActionFooterSideStyle()).className);
expectStyleXClass(stylex.props(stickyActionFooterRightStyle()).className);
+ expectClasses(
+ overlaySurfaceClassName,
+ "max-h-60 overflow-y-auto overflow-x-hidden rounded-sm border border-control-border bg-background py-1 shadow-md focus:outline-hidden"
+ );
+ });
+
+ test("keeps list row state separate from menu row state", () => {
+ expectClasses(
+ listRowStateClassName,
+ "hover:bg-control-bg data-selected:bg-accent/5 aria-selected:bg-accent/5 disabled:pointer-events-none disabled:opacity-50 data-disabled:pointer-events-none data-disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50"
+ );
+ expect(listRowStateClassName).not.toContain("data-highlighted:");
+ expect(menuRowStateClassName).toContain("data-highlighted:bg-control-bg");
});
test("applies StyleX classes to shared primitive consumers", () => {
diff --git a/frontend/src/react/components/ui/styles.stylex.ts b/frontend/src/react/components/ui/styles.stylex.ts
index 7182826382..c6ce8fa8c9 100644
--- a/frontend/src/react/components/ui/styles.stylex.ts
+++ b/frontend/src/react/components/ui/styles.stylex.ts
@@ -304,6 +304,9 @@ export function formControlAffixStyle() {
const stickyActionFooterStyles = stylex.create({
root: {
+ width: "100%",
+ },
+ content: {
alignItems: "center",
display: "flex",
justifyContent: "space-between",
@@ -321,6 +324,10 @@ export function stickyActionFooterStyle() {
return stickyActionFooterStyles.root;
}
+export function stickyActionFooterContentStyle() {
+ return stickyActionFooterStyles.content;
+}
+
export function stickyActionFooterSideStyle() {
return stickyActionFooterStyles.side;
}
@@ -329,6 +336,19 @@ export function stickyActionFooterRightStyle() {
return stickyActionFooterStyles.right;
}
+export const overlaySurfaceClassName = [
+ "max-h-60",
+ "overflow-y-auto",
+ "overflow-x-hidden",
+ "rounded-sm",
+ "border",
+ "border-control-border",
+ "bg-background",
+ "py-1",
+ "shadow-md",
+ "focus:outline-hidden",
+].join(" ");
+
const rowBaseStyles = stylex.create({
base: {
alignItems: "center",
@@ -371,6 +391,18 @@ export const menuRowStateClassName = [
"data-disabled:opacity-50",
].join(" ");
+export const listRowStateClassName = [
+ "hover:bg-control-bg",
+ "data-selected:bg-accent/5",
+ "aria-selected:bg-accent/5",
+ "disabled:pointer-events-none",
+ "disabled:opacity-50",
+ "aria-disabled:pointer-events-none",
+ "aria-disabled:opacity-50",
+ "data-disabled:pointer-events-none",
+ "data-disabled:opacity-50",
+].join(" ");
+
const rowSizeStyles = stylex.create({
sm: {
columnGap: 8,
@@ -393,6 +425,22 @@ const listRowStyles = stylex.create({
textAlign: "start",
width: "100%",
},
+ icon: {
+ color: "rgb(var(--color-control-light))",
+ flexShrink: 0,
+ height: 16,
+ width: 16,
+ },
+ primaryText: {
+ color: "rgb(var(--color-control))",
+ minWidth: 0,
+ },
+ secondaryText: {
+ color: "rgb(var(--color-control-light))",
+ fontSize: 12,
+ lineHeight: "16px",
+ minWidth: 0,
+ },
});
export type RowSize = keyof typeof rowSizeStyles;
@@ -405,6 +453,18 @@ export function listRowStyle(size: RowSize = "sm") {
return [rowBaseStyles.base, rowSizeStyles[size], listRowStyles.base];
}
+export function listRowIconStyle() {
+ return listRowStyles.icon;
+}
+
+export function listRowPrimaryTextStyle() {
+ return listRowStyles.primaryText;
+}
+
+export function listRowSecondaryTextStyle() {
+ return listRowStyles.secondaryText;
+}
+
export function interactiveRowStyle(size: RowSize = "sm") {
return listRowStyle(size);
}
diff --git a/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.test.tsx b/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.test.tsx
index 7d434c31d1..96905c22f9 100644
--- a/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.test.tsx
+++ b/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.test.tsx
@@ -255,7 +255,7 @@ const submittedExpression = (): string | undefined => {
const clickRadio = async (container: HTMLElement, index: number) => {
const radios = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
+ container.querySelectorAll<HTMLElement>('[role="radio"]')
);
await click(radios[index]!);
};
diff --git a/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.tsx b/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.tsx
index fae4fc2577..7340678707 100644
--- a/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.tsx
+++ b/frontend/src/react/pages/project/ProjectMaskingExemptionCreatePage.tsx
@@ -18,6 +18,8 @@ import { Button } from "@/react/components/ui/button";
import { ExpirationPicker } from "@/react/components/ui/expiration-picker";
import { FeatureModal } from "@/react/components/ui/feature-modal";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
+import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
import { Tooltip } from "@/react/components/ui/tooltip";
import { useProjectByName } from "@/react/hooks/useProjectByName";
import {
@@ -212,50 +214,31 @@ export function ProjectMaskingExemptionCreatePage({
{/* Radio group */}
<div className="w-full mb-2">
- <div className="flex flex-col sm:flex-row justify-start sm:items-center gap-2 sm:gap-4">
+ <RadioGroup
+ className="flex-col items-start gap-2 sm:flex-row sm:items-center sm:gap-4"
+ value={radioValue}
+ onValueChange={(value) => onRadioChange(value as RadioValue)}
+ >
<Tooltip content={t("issue.role-grant.all-databases-tip")}>
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="resource-mode"
- checked={radioValue === "ALL"}
- onChange={() => onRadioChange("ALL")}
- className="accent-accent"
- />
- <span>{t("issue.role-grant.all-databases")}</span>
- </label>
+ <RadioGroupItem value="ALL">
+ {t("issue.role-grant.all-databases")}
+ </RadioGroupItem>
</Tooltip>
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="resource-mode"
- checked={radioValue === "EXPRESSION"}
- onChange={() => onRadioChange("EXPRESSION")}
- disabled={!project}
- className="accent-accent"
- />
+ <RadioGroupItem value="EXPRESSION" disabled={!project}>
<div className="flex items-center gap-x-1">
<FeatureBadge feature={PlanFeature.FEATURE_DATA_MASKING} />
<span>{t("issue.role-grant.use-cel")}</span>
</div>
- </label>
+ </RadioGroupItem>
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="resource-mode"
- checked={radioValue === "SELECT"}
- onChange={() => onRadioChange("SELECT")}
- disabled={!project}
- className="accent-accent"
- />
+ <RadioGroupItem value="SELECT" disabled={!project}>
<div className="flex items-center gap-x-1">
<FeatureBadge feature={PlanFeature.FEATURE_DATA_MASKING} />
<span>{t("issue.role-grant.manually-select")}</span>
</div>
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
{/* Resource selector content */}
@@ -318,16 +301,19 @@ export function ProjectMaskingExemptionCreatePage({
</div>
{/* Footer */}
- <div className="sticky bottom-0 z-10 border-t bg-background">
- <div className="flex justify-end items-center gap-x-4 px-4 py-3">
+ <StickyActionFooter
+ className="py-3"
+ left={
<Button variant="outline" onClick={onDismiss}>
{t("common.cancel")}
</Button>
+ }
+ right={
<Button disabled={submitDisabled || processing} onClick={onSubmit}>
{t("common.confirm")}
</Button>
- </div>
- </div>
+ }
+ />
{/* Feature paywall — shared FeatureModal so the dialog content is
driven by the subscription dynamic feature copy + plan info. */}
diff --git a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx
index 7ecfb72688..a098da862e 100644
--- a/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx
+++ b/frontend/src/react/pages/project/ProjectPlanDashboardPage.tsx
@@ -28,6 +28,7 @@ import { Alert } from "@/react/components/ui/alert";
import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { SearchInput } from "@/react/components/ui/search-input";
import {
Sheet,
@@ -1099,47 +1100,48 @@ function DatabaseGroupSelector({
}
return (
- <table className="w-full text-sm">
- <thead>
- <tr className="border-b text-left text-control-light">
- <th className="py-2 pr-2 w-8" />
- <th className="py-2 pr-4 font-medium">
- {t("common.database-group")}
- </th>
- </tr>
- </thead>
- <tbody>
- {groups.map((group) => {
- const isSelected = selectedGroup === group.name;
- return (
- <tr
- key={group.name}
- className={cn(
- "border-b cursor-pointer hover:bg-control-bg",
- isSelected && "bg-accent/5"
- )}
- onClick={() =>
- onSelectedGroupChange(isSelected ? undefined : group.name)
- }
- >
- <td className="py-2 pr-2">
- <input
- type="radio"
- checked={isSelected}
- readOnly
- className="accent-accent"
- />
- </td>
- <td className="py-2 pr-4">
- <div className="flex items-center gap-x-1.5">
- <FolderTree className="size-4 text-control-light shrink-0" />
- <span>{group.title}</span>
- </div>
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
+ <RadioGroup
+ value={selectedGroup ?? ""}
+ onValueChange={(value) => onSelectedGroupChange(String(value))}
+ className="block"
+ >
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b text-left text-control-light">
+ <th className="py-2 pr-2 w-8" />
+ <th className="py-2 pr-4 font-medium">
+ {t("common.database-group")}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {groups.map((group) => {
+ const isSelected = selectedGroup === group.name;
+ return (
+ <tr
+ key={group.name}
+ className={cn(
+ "border-b cursor-pointer hover:bg-control-bg",
+ isSelected && "bg-accent/5"
+ )}
+ onClick={() =>
+ onSelectedGroupChange(isSelected ? undefined : group.name)
+ }
+ >
+ <td className="py-2 pr-2">
+ <RadioGroupItem value={group.name} aria-label={group.title} />
+ </td>
+ <td className="py-2 pr-4">
+ <div className="flex items-center gap-x-1.5">
+ <FolderTree className="size-4 text-control-light shrink-0" />
+ <span>{group.title}</span>
+ </div>
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ </RadioGroup>
);
}
diff --git a/frontend/src/react/pages/project/ProjectSettingsPage.tsx b/frontend/src/react/pages/project/ProjectSettingsPage.tsx
index d045f082b4..64f726a92d 100644
--- a/frontend/src/react/pages/project/ProjectSettingsPage.tsx
+++ b/frontend/src/react/pages/project/ProjectSettingsPage.tsx
@@ -16,6 +16,7 @@ import {
} from "@/react/components/ui/dialog";
import { Input } from "@/react/components/ui/input";
import { NumberInput } from "@/react/components/ui/number-input";
+import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
import { Switch } from "@/react/components/ui/switch";
import { Tooltip } from "@/react/components/ui/tooltip";
import { useProjectByName } from "@/react/hooks/useProjectByName";
@@ -1156,19 +1157,21 @@ export function ProjectSettingsPage() {
{/* Save / Cancel Bar */}
{/* ============================================================= */}
{allowEdit && isDirty && (
- <div className="sticky bottom-0 z-10">
- <div className="flex justify-end gap-x-4 w-full py-4 border-t border-block-border bg-background">
+ <StickyActionFooter
+ left={
<Button variant="outline" onClick={revert}>
{t("common.cancel")}
</Button>
+ }
+ right={
<Button
onClick={handleSave}
disabled={labelErrors.length > 0 || saving || !title.trim()}
>
{t("common.update")}
</Button>
- </div>
- </div>
+ }
+ />
)}
</div>
diff --git a/frontend/src/react/pages/project/ProjectWebhookForm.tsx b/frontend/src/react/pages/project/ProjectWebhookForm.tsx
index 3e16cf0c9c..4fd3e31cb4 100644
--- a/frontend/src/react/pages/project/ProjectWebhookForm.tsx
+++ b/frontend/src/react/pages/project/ProjectWebhookForm.tsx
@@ -20,6 +20,8 @@ import {
DropdownMenuTrigger,
} from "@/react/components/ui/dropdown-menu";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
+import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
import { Tooltip } from "@/react/components/ui/tooltip";
import { WebhookTypeIcon } from "@/react/components/WebhookTypeIcon";
import { router } from "@/react/router";
@@ -358,7 +360,11 @@ export function ProjectWebhookForm({
{t("project.webhook.destination")}{" "}
<span className="text-error">*</span>
</label>
- <div className="grid grid-cols-1 gap-4 sm:grid-cols-7 mt-1">
+ <RadioGroup
+ className="mt-1 grid grid-cols-1 gap-4 sm:grid-cols-7"
+ value={String(state.type)}
+ onValueChange={(value) => updateField("type", Number(value))}
+ >
{webhookTypeItemList.map((item) => (
<div
key={item.type}
@@ -375,16 +381,15 @@ export function ProjectWebhookForm({
{item.name}
</p>
<div className="mt-3">
- <input
- type="radio"
- checked={state.type === item.type}
- onChange={() => updateField("type", item.type)}
+ <RadioGroupItem
+ value={String(item.type)}
+ aria-label={item.name}
/>
</div>
</div>
</div>
))}
- </div>
+ </RadioGroup>
</div>
)}
@@ -535,43 +540,37 @@ export function ProjectWebhookForm({
</div>
{/* Footer */}
- <div className="w-full sticky bottom-0 z-10">
- <div className="w-full py-4 px-4 border-t border-block-border bg-background">
- <div className="flex justify-end items-center gap-x-4">
- {create ? (
- <Button variant="outline" onClick={cancel}>
- {t("common.cancel")}
- </Button>
- ) : (
- valueChanged && (
- <Button variant="outline" onClick={discardChanges}>
- {t("common.discard-changes")}
- </Button>
- )
- )}
- {allowEdit &&
- (create ? (
- <Button
- disabled={!allowCreate || loading}
- onClick={createWebhook}
- >
- {t("common.create")}
- </Button>
- ) : (
- <Button
- disabled={
- loading ||
- !valueChanged ||
- state.notificationTypes.length === 0
- }
- onClick={updateWebhook}
- >
- {t("common.update")}
- </Button>
- ))}
- </div>
- </div>
- </div>
+ <StickyActionFooter
+ className="w-full"
+ left={
+ create ? (
+ <Button variant="outline" onClick={cancel}>
+ {t("common.cancel")}
+ </Button>
+ ) : valueChanged ? (
+ <Button variant="outline" onClick={discardChanges}>
+ {t("common.discard-changes")}
+ </Button>
+ ) : undefined
+ }
+ right={
+ allowEdit &&
+ (create ? (
+ <Button disabled={!allowCreate || loading} onClick={createWebhook}>
+ {t("common.create")}
+ </Button>
+ ) : (
+ <Button
+ disabled={
+ loading || !valueChanged || state.notificationTypes.length === 0
+ }
+ onClick={updateWebhook}
+ >
+ {t("common.update")}
+ </Button>
+ ))
+ }
+ />
{/* Delete confirmation dialog */}
<AlertDialog open={deleteOpen} onOpenChange={setDeleteOpen}>
diff --git a/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.test.tsx b/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.test.tsx
index caf591d1bf..766791f93e 100644
--- a/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.test.tsx
+++ b/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.test.tsx
@@ -272,6 +272,15 @@ const flush = async () => {
});
};
+const getRadios = (container: HTMLElement) =>
+ Array.from(container.querySelectorAll<HTMLElement>('[role="radio"]'));
+
+const isChecked = (radio: HTMLElement | undefined) =>
+ radio?.getAttribute("aria-checked") === "true";
+
+const isDisabled = (radio: HTMLElement | undefined) =>
+ radio?.getAttribute("aria-disabled") === "true";
+
const deferred = <T,>() => {
let resolve!: (value: T) => void;
const promise = new Promise<T>((resolver) => {
@@ -365,12 +374,10 @@ describe("GrantAccessDialog", () => {
const { container, unmount } = renderGrantAccessDialog();
await flush();
- const radioList = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
- );
+ const radioList = getRadios(container);
expect(radioList).toHaveLength(3);
- expect(radioList[2]?.checked).toBe(true);
+ expect(isChecked(radioList[2])).toBe(true);
await click(radioList[1]!);
@@ -420,11 +427,9 @@ describe("GrantAccessDialog", () => {
});
await flush();
- const radioList = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
- );
- expect(radioList[1]?.checked).toBe(true);
- expect(radioList[2]?.disabled).toBe(false);
+ const radioList = getRadios(container);
+ expect(isChecked(radioList[1])).toBe(true);
+ expect(isDisabled(radioList[2])).toBe(false);
const exprEditor = container.querySelector('[data-testid="expr-editor"]');
expect(exprEditor?.textContent).toContain("serialized-selection");
@@ -436,11 +441,9 @@ describe("GrantAccessDialog", () => {
const { container, unmount } = renderGrantAccessDialog();
await flush();
- let radioList = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
- );
- expect(radioList[2]?.checked).toBe(true);
- expect(radioList[2]?.disabled).toBe(false);
+ let radioList = getRadios(container);
+ expect(isChecked(radioList[2])).toBe(true);
+ expect(isDisabled(radioList[2])).toBe(false);
await click(radioList[1]!);
await click(
@@ -449,18 +452,14 @@ describe("GrantAccessDialog", () => {
)!
);
- radioList = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
- );
- expect(radioList[1]?.checked).toBe(true);
- expect(radioList[2]?.disabled).toBe(false);
+ radioList = getRadios(container);
+ expect(isChecked(radioList[1])).toBe(true);
+ expect(isDisabled(radioList[2])).toBe(false);
await click(radioList[2]!);
- radioList = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
- );
- expect(radioList[2]?.checked).toBe(true);
+ radioList = getRadios(container);
+ expect(isChecked(radioList[2])).toBe(true);
expect(
container
.querySelector('[data-testid="database-resource-selector"]')
@@ -501,7 +500,7 @@ describe("GrantAccessDialog", () => {
vi.useRealTimers();
});
- test("keeps the latest mode when an earlier async conversion resolves late", async () => {
+ test("disables mode changes while async conversion is pending", async () => {
const pendingConversion = deferred<[{ parsed: true }]>();
mocks.batchConvertCELStringToParsedExpr.mockImplementationOnce(
() => pendingConversion.promise
@@ -510,37 +509,25 @@ describe("GrantAccessDialog", () => {
const { container, unmount } = renderGrantAccessDialog();
await flush();
- const radioList = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
- );
+ const radioList = getRadios(container);
- expect(radioList[2]?.checked).toBe(true);
+ expect(isChecked(radioList[2])).toBe(true);
- act(() => {
- radioList[1]?.dispatchEvent(
- new MouseEvent("click", { bubbles: true, cancelable: true })
- );
- });
+ await click(radioList[1]!);
await flush();
- act(() => {
- radioList[0]?.dispatchEvent(
- new MouseEvent("click", { bubbles: true, cancelable: true })
- );
- });
- await flush();
+ const pendingRadioList = getRadios(container);
+ expect(isDisabled(pendingRadioList[0])).toBe(true);
+ expect(isDisabled(pendingRadioList[1])).toBe(true);
+ expect(isDisabled(pendingRadioList[2])).toBe(true);
pendingConversion.resolve([{ parsed: true }]);
await flush();
- const refreshedRadioList = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
- );
- expect(refreshedRadioList[0]?.checked).toBe(true);
- expect(refreshedRadioList[1]?.checked).toBe(false);
- expect(
- container.querySelector('[data-testid="expr-editor"]')
- ).not.toBeTruthy();
+ const refreshedRadioList = getRadios(container);
+ expect(isChecked(refreshedRadioList[1])).toBe(true);
+ expect(isChecked(refreshedRadioList[2])).toBe(false);
+ expect(container.querySelector('[data-testid="expr-editor"]')).toBeTruthy();
unmount();
});
@@ -614,10 +601,8 @@ describe("GrantAccessDialog — composite exemption precedence (BYT-9791)", () =
await flush();
// Default mode for a non-column-scoped selection is SELECT (radio index 2).
- const radios = Array.from(
- container.querySelectorAll<HTMLInputElement>('input[type="radio"]')
- );
- expect(radios[2]?.checked).toBe(true);
+ const radios = getRadios(container);
+ expect(isChecked(radios[2])).toBe(true);
await click(
container.querySelector<HTMLElement>('[data-testid="set-two-resources"]')!
diff --git a/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.tsx b/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.tsx
index e57c1616d1..c30152de98 100644
--- a/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.tsx
+++ b/frontend/src/react/pages/project/database-detail/catalog/GrantAccessDialog.tsx
@@ -26,6 +26,7 @@ import {
import { ExpirationPicker } from "@/react/components/ui/expiration-picker";
import { FeatureModal } from "@/react/components/ui/feature-modal";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { Tooltip } from "@/react/components/ui/tooltip";
import {
buildMaskingExemption,
@@ -416,30 +417,21 @@ export function GrantAccessDialog({
</div>
<div className="w-full mb-2">
- <div className="flex flex-col sm:flex-row justify-start sm:items-center gap-2 sm:gap-4">
+ <RadioGroup
+ className="flex-col items-start gap-2 sm:flex-row sm:items-center sm:gap-4"
+ value={radioValue}
+ onValueChange={(value) => onRadioChange(value as RadioValue)}
+ >
<Tooltip content={t("issue.role-grant.all-databases-tip")}>
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="resource-mode"
- checked={radioValue === "ALL"}
- onChange={() => onRadioChange("ALL")}
- disabled={modeChangeProcessing}
- className="accent-accent"
- />
- <span>{t("issue.role-grant.all-databases")}</span>
- </label>
+ <RadioGroupItem value="ALL" disabled={modeChangeProcessing}>
+ {t("issue.role-grant.all-databases")}
+ </RadioGroupItem>
</Tooltip>
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="resource-mode"
- checked={radioValue === "EXPRESSION"}
- onChange={() => onRadioChange("EXPRESSION")}
- disabled={modeChangeProcessing}
- className="accent-accent"
- />
+ <RadioGroupItem
+ value="EXPRESSION"
+ disabled={modeChangeProcessing}
+ >
<div className="flex items-center gap-x-1">
<FeatureBadge
feature={PlanFeature.FEATURE_DATA_MASKING}
@@ -447,17 +439,12 @@ export function GrantAccessDialog({
/>
<span>{t("issue.role-grant.use-cel")}</span>
</div>
- </label>
-
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="resource-mode"
- checked={radioValue === "SELECT"}
- onChange={() => onRadioChange("SELECT")}
- disabled={modeChangeProcessing}
- className="accent-accent"
- />
+ </RadioGroupItem>
+
+ <RadioGroupItem
+ value="SELECT"
+ disabled={modeChangeProcessing}
+ >
<div className="flex items-center gap-x-1">
<FeatureBadge
feature={PlanFeature.FEATURE_DATA_MASKING}
@@ -465,8 +452,8 @@ export function GrantAccessDialog({
/>
<span>{t("issue.role-grant.manually-select")}</span>
</div>
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
{radioValue === "SELECT" && (
diff --git a/frontend/src/react/pages/project/database-detail/revision/ImportRevisionSheet.tsx b/frontend/src/react/pages/project/database-detail/revision/ImportRevisionSheet.tsx
index d1970078f9..06b22953a5 100644
--- a/frontend/src/react/pages/project/database-detail/revision/ImportRevisionSheet.tsx
+++ b/frontend/src/react/pages/project/database-detail/revision/ImportRevisionSheet.tsx
@@ -14,6 +14,7 @@ import { revisionServiceClientConnect } from "@/connect";
import { ReleaseFileTable } from "@/react/components/release/ReleaseFileTable";
import { Button } from "@/react/components/ui/button";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
SheetBody,
@@ -626,7 +627,14 @@ function ReleaseSelector({
<div className="text-sm text-control-light">
{t("database.revision.select-release-description")}
</div>
- <div className="overflow-x-auto rounded-sm border border-control-border">
+ <RadioGroup
+ value={selectedRelease?.name ?? ""}
+ onValueChange={(value) => {
+ const release = releases.find((release) => release.name === value);
+ onSelectedReleaseChange(release ?? null);
+ }}
+ className="block overflow-x-auto rounded-sm border border-control-border"
+ >
<table className="w-full text-sm">
<thead>
<tr className="border-b border-control-border bg-control-bg text-left">
@@ -643,11 +651,9 @@ function ReleaseSelector({
onClick={() => onSelectedReleaseChange(release)}
>
<td className="px-4 py-2">
- <input
- type="radio"
- checked={selectedRelease?.name === release.name}
- onChange={() => onSelectedReleaseChange(release)}
- className="border-control-border"
+ <RadioGroupItem
+ value={release.name}
+ aria-label={release.name.split("/").pop()}
/>
</td>
<td className="px-4 py-2">{release.name.split("/").pop()}</td>
@@ -656,7 +662,7 @@ function ReleaseSelector({
))}
</tbody>
</table>
- </div>
+ </RadioGroup>
</div>
);
}
diff --git a/frontend/src/react/pages/project/issue-detail/components/IssueDetailActionBar.tsx b/frontend/src/react/pages/project/issue-detail/components/IssueDetailActionBar.tsx
index 2beb0776b4..51ad8d4a8f 100644
--- a/frontend/src/react/pages/project/issue-detail/components/IssueDetailActionBar.tsx
+++ b/frontend/src/react/pages/project/issue-detail/components/IssueDetailActionBar.tsx
@@ -32,7 +32,14 @@ import {
DialogContent,
DialogTitle,
} from "@/react/components/ui/dialog";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from "@/react/components/ui/dropdown-menu";
import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
SheetBody,
@@ -106,15 +113,11 @@ export function IssueDetailActionBar() {
"ROLLOUT_START" | "ROLLOUT_CANCEL" | undefined
>();
const [isSubmitting, setIsSubmitting] = useState(false);
- const menuRef = useRef<HTMLDivElement>(null);
- const [menuOpen, setMenuOpen] = useState(false);
const projectName = `${projectNamePrefix}${page.projectId}`;
const project = useProjectByName(projectName);
void projectsByName;
const { isSpecEmpty } = useIssueDetailSpecValidation(page.plan?.specs ?? []);
- useClickOutside(menuRef, menuOpen, () => setMenuOpen(false));
-
const context = useMemo<ActionContext | undefined>(() => {
if (!page.plan || !project || !currentUser) {
return undefined;
@@ -489,65 +492,45 @@ export function IssueDetailActionBar() {
))}
{secondaryActions.length > 0 && (
- <div className="relative" ref={menuRef}>
+ <DropdownMenu>
<Tooltip
content={
primaryAction ? getDisabledReason(primaryAction) : undefined
}
>
- <span className="inline-flex">
- <Button
- aria-label={t("common.more")}
- className="px-1"
- disabled={Boolean(
- primaryAction && isActionDisabled(primaryAction)
- )}
- onClick={() => setMenuOpen((open) => !open)}
- variant="ghost"
- >
- <EllipsisVertical className="h-4 w-4" />
- </Button>
- </span>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ aria-label={t("common.more")}
+ className="px-1"
+ disabled={Boolean(
+ primaryAction && isActionDisabled(primaryAction)
+ )}
+ variant="ghost"
+ >
+ <EllipsisVertical className="h-4 w-4" />
+ </Button>
+ }
+ />
</Tooltip>
- {menuOpen && (
- <div
- className={cn(
- "absolute right-0 top-full mt-1 min-w-44 overflow-hidden rounded-sm border border-control-border bg-white py-1 shadow-lg",
- LAYER_SURFACE_CLASS
- )}
- >
- {secondaryActions.map((action) => {
- const disabled = isActionDisabled(action) || isSubmitting;
- return (
- <Tooltip
- key={action.id}
- content={disabled ? getDisabledReason(action) : undefined}
- side="left"
- >
- <span className="block">
- <button
- className={cn(
- "flex w-full items-center px-3 py-2 text-left text-sm",
- disabled
- ? "cursor-not-allowed text-control-placeholder"
- : "hover:bg-control-bg"
- )}
- disabled={disabled}
- onClick={() => {
- setMenuOpen(false);
- void executeAction(action.id);
- }}
- type="button"
- >
- {action.label(context)}
- </button>
- </span>
- </Tooltip>
- );
- })}
- </div>
- )}
- </div>
+ <DropdownMenuContent className="min-w-44">
+ {secondaryActions.map((action) => {
+ const disabled = isActionDisabled(action) || isSubmitting;
+ return (
+ <DropdownMenuItem
+ key={action.id}
+ disabled={disabled}
+ title={disabled ? getDisabledReason(action) : undefined}
+ onClick={() => {
+ void executeAction(action.id);
+ }}
+ >
+ {action.label(context)}
+ </DropdownMenuItem>
+ );
+ })}
+ </DropdownMenuContent>
+ </DropdownMenu>
)}
</div>
@@ -724,6 +707,8 @@ function IssueDetailConfirmDialog({
);
}
+type IssueReviewAction = "COMMENT" | "APPROVE" | "REJECT";
+
function IssueDetailReviewPopover({
context,
mobile,
@@ -744,9 +729,8 @@ function IssueDetailReviewPopover({
const popoverRef = useRef<HTMLDivElement>(null);
const [loading, setLoading] = useState(false);
const [comment, setComment] = useState("");
- const [selectedAction, setSelectedAction] = useState<
- "COMMENT" | "APPROVE" | "REJECT"
- >("COMMENT");
+ const [selectedAction, setSelectedAction] =
+ useState<IssueReviewAction>("COMMENT");
const issue = page.issue;
const submitDisabled =
loading || (selectedAction === "COMMENT" && comment.trim().length === 0);
@@ -851,21 +835,25 @@ function IssueDetailReviewPopover({
}}
/>
- <div className="flex flex-col gap-y-2.5">
+ <RadioGroup
+ className="flex-col items-stretch gap-y-2.5"
+ value={selectedAction}
+ onValueChange={(value) => setSelectedAction(value as IssueReviewAction)}
+ >
<IssueDetailReviewOption
description={t("issue.review.comment-description")}
icon={<MessageCircle className="size-4 text-control" />}
label={t("common.comment")}
- onSelect={() => setSelectedAction("COMMENT")}
selected={selectedAction === "COMMENT"}
+ value="COMMENT"
/>
{context.permissions.isApprovalCandidate && (
<IssueDetailReviewOption
description={t("issue.review.approve-description")}
icon={<Check className="size-4 text-success" />}
label={t("common.approve")}
- onSelect={() => setSelectedAction("APPROVE")}
selected={selectedAction === "APPROVE"}
+ value="APPROVE"
/>
)}
{context.permissions.isApprovalCandidate && (
@@ -873,11 +861,11 @@ function IssueDetailReviewPopover({
description={t("issue.review.reject-description")}
icon={<X className="size-4 text-error" />}
label={t("common.reject")}
- onSelect={() => setSelectedAction("REJECT")}
selected={selectedAction === "REJECT"}
+ value="REJECT"
/>
)}
- </div>
+ </RadioGroup>
<div className="flex items-center justify-start gap-x-2 pt-1">
<Button
@@ -930,28 +918,25 @@ function IssueDetailReviewOption({
description,
icon,
label,
- onSelect,
selected,
+ value,
}: {
description?: string;
icon?: ReactNode;
label: string;
- onSelect: () => void;
selected: boolean;
+ value: IssueReviewAction;
}) {
return (
- <label
+ <RadioGroupItem
+ value={value}
+ radioClassName="mt-1"
className={cn(
- "flex cursor-pointer items-start gap-3 text-left transition-colors",
+ "items-start gap-3 text-left transition-colors",
selected ? "text-main" : "text-control"
)}
+ contentClassName="flex items-start gap-3"
>
- <input
- checked={selected}
- className="mt-1 h-4 w-4 accent-accent"
- onChange={onSelect}
- type="radio"
- />
{icon && <span className="mt-1 shrink-0">{icon}</span>}
<span className="flex flex-col">
<span className="text-sm font-medium leading-6">{label}</span>
@@ -959,7 +944,7 @@ function IssueDetailReviewOption({
<span className="text-xs text-control-light">{description}</span>
)}
</span>
- </label>
+ </RadioGroupItem>
);
}
diff --git a/frontend/src/react/pages/project/issue-detail/components/IssueDetailDatabaseExportView.tsx b/frontend/src/react/pages/project/issue-detail/components/IssueDetailDatabaseExportView.tsx
index 85e2c02cf6..340f9389da 100644
--- a/frontend/src/react/pages/project/issue-detail/components/IssueDetailDatabaseExportView.tsx
+++ b/frontend/src/react/pages/project/issue-detail/components/IssueDetailDatabaseExportView.tsx
@@ -18,6 +18,7 @@ import {
DropdownMenuTrigger,
} from "@/react/components/ui/dropdown-menu";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { Switch } from "@/react/components/ui/switch";
import { Tooltip } from "@/react/components/ui/tooltip";
import { cn } from "@/react/lib/utils";
@@ -307,23 +308,17 @@ function IssueDetailDatabaseExportOptions() {
<div className="flex items-center gap-4">
<span className="text-sm">{t("issue.data-export.format")}</span>
{optionsEditable ? (
- <div className="flex flex-wrap items-center gap-4">
+ <RadioGroup
+ className="flex-wrap gap-4"
+ value={String(editableConfig.format)}
+ onValueChange={(value) => handleFormatChange(String(value))}
+ >
{EXPORT_FORMATS.map((item) => (
- <label
- key={item.value}
- className="inline-flex cursor-pointer items-center gap-2 text-sm"
- >
- <input
- checked={editableConfig.format === item.value}
- className="h-4 w-4"
- name="export-format"
- onChange={() => handleFormatChange(String(item.value))}
- type="radio"
- />
- <span>{item.label}</span>
- </label>
+ <RadioGroupItem key={item.value} value={String(item.value)}>
+ {item.label}
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
) : (
<span className="text-sm font-medium leading-6">
{selectedFormatLabel}
diff --git a/frontend/src/react/pages/project/plan-detail/components/PlanDetailChangesBranch.tsx b/frontend/src/react/pages/project/plan-detail/components/PlanDetailChangesBranch.tsx
index bda2071cb5..41437437f3 100644
--- a/frontend/src/react/pages/project/plan-detail/components/PlanDetailChangesBranch.tsx
+++ b/frontend/src/react/pages/project/plan-detail/components/PlanDetailChangesBranch.tsx
@@ -43,6 +43,7 @@ import {
PopoverContent,
PopoverTrigger,
} from "@/react/components/ui/popover";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { SearchInput } from "@/react/components/ui/search-input";
import {
Select,
@@ -1876,48 +1877,49 @@ function DatabaseGroupSelector({
}
return (
- <table className="w-full text-sm">
- <thead>
- <tr className="border-b text-left text-control-light">
- <th className="w-8 py-2 pr-2" />
- <th className="py-2 pr-4 font-medium">
- {t("common.database-group")}
- </th>
- </tr>
- </thead>
- <tbody>
- {groups.map((group) => {
- const isSelected = selectedGroup === group.name;
- return (
- <tr
- key={group.name}
- className={cn(
- "cursor-pointer border-b hover:bg-control-bg",
- isSelected && "bg-accent/5"
- )}
- onClick={() =>
- onSelectedGroupChange(isSelected ? undefined : group.name)
- }
- >
- <td className="py-2 pr-2">
- <input
- type="radio"
- checked={isSelected}
- readOnly
- className="accent-accent"
- />
- </td>
- <td className="py-2 pr-4">
- <div className="flex items-center gap-x-1.5">
- <FolderTree className="size-4 shrink-0 text-control-light" />
- <span>{group.title}</span>
- </div>
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
+ <RadioGroup
+ value={selectedGroup ?? ""}
+ onValueChange={(value) => onSelectedGroupChange(String(value))}
+ className="block"
+ >
+ <table className="w-full text-sm">
+ <thead>
+ <tr className="border-b text-left text-control-light">
+ <th className="w-8 py-2 pr-2" />
+ <th className="py-2 pr-4 font-medium">
+ {t("common.database-group")}
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ {groups.map((group) => {
+ const isSelected = selectedGroup === group.name;
+ return (
+ <tr
+ key={group.name}
+ className={cn(
+ "cursor-pointer border-b hover:bg-control-bg",
+ isSelected && "bg-accent/5"
+ )}
+ onClick={() =>
+ onSelectedGroupChange(isSelected ? undefined : group.name)
+ }
+ >
+ <td className="py-2 pr-2">
+ <RadioGroupItem value={group.name} aria-label={group.title} />
+ </td>
+ <td className="py-2 pr-4">
+ <div className="flex items-center gap-x-1.5">
+ <FolderTree className="size-4 shrink-0 text-control-light" />
+ <span>{group.title}</span>
+ </div>
+ </td>
+ </tr>
+ );
+ })}
+ </tbody>
+ </table>
+ </RadioGroup>
);
}
diff --git a/frontend/src/react/pages/project/plan-detail/components/review/ReviewActionPopover.tsx b/frontend/src/react/pages/project/plan-detail/components/review/ReviewActionPopover.tsx
index 380c084a27..f52bc7f9f7 100644
--- a/frontend/src/react/pages/project/plan-detail/components/review/ReviewActionPopover.tsx
+++ b/frontend/src/react/pages/project/plan-detail/components/review/ReviewActionPopover.tsx
@@ -10,6 +10,7 @@ import {
} from "@/react/components/issue-activity/activityIcons";
import { MarkdownEditor } from "@/react/components/MarkdownEditor";
import { Button } from "@/react/components/ui/button";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { Tooltip } from "@/react/components/ui/tooltip";
import { cn } from "@/react/lib/utils";
import { useAppStore } from "@/react/stores/app";
@@ -88,29 +89,33 @@ export function ReviewActionPopover({
onChange={setComment}
onSubmit={() => void submit()}
/>
- <div className="flex flex-col gap-y-2.5">
+ <RadioGroup
+ className="flex-col items-stretch gap-y-2.5"
+ value={action}
+ onValueChange={(value) => setAction(value as ReviewAction)}
+ >
<ReviewOption
description={t("issue.review.comment-description")}
icon={<MessageCircle className="size-4 text-control" />}
label={t("common.comment")}
- onSelect={() => setAction("COMMENT")}
selected={action === "COMMENT"}
+ value="COMMENT"
/>
<ReviewOption
description={t("issue.review.approve-description")}
icon={<DecisionIcon spec={REVIEW_DECISION_ICON.approved} />}
label={t("common.approve")}
- onSelect={() => setAction("APPROVE")}
selected={action === "APPROVE"}
+ value="APPROVE"
/>
<ReviewOption
description={t("issue.review.reject-description")}
icon={<DecisionIcon spec={REVIEW_DECISION_ICON.rejected} />}
label={t("common.reject")}
- onSelect={() => setAction("REJECT")}
selected={action === "REJECT"}
+ value="REJECT"
/>
- </div>
+ </RadioGroup>
<div className="flex items-center justify-start gap-x-2 pt-1">
<Tooltip
content={
@@ -149,28 +154,25 @@ function ReviewOption({
description,
icon,
label,
- onSelect,
selected,
+ value,
}: {
description?: string;
icon?: ReactNode;
label: string;
- onSelect: () => void;
selected: boolean;
+ value: ReviewAction;
}) {
return (
- <label
+ <RadioGroupItem
+ value={value}
+ radioClassName="mt-1"
className={cn(
- "flex cursor-pointer items-start gap-3 text-left transition-colors",
+ "items-start gap-3 text-left transition-colors",
selected ? "text-main" : "text-control"
)}
+ contentClassName="flex items-start gap-3"
>
- <input
- checked={selected}
- className="mt-1 size-4 accent-accent"
- onChange={onSelect}
- type="radio"
- />
{icon && <span className="mt-1 shrink-0">{icon}</span>}
<span className="flex flex-col">
<span className="text-sm font-medium leading-6">{label}</span>
@@ -178,6 +180,6 @@ function ReviewOption({
<span className="text-xs text-control-light">{description}</span>
)}
</span>
- </label>
+ </RadioGroupItem>
);
}
diff --git a/frontend/src/react/pages/settings/CreateInstancePage.test.tsx b/frontend/src/react/pages/settings/CreateInstancePage.test.tsx
index e2b85fe530..4d3a117157 100644
--- a/frontend/src/react/pages/settings/CreateInstancePage.test.tsx
+++ b/frontend/src/react/pages/settings/CreateInstancePage.test.tsx
@@ -94,8 +94,8 @@ describe("CreateInstancePage", () => {
const buttons = container.querySelector(
"[data-testid='instance-form-buttons']"
);
- expect(buttons).toHaveClass("px-4");
- expect(buttons).toHaveClass("sm:px-6");
+ expect(buttons).not.toHaveClass("px-4");
+ expect(buttons).not.toHaveClass("sm:px-6");
act(() => {
root.unmount();
diff --git a/frontend/src/react/pages/settings/CreateInstancePage.tsx b/frontend/src/react/pages/settings/CreateInstancePage.tsx
index 40f8c6af63..73284eb687 100644
--- a/frontend/src/react/pages/settings/CreateInstancePage.tsx
+++ b/frontend/src/react/pages/settings/CreateInstancePage.tsx
@@ -136,10 +136,7 @@ function CreateInstanceFormInner() {
</div>
</div>
- {/* Sticky footer */}
- <div className="sticky bottom-0 z-10 bg-background">
- <InstanceFormButtons className="px-4 sm:px-6" />
- </div>
+ <InstanceFormButtons />
<UnsavedChangesGuard />
</div>
diff --git a/frontend/src/react/pages/settings/EnvironmentsPage.tsx b/frontend/src/react/pages/settings/EnvironmentsPage.tsx
index 5f228f7d1e..7b2e1db3e0 100644
--- a/frontend/src/react/pages/settings/EnvironmentsPage.tsx
+++ b/frontend/src/react/pages/settings/EnvironmentsPage.tsx
@@ -40,8 +40,20 @@ import {
DialogContent,
DialogTitle,
} from "@/react/components/ui/dialog";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "@/react/components/ui/dropdown-menu";
+import {
+ FormDescription,
+ FormField,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
-import { LAYER_SURFACE_CLASS } from "@/react/components/ui/layer";
import {
Sheet,
SheetBody,
@@ -50,6 +62,7 @@ import {
SheetHeader,
SheetTitle,
} from "@/react/components/ui/sheet";
+import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
import {
Tabs,
TabsList,
@@ -295,23 +308,6 @@ function RolloutPolicyConfig({
t,
]);
- const [showRoleDropdown, setShowRoleDropdown] = useState(false);
- const dropdownRef = useRef<HTMLDivElement>(null);
-
- useEffect(() => {
- if (!showRoleDropdown) return;
- const handler = (e: MouseEvent) => {
- if (
- dropdownRef.current &&
- !dropdownRef.current.contains(e.target as Node)
- ) {
- setShowRoleDropdown(false);
- }
- };
- document.addEventListener("mousedown", handler);
- return () => document.removeEventListener("mousedown", handler);
- }, [showRoleDropdown]);
-
return (
<div className="flex flex-col items-start gap-y-2">
<PermissionGuard permissions={["bb.policies.update"]} display="block">
@@ -336,50 +332,41 @@ function RolloutPolicyConfig({
</span>
))}
{canUpdatePolicy && (
- <div className="relative" ref={dropdownRef}>
- <Button
- variant="outline"
- size="sm"
- onClick={() => setShowRoleDropdown(!showRoleDropdown)}
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button variant="outline" size="sm">
+ <Plus className="w-3.5 h-3.5 mr-1" />
+ {t("common.add")}
+ </Button>
+ }
+ />
+ <DropdownMenuContent
+ align="start"
+ className="w-64 max-h-60 overflow-auto"
>
- <Plus className="w-3.5 h-3.5 mr-1" />
- {t("common.add")}
- </Button>
- {showRoleDropdown && (
- <div
- className={cn(
- "absolute mt-1 w-64 max-h-60 overflow-auto rounded-sm border border-control-border bg-white py-1 shadow-md",
- LAYER_SURFACE_CLASS
- )}
- >
- {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>
- ))}
- {availableRoles.length === 0 && (
- <div className="px-3 py-2 text-sm text-gray-400">
- {t("common.no-data")}
- </div>
- )}
- </div>
- )}
- </div>
+ {availableRoles.map((group) => (
+ <div key={group.label}>
+ <DropdownMenuLabel className="uppercase">
+ {group.label}
+ </DropdownMenuLabel>
+ {group.roles.map((role) => (
+ <DropdownMenuItem
+ key={role.name}
+ onClick={() => addRole(role.name)}
+ >
+ {role.title}
+ </DropdownMenuItem>
+ ))}
+ </div>
+ ))}
+ {availableRoles.length === 0 && (
+ <div className="px-3 py-2 text-sm text-control-placeholder">
+ {t("common.no-data")}
+ </div>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
)}
</div>
@@ -437,22 +424,6 @@ function SQLReviewSectionInner(
const [pendingPolicy, setPendingPolicy] = useState(currentPolicy);
const [enforce, setEnforce] = useState(currentPolicy?.enforce ?? false);
- const [showSelectPanel, setShowSelectPanel] = useState(false);
- const selectPanelRef = useRef<HTMLDivElement>(null);
-
- useEffect(() => {
- if (!showSelectPanel) return;
- const handler = (e: MouseEvent) => {
- if (
- selectPanelRef.current &&
- !selectPanelRef.current.contains(e.target as Node)
- ) {
- setShowSelectPanel(false);
- }
- };
- document.addEventListener("mousedown", handler);
- return () => document.removeEventListener("mousedown", handler);
- }, [showSelectPanel]);
useEffect(() => {
setPendingPolicy(currentPolicy);
@@ -558,62 +529,52 @@ function SQLReviewSectionInner(
</div>
</div>
) : (
- <div className="relative" ref={selectPanelRef}>
- <Button
- variant="outline"
- disabled={!canUpdatePolicy}
- onClick={() => setShowSelectPanel(!showSelectPanel)}
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button variant="outline" disabled={!canUpdatePolicy}>
+ {t("sql-review.configure-policy")}
+ </Button>
+ }
+ />
+ <DropdownMenuContent
+ align="start"
+ className="w-80 max-h-60 overflow-auto"
>
- {t("sql-review.configure-policy")}
- </Button>
- {showSelectPanel && (
- <div
- className={cn(
- "absolute mt-1 w-80 max-h-60 overflow-auto rounded-sm border border-control-border bg-white py-1 shadow-md",
- LAYER_SURFACE_CLASS
- )}
+ {reviewPolicyList.length === 0 ? (
+ <div className="px-3 py-2 text-sm text-control-placeholder">
+ {t("common.no-data")}
+ </div>
+ ) : (
+ reviewPolicyList.map((review) => (
+ <DropdownMenuItem
+ key={review.id}
+ onClick={() => {
+ setPendingPolicy(review);
+ setEnforce(true);
+ }}
+ >
+ <span className="font-medium">{review.name}</span>
+ </DropdownMenuItem>
+ ))
+ )}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ className="text-accent"
+ onClick={() => {
+ router.push({
+ name: WORKSPACE_ROUTE_SQL_REVIEW_CREATE,
+ query: {
+ attachedResource: resourcePath,
+ },
+ });
+ }}
>
- {reviewPolicyList.length === 0 ? (
- <div className="px-3 py-2 text-sm text-gray-400">
- {t("common.no-data")}
- </div>
- ) : (
- reviewPolicyList.map((review) => (
- <button
- key={review.id}
- type="button"
- className="w-full text-left px-3 py-2 text-sm hover:bg-control-bg cursor-pointer"
- onClick={() => {
- setPendingPolicy(review);
- setEnforce(true);
- setShowSelectPanel(false);
- }}
- >
- <div className="font-medium">{review.name}</div>
- </button>
- ))
- )}
- <button
- type="button"
- className="w-full text-left px-3 py-2 text-sm text-accent hover:bg-control-bg cursor-pointer border-t border-control-border"
- onClick={() => {
- setShowSelectPanel(false);
- router.push({
- name: WORKSPACE_ROUTE_SQL_REVIEW_CREATE,
- query: {
- attachedResource: resourcePath,
- },
- });
- }}
- >
- <div className="flex items-center gap-x-1 font-medium">
- <Plus className="w-4 h-4" />
- {t("common.create")}
- </div>
- </button>
- </div>
- )}
- </div>
+ <Plus className="w-4 h-4" />
+ <span className="font-medium">{t("common.create")}</span>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
)}
</div>
</div>
@@ -829,7 +790,7 @@ function EnvironmentDetail({
<div className="flex-1 px-4">
<div className="flex flex-col gap-y-6">
{/* Name section */}
- <div className="flex flex-col gap-y-2">
+ <FormField>
<div className="flex items-center gap-x-2">
<input
type="color"
@@ -842,10 +803,10 @@ function EnvironmentDetail({
"cursor-pointer"
)}
/>
- <span className="font-medium">
+ <FormLabel>
{t("common.environment-name")}
<span className="ml-0.5 text-error">*</span>
- </span>
+ </FormLabel>
</div>
<Input
value={editTitle}
@@ -857,16 +818,16 @@ function EnvironmentDetail({
resourceName={t("common.environment")}
readonly
/>
- </div>
+ </FormField>
{/* Tier section */}
- <div className="flex flex-col gap-y-2">
+ <FormField>
<div className="gap-y-1">
- <label className="font-medium flex items-center gap-x-1">
+ <FormLabel>
{t("policy.environment-tier.name")}
<FeatureBadge feature={PlanFeature.FEATURE_ENVIRONMENT_TIERS} />
- </label>
- <p className="text-sm text-gray-600">
+ </FormLabel>
+ <FormDescription>
{t("policy.environment-tier.description", { newline: "\n" })}
<a
href="https://docs.bytebase.com/change-database/environment-policy/overview/?source=console#environment-tier"
@@ -876,7 +837,7 @@ function EnvironmentDetail({
>
{t("common.learn-more")}
</a>
- </p>
+ </FormDescription>
</div>
<label className="inline-flex items-center gap-x-2 cursor-pointer">
<Checkbox
@@ -893,23 +854,21 @@ function EnvironmentDetail({
feature={PlanFeature.FEATURE_ENVIRONMENT_TIERS}
/>
)}
- </div>
+ </FormField>
{/* Rollout policy section */}
{canGetPolicy && rolloutPolicy && (
- <div className="flex flex-col gap-y-2">
+ <FormField>
<div className="gap-y-1">
<div className="flex items-baseline gap-x-2">
- <label className="font-medium">
- {t("policy.rollout.name")}
- </label>
+ <FormLabel>{t("policy.rollout.name")}</FormLabel>
{policyChanged && (
<span className="textlabeltip">
{t("policy.rollout.tip")}
</span>
)}
</div>
- <div className="textinfolabel">
+ <FormDescription>
{t("policy.rollout.info", {
permission: "bb.taskRuns.create",
})}
@@ -921,13 +880,13 @@ function EnvironmentDetail({
>
{t("common.learn-more")}
</a>
- </div>
+ </FormDescription>
</div>
<RolloutPolicyConfig
policy={rolloutPolicy}
onChange={setRolloutPolicy}
/>
- </div>
+ </FormField>
)}
{/* SQL Review section */}
@@ -953,12 +912,15 @@ function EnvironmentDetail({
{/* Sticky bottom buttons */}
{canEdit && hasChanges && (
- <div className="sticky -bottom-2 bg-white py-4 px-4 border-t border-block-border flex items-center justify-end gap-x-4">
- <Button variant="outline" onClick={revert}>
- {t("common.cancel")}
- </Button>
- <Button onClick={save}>{t("common.update")}</Button>
- </div>
+ <StickyActionFooter
+ className="-bottom-2 bg-white"
+ left={
+ <Button variant="outline" onClick={revert}>
+ {t("common.cancel")}
+ </Button>
+ }
+ right={<Button onClick={save}>{t("common.update")}</Button>}
+ />
)}
{/* Delete confirmation dialog */}
@@ -1133,7 +1095,7 @@ function CreateSheet({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Name */}
- <div className="flex flex-col gap-y-2">
+ <FormField>
<div className="flex items-center gap-x-2">
<input
type="color"
@@ -1145,10 +1107,10 @@ function CreateSheet({
"cursor-pointer"
)}
/>
- <span className="font-medium">
+ <FormLabel>
{t("common.environment-name")}
<span className="ml-0.5 text-error">*</span>
- </span>
+ </FormLabel>
</div>
<Input
value={title}
@@ -1163,16 +1125,14 @@ function CreateSheet({
onChange={setResourceId}
onValidationChange={setResourceIdValid}
/>
- </div>
+ </FormField>
{/* Tier */}
- <div className="flex flex-col gap-y-2">
- <label className="font-medium">
- {t("policy.environment-tier.name")}
- </label>
- <p className="text-sm text-gray-600">
+ <FormField>
+ <FormLabel>{t("policy.environment-tier.name")}</FormLabel>
+ <FormDescription>
{t("policy.environment-tier.description", { newline: "\n" })}
- </p>
+ </FormDescription>
<label className="inline-flex items-center gap-x-2 cursor-pointer">
<Checkbox
checked={isProtected}
@@ -1187,25 +1147,23 @@ function CreateSheet({
feature={PlanFeature.FEATURE_ENVIRONMENT_TIERS}
/>
)}
- </div>
+ </FormField>
{/* Rollout Policy */}
- <div className="flex flex-col gap-y-2">
+ <FormField>
<div className="gap-y-1">
- <label className="font-medium">
- {t("policy.rollout.name")}
- </label>
- <div className="textinfolabel">
+ <FormLabel>{t("policy.rollout.name")}</FormLabel>
+ <FormDescription>
{t("policy.rollout.info", {
permission: "bb.taskRuns.create",
})}
- </div>
+ </FormDescription>
</div>
<RolloutPolicyConfig
policy={rolloutPolicy}
onChange={setRolloutPolicy}
/>
- </div>
+ </FormField>
</div>
</SheetBody>
diff --git a/frontend/src/react/pages/settings/GlobalMaskingPage.test.tsx b/frontend/src/react/pages/settings/GlobalMaskingPage.test.tsx
new file mode 100644
index 0000000000..ed90395463
--- /dev/null
+++ b/frontend/src/react/pages/settings/GlobalMaskingPage.test.tsx
@@ -0,0 +1,230 @@
+import type { InputHTMLAttributes, ReactNode } from "react";
+import { act, createElement } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+vi.mock("@/plugins/cel", () => ({
+ buildCELExpr: vi.fn(),
+ emptySimpleExpr: () => ({}),
+ resolveCELExpr: () => ({}),
+ validateSimpleExpr: () => true,
+ wrapAsGroup: (expr: unknown) => expr,
+}));
+
+vi.mock("@/react/components/ExprEditor", () => ({
+ ExprEditor: () => createElement("div", { "data-testid": "expr-editor" }),
+}));
+
+vi.mock("@/react/components/FeatureAttention", () => ({
+ FeatureAttention: () => null,
+}));
+
+vi.mock("@/react/components/ui/alert", () => ({
+ Alert: ({
+ children,
+ description,
+ }: {
+ children?: ReactNode;
+ description?: ReactNode;
+ }) => createElement("div", {}, description, children),
+}));
+
+vi.mock("@/react/components/ui/button", () => ({
+ Button: ({
+ children,
+ disabled,
+ onClick,
+ }: {
+ children?: ReactNode;
+ disabled?: boolean;
+ onClick?: () => void;
+ }) => createElement("button", { disabled, onClick }, children),
+}));
+
+vi.mock("@/react/components/ui/input", () => ({
+ Input: (props: InputHTMLAttributes<HTMLInputElement>) =>
+ createElement("input", props),
+}));
+
+vi.mock("@/react/components/ui/select", () => ({
+ Select: ({ children }: { children: ReactNode }) =>
+ createElement("div", {}, children),
+ SelectContent: ({ children }: { children: ReactNode }) =>
+ createElement("div", {}, children),
+ SelectItem: ({ children }: { children: ReactNode; value: string }) =>
+ createElement("div", {}, children),
+ SelectTrigger: ({
+ children,
+ className,
+ }: {
+ children?: ReactNode;
+ className?: string;
+ }) =>
+ createElement(
+ "button",
+ { className, "data-testid": "semantic-type-trigger", type: "button" },
+ children
+ ),
+ SelectValue: ({ children }: { children?: ReactNode }) =>
+ createElement("span", {}, typeof children === "function" ? null : children),
+}));
+
+vi.mock("@/react/lib/sensitive-data/components-utils", () => ({
+ factorOperatorOverrideMap: {},
+ getClassificationLevelOptions: () => [],
+}));
+
+vi.mock("@/react/stores/app", () => {
+ const state = {
+ environmentList: [],
+ getOrFetchPolicyByParentAndType: vi.fn(async () => ({
+ policy: {
+ case: "maskingRulePolicy",
+ value: {
+ rules: [
+ {
+ condition: { title: "Default masking" },
+ id: "rule-1",
+ semanticType: "DEFAULT",
+ },
+ ],
+ },
+ },
+ })),
+ getOrFetchSettingByName: vi.fn(async () => undefined),
+ getSettingByName: () => ({
+ value: {
+ value: {
+ case: "semanticType",
+ value: {
+ types: [{ id: "DEFAULT", title: "Default" }],
+ },
+ },
+ },
+ }),
+ hasInstanceFeature: () => true,
+ settingsByName: {},
+ workspaceResourceName: () => "workspaces/default",
+ };
+ type StoreState = typeof state;
+ const useAppStore = (selector?: (store: StoreState) => unknown) =>
+ selector ? selector(state) : state;
+ useAppStore.getState = () => state;
+ return { useAppStore };
+});
+
+vi.mock("@/store", () => ({
+ pushNotification: vi.fn(),
+}));
+
+vi.mock("@/types/proto-es/google/type/expr_pb", () => ({
+ ExprSchema: {},
+}));
+
+vi.mock("@/types/proto-es/v1/org_policy_service_pb", () => ({
+ MaskingRulePolicy_MaskingRuleSchema: {},
+ MaskingRulePolicySchema: {},
+ PolicyResourceType: { WORKSPACE: 1 },
+ PolicyType: { MASKING_RULE: 1 },
+}));
+
+vi.mock("@/types/proto-es/v1/setting_service_pb", () => ({
+ Setting_SettingName: {
+ DATA_CLASSIFICATION: 2,
+ SEMANTIC_TYPES: 1,
+ },
+}));
+
+vi.mock("@/types/proto-es/v1/subscription_service_pb", () => ({
+ PlanFeature: { FEATURE_DATA_MASKING: 1 },
+}));
+
+vi.mock("@bufbuild/protobuf", () => ({
+ create: (_schema: unknown, init?: Record<string, unknown>) => ({ ...init }),
+}));
+
+vi.mock("lucide-react", () => ({
+ ChevronDown: () => createElement("span", {}),
+ ChevronUp: () => createElement("span", {}),
+ ListOrdered: () => createElement("span", {}),
+ Pencil: () => createElement("span", {}),
+ Plus: () => createElement("span", {}),
+ Trash2: () => createElement("span", {}),
+}));
+
+vi.mock("uuid", () => ({
+ v4: () => "new-rule",
+}));
+
+vi.mock("@/utils", () => {
+ return {
+ arraySwap: (items: unknown[], a: number, b: number) => {
+ [items[a], items[b]] = [items[b], items[a]];
+ },
+ batchConvertCELStringToParsedExpr: vi.fn(async () => []),
+ batchConvertParsedExprToCELString: vi.fn(async () => [""]),
+ getDatabaseIdOptionConfig: () => ({ options: [] }),
+ getInstanceIdOptionConfig: () => ({ options: [] }),
+ getProjectIdOptionConfig: () => ({ options: [] }),
+ hasWorkspacePermissionV2: () => true,
+ };
+});
+
+vi.mock("react-i18next", () => ({
+ initReactI18next: { type: "3rdParty", init: () => {} },
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+import { GlobalMaskingPage } from "./GlobalMaskingPage";
+
+let container: HTMLDivElement;
+let root: ReturnType<typeof createRoot>;
+
+beforeEach(() => {
+ vi.clearAllMocks();
+ container = document.createElement("div");
+ document.body.appendChild(container);
+ root = createRoot(container);
+});
+
+afterEach(() => {
+ act(() => {
+ root.unmount();
+ });
+ document.body.removeChild(container);
+});
+
+async function renderPage(): Promise<void> {
+ await act(async () => {
+ root.render(createElement(GlobalMaskingPage));
+ await Promise.resolve();
+ });
+}
+
+describe("GlobalMaskingPage", () => {
+ it("aligns the semantic type select with the expression editor", async () => {
+ await renderPage();
+
+ const semanticTypeHeading = Array.from(
+ container.querySelectorAll("h3")
+ ).find(
+ (heading) =>
+ heading.textContent ===
+ "settings.sensitive-data.semantic-types.table.semantic-type"
+ );
+
+ expect(semanticTypeHeading?.className).toContain("h-9");
+ expect(semanticTypeHeading?.className).toContain("items-center");
+ expect(semanticTypeHeading?.parentElement?.className).toContain("gap-y-2");
+ expect(
+ container.querySelector("[data-testid='expr-editor']")
+ ).not.toBeNull();
+ expect(
+ container.querySelector("[data-testid='semantic-type-trigger']")
+ ).not.toBeNull();
+ });
+});
diff --git a/frontend/src/react/pages/settings/GlobalMaskingPage.tsx b/frontend/src/react/pages/settings/GlobalMaskingPage.tsx
index cd7e8b535b..e93cd41e0a 100644
--- a/frontend/src/react/pages/settings/GlobalMaskingPage.tsx
+++ b/frontend/src/react/pages/settings/GlobalMaskingPage.tsx
@@ -233,8 +233,8 @@ function MaskingRuleConfig({
onUpdate={handleExprUpdate}
/>
</div>
- <div>
- <h3 className="font-medium text-sm text-main py-2">
+ <div className="flex flex-col gap-y-2">
+ <h3 className="flex items-center h-9 font-medium text-sm text-main">
{t("settings.sensitive-data.semantic-types.table.semantic-type")}
</h3>
<Select
diff --git a/frontend/src/react/pages/settings/GroupsPage.test.tsx b/frontend/src/react/pages/settings/GroupsPage.test.tsx
index b0c9ae71cf..2a750b3eb3 100644
--- a/frontend/src/react/pages/settings/GroupsPage.test.tsx
+++ b/frontend/src/react/pages/settings/GroupsPage.test.tsx
@@ -313,6 +313,33 @@ async function renderPage(): Promise<void> {
}
describe("GroupsPage create group sheet", () => {
+ it("renders the title-required error under the title field", async () => {
+ await renderPage();
+
+ const createButton = [...container.querySelectorAll("button")].find(
+ (button) => button.textContent === "common.create"
+ ) as HTMLButtonElement;
+ await act(async () => {
+ createButton.click();
+ });
+
+ const sheet = container.querySelector(
+ "[data-testid='sheet']"
+ ) as HTMLDivElement;
+ const titleInput = sheet.querySelector(
+ "input[maxlength='200']"
+ ) as HTMLInputElement;
+ const titleField = titleInput.closest('[data-slot="form-field"]');
+ const titleMessage = titleField?.querySelector(
+ '[data-slot="form-message"]'
+ );
+
+ expect(titleMessage?.getAttribute("role")).toBe("alert");
+ expect(titleMessage?.textContent).toBe(
+ "settings.members.groups.form.title common.is-required"
+ );
+ });
+
it("asks for explicit confirmation before closing with unsaved changes", async () => {
await renderPage();
diff --git a/frontend/src/react/pages/settings/GroupsPage.tsx b/frontend/src/react/pages/settings/GroupsPage.tsx
index 7bbbbd190e..655e80ac99 100644
--- a/frontend/src/react/pages/settings/GroupsPage.tsx
+++ b/frontend/src/react/pages/settings/GroupsPage.tsx
@@ -25,6 +25,15 @@ import {
} from "@/react/components/ui/alert-dialog";
import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
+import {
+ FormControlAffix,
+ FormDescription,
+ FormField,
+ FormFieldGroup,
+ FormInlineAffix,
+ FormLabel,
+ FormMessage,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { SearchInput } from "@/react/components/ui/search-input";
import {
@@ -42,6 +51,7 @@ import {
SheetHeader,
SheetTitle,
} from "@/react/components/ui/sheet";
+import { listRowStateClassName } from "@/react/components/ui/styles.stylex";
import {
Table,
TableBody,
@@ -317,7 +327,8 @@ function GroupRow({
className={cn(
stripeBg,
canOpen &&
- "cursor-pointer hover:bg-control-bg focus-visible:outline-none focus-visible:bg-control-bg"
+ "cursor-pointer focus-visible:outline-none focus-visible:bg-control-bg",
+ canOpen && listRowStateClassName
)}
tabIndex={canOpen ? 0 : undefined}
role={canOpen ? "button" : undefined}
@@ -689,13 +700,21 @@ function GroupForm({
return email;
}, [email, isEditMode, domainOptions, selectedDomain]);
- const errorMessage = useMemo(() => {
+ const titleErrorMessage = useMemo(() => {
if (!title.trim())
return (
t("settings.members.groups.form.title") + " " + t("common.is-required")
);
+ return "";
+ }, [title, t]);
+
+ const emailErrorMessage = useMemo(() => {
if (!fullEmail || !isValidEmail(fullEmail))
return t("settings.members.groups.form.email-tips");
+ return "";
+ }, [fullEmail, t]);
+
+ const memberErrorMessage = useMemo(() => {
// Validate member identifiers — extract email part and check format
for (const m of members) {
const raw = m.member.trim();
@@ -706,7 +725,10 @@ function GroupForm({
}
}
return "";
- }, [title, fullEmail, members, t]);
+ }, [members]);
+
+ const errorMessage =
+ titleErrorMessage || emailErrorMessage || memberErrorMessage;
const hasChanged = useMemo(() => {
if (!isEditMode) return true;
@@ -885,7 +907,7 @@ function GroupForm({
</SheetHeader>
<SheetBody>
- <div className="flex flex-col gap-y-6">
+ <FormFieldGroup>
{isExternalGroup && (
<Alert
variant="info"
@@ -894,27 +916,26 @@ function GroupForm({
)}
{/* Email */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.groups.form.email")}
<span className="ml-0.5 text-error">*</span>
- </label>
- <span className="textinfolabel text-sm">
+ </FormLabel>
+ <FormDescription>
{t("settings.members.groups.form.email-tips")}
- </span>
- <div className="flex items-center gap-x-1">
+ </FormDescription>
+ <FormInlineAffix>
<Input
value={isEditMode ? email : email.split("@")[0]}
+ className="min-w-0 flex-1"
onChange={(e) => setEmail(e.target.value)}
disabled={isEditMode || !allowEdit}
/>
{!isEditMode && domainOptions.length > 0 && (
<>
- <span className="text-sm text-control-light">@</span>
+ <FormControlAffix>@</FormControlAffix>
{domainOptions.length === 1 ? (
- <span className="text-sm text-control-light whitespace-nowrap">
- {domainOptions[0]}
- </span>
+ <FormControlAffix>{domainOptions[0]}</FormControlAffix>
) : (
<select
value={selectedDomain}
@@ -931,41 +952,45 @@ function GroupForm({
)}
</>
)}
- </div>
- </div>
+ </FormInlineAffix>
+ {emailErrorMessage && errorMessage === emailErrorMessage && (
+ <FormMessage>{emailErrorMessage}</FormMessage>
+ )}
+ </FormField>
{/* Title */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.groups.form.title")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
<Input
value={title}
onChange={(e) => setTitle(e.target.value)}
maxLength={200}
disabled={!allowEdit}
/>
- </div>
+ {titleErrorMessage && errorMessage === titleErrorMessage && (
+ <FormMessage>{titleErrorMessage}</FormMessage>
+ )}
+ </FormField>
{/* Description */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.groups.form.description")}
- </label>
+ </FormLabel>
<Input
value={description}
onChange={(e) => setDescription(e.target.value)}
maxLength={1000}
disabled={!allowEdit}
/>
- </div>
+ </FormField>
{/* Members */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("common.members", { count: 2 })}
- </label>
+ <FormField>
+ <FormLabel>{t("common.members", { count: 2 })}</FormLabel>
<div className="flex flex-col gap-y-2">
{members.map((member, index) => (
<div key={index} className="flex items-center gap-x-2">
@@ -1025,10 +1050,11 @@ function GroupForm({
</Button>
)}
</div>
- </div>
-
- {errorMessage && <p className="text-error text-sm">{errorMessage}</p>}
- </div>
+ {memberErrorMessage && errorMessage === memberErrorMessage && (
+ <FormMessage>{memberErrorMessage}</FormMessage>
+ )}
+ </FormField>
+ </FormFieldGroup>
</SheetBody>
<SheetFooter className="justify-between">
diff --git a/frontend/src/react/pages/settings/IDPDetailPage.tsx b/frontend/src/react/pages/settings/IDPDetailPage.tsx
index ee8a4d2c7f..5f66fc162c 100644
--- a/frontend/src/react/pages/settings/IDPDetailPage.tsx
+++ b/frontend/src/react/pages/settings/IDPDetailPage.tsx
@@ -22,6 +22,7 @@ import {
DialogTitle,
} from "@/react/components/ui/dialog";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { router, useCurrentRoute } from "@/react/router";
import { WORKSPACE_ROUTE_IDENTITY_PROVIDERS } from "@/react/router/handles";
import { useAppStore } from "@/react/stores/app";
@@ -490,22 +491,21 @@ function ProviderConfigForm({
{t("settings.sso.form.authentication-style")}{" "}
<span className="text-error">*</span>
</label>
- <div className="flex flex-col gap-y-3">
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="oauth2-auth-style"
- checked={
- configForOAuth2.authStyle === OAuth2AuthStyle.IN_PARAMS
- }
- onChange={() =>
- onUpdateOAuth2({
- ...configForOAuth2,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- })
- }
- className="mt-1"
- />
+ <RadioGroup
+ className="flex-col items-stretch gap-y-3"
+ value={String(configForOAuth2.authStyle)}
+ onValueChange={(value) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ authStyle: Number(value) as OAuth2AuthStyle,
+ })
+ }
+ >
+ <RadioGroupItem
+ value={String(OAuth2AuthStyle.IN_PARAMS)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.in-parameters")}
@@ -514,22 +514,12 @@ function ProviderConfigForm({
{t("settings.sso.form.in-parameters-description")}
</div>
</div>
- </label>
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="oauth2-auth-style"
- checked={
- configForOAuth2.authStyle === OAuth2AuthStyle.IN_HEADER
- }
- onChange={() =>
- onUpdateOAuth2({
- ...configForOAuth2,
- authStyle: OAuth2AuthStyle.IN_HEADER,
- })
- }
- className="mt-1"
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(OAuth2AuthStyle.IN_HEADER)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.in-header")}
@@ -538,8 +528,8 @@ function ProviderConfigForm({
{t("settings.sso.form.in-header-description")}
</div>
</div>
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
<div>
@@ -641,20 +631,21 @@ function ProviderConfigForm({
{t("settings.sso.form.authentication-style")}{" "}
<span className="text-error">*</span>
</label>
- <div className="flex flex-col gap-y-3">
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="oidc-auth-style"
- checked={configForOIDC.authStyle === OAuth2AuthStyle.IN_PARAMS}
- onChange={() =>
- onUpdateOIDC({
- ...configForOIDC,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- })
- }
- className="mt-1"
- />
+ <RadioGroup
+ className="flex-col items-stretch gap-y-3"
+ value={String(configForOIDC.authStyle)}
+ onValueChange={(value) =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ authStyle: Number(value) as OAuth2AuthStyle,
+ })
+ }
+ >
+ <RadioGroupItem
+ value={String(OAuth2AuthStyle.IN_PARAMS)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.in-parameters")}
@@ -663,20 +654,12 @@ function ProviderConfigForm({
{t("settings.sso.form.in-parameters-description")}
</div>
</div>
- </label>
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="oidc-auth-style"
- checked={configForOIDC.authStyle === OAuth2AuthStyle.IN_HEADER}
- onChange={() =>
- onUpdateOIDC({
- ...configForOIDC,
- authStyle: OAuth2AuthStyle.IN_HEADER,
- })
- }
- className="mt-1"
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(OAuth2AuthStyle.IN_HEADER)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.in-header")}
@@ -685,8 +668,8 @@ function ProviderConfigForm({
{t("settings.sso.form.in-header-description")}
</div>
</div>
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
<div>
@@ -827,24 +810,25 @@ function ProviderConfigForm({
{t("settings.sso.form.security-protocol")}{" "}
<span className="text-error">*</span>
</label>
- <div className="flex flex-col gap-y-3">
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="ldap-security"
- checked={
- configForLDAP.securityProtocol ===
- LDAPIdentityProviderConfig_SecurityProtocol.START_TLS
- }
- onChange={() =>
- onUpdateLDAP({
- ...configForLDAP,
- securityProtocol:
- LDAPIdentityProviderConfig_SecurityProtocol.START_TLS,
- })
- }
- className="mt-1"
- />
+ <RadioGroup
+ className="flex-col items-stretch gap-y-3"
+ value={String(configForLDAP.securityProtocol)}
+ onValueChange={(value) =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ securityProtocol: Number(
+ value
+ ) as LDAPIdentityProviderConfig_SecurityProtocol,
+ })
+ }
+ >
+ <RadioGroupItem
+ value={String(
+ LDAPIdentityProviderConfig_SecurityProtocol.START_TLS
+ )}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.starttls")}
@@ -853,24 +837,12 @@ function ProviderConfigForm({
{t("settings.sso.form.starttls-description")}
</div>
</div>
- </label>
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="ldap-security"
- checked={
- configForLDAP.securityProtocol ===
- LDAPIdentityProviderConfig_SecurityProtocol.LDAPS
- }
- onChange={() =>
- onUpdateLDAP({
- ...configForLDAP,
- securityProtocol:
- LDAPIdentityProviderConfig_SecurityProtocol.LDAPS,
- })
- }
- className="mt-1"
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(LDAPIdentityProviderConfig_SecurityProtocol.LDAPS)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.ldaps")}
@@ -879,32 +851,22 @@ function ProviderConfigForm({
{t("settings.sso.form.ldaps-description")}
</div>
</div>
- </label>
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="ldap-security"
- checked={
- configForLDAP.securityProtocol ===
- LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED
- }
- onChange={() =>
- onUpdateLDAP({
- ...configForLDAP,
- securityProtocol:
- LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED,
- })
- }
- className="mt-1"
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(
+ LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED
+ )}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">{t("settings.sso.form.none")}</div>
<div className="text-sm text-control-light">
{t("settings.sso.form.none-description")}
</div>
</div>
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
<div>
diff --git a/frontend/src/react/pages/settings/IDPsPage.tsx b/frontend/src/react/pages/settings/IDPsPage.tsx
index 6ee7f0fc7a..91ff128ecf 100644
--- a/frontend/src/react/pages/settings/IDPsPage.tsx
+++ b/frontend/src/react/pages/settings/IDPsPage.tsx
@@ -31,6 +31,7 @@ import {
DialogTitle,
} from "@/react/components/ui/dialog";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
SheetBody,
@@ -592,22 +593,21 @@ function ProviderConfigForm({
{t("settings.sso.form.authentication-style")}{" "}
<span className="text-error">*</span>
</label>
- <div className="flex flex-col gap-y-3">
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="oauth2-auth-style"
- checked={
- configForOAuth2.authStyle === OAuth2AuthStyle.IN_PARAMS
- }
- onChange={() =>
- onUpdateOAuth2({
- ...configForOAuth2,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- })
- }
- className="mt-1"
- />
+ <RadioGroup
+ className="flex-col items-stretch gap-y-3"
+ value={String(configForOAuth2.authStyle)}
+ onValueChange={(value) =>
+ onUpdateOAuth2({
+ ...configForOAuth2,
+ authStyle: Number(value) as OAuth2AuthStyle,
+ })
+ }
+ >
+ <RadioGroupItem
+ value={String(OAuth2AuthStyle.IN_PARAMS)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.in-parameters")}
@@ -616,22 +616,12 @@ function ProviderConfigForm({
{t("settings.sso.form.in-parameters-description")}
</div>
</div>
- </label>
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="oauth2-auth-style"
- checked={
- configForOAuth2.authStyle === OAuth2AuthStyle.IN_HEADER
- }
- onChange={() =>
- onUpdateOAuth2({
- ...configForOAuth2,
- authStyle: OAuth2AuthStyle.IN_HEADER,
- })
- }
- className="mt-1"
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(OAuth2AuthStyle.IN_HEADER)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.in-header")}
@@ -640,8 +630,8 @@ function ProviderConfigForm({
{t("settings.sso.form.in-header-description")}
</div>
</div>
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
<div>
@@ -738,20 +728,21 @@ function ProviderConfigForm({
{t("settings.sso.form.authentication-style")}{" "}
<span className="text-error">*</span>
</label>
- <div className="flex flex-col gap-y-3">
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="oidc-auth-style"
- checked={configForOIDC.authStyle === OAuth2AuthStyle.IN_PARAMS}
- onChange={() =>
- onUpdateOIDC({
- ...configForOIDC,
- authStyle: OAuth2AuthStyle.IN_PARAMS,
- })
- }
- className="mt-1"
- />
+ <RadioGroup
+ className="flex-col items-stretch gap-y-3"
+ value={String(configForOIDC.authStyle)}
+ onValueChange={(value) =>
+ onUpdateOIDC({
+ ...configForOIDC,
+ authStyle: Number(value) as OAuth2AuthStyle,
+ })
+ }
+ >
+ <RadioGroupItem
+ value={String(OAuth2AuthStyle.IN_PARAMS)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.in-parameters")}
@@ -760,20 +751,12 @@ function ProviderConfigForm({
{t("settings.sso.form.in-parameters-description")}
</div>
</div>
- </label>
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="oidc-auth-style"
- checked={configForOIDC.authStyle === OAuth2AuthStyle.IN_HEADER}
- onChange={() =>
- onUpdateOIDC({
- ...configForOIDC,
- authStyle: OAuth2AuthStyle.IN_HEADER,
- })
- }
- className="mt-1"
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(OAuth2AuthStyle.IN_HEADER)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.in-header")}
@@ -782,8 +765,8 @@ function ProviderConfigForm({
{t("settings.sso.form.in-header-description")}
</div>
</div>
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
<div>
@@ -920,24 +903,25 @@ function ProviderConfigForm({
{t("settings.sso.form.security-protocol")}{" "}
<span className="text-error">*</span>
</label>
- <div className="flex flex-col gap-y-3">
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="ldap-security"
- checked={
- configForLDAP.securityProtocol ===
- LDAPIdentityProviderConfig_SecurityProtocol.START_TLS
- }
- onChange={() =>
- onUpdateLDAP({
- ...configForLDAP,
- securityProtocol:
- LDAPIdentityProviderConfig_SecurityProtocol.START_TLS,
- })
- }
- className="mt-1"
- />
+ <RadioGroup
+ className="flex-col items-stretch gap-y-3"
+ value={String(configForLDAP.securityProtocol)}
+ onValueChange={(value) =>
+ onUpdateLDAP({
+ ...configForLDAP,
+ securityProtocol: Number(
+ value
+ ) as LDAPIdentityProviderConfig_SecurityProtocol,
+ })
+ }
+ >
+ <RadioGroupItem
+ value={String(
+ LDAPIdentityProviderConfig_SecurityProtocol.START_TLS
+ )}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.starttls")}
@@ -946,24 +930,12 @@ function ProviderConfigForm({
{t("settings.sso.form.starttls-description")}
</div>
</div>
- </label>
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="ldap-security"
- checked={
- configForLDAP.securityProtocol ===
- LDAPIdentityProviderConfig_SecurityProtocol.LDAPS
- }
- onChange={() =>
- onUpdateLDAP({
- ...configForLDAP,
- securityProtocol:
- LDAPIdentityProviderConfig_SecurityProtocol.LDAPS,
- })
- }
- className="mt-1"
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(LDAPIdentityProviderConfig_SecurityProtocol.LDAPS)}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">
{t("settings.sso.form.ldaps")}
@@ -972,32 +944,22 @@ function ProviderConfigForm({
{t("settings.sso.form.ldaps-description")}
</div>
</div>
- </label>
- <label className="flex items-start gap-x-3 cursor-pointer">
- <input
- type="radio"
- name="ldap-security"
- checked={
- configForLDAP.securityProtocol ===
- LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED
- }
- onChange={() =>
- onUpdateLDAP({
- ...configForLDAP,
- securityProtocol:
- LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED,
- })
- }
- className="mt-1"
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(
+ LDAPIdentityProviderConfig_SecurityProtocol.SECURITY_PROTOCOL_UNSPECIFIED
+ )}
+ className="items-start gap-x-3"
+ radioClassName="mt-1"
+ >
<div>
<div className="font-medium">{t("settings.sso.form.none")}</div>
<div className="text-sm text-gray-600">
{t("settings.sso.form.none-description")}
</div>
</div>
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
<div>
@@ -1703,29 +1665,48 @@ function CreateWizardDrawer({
{t("settings.sso.form.type-description")}
</p>
</div>
- <div className="max-w-2xl mx-auto w-full">
+ <RadioGroup
+ className="max-w-2xl mx-auto w-full flex-col items-stretch gap-4"
+ value={String(selectedType)}
+ onValueChange={(value) => {
+ const item = PROVIDER_TYPE_LIST.find(
+ (item) => String(item.type) === value
+ );
+ if (
+ item &&
+ useAppStore.getState().hasFeature(item.feature)
+ ) {
+ handleTypeChange(item.type);
+ }
+ }}
+ >
{PROVIDER_TYPE_LIST.map((item) => {
const Icon = getProviderIcon(item.type);
const hasFeature = useAppStore
.getState()
.hasFeature(item.feature);
return (
- <label
+ <div
key={item.type}
- className={`block border rounded-sm mb-4 p-4 transition-colors cursor-pointer ${
+ className={`block border rounded-sm p-4 transition-colors cursor-pointer ${
selectedType === item.type
? "border-blue-500 bg-blue-50"
: "border-gray-200 hover:border-gray-300"
} ${!hasFeature ? "opacity-50 cursor-not-allowed" : ""}`}
+ onClick={() => {
+ if (hasFeature) {
+ handleTypeChange(item.type);
+ }
+ }}
>
<div className="flex items-start gap-x-3">
- <input
- type="radio"
- name="provider-type"
- checked={selectedType === item.type}
+ <RadioGroupItem
+ value={String(item.type)}
+ aria-label={identityProviderTypeToString(
+ item.type
+ )}
disabled={!hasFeature}
- onChange={() => handleTypeChange(item.type)}
- className="mt-1.5"
+ radioClassName="mt-1.5"
/>
<Icon
className="w-6 h-6 mt-1 shrink-0"
@@ -1742,10 +1723,10 @@ function CreateWizardDrawer({
</p>
</div>
</div>
- </label>
+ </div>
);
})}
- </div>
+ </RadioGroup>
</div>
)}
@@ -1760,29 +1741,45 @@ function CreateWizardDrawer({
{t("settings.sso.form.template-description")}
</p>
</div>
- <div className="max-w-3xl mx-auto grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <RadioGroup
+ className="max-w-3xl mx-auto grid grid-cols-1 sm:grid-cols-2 gap-4"
+ value={selectedTemplate?.title ?? ""}
+ onValueChange={(value) => {
+ const template = templateList.find(
+ (template) => template.title === value
+ );
+ if (
+ template &&
+ useAppStore.getState().hasFeature(template.feature)
+ ) {
+ applyTemplate(template);
+ }
+ }}
+ >
{templateList.map((tmpl) => {
const Icon = getTemplateIcon(tmpl.title);
const hasFeature = useAppStore
.getState()
.hasFeature(tmpl.feature);
return (
- <label
+ <div
key={tmpl.title}
className={`block border rounded-sm p-4 transition-colors cursor-pointer ${
selectedTemplate?.title === tmpl.title
? "border-blue-500 bg-blue-50"
: "border-gray-200 hover:border-gray-300"
} ${!hasFeature ? "opacity-50 cursor-not-allowed" : ""}`}
+ onClick={() => {
+ if (hasFeature) {
+ applyTemplate(tmpl);
+ }
+ }}
>
<div className="flex items-center gap-x-3">
- <input
- type="radio"
- name="template"
- checked={selectedTemplate?.title === tmpl.title}
+ <RadioGroupItem
+ value={tmpl.title}
+ aria-label={tmpl.title}
disabled={!hasFeature}
- onChange={() => applyTemplate(tmpl)}
- className="shrink-0"
/>
<Icon
className="w-8 h-8 shrink-0"
@@ -1797,10 +1794,10 @@ function CreateWizardDrawer({
</p>
</div>
</div>
- </label>
+ </div>
);
})}
- </div>
+ </RadioGroup>
</div>
)}
diff --git a/frontend/src/react/pages/settings/IMPage.test.tsx b/frontend/src/react/pages/settings/IMPage.test.tsx
new file mode 100644
index 0000000000..da6e7eaf3b
--- /dev/null
+++ b/frontend/src/react/pages/settings/IMPage.test.tsx
@@ -0,0 +1,125 @@
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ getOrFetchSettingByName: vi.fn(async () => undefined),
+ getSettingByName: vi.fn(() => undefined),
+ settingsByName: {},
+ upsertSetting: vi.fn(async () => undefined),
+}));
+
+const t = vi.hoisted(
+ () => (key: string) =>
+ ({
+ "bbkit.confirm-button.sure-to-delete": "Sure to delete?",
+ "common.create": "Create",
+ "common.deleted": "Deleted",
+ "common.discard-changes": "Discard changes",
+ "common.learn-more": "Learn more",
+ "common.no-data": "No data",
+ "common.save": "Save",
+ "common.sensitive-placeholder": "Sensitive - write only",
+ "common.updated": "Updated",
+ "settings.im-integration.description": "IM integration description",
+ })[key] ?? key
+);
+
+vi.mock("react-i18next", () => ({
+ initReactI18next: {
+ type: "3rdParty",
+ init: vi.fn(),
+ },
+ useTranslation: () => ({
+ t,
+ }),
+}));
+
+vi.mock("@/react/components/PermissionGuard", () => ({
+ PermissionGuard: ({ children }: { children: ReactElement }) => children,
+}));
+
+vi.mock("@/react/stores/app", () => {
+ const useAppStore = <T,>(
+ selector: (state: { settingsByName: typeof mocks.settingsByName }) => T
+ ) =>
+ selector({
+ settingsByName: mocks.settingsByName,
+ });
+ useAppStore.getState = () => ({
+ getOrFetchSettingByName: mocks.getOrFetchSettingByName,
+ getSettingByName: mocks.getSettingByName,
+ upsertSetting: mocks.upsertSetting,
+ });
+ return { useAppStore };
+});
+
+vi.mock("@/store", () => ({
+ pushNotification: vi.fn(),
+}));
+
+vi.mock("@/utils", () => ({
+ hasWorkspacePermissionV2: () => true,
+}));
+
+vi.mock("@/assets/im/dingtalk.png", () => ({ default: "/dingtalk.png" }));
+vi.mock("@/assets/im/feishu.webp", () => ({ default: "/feishu.webp" }));
+vi.mock("@/assets/im/slack.png", () => ({ default: "/slack.png" }));
+vi.mock("@/assets/im/teams.svg", () => ({ default: "/teams.svg" }));
+vi.mock("@/assets/im/wecom.png", () => ({ default: "/wecom.png" }));
+
+let IMPage: typeof import("./IMPage").IMPage;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ return {
+ container,
+ render: async () => {
+ await act(async () => {
+ root.render(element);
+ });
+ },
+ unmount: () =>
+ act(() => {
+ root.unmount();
+ container.remove();
+ }),
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ mocks.getOrFetchSettingByName.mockResolvedValue(undefined);
+ mocks.getSettingByName.mockReturnValue(undefined);
+ mocks.settingsByName = {};
+ ({ IMPage } = await import("./IMPage"));
+});
+
+describe("IMPage", () => {
+ test("uses shared Select for new IM integration type", async () => {
+ const { container, render, unmount } = renderIntoContainer(<IMPage />);
+ await render();
+
+ await act(async () => {
+ Array.from(container.querySelectorAll("button"))
+ .find((button) => button.textContent?.includes("Create"))
+ ?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ expect(container.querySelector("select")).toBeNull();
+ expect(
+ Array.from(container.querySelectorAll("button")).some((button) =>
+ button.textContent?.includes("Slack")
+ )
+ ).toBe(true);
+
+ unmount();
+ });
+});
diff --git a/frontend/src/react/pages/settings/IMPage.tsx b/frontend/src/react/pages/settings/IMPage.tsx
index 899a2a339a..9502d67774 100644
--- a/frontend/src/react/pages/settings/IMPage.tsx
+++ b/frontend/src/react/pages/settings/IMPage.tsx
@@ -17,7 +17,19 @@ 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 {
+ FormField,
+ FormFieldGroup,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/react/components/ui/select";
import { useAppStore } from "@/react/stores/app";
import { pushNotification } from "@/store";
import { WebhookType } from "@/types/proto-es/v1/common_pb";
@@ -419,28 +431,35 @@ export function IMPage() {
{item.isConfigured ? (
<IMTypeLabel type={item.type} label={item.typeLabel} />
) : (
- <select
+ <Select
value={item.type}
- 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)}
+ onValueChange={(value) => {
+ if (value !== null) {
+ handleChangeType(i, value);
+ }
+ }}
>
- <option value={item.type}>{item.typeLabel}</option>
- {availableTypes
- .filter((opt) => opt.type !== item.type)
- .map((opt) => (
- <option key={opt.type} value={opt.type}>
- {opt.label}
- </option>
- ))}
- </select>
+ <SelectTrigger className="w-full max-w-xs">
+ <SelectValue>{item.typeLabel}</SelectValue>
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value={item.type}>{item.typeLabel}</SelectItem>
+ {availableTypes
+ .filter((opt) => opt.type !== item.type)
+ .map((opt) => (
+ <SelectItem key={opt.type} value={opt.type}>
+ {opt.label}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
)}
- <div className="mt-4 flex flex-col gap-y-4">
+ <FormFieldGroup className="mt-4 gap-y-4">
{item.fields.map((field) => (
- <div key={field.key}>
- <label className="textlabel">{field.label}</label>
+ <FormField key={field.key}>
+ <FormLabel>{field.label}</FormLabel>
<Input
- className="mt-2"
disabled={!allowEdit}
placeholder={t("common.sensitive-placeholder")}
value={localValues[i]?.[field.key] ?? ""}
@@ -448,9 +467,9 @@ export function IMPage() {
updateField(i, field.key, e.target.value)
}
/>
- </div>
+ </FormField>
))}
- </div>
+ </FormFieldGroup>
<div className="flex items-center justify-between mt-4 gap-x-2">
<div>
diff --git a/frontend/src/react/pages/settings/InstanceDetailPage.tsx b/frontend/src/react/pages/settings/InstanceDetailPage.tsx
index af5fbbb001..6c2be5bda3 100644
--- a/frontend/src/react/pages/settings/InstanceDetailPage.tsx
+++ b/frontend/src/react/pages/settings/InstanceDetailPage.tsx
@@ -443,7 +443,7 @@ export function InstanceDetailPage({ instanceId }: { instanceId: string }) {
<TabsPanel value="overview">
<InstanceFormProvider instance={instance}>
<InstanceFormBody />
- <InstanceFormButtons className="sticky bottom-0 z-10" />
+ <InstanceFormButtons />
<UnsavedChangesGuard />
</InstanceFormProvider>
</TabsPanel>
diff --git a/frontend/src/react/pages/settings/InstancesPage.tsx b/frontend/src/react/pages/settings/InstancesPage.tsx
index 79f0a2c2b5..ca74b927e7 100644
--- a/frontend/src/react/pages/settings/InstancesPage.tsx
+++ b/frontend/src/react/pages/settings/InstancesPage.tsx
@@ -41,6 +41,7 @@ import {
DropdownMenuTrigger,
} from "@/react/components/ui/dropdown-menu";
import { EllipsisText } from "@/react/components/ui/ellipsis-text";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
SheetBody,
@@ -459,10 +460,15 @@ function EditEnvironmentSheet({
<SheetTitle>{t("common.environment")}</SheetTitle>
</SheetHeader>
<SheetBody>
- <div className="flex flex-col gap-y-2">
+ <RadioGroup
+ className="flex-col items-stretch gap-y-2"
+ value={selected}
+ onValueChange={(value) => setSelected(value as string)}
+ >
{environments.map((env) => (
- <label
+ <RadioGroupItem
key={env.name}
+ value={env.name}
className={cn(
"flex items-center gap-x-3 px-3 py-2 rounded-xs cursor-pointer border",
selected === env.name
@@ -470,13 +476,6 @@ function EditEnvironmentSheet({
: "border-transparent hover:bg-control-bg"
)}
>
- <input
- type="radio"
- name="environment"
- checked={selected === env.name}
- onChange={() => setSelected(env.name)}
- className="accent-accent"
- />
<div className="flex items-center gap-x-2">
<span
className="inline-block size-3 rounded-full"
@@ -486,9 +485,9 @@ function EditEnvironmentSheet({
/>
<span>{env.title}</span>
</div>
- </label>
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
</SheetBody>
<SheetFooter>
<Button variant="ghost" onClick={onClose}>
diff --git a/frontend/src/react/pages/settings/MembersPage.test.tsx b/frontend/src/react/pages/settings/MembersPage.test.tsx
index 5c533a69d3..5d80ba8ea5 100644
--- a/frontend/src/react/pages/settings/MembersPage.test.tsx
+++ b/frontend/src/react/pages/settings/MembersPage.test.tsx
@@ -396,12 +396,11 @@ describe("MembersPage project role grant drawer", () => {
});
await flush();
- const expressionRadio = [...container.querySelectorAll("input")].find(
- (input) =>
- input instanceof HTMLInputElement &&
- input.type === "radio" &&
- input.parentElement?.textContent === "CEL Expression"
- ) as HTMLInputElement;
+ const expressionRadio = [
+ ...container.querySelectorAll<HTMLElement>('[role="radio"]'),
+ ].find(
+ (radio) => radio.parentElement?.textContent === "CEL Expression"
+ ) as HTMLElement;
await act(async () => {
expressionRadio.click();
});
@@ -445,12 +444,11 @@ describe("MembersPage project role grant drawer", () => {
});
await flush();
- const expressionRadio = [...container.querySelectorAll("input")].find(
- (input) =>
- input instanceof HTMLInputElement &&
- input.type === "radio" &&
- input.parentElement?.textContent === "CEL Expression"
- ) as HTMLInputElement;
+ const expressionRadio = [
+ ...container.querySelectorAll<HTMLElement>('[role="radio"]'),
+ ].find(
+ (radio) => radio.parentElement?.textContent === "CEL Expression"
+ ) as HTMLElement;
await act(async () => {
expressionRadio.click();
});
diff --git a/frontend/src/react/pages/settings/MembersPage.tsx b/frontend/src/react/pages/settings/MembersPage.tsx
index bc74d5b631..3d3ac3da14 100644
--- a/frontend/src/react/pages/settings/MembersPage.tsx
+++ b/frontend/src/react/pages/settings/MembersPage.tsx
@@ -42,7 +42,14 @@ import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
import { ExpirationPicker } from "@/react/components/ui/expiration-picker";
+import {
+ FormDescription,
+ FormError,
+ FormField,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { SearchInput } from "@/react/components/ui/search-input";
import {
Sheet,
@@ -137,10 +144,6 @@ import type { DatabaseMode } from "./types";
const EMPTY_ROLE_SET = new Set<string>();
-const assertNever = (value: never): never => {
- throw new Error(`Unexpected value: ${String(value)}`);
-};
-
// ============================================================
// MemberTable (view by members)
// ============================================================
@@ -968,7 +971,6 @@ function DatabaseResourceSection({
factorList,
factorOptionConfigMap,
factorOperatorOverrideMap,
- formId,
}: {
projectName: string;
mode: DatabaseMode;
@@ -980,7 +982,6 @@ function DatabaseResourceSection({
factorList: Factor[];
factorOptionConfigMap: Map<Factor, OptionConfig>;
factorOperatorOverrideMap: Map<Factor, Operator[]>;
- formId: string;
}) {
const { t } = useTranslation();
@@ -991,27 +992,22 @@ function DatabaseResourceSection({
];
return (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.databases")}
<span className="ml-0.5 text-error">*</span>
- </label>
- <div className="flex items-center gap-x-4">
+ </FormLabel>
+ <RadioGroup
+ className="gap-x-4"
+ value={mode}
+ onValueChange={(value) => onModeChange(value as DatabaseMode)}
+ >
{modes.map((m) => (
- <label
- key={m.value}
- className="flex items-center gap-x-2 text-sm cursor-pointer"
- >
- <input
- type="radio"
- name={`db-mode-${formId}`}
- checked={mode === m.value}
- onChange={() => onModeChange(m.value)}
- />
+ <RadioGroupItem key={m.value} value={m.value}>
{m.label}
- </label>
+ </RadioGroupItem>
))}
- </div>
+ </RadioGroup>
{mode === "EXPRESSION" && (
<ExprEditor
@@ -1030,7 +1026,7 @@ function DatabaseResourceSection({
onChange={onDatabaseResourcesChange}
/>
)}
- </div>
+ </FormField>
);
}
@@ -1189,24 +1185,20 @@ function ProjectRoleBindingForm({
)}
{/* Role select */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("settings.members.assign-role")}
- </label>
+ <FormField>
+ <FormLabel>{t("settings.members.assign-role")}</FormLabel>
<RoleSelect
value={form.role ? [form.role] : []}
onChange={(roles) => handleRoleChange(roles[0] ?? "")}
multiple={false}
scope="project"
/>
- </div>
+ </FormField>
{/* Permissions display */}
{permissions.length > 0 && (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("common.permissions")}
- </label>
+ <FormField>
+ <FormLabel>{t("common.permissions")}</FormLabel>
<div className="max-h-32 overflow-auto border rounded-sm bg-control-bg p-2">
<div className="flex flex-wrap gap-1">
{permissions.map((perm) => (
@@ -1219,24 +1211,24 @@ function ProjectRoleBindingForm({
))}
</div>
</div>
- </div>
+ </FormField>
)}
{/* Reason */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.reason")}{" "}
<span className="text-control-light font-normal">
({t("common.optional")})
</span>
- </label>
+ </FormLabel>
<textarea
className="w-full rounded-xs border border-control-border bg-transparent px-3 py-2 text-sm resize-none"
rows={2}
value={form.reason}
onChange={(e) => handleReasonChange(e.target.value)}
/>
- </div>
+ </FormField>
{/* Databases (conditional on role) */}
{showDatabases && (
@@ -1262,16 +1254,13 @@ function ProjectRoleBindingForm({
factorList={factorList}
factorOptionConfigMap={factorOptionConfigMap}
factorOperatorOverrideMap={factorOperatorOverrideMap}
- formId={form.id}
/>
)}
{/* Environments (conditional on role) */}
{envKind && (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("common.environments")}
- </label>
+ <FormField>
+ <FormLabel>{t("common.environments")}</FormLabel>
<DDLWarningCallout type="drawer" kind={envKind} />
<EnvironmentSelect
multiple
@@ -1279,15 +1268,15 @@ function ProjectRoleBindingForm({
value={form.environments}
onChange={(envs) => onChange({ ...form, environments: envs })}
/>
- </div>
+ </FormField>
)}
{/* Expiration */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.expiration")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
<div className="flex flex-wrap gap-1.5">
{/* "Never" is only offered when the workspace sets no cap. */}
{maximumRequestExpirationDays === undefined && (
@@ -1328,32 +1317,32 @@ function ProjectRoleBindingForm({
/>
)}
{maximumRequestExpirationDays !== undefined && (
- <p className="text-xs text-control-light">
+ <FormDescription>
{t("project.members.request-role.max-expiration-hint", {
days: maximumRequestExpirationDays,
})}
- </p>
+ </FormDescription>
)}
{expirationIsInPast && (
- <p className="text-xs text-error">
+ <FormError>
{t("project.members.request-role.expiration-must-be-future")}
- </p>
+ </FormError>
)}
{expirationExceedsMax && (
- <p className="text-xs text-error">
+ <FormError>
{t("project.members.request-role.expiration-exceeds-max", {
days: maximumRequestExpirationDays,
})}
- </p>
+ </FormError>
)}
{!form.expirationCustom && form.expirationTimestampInMS && (
- <span className="text-xs text-control-light">
+ <FormDescription>
{t("project.members.expires-at", {
date: formatExpirationDate(form.expirationTimestampInMS),
})}
- </span>
+ </FormDescription>
)}
- </div>
+ </FormField>
</div>
);
}
@@ -1968,10 +1957,10 @@ function EditMemberRoleDrawer({
/>
)}
{/* Member input */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.select-account", { count: 1 })}
- </label>
+ </FormLabel>
{isEditMode ? (
<Input value={member.binding} disabled />
) : (
@@ -1981,7 +1970,7 @@ function EditMemberRoleDrawer({
includeAllUsers={!isSaaSMode}
/>
)}
- </div>
+ </FormField>
{/* Roles — project create mode uses rich form, otherwise simple multi-select */}
{isProjectCreateMode ? (
@@ -1996,16 +1985,16 @@ function EditMemberRoleDrawer({
/>
</div>
) : (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.members.select-role", { count: 2 })}
- </label>
+ </FormLabel>
<RoleSelect
value={selectedRoles}
onChange={setSelectedRoles}
scope={projectName ? "project" : undefined}
/>
- </div>
+ </FormField>
)}
</div>
</SheetBody>
@@ -2232,38 +2221,17 @@ export function MembersPage({ projectId }: { projectId?: string }) {
const requestRoleButtonState = useMemo(
() =>
getRequestRoleButtonState({
+ t,
projectName,
projectReady: !!project,
allowRequestRole: project?.allowRequestRole ?? false,
hasFullProjectAccess,
hasRequestRoleFeature,
}),
- [projectName, project, hasFullProjectAccess, hasRequestRoleFeature]
+ [t, projectName, project, hasFullProjectAccess, hasRequestRoleFeature]
);
- const requestRoleDisabledReason = useMemo(() => {
- const reason = requestRoleButtonState.disabledReason;
- if (!reason) return undefined;
-
- switch (reason.kind) {
- case "loading":
- return t("common.loading");
- case "allow-request-role-disabled":
- return t(
- "project.members.request-role.disabled-reason.allow-request-role-disabled"
- );
- case "can-grant-access-directly":
- return t(
- "project.members.request-role.disabled-reason.can-grant-access-directly"
- );
- case "feature-unavailable":
- return t(
- "project.members.request-role.disabled-reason.feature-unavailable"
- );
- default:
- return assertNever(reason);
- }
- }, [requestRoleButtonState.disabledReason, t]);
+ const requestRoleDisabledReason = requestRoleButtonState.disabledReason;
const setIamPolicyPermissionGuard = useMemo(
() => getSetIamPolicyPermissionGuardConfig(project),
diff --git a/frontend/src/react/pages/settings/RequestRoleSheet.tsx b/frontend/src/react/pages/settings/RequestRoleSheet.tsx
index f6c1b16207..66203653fb 100644
--- a/frontend/src/react/pages/settings/RequestRoleSheet.tsx
+++ b/frontend/src/react/pages/settings/RequestRoleSheet.tsx
@@ -26,6 +26,13 @@ import type { SQLEditorTheme } from "@/react/components/sql-editor/theme/types";
import { Alert } from "@/react/components/ui/alert";
import { Button } from "@/react/components/ui/button";
import { ExpirationPicker } from "@/react/components/ui/expiration-picker";
+import {
+ FormDescription,
+ FormError,
+ FormField,
+ FormLabel,
+} from "@/react/components/ui/form";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
SheetBody,
@@ -497,11 +504,11 @@ function RequestRoleForm({
}
/>
)}
- <div className="flex flex-col gap-y-1">
- <label className="text-sm font-medium">
+ <FormField>
+ <FormLabel>
{t("common.role.self")}
<span className="text-error ml-0.5">*</span>
- </label>
+ </FormLabel>
<RoleSelect
scope="project"
multiple={false}
@@ -518,53 +525,48 @@ function RequestRoleForm({
filterRole={roleMatchesRequiredPermissions}
/>
{!!role && !selectedRoleMatchesRequiredPermissions && (
- <p className="text-xs text-error">
+ <FormError>
{t("common.missing-required-permission", {
permissions: requiredPermissionList.join(", "),
})}
- </p>
+ </FormError>
)}
- </div>
- <div className="flex flex-col gap-y-1">
- <label className="text-sm font-medium">
+ </FormField>
+ <FormField>
+ <FormLabel>
{t("common.reason")}
{reasonRequired && <span className="text-error ml-0.5">*</span>}
- </label>
+ </FormLabel>
<Textarea
value={reason}
onChange={(e) => setReason(e.target.value)}
placeholder={t("common.reason")}
rows={3}
/>
- </div>
+ </FormField>
{showDatabases && (
- <div className="flex flex-col gap-y-2">
- <label className="text-sm font-medium">
+ <FormField>
+ <FormLabel>
{t("common.databases")}
<span className="text-error ml-0.5">*</span>
- </label>
- <div className="flex items-center gap-x-4">
+ </FormLabel>
+ <RadioGroup
+ className="gap-x-4"
+ value={databaseMode}
+ onValueChange={(value) => {
+ setDatabaseMode(value as DatabaseMode);
+ setDatabaseResources([]);
+ setExprGroup(wrapAsGroup(emptySimpleExpr()));
+ }}
+ >
{(["ALL", "EXPRESSION", "SELECT"] as DatabaseMode[]).map(
(m) => (
- <label
- key={m}
- className="flex items-center gap-x-2 text-sm cursor-pointer"
- >
- <input
- type="radio"
- name="request-role-db-mode"
- checked={databaseMode === m}
- onChange={() => {
- setDatabaseMode(m);
- setDatabaseResources([]);
- setExprGroup(wrapAsGroup(emptySimpleExpr()));
- }}
- />
+ <RadioGroupItem key={m} value={m}>
{t(databaseModeLabelKey(m))}
- </label>
+ </RadioGroupItem>
)
)}
- </div>
+ </RadioGroup>
{databaseMode === "EXPRESSION" && (
<ExprEditor
expr={exprGroup}
@@ -581,13 +583,11 @@ function RequestRoleForm({
onChange={setDatabaseResources}
/>
)}
- </div>
+ </FormField>
)}
{envKind && (
- <div className="flex flex-col gap-y-2">
- <label className="text-sm font-medium">
- {t("common.environments")}
- </label>
+ <FormField>
+ <FormLabel>{t("common.environments")}</FormLabel>
<DDLWarningCallout type="drawer" kind={envKind} />
<EnvironmentSelect
multiple
@@ -595,15 +595,15 @@ function RequestRoleForm({
value={environments}
onChange={setEnvironments}
/>
- </div>
+ </FormField>
)}
- <div className="flex flex-col gap-y-1">
- <label className="text-sm font-medium">
+ <FormField>
+ <FormLabel>
{t("common.expiration")}
{expirationRequired && (
<span className="text-error ml-0.5">*</span>
)}
- </label>
+ </FormLabel>
<ExpirationPicker
value={expirationTimestamp}
onChange={setExpirationTimestamp}
@@ -611,25 +611,25 @@ function RequestRoleForm({
maxDate={maxDatetime}
/>
{maximumRequestExpirationDays !== undefined && (
- <p className="text-xs text-control-light">
+ <FormDescription>
{t("project.members.request-role.max-expiration-hint", {
days: maximumRequestExpirationDays,
})}
- </p>
+ </FormDescription>
)}
{expirationIsInPast && (
- <p className="text-xs text-error">
+ <FormError>
{t("project.members.request-role.expiration-must-be-future")}
- </p>
+ </FormError>
)}
{expirationExceedsMax && (
- <p className="text-xs text-error">
+ <FormError>
{t("project.members.request-role.expiration-exceeds-max", {
days: maximumRequestExpirationDays,
})}
- </p>
+ </FormError>
)}
- </div>
+ </FormField>
{showLabelSelect && (
<IssueLabelSelect
labels={project.issueLabels}
diff --git a/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx b/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx
index ba6fd16abf..8e881366cd 100644
--- a/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx
+++ b/frontend/src/react/pages/settings/SQLReviewDetailPage.tsx
@@ -16,6 +16,7 @@ import {
DialogTitle,
} from "@/react/components/ui/dialog";
import { Input } from "@/react/components/ui/input";
+import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
import {
getRuleMapValidationErrorTitle,
rulesToTemplate,
@@ -381,12 +382,15 @@ export function SQLReviewDetailPage({
{/* Sticky save bar when rules changed */}
{rulesUpdated && (
- <div className="w-full mt-4 py-2 border-t border-control-border flex justify-end gap-x-4 bg-background sticky bottom-0 z-10">
- <Button variant="outline" onClick={onCancelChanges}>
- {t("common.cancel")}
- </Button>
- <Button onClick={onApplyChanges}>{t("common.update")}</Button>
- </div>
+ <StickyActionFooter
+ className="mt-4 py-2 border-control-border"
+ left={
+ <Button variant="outline" onClick={onCancelChanges}>
+ {t("common.cancel")}
+ </Button>
+ }
+ right={<Button onClick={onApplyChanges}>{t("common.update")}</Button>}
+ />
)}
{/* Disable confirmation dialog */}
diff --git a/frontend/src/react/pages/settings/SemanticTypesPage.tsx b/frontend/src/react/pages/settings/SemanticTypesPage.tsx
index 3676c9055a..c90747a717 100644
--- a/frontend/src/react/pages/settings/SemanticTypesPage.tsx
+++ b/frontend/src/react/pages/settings/SemanticTypesPage.tsx
@@ -12,6 +12,7 @@ import {
PopoverContent,
PopoverTrigger,
} from "@/react/components/ui/popover";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
SheetBody,
@@ -849,44 +850,30 @@ function MaskingAlgorithmDrawer({
"settings.sensitive-data.algorithms.inner-outer-mask.outer-label"
)}
</p>
- <div className="flex gap-x-4 mt-2">
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="innerOuterType"
- checked={
- innerOuterType ===
- Algorithm_InnerOuterMask_MaskType.INNER
- }
- onChange={() =>
- setInnerOuterType(
- Algorithm_InnerOuterMask_MaskType.INNER
- )
- }
- />
+ <RadioGroup
+ className="mt-2 gap-x-4"
+ value={String(innerOuterType)}
+ onValueChange={(value) =>
+ setInnerOuterType(
+ Number(value) as Algorithm_InnerOuterMask_MaskType
+ )
+ }
+ >
+ <RadioGroupItem
+ value={String(Algorithm_InnerOuterMask_MaskType.INNER)}
+ >
{t(
"settings.sensitive-data.algorithms.inner-outer-mask.inner-mask"
)}
- </label>
- <label className="flex items-center gap-x-2 cursor-pointer">
- <input
- type="radio"
- name="innerOuterType"
- checked={
- innerOuterType ===
- Algorithm_InnerOuterMask_MaskType.OUTER
- }
- onChange={() =>
- setInnerOuterType(
- Algorithm_InnerOuterMask_MaskType.OUTER
- )
- }
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(Algorithm_InnerOuterMask_MaskType.OUTER)}
+ >
{t(
"settings.sensitive-data.algorithms.inner-outer-mask.outer-mask"
)}
- </label>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
</div>
<div className="flex gap-x-2 items-end">
<div className="flex flex-col gap-y-1">
diff --git a/frontend/src/react/pages/settings/ServiceAccountsPage.tsx b/frontend/src/react/pages/settings/ServiceAccountsPage.tsx
index 1ccb299911..51cfb7f0fb 100644
--- a/frontend/src/react/pages/settings/ServiceAccountsPage.tsx
+++ b/frontend/src/react/pages/settings/ServiceAccountsPage.tsx
@@ -9,6 +9,7 @@ import { UserCell } from "@/react/components/UserCell";
import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { FormField, FormLabel } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Sheet,
@@ -565,10 +566,8 @@ function ServiceAccountForm({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Name */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("common.name")}
- </label>
+ <FormField>
+ <FormLabel>{t("common.name")}</FormLabel>
<Input
autoComplete="off"
value={title}
@@ -576,14 +575,14 @@ function ServiceAccountForm({
placeholder="Foo"
maxLength={200}
/>
- </div>
+ </FormField>
{/* Email */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.email")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
{isEditMode ? (
<Input value={serviceAccount?.email ?? ""} disabled />
) : (
@@ -600,7 +599,7 @@ function ServiceAccountForm({
</span>
</div>
)}
- </div>
+ </FormField>
{/* Roles (create mode only) */}
{!isEditMode &&
@@ -610,17 +609,15 @@ function ServiceAccountForm({
"bb.projects.setIamPolicy"
)
: hasWorkspacePermissionV2("bb.workspaces.setIamPolicy")) && (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("settings.members.table.roles")}
- </label>
+ <FormField>
+ <FormLabel>{t("settings.members.table.roles")}</FormLabel>
<RoleSelect
value={roles}
onChange={setRoles}
disabled={false}
scope={project ? "project" : undefined}
/>
- </div>
+ </FormField>
)}
</div>
</SheetBody>
diff --git a/frontend/src/react/pages/settings/UsersPage.tsx b/frontend/src/react/pages/settings/UsersPage.tsx
index 0569f0d6fc..b318a3c346 100644
--- a/frontend/src/react/pages/settings/UsersPage.tsx
+++ b/frontend/src/react/pages/settings/UsersPage.tsx
@@ -20,6 +20,12 @@ import { UserCell } from "@/react/components/UserCell";
import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
+import {
+ FormDescription,
+ FormError,
+ FormField,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { SearchInput } from "@/react/components/ui/search-input";
import {
@@ -30,6 +36,7 @@ import {
SheetHeader,
SheetTitle,
} from "@/react/components/ui/sheet";
+import { listRowStateClassName } from "@/react/components/ui/styles.stylex";
import {
Table,
TableBody,
@@ -258,7 +265,9 @@ function UserTable({
key={user.name}
className={cn(
hasWorkspacePermissionV2(getViewPermission(accountType)) &&
- "cursor-pointer hover:bg-control-bg focus-visible:outline-none focus-visible:bg-control-bg"
+ "cursor-pointer focus-visible:outline-none focus-visible:bg-control-bg",
+ hasWorkspacePermissionV2(getViewPermission(accountType)) &&
+ listRowStateClassName
)}
tabIndex={
hasWorkspacePermissionV2(getViewPermission(accountType))
@@ -743,10 +752,8 @@ function UserForm({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Name */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("common.name")}
- </label>
+ <FormField>
+ <FormLabel>{t("common.name")}</FormLabel>
<Input
value={title}
onChange={(e) => setTitle(e.target.value)}
@@ -754,42 +761,36 @@ function UserForm({
maxLength={200}
disabled={!allowUpdate}
/>
- </div>
+ </FormField>
{/* Email */}
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("common.email")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
<Input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
disabled={isEditMode}
/>
- </div>
+ </FormField>
{/* Roles */}
{hasWorkspacePermissionV2("bb.workspaces.setIamPolicy") && (
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium text-control">
- {t("settings.members.table.roles")}
- </label>
+ <FormField>
+ <FormLabel>{t("settings.members.table.roles")}</FormLabel>
<RoleSelect value={roles} onChange={setRoles} disabled={false} />
- </div>
+ </FormField>
)}
{/* Phone */}
- <div className="flex flex-col gap-y-2">
- <div>
- <label className="block text-sm font-medium text-control">
- {t("settings.profile.phone")}
- </label>
- <span className="textinfolabel text-sm">
- {t("settings.profile.phone-tips")}
- </span>
- </div>
+ <FormField>
+ <FormLabel>{t("settings.profile.phone")}</FormLabel>
+ <FormDescription>
+ {t("settings.profile.phone-tips")}
+ </FormDescription>
<Input
type="tel"
value={phone}
@@ -797,15 +798,15 @@ function UserForm({
autoComplete="new-password"
disabled={!allowUpdate}
/>
- </div>
+ </FormField>
{/* Password */}
<div className="flex flex-col gap-y-6">
- <div>
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.profile.password")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
<span
className={`flex items-center gap-x-1 textinfolabel text-sm ${passwordHint ? "text-error" : ""}`}
>
@@ -851,13 +852,13 @@ function UserForm({
)}
</button>
</div>
- </div>
+ </FormField>
- <div>
- <label className="block text-sm font-medium text-control">
+ <FormField>
+ <FormLabel>
{t("settings.profile.password-confirm")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormLabel>
<div className="mt-1 relative flex items-center">
<Input
type={showPassword ? "text" : "password"}
@@ -883,11 +884,11 @@ function UserForm({
</button>
</div>
{passwordMismatch && (
- <span className="text-error text-sm mt-1 pl-1">
+ <FormError className="pl-1">
{t("settings.profile.password-mismatch")}
- </span>
+ </FormError>
)}
- </div>
+ </FormField>
</div>
</div>
</SheetBody>
diff --git a/frontend/src/react/pages/settings/WorkloadIdentitiesPage.tsx b/frontend/src/react/pages/settings/WorkloadIdentitiesPage.tsx
index dd08cf32de..a39507d9f5 100644
--- a/frontend/src/react/pages/settings/WorkloadIdentitiesPage.tsx
+++ b/frontend/src/react/pages/settings/WorkloadIdentitiesPage.tsx
@@ -6,6 +6,7 @@ import { PermissionGuard } from "@/react/components/PermissionGuard";
import { UserCell } from "@/react/components/UserCell";
import { Button } from "@/react/components/ui/button";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { listRowStateClassName } from "@/react/components/ui/styles.stylex";
import {
Table,
TableBody,
@@ -17,6 +18,7 @@ import {
import { Tooltip } from "@/react/components/ui/tooltip";
import { PagedTableFooter, usePagedData } from "@/react/hooks/usePagedData";
import { useProjectByName } from "@/react/hooks/useProjectByName";
+import { cn } from "@/react/lib/utils";
import { useAppStore } from "@/react/stores/app";
import {
ensureWorkloadIdentityFullName,
@@ -139,7 +141,10 @@ function WorkloadIdentityTable({
key={user.name}
className={
canOpenDetail
- ? "cursor-pointer hover:bg-control-bg focus-visible:outline-none focus-visible:bg-control-bg"
+ ? cn(
+ "cursor-pointer focus-visible:outline-none focus-visible:bg-control-bg",
+ listRowStateClassName
+ )
: undefined
}
tabIndex={canOpenDetail ? 0 : undefined}
diff --git a/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx b/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx
index 8326345d27..0434baf8b3 100644
--- a/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx
+++ b/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx
@@ -15,6 +15,7 @@ import { LearnMoreLink } from "@/react/components/LearnMoreLink";
import { PermissionGuard } from "@/react/components/PermissionGuard";
import { Alert } from "@/react/components/ui/alert";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { FormFieldGroup } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Select,
@@ -217,10 +218,10 @@ export const AIAugmentationSection = forwardRef<
</div>
<ComponentPermissionGuard
permissions={["bb.settings.get"]}
- className="flex-1 lg:px-4"
+ className="flex-1"
>
<PermissionGuard permissions={["bb.settings.set"]} display="block">
- <div className="flex-1 lg:px-4">
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
{isSaaSMode ? (
<Alert
variant="info"
@@ -229,7 +230,7 @@ export const AIAugmentationSection = forwardRef<
)}
/>
) : (
- <div className="mt-4 lg:mt-0 flex flex-col gap-y-4">
+ <>
{/* Enable toggle */}
<div>
<div className="flex items-center gap-x-2">
@@ -385,9 +386,9 @@ export const AIAugmentationSection = forwardRef<
</div>
</>
)}
- </div>
+ </>
)}
- </div>
+ </FormFieldGroup>
</PermissionGuard>
</ComponentPermissionGuard>
</div>
diff --git a/frontend/src/react/pages/settings/general/AccountSection.tsx b/frontend/src/react/pages/settings/general/AccountSection.tsx
index 1101d713bf..3b074361b0 100644
--- a/frontend/src/react/pages/settings/general/AccountSection.tsx
+++ b/frontend/src/react/pages/settings/general/AccountSection.tsx
@@ -18,8 +18,10 @@ import {
usePermissionCheck,
} from "@/react/components/PermissionGuard";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { FormFieldGroup } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { NumberInput } from "@/react/components/ui/number-input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { usePlanFeature, useServerState } from "@/react/hooks/useAppState";
import { useAppStore } from "@/react/stores/app";
import {
@@ -421,7 +423,7 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <div className="flex-1 lg:px-4">
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
{/* Sub-section 1: Disallow signup (non-SaaS only) */}
{!isSaaSMode && (
<>
@@ -767,40 +769,34 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
setTokenState((s) => ({ ...s, accessTokenDuration: v }))
}
/>
- <label className="flex items-center gap-x-1">
- <input
- type="radio"
- name="accessTokenTimeFormat"
+ <RadioGroup
+ className="gap-x-4"
+ value={tokenState.accessTokenTimeFormat}
+ onValueChange={(value) =>
+ setTokenState((s) => ({
+ ...s,
+ accessTokenTimeFormat:
+ value as TokenState["accessTokenTimeFormat"],
+ }))
+ }
+ >
+ <RadioGroupItem
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"
+ >
+ {t(
+ "settings.general.workspace.access-token-duration.minutes"
+ )}
+ </RadioGroupItem>
+ <RadioGroupItem
value="HOURS"
- checked={tokenState.accessTokenTimeFormat === "HOURS"}
disabled={disabled || !hasSecureTokenFeature}
- onChange={() =>
- setTokenState((s) => ({
- ...s,
- accessTokenTimeFormat: "HOURS",
- }))
- }
- />
- {t("settings.general.workspace.access-token-duration.hours")}
- </label>
+ >
+ {t(
+ "settings.general.workspace.access-token-duration.hours"
+ )}
+ </RadioGroupItem>
+ </RadioGroup>
</div>
</div>
@@ -835,38 +831,34 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
setTokenState((s) => ({ ...s, refreshTokenDuration: v }))
}
/>
- <label className="flex items-center gap-x-1">
- <input
- type="radio"
- name="refreshTokenTimeFormat"
+ <RadioGroup
+ className="gap-x-4"
+ value={tokenState.refreshTokenTimeFormat}
+ onValueChange={(value) =>
+ setTokenState((s) => ({
+ ...s,
+ refreshTokenTimeFormat:
+ value as TokenState["refreshTokenTimeFormat"],
+ }))
+ }
+ >
+ <RadioGroupItem
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"
+ >
+ {t(
+ "settings.general.workspace.refresh-token-duration.hours"
+ )}
+ </RadioGroupItem>
+ <RadioGroupItem
value="DAYS"
- checked={tokenState.refreshTokenTimeFormat === "DAYS"}
disabled={disabled || !hasSecureTokenFeature}
- onChange={() =>
- setTokenState((s) => ({
- ...s,
- refreshTokenTimeFormat: "DAYS",
- }))
- }
- />
- {t("settings.general.workspace.refresh-token-duration.days")}
- </label>
+ >
+ {t(
+ "settings.general.workspace.refresh-token-duration.days"
+ )}
+ </RadioGroupItem>
+ </RadioGroup>
</div>
</div>
@@ -908,7 +900,7 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
</span>
</div>
</div>
- </div>
+ </FormFieldGroup>
</PermissionGuard>
</div>
);
diff --git a/frontend/src/react/pages/settings/general/AnnouncementSection.test.tsx b/frontend/src/react/pages/settings/general/AnnouncementSection.test.tsx
new file mode 100644
index 0000000000..d03445afcb
--- /dev/null
+++ b/frontend/src/react/pages/settings/general/AnnouncementSection.test.tsx
@@ -0,0 +1,129 @@
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ getWorkspaceProfile: vi.fn(() => ({
+ announcement: {
+ text: "Bytebase now supports custom themes!",
+ link: "bytebase.com",
+ },
+ })),
+ updateWorkspaceProfile: vi.fn(async () => undefined),
+}));
+
+const t = vi.hoisted(
+ () => (key: string) =>
+ ({
+ "common.preview": "Preview",
+ "settings.general.workspace.announcement-alert-level.field.critical":
+ "Critical",
+ "settings.general.workspace.announcement-alert-level.field.info":
+ "Normal",
+ "settings.general.workspace.announcement-alert-level.field.warning":
+ "Warning",
+ "settings.general.workspace.announcement-text.description":
+ "To hide the announcement, leave it empty.",
+ "settings.general.workspace.announcement-text.placeholder":
+ "Bytebase now supports custom themes!",
+ "settings.general.workspace.announcement-text.self": "Title",
+ "settings.general.workspace.announcement-theme.background": "Background",
+ "settings.general.workspace.announcement-theme.custom": "Custom",
+ "settings.general.workspace.announcement-theme.description":
+ "Choose a built-in theme or define custom colors for the announcement banner.",
+ "settings.general.workspace.announcement-theme.self": "Theme",
+ "settings.general.workspace.announcement-theme.text": "Text",
+ "settings.general.workspace.extra-link.placeholder": "bytebase.com",
+ "settings.general.workspace.extra-link.self": "Link",
+ })[key] ?? key
+);
+
+vi.mock("react-i18next", () => ({
+ initReactI18next: {
+ type: "3rdParty",
+ init: vi.fn(),
+ },
+ useTranslation: () => ({
+ t,
+ }),
+}));
+
+vi.mock("@/react/components/FeatureBadge", () => ({
+ FeatureBadge: () => null,
+}));
+
+vi.mock("@/react/components/PermissionGuard", () => ({
+ PermissionGuard: ({ children }: { children: ReactElement }) => children,
+ usePermissionCheck: () => [true],
+}));
+
+vi.mock("@/react/hooks/useAppState", () => ({
+ usePlanFeature: () => true,
+}));
+
+vi.mock("@/react/stores/app", () => ({
+ useAppStore: {
+ getState: () => ({
+ getWorkspaceProfile: mocks.getWorkspaceProfile,
+ updateWorkspaceProfile: mocks.updateWorkspaceProfile,
+ }),
+ },
+}));
+
+vi.mock("@/utils", () => ({
+ colorToHex: () => "#4f46e5",
+ hexToColor: (hex: string) => ({ hex }),
+}));
+
+let AnnouncementSection: typeof import("./AnnouncementSection").AnnouncementSection;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ act(() => {
+ root.render(element);
+ });
+ return {
+ container,
+ unmount: () =>
+ act(() => {
+ root.unmount();
+ container.remove();
+ }),
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ ({ AnnouncementSection } = await import("./AnnouncementSection"));
+});
+
+describe("AnnouncementSection", () => {
+ test("keeps announcement sections as peers for consistent field group spacing", () => {
+ const { container, unmount } = renderIntoContainer(
+ <AnnouncementSection title="Announcement" onDirtyChange={() => {}} />
+ );
+
+ const fieldGroup = container.querySelector(
+ '[data-slot="form-field-group"]'
+ );
+ const sections = Array.from(fieldGroup?.children ?? []).filter(
+ (element) => element.getAttribute("data-slot") === "form-field"
+ );
+
+ expect(sections.map((section) => section.textContent)).toEqual([
+ expect.stringContaining("Theme"),
+ expect.stringContaining("Preview"),
+ expect.stringContaining("Title"),
+ expect.stringContaining("Link"),
+ ]);
+
+ unmount();
+ });
+});
diff --git a/frontend/src/react/pages/settings/general/AnnouncementSection.tsx b/frontend/src/react/pages/settings/general/AnnouncementSection.tsx
index bd2781a10a..d25c31a5ac 100644
--- a/frontend/src/react/pages/settings/general/AnnouncementSection.tsx
+++ b/frontend/src/react/pages/settings/general/AnnouncementSection.tsx
@@ -23,6 +23,14 @@ import {
usePermissionCheck,
} from "@/react/components/PermissionGuard";
import { ColorInput } from "@/react/components/ui/color-input";
+import {
+ FormControlGroup,
+ FormControlRow,
+ FormDescription,
+ FormField,
+ FormFieldGroup,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { SegmentedControl } from "@/react/components/ui/segmented-control";
import { usePlanFeature } from "@/react/hooks/useAppState";
@@ -174,140 +182,136 @@ export const AnnouncementSection = forwardRef<
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <div className="flex-1 lg:px-5">
- <div className="mt-5 flex flex-col gap-y-6 lg:mt-0">
- {/* Theme selector */}
- <div className="flex flex-col gap-y-3">
- <div>
- <p className="text-base font-semibold">
- {t("settings.general.workspace.announcement-theme.self")}
- </p>
- <p className="mt-1 text-sm text-gray-400">
- {t(
- "settings.general.workspace.announcement-theme.description"
- )}
- </p>
- </div>
-
- <SegmentedControl
- ariaLabel={t(
- "settings.general.workspace.announcement-theme.self"
- )}
- disabled={disabled}
- value={selectedTheme}
- onValueChange={onSelectTheme}
- options={THEME_OPTIONS.map((option) => ({
- value: option,
- label: themeOptionLabel(option),
- }))}
- />
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ {/* Theme selector */}
+ <FormField className="gap-y-3">
+ <div>
+ <FormLabel className="text-base font-semibold">
+ {t("settings.general.workspace.announcement-theme.self")}
+ </FormLabel>
+ <FormDescription className="mt-1 text-sm">
+ {t("settings.general.workspace.announcement-theme.description")}
+ </FormDescription>
+ </div>
- {selectedTheme === "custom" && (
- <div className="flex flex-col gap-y-3">
- <div className="flex items-center gap-x-3">
- <label
- className="w-28 text-sm text-control"
- htmlFor="announcement-theme-background"
- >
- {t(
- "settings.general.workspace.announcement-theme.background"
- )}
- </label>
- <ColorInput
- id="announcement-theme-background"
- value={state.theme.background}
- disabled={disabled}
- ariaLabel={t(
- "settings.general.workspace.announcement-theme.background"
- )}
- onChange={(hex) =>
- setState((s) => ({
- ...s,
- theme: { ...s.theme, background: hex },
- }))
- }
- />
- </div>
- <div className="flex items-center gap-x-3">
- <label
- className="w-28 text-sm text-control"
- htmlFor="announcement-theme-text"
- >
- {t("settings.general.workspace.announcement-theme.text")}
- </label>
- <ColorInput
- id="announcement-theme-text"
- value={state.theme.text}
- disabled={disabled}
- ariaLabel={t(
- "settings.general.workspace.announcement-theme.text"
- )}
- onChange={(hex) =>
- setState((s) => ({
- ...s,
- theme: { ...s.theme, text: hex },
- }))
- }
- />
- </div>
- </div>
+ <SegmentedControl
+ ariaLabel={t(
+ "settings.general.workspace.announcement-theme.self"
)}
+ disabled={disabled}
+ value={selectedTheme}
+ onValueChange={onSelectTheme}
+ options={THEME_OPTIONS.map((option) => ({
+ value: option,
+ label: themeOptionLabel(option),
+ }))}
+ />
- <div className="flex flex-col gap-y-2">
- <p className="text-sm font-medium text-control">
- {t("common.preview")}
- </p>
- <AnnouncementBanner
- text={previewText}
- link={state.link}
- background={state.theme.background}
- textColor={state.theme.text}
- interactive={false}
- className="rounded-xs"
- />
- </div>
- </div>
+ {selectedTheme === "custom" && (
+ <FormControlGroup>
+ <FormControlRow>
+ <FormLabel
+ className="w-28 text-sm text-control"
+ htmlFor="announcement-theme-background"
+ >
+ {t(
+ "settings.general.workspace.announcement-theme.background"
+ )}
+ </FormLabel>
+ <ColorInput
+ id="announcement-theme-background"
+ value={state.theme.background}
+ disabled={disabled}
+ ariaLabel={t(
+ "settings.general.workspace.announcement-theme.background"
+ )}
+ onChange={(hex) =>
+ setState((s) => ({
+ ...s,
+ theme: { ...s.theme, background: hex },
+ }))
+ }
+ />
+ </FormControlRow>
+ <FormControlRow>
+ <FormLabel
+ className="w-28 text-sm text-control"
+ htmlFor="announcement-theme-text"
+ >
+ {t("settings.general.workspace.announcement-theme.text")}
+ </FormLabel>
+ <ColorInput
+ id="announcement-theme-text"
+ value={state.theme.text}
+ disabled={disabled}
+ ariaLabel={t(
+ "settings.general.workspace.announcement-theme.text"
+ )}
+ onChange={(hex) =>
+ setState((s) => ({
+ ...s,
+ theme: { ...s.theme, text: hex },
+ }))
+ }
+ />
+ </FormControlRow>
+ </FormControlGroup>
+ )}
+ </FormField>
- {/* Announcement text */}
- <div>
- <p className="text-base font-semibold">
- {t("settings.general.workspace.announcement-text.self")}
- </p>
- <p className="mb-3 text-sm text-gray-400">
- {t("settings.general.workspace.announcement-text.description")}
- </p>
- <Input
- value={state.text}
- className="w-full"
- placeholder={t(
- "settings.general.workspace.announcement-text.placeholder"
- )}
- disabled={disabled}
- onChange={(e) =>
- setState((s) => ({ ...s, text: e.target.value }))
- }
- />
- </div>
+ <FormField className="gap-y-2">
+ <p className="text-sm font-medium text-control">
+ {t("common.preview")}
+ </p>
+ <AnnouncementBanner
+ text={previewText}
+ link={state.link}
+ background={state.theme.background}
+ textColor={state.theme.text}
+ interactive={false}
+ className="rounded-xs"
+ />
+ </FormField>
- {/* Extra link */}
- <div>
- <p className="mb-2 text-base font-semibold">
- {t("settings.general.workspace.extra-link.self")}
- </p>
- <Input
- value={state.link}
- className="w-full"
- placeholder={t(
- "settings.general.workspace.extra-link.placeholder"
- )}
- disabled={disabled}
- onChange={(e) =>
- setState((s) => ({ ...s, link: e.target.value }))
- }
- />
- </div>
- </div>
- </div>
+ {/* Announcement text */}
+ <FormField>
+ <FormLabel className="text-base font-semibold">
+ {t("settings.general.workspace.announcement-text.self")}
+ </FormLabel>
+ <FormDescription className="text-sm">
+ {t("settings.general.workspace.announcement-text.description")}
+ </FormDescription>
+ <Input
+ value={state.text}
+ className="w-full"
+ placeholder={t(
+ "settings.general.workspace.announcement-text.placeholder"
+ )}
+ disabled={disabled}
+ onChange={(e) =>
+ setState((s) => ({ ...s, text: e.target.value }))
+ }
+ />
+ </FormField>
+
+ {/* Extra link */}
+ <FormField>
+ <FormLabel className="text-base font-semibold">
+ {t("settings.general.workspace.extra-link.self")}
+ </FormLabel>
+ <Input
+ value={state.link}
+ className="w-full"
+ placeholder={t(
+ "settings.general.workspace.extra-link.placeholder"
+ )}
+ disabled={disabled}
+ onChange={(e) =>
+ setState((s) => ({ ...s, link: e.target.value }))
+ }
+ />
+ </FormField>
+ </FormFieldGroup>
</PermissionGuard>
</div>
);
diff --git a/frontend/src/react/pages/settings/general/AuditLogSection.tsx b/frontend/src/react/pages/settings/general/AuditLogSection.tsx
index d1d2315005..c5153be6a1 100644
--- a/frontend/src/react/pages/settings/general/AuditLogSection.tsx
+++ b/frontend/src/react/pages/settings/general/AuditLogSection.tsx
@@ -11,6 +11,7 @@ import {
import { useTranslation } from "react-i18next";
import { FeatureBadge } from "@/react/components/FeatureBadge";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { FormFieldGroup } from "@/react/components/ui/form";
import { usePlanFeature } from "@/react/hooks/useAppState";
import { useAppStore } from "@/react/stores/app";
import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
@@ -82,7 +83,7 @@ export const AuditLogSection = forwardRef<SectionHandle, AuditLogSectionProps>(
<FeatureBadge feature={PlanFeature.FEATURE_AUDIT_LOG} />
</div>
</div>
- <div className="flex-1 lg:px-4 flex flex-col gap-y-6">
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
{/* Audit log stdout toggle */}
<label className="flex items-start gap-x-3 cursor-pointer">
<Checkbox
@@ -125,7 +126,7 @@ export const AuditLogSection = forwardRef<SectionHandle, AuditLogSectionProps>(
</div>
</div>
</label>
- </div>
+ </FormFieldGroup>
</div>
);
}
diff --git a/frontend/src/react/pages/settings/general/BrandingSection.tsx b/frontend/src/react/pages/settings/general/BrandingSection.tsx
index e2ebc10a0b..c2cba6e60a 100644
--- a/frontend/src/react/pages/settings/general/BrandingSection.tsx
+++ b/frontend/src/react/pages/settings/general/BrandingSection.tsx
@@ -16,6 +16,7 @@ import {
usePermissionCheck,
} from "@/react/components/PermissionGuard";
import { Button } from "@/react/components/ui/button";
+import { FormFieldGroup } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { usePlanFeature, useWorkspace } from "@/react/hooks/useAppState";
import { useAppStore } from "@/react/stores/app";
@@ -176,7 +177,7 @@ export const BrandingSection = forwardRef<SectionHandle, BrandingSectionProps>(
<h1 className="text-2xl font-bold">{title}</h1>
</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">
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
{/* Workspace ID */}
<div>
<label className="text-base font-semibold">
@@ -275,7 +276,7 @@ export const BrandingSection = forwardRef<SectionHandle, BrandingSectionProps>(
</div>
)}
</div>
- </div>
+ </FormFieldGroup>
</PermissionGuard>
</div>
);
diff --git a/frontend/src/react/pages/settings/general/GeneralPage.tsx b/frontend/src/react/pages/settings/general/GeneralPage.tsx
index 7d5a4ff20c..fa2e0ac20f 100644
--- a/frontend/src/react/pages/settings/general/GeneralPage.tsx
+++ b/frontend/src/react/pages/settings/general/GeneralPage.tsx
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { PermissionGuard } from "@/react/components/PermissionGuard";
import { Button } from "@/react/components/ui/button";
+import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
import { useServerState } from "@/react/hooks/useAppState";
import { useUnsavedChangesGuard } from "@/react/hooks/useUnsavedChangesGuard";
import { pushNotification } from "@/store";
@@ -207,14 +208,15 @@ export function GeneralPage() {
{isSaaSMode && <DangerZoneSection />}
{isDirty && (
- <div className="sticky bottom-0 z-10 -mb-4">
- <div className="flex justify-end gap-x-4 w-full py-4 border-t border-block-border bg-background">
+ <StickyActionFooter
+ className="-mb-4"
+ left={
<Button variant="outline" onClick={handleRevert}>
{t("common.cancel")}
</Button>
- <Button onClick={handleUpdate}>{t("common.update")}</Button>
- </div>
- </div>
+ }
+ right={<Button onClick={handleUpdate}>{t("common.update")}</Button>}
+ />
)}
</div>
);
diff --git a/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts b/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts
new file mode 100644
index 0000000000..2032fc88e3
--- /dev/null
+++ b/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts
@@ -0,0 +1,37 @@
+import { readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { describe, expect, test } from "vitest";
+
+const sectionDir = dirname(fileURLToPath(import.meta.url));
+
+const configurableSections = [
+ "AccountSection.tsx",
+ "AIAugmentationSection.tsx",
+ "AnnouncementSection.tsx",
+ "AuditLogSection.tsx",
+ "BrandingSection.tsx",
+ "GeneralSection.tsx",
+ "ProductImprovementSection.tsx",
+ "SecuritySection.tsx",
+ "SQLEditorSection.tsx",
+] as const;
+
+describe("GeneralPage section layout", () => {
+ test("uses the shared field group wrapper for configurable section content", () => {
+ for (const file of configurableSections) {
+ const source = readFileSync(join(sectionDir, file), "utf8");
+
+ expect(source, file).toContain("FormFieldGroup");
+ expect(source, file).toContain('className="flex-1 mt-4 lg:px-4 lg:mt-0"');
+ }
+ });
+
+ test("uses the shared RadioGroup for AccountSection radio controls", () => {
+ const source = readFileSync(join(sectionDir, "AccountSection.tsx"), "utf8");
+
+ expect(source).toContain("RadioGroup");
+ expect(source).toContain("RadioGroupItem");
+ expect(source).not.toContain(`type=${JSON.stringify("radio")}`);
+ });
+});
diff --git a/frontend/src/react/pages/settings/general/GeneralSection.tsx b/frontend/src/react/pages/settings/general/GeneralSection.tsx
index f7fba0627c..9de33452d6 100644
--- a/frontend/src/react/pages/settings/general/GeneralSection.tsx
+++ b/frontend/src/react/pages/settings/general/GeneralSection.tsx
@@ -21,7 +21,14 @@ import {
DialogContent,
DialogTitle,
} from "@/react/components/ui/dialog";
+import {
+ FormDescription,
+ FormField,
+ FormFieldGroup,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
+import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import { useServerState } from "@/react/hooks/useAppState";
import { router } from "@/react/router";
import { SQL_EDITOR_HOME_MODULE } from "@/react/router/handles";
@@ -133,29 +140,29 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <div className="flex-1 mt-4 lg:px-4 lg:mt-0 flex flex-col gap-y-6">
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
{/* Database change mode */}
- <div>
+ <FormField>
<div className="mb-4 text-base font-semibold">
{t("settings.general.workspace.default-landing-page.self")}
</div>
- <div className="w-full flex flex-col gap-4">
- <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,
- }))
- }
- />
+ <RadioGroup
+ className="flex-col items-stretch gap-4"
+ value={String(state.databaseChangeMode)}
+ onValueChange={(value) =>
+ setState((s) => ({
+ ...s,
+ databaseChangeMode: Number(value),
+ }))
+ }
+ >
+ <RadioGroupItem
+ value={String(DatabaseChangeMode.PIPELINE)}
+ disabled={!canEdit}
+ className="items-start gap-x-3"
+ contentClassName="flex flex-col gap-1"
+ radioClassName="mt-1"
+ >
<div className="flex flex-col gap-1">
<div className="textinfo font-semibold">
{t(
@@ -168,23 +175,14 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(
)}
</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,
- }))
- }
- />
+ </RadioGroupItem>
+ <RadioGroupItem
+ value={String(DatabaseChangeMode.EDITOR)}
+ disabled={!canEdit}
+ className="items-start gap-x-3"
+ contentClassName="flex flex-col gap-1"
+ radioClassName="mt-1"
+ >
<div className="flex flex-col gap-1">
<div className="textinfo font-semibold">
{t(
@@ -197,29 +195,26 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(
)}
</div>
</div>
- </label>
- </div>
- </div>
+ </RadioGroupItem>
+ </RadioGroup>
+ </FormField>
{/* External URL — hidden in SaaS/cloud mode */}
{!isSaaSMode && (
- <div>
- <label className="flex items-center gap-x-2">
- <span className="text-base font-semibold">
- {t("settings.general.workspace.external-url.self")}
- </span>
- </label>
- <div className="mb-3 text-sm text-control-placeholder">
+ <FormField>
+ <FormLabel className="text-base font-semibold">
+ {t("settings.general.workspace.external-url.self")}
+ </FormLabel>
+ <FormDescription className="text-sm">
{t("settings.general.workspace.external-url.description")}{" "}
<LearnMoreLink
href="https://docs.bytebase.com/get-started/self-host/external-url?source=console"
className="text-accent"
/>
- </div>
+ </FormDescription>
{externalUrlFromFlag && (
<Alert
variant="info"
- className="mb-3"
description={t(
"settings.general.workspace.external-url.cannot-edit-flag"
)}
@@ -233,9 +228,9 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(
setState((s) => ({ ...s, externalUrl: e.target.value }))
}
/>
- </div>
+ </FormField>
)}
- </div>
+ </FormFieldGroup>
</PermissionGuard>
{/* Modal after switching to Editor mode */}
diff --git a/frontend/src/react/pages/settings/general/ProductImprovementSection.tsx b/frontend/src/react/pages/settings/general/ProductImprovementSection.tsx
index fb6ff1d0b0..d14c640dfb 100644
--- a/frontend/src/react/pages/settings/general/ProductImprovementSection.tsx
+++ b/frontend/src/react/pages/settings/general/ProductImprovementSection.tsx
@@ -9,6 +9,7 @@ import {
} from "react";
import { useTranslation } from "react-i18next";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { FormFieldGroup } from "@/react/components/ui/form";
import { useAppStore } from "@/react/stores/app";
import type { SectionHandle } from "./useSettingSection";
@@ -71,7 +72,7 @@ export const ProductImprovementSection = forwardRef<
<div className="text-left lg:w-1/4">
<h1 className="text-2xl font-bold">{title}</h1>
</div>
- <div className="flex-1 lg:px-4">
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
<label className="flex items-start gap-x-3 cursor-pointer">
<Checkbox
checked={state.enableMetricCollection}
@@ -93,7 +94,7 @@ export const ProductImprovementSection = forwardRef<
</div>
</div>
</label>
- </div>
+ </FormFieldGroup>
</div>
);
});
diff --git a/frontend/src/react/pages/settings/general/SQLEditorSection.tsx b/frontend/src/react/pages/settings/general/SQLEditorSection.tsx
index 289ff34870..56d86bcc16 100644
--- a/frontend/src/react/pages/settings/general/SQLEditorSection.tsx
+++ b/frontend/src/react/pages/settings/general/SQLEditorSection.tsx
@@ -34,6 +34,7 @@ import type {
} from "@/react/components/sql-editor/theme/types";
import { resolveWorkspaceTheme } from "@/react/components/sql-editor/theme/useWorkspaceSQLEditorTheme";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { FormFieldGroup } from "@/react/components/ui/form";
import { NumberInput } from "@/react/components/ui/number-input";
import { SegmentedControl } from "@/react/components/ui/segmented-control";
import {
@@ -420,7 +421,7 @@ export const SQLEditorSection = forwardRef<
<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">
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
{/* Data Export toggle */}
<PermissionGuard permissions={["bb.policies.update"]} display="block">
<div className="w-full inline-flex items-center gap-x-2">
@@ -643,7 +644,7 @@ export const SQLEditorSection = forwardRef<
</div>
</div>
</PermissionGuard>
- </div>
+ </FormFieldGroup>
</div>
);
});
diff --git a/frontend/src/react/pages/settings/general/SecuritySection.tsx b/frontend/src/react/pages/settings/general/SecuritySection.tsx
index 58da05fa87..1d0f7552b8 100644
--- a/frontend/src/react/pages/settings/general/SecuritySection.tsx
+++ b/frontend/src/react/pages/settings/general/SecuritySection.tsx
@@ -17,6 +17,7 @@ import {
usePermissionCheck,
} from "@/react/components/PermissionGuard";
import { Checkbox } from "@/react/components/ui/checkbox";
+import { FormFieldGroup } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { usePlanFeature } from "@/react/hooks/useAppState";
import { useAppStore } from "@/react/stores/app";
@@ -217,7 +218,7 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <div className="flex-1 lg:px-4 flex flex-col gap-y-6">
+ <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
{/* Watermark */}
<div>
<div className="flex items-center gap-x-2">
@@ -387,7 +388,7 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(
</div>
</div>
</div>
- </div>
+ </FormFieldGroup>
</PermissionGuard>
</div>
);
diff --git a/frontend/src/react/pages/settings/requestRoleButton.test.ts b/frontend/src/react/pages/settings/requestRoleButton.test.ts
index 9a2ba9810c..7e1b175d00 100644
--- a/frontend/src/react/pages/settings/requestRoleButton.test.ts
+++ b/frontend/src/react/pages/settings/requestRoleButton.test.ts
@@ -2,7 +2,10 @@ import { describe, expect, test } from "vitest";
import { getRequestRoleButtonState } from "./requestRoleButton";
describe("getRequestRoleButtonState", () => {
+ const t = (key: string) => `translated:${key}`;
+
const base = {
+ t,
projectName: "projects/demo",
projectReady: true,
allowRequestRole: true,
@@ -29,9 +32,7 @@ describe("getRequestRoleButtonState", () => {
})
).toEqual({
visible: true,
- disabledReason: {
- kind: "loading",
- },
+ disabledReason: "translated:common.loading",
});
});
@@ -43,9 +44,8 @@ describe("getRequestRoleButtonState", () => {
})
).toEqual({
visible: true,
- disabledReason: {
- kind: "allow-request-role-disabled",
- },
+ disabledReason:
+ "translated:project.members.request-role.disabled-reason.allow-request-role-disabled",
});
});
@@ -56,10 +56,7 @@ describe("getRequestRoleButtonState", () => {
hasFullProjectAccess: true,
})
).toEqual({
- visible: true,
- disabledReason: {
- kind: "can-grant-access-directly",
- },
+ visible: false,
});
});
@@ -81,9 +78,8 @@ describe("getRequestRoleButtonState", () => {
})
).toEqual({
visible: true,
- disabledReason: {
- kind: "feature-unavailable",
- },
+ disabledReason:
+ "translated:project.members.request-role.disabled-reason.feature-unavailable",
});
});
diff --git a/frontend/src/react/pages/settings/requestRoleButton.ts b/frontend/src/react/pages/settings/requestRoleButton.ts
index e2b14c43b1..29e4b10347 100644
--- a/frontend/src/react/pages/settings/requestRoleButton.ts
+++ b/frontend/src/react/pages/settings/requestRoleButton.ts
@@ -5,21 +5,8 @@ export const REQUEST_ROLE_REQUIRED_PERMISSIONS = [
"bb.roles.list",
] as const satisfies readonly Permission[];
-export type RequestRoleButtonDisabledReason =
- | {
- kind: "loading";
- }
- | {
- kind: "allow-request-role-disabled";
- }
- | {
- kind: "can-grant-access-directly";
- }
- | {
- kind: "feature-unavailable";
- };
-
interface RequestRoleButtonStateArgs {
+ readonly t: (key: string) => string;
readonly projectName?: string;
readonly projectReady: boolean;
readonly allowRequestRole: boolean;
@@ -33,10 +20,11 @@ interface RequestRoleButtonStateArgs {
interface RequestRoleButtonState {
readonly visible: boolean;
- readonly disabledReason?: RequestRoleButtonDisabledReason;
+ readonly disabledReason?: string;
}
export const getRequestRoleButtonState = ({
+ t,
projectName,
projectReady,
allowRequestRole,
@@ -52,36 +40,31 @@ export const getRequestRoleButtonState = ({
if (!projectReady) {
return {
visible: true,
- disabledReason: {
- kind: "loading",
- },
+ disabledReason: t("common.loading"),
};
}
if (!allowRequestRole) {
return {
visible: true,
- disabledReason: {
- kind: "allow-request-role-disabled",
- },
+ disabledReason: t(
+ "project.members.request-role.disabled-reason.allow-request-role-disabled"
+ ),
};
}
if (hasFullProjectAccess) {
return {
- visible: true,
- disabledReason: {
- kind: "can-grant-access-directly",
- },
+ visible: false,
};
}
if (!hasRequestRoleFeature) {
return {
visible: true,
- disabledReason: {
- kind: "feature-unavailable",
- },
+ disabledReason: t(
+ "project.members.request-role.disabled-reason.feature-unavailable"
+ ),
};
}