Skip to content

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

refactor: form layout (#20763)

ecmadao402ce151ea59
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 2ea1fffa87..44db744b65 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -432,7 +432,6 @@
"select-all": "Select all",
"selected": "selected",
"sensitive-placeholder": "Sensitive - write only",
- "setting": "Setting",
"settings": "Settings",
"share": "Share",
"show-less": "Show less",
@@ -495,6 +494,7 @@
"create-db": {
"cluster": "Cluster",
"database-owner-name": "Database owner name",
+ "issue-title": "Issue title",
"new-collection-name": "New Collection Name",
"new-database-name": "New database name",
"reserved-db-error": "{{databaseName}} is a reserved name"
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 601a79faea..b00e64b013 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -432,7 +432,6 @@
"select-all": "Seleccionar todo",
"selected": "seleccionado",
"sensitive-placeholder": "Sensible - solo escritura",
- "setting": "Configuración",
"settings": "Configuraciones",
"share": "Compartir",
"show-less": "Mostrar menos",
@@ -495,6 +494,7 @@
"create-db": {
"cluster": "Clúster",
"database-owner-name": "Nombre del propietario de la base de datos",
+ "issue-title": "Título del problema",
"new-collection-name": "Nuevo Nombre de Colección",
"new-database-name": "Nuevo nombre de la base de datos",
"reserved-db-error": "{{databaseName}} es un nombre reservado"
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index dd3af50111..35170caf69 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -432,7 +432,6 @@
"select-all": "すべて選択",
"selected": "選択済み",
"sensitive-placeholder": "機密データ - 書き込みのみ",
- "setting": "設定",
"settings": "設定",
"share": "共有",
"show-less": "折りたたむ",
@@ -495,6 +494,7 @@
"create-db": {
"cluster": "集まる",
"database-owner-name": "データベース所有者",
+ "issue-title": "課題タイトル",
"new-collection-name": "新しいコレクション名",
"new-database-name": "新しいデータベース名",
"reserved-db-error": "{{databaseName}} は予約された名前です"
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 843b76f67c..47d3e42c9e 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -432,7 +432,6 @@
"select-all": "Chọn tất cả",
"selected": "đã chọn",
"sensitive-placeholder": "Nhạy cảm - Chỉ ghi",
- "setting": "Cài đặt",
"settings": "Cài đặt",
"share": "Chia sẻ",
"show-less": "Thu gọn",
@@ -495,6 +494,7 @@
"create-db": {
"cluster": "Cụm",
"database-owner-name": "Tên chủ sở hữu cơ sở dữ liệu",
+ "issue-title": "Tiêu đề vấn đề",
"new-collection-name": "Tên bộ sưu tập mới",
"new-database-name": "Tên cơ sở dữ liệu mới",
"reserved-db-error": "{{databaseName}} là một tên dành riêng"
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 78ce4f0380..5ae3568695 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -432,7 +432,6 @@
"select-all": "全选",
"selected": "已选择",
"sensitive-placeholder": "敏感数据 - 仅写入",
- "setting": "设置",
"settings": "设置",
"share": "分享",
"show-less": "收起",
@@ -495,6 +494,7 @@
"create-db": {
"cluster": "集群",
"database-owner-name": "数据库所有者",
+ "issue-title": "工单标题",
"new-collection-name": "新集合名称",
"new-database-name": "新数据库名称",
"reserved-db-error": "{{databaseName}} 是一个预留名称"
diff --git a/frontend/src/react/components/CreateWorkloadIdentitySheet.test.tsx b/frontend/src/react/components/CreateWorkloadIdentitySheet.test.tsx
index e3f06bbc21..12a70c8f58 100644
--- a/frontend/src/react/components/CreateWorkloadIdentitySheet.test.tsx
+++ b/frontend/src/react/components/CreateWorkloadIdentitySheet.test.tsx
@@ -115,4 +115,49 @@ describe("CreateWorkloadIdentitySheet", () => {
root.unmount();
});
});
+
+ test("places repository and branch helper text under the field title", () => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+
+ act(() => {
+ root.render(
+ <CreateWorkloadIdentitySheet
+ open
+ onClose={() => undefined}
+ onCreated={() => undefined}
+ />
+ );
+ });
+
+ const fields = Array.from(
+ container.querySelectorAll('[data-slot="form-field"]')
+ );
+ const repositoryField = fields.find((field) =>
+ field.textContent?.includes("settings.members.workload-identity-repo")
+ );
+ const branchField = fields.find((field) =>
+ field.textContent?.includes("settings.members.workload-identity-branch")
+ );
+
+ for (const field of [repositoryField, branchField]) {
+ expect(field).toBeTruthy();
+ const header = field?.querySelector('[data-slot="form-field-header"]');
+ const input = field?.querySelector("input");
+
+ expect(header).toBeTruthy();
+ expect(header?.textContent).toContain("hint");
+ expect(
+ header && input
+ ? Node.DOCUMENT_POSITION_FOLLOWING &
+ header.compareDocumentPosition(input)
+ : 0
+ ).toBeTruthy();
+ }
+
+ act(() => {
+ root.unmount();
+ });
+ });
});
diff --git a/frontend/src/react/components/CreateWorkloadIdentitySheet.tsx b/frontend/src/react/components/CreateWorkloadIdentitySheet.tsx
index 6bb4f5f944..bda6656698 100644
--- a/frontend/src/react/components/CreateWorkloadIdentitySheet.tsx
+++ b/frontend/src/react/components/CreateWorkloadIdentitySheet.tsx
@@ -5,11 +5,7 @@ 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 { FormField } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Sheet,
@@ -441,8 +437,7 @@ function WorkloadIdentityForm({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Title */}
- <FormField>
- <FormLabel>{t("common.name")}</FormLabel>
+ <FormField title={<>{t("common.name")}</>}>
<Input
value={title}
onChange={(e) => setTitle(e.target.value)}
@@ -453,11 +448,14 @@ function WorkloadIdentityForm({
</FormField>
{/* Email */}
- <FormField>
- <FormLabel>
- {t("common.email")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.email")}
+ <span className="ml-0.5 text-error">*</span>
+ </>
+ }
+ >
{isEditMode ? (
<Input value={workloadIdentity!.email} disabled />
) : (
@@ -478,18 +476,20 @@ function WorkloadIdentityForm({
{/* Roles (create mode only) */}
{!isEditMode && canSetRoles && (
- <FormField>
- <FormLabel>{t("settings.members.table.roles")}</FormLabel>
+ <FormField title={<>{t("settings.members.table.roles")}</>}>
<RoleSelect value={roles} onChange={setRoles} disabled={false} />
</FormField>
)}
{/* Platform */}
- <FormField>
- <FormLabel>
- {t("settings.members.workload-identity-platform")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("settings.members.workload-identity-platform")}
+ <span className="ml-0.5 text-error">*</span>
+ </>
+ }
+ >
<select
value={providerType}
onChange={(e) =>
@@ -511,13 +511,16 @@ function WorkloadIdentityForm({
</FormField>
{/* Owner / Group */}
- <FormField>
- <FormLabel>
- {isGitLab
- ? t("settings.members.workload-identity-group")
- : t("settings.members.workload-identity-owner")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {isGitLab
+ ? t("settings.members.workload-identity-group")
+ : t("settings.members.workload-identity-owner")}
+ <span className="ml-0.5 text-error">*</span>
+ </>
+ }
+ >
<Input
value={owner}
onChange={(e) => setOwner(e.target.value)}
@@ -528,12 +531,22 @@ function WorkloadIdentityForm({
</FormField>
{/* Repository / Project */}
- <FormField>
- <FormLabel>
- {isGitLab
- ? t("settings.members.workload-identity-project")
- : t("settings.members.workload-identity-repo")}
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {isGitLab
+ ? t("settings.members.workload-identity-project")
+ : t("settings.members.workload-identity-repo")}
+ </>
+ }
+ description={
+ <>
+ {isGitLab
+ ? t("settings.members.workload-identity-project-hint")
+ : t("settings.members.workload-identity-repo-hint")}
+ </>
+ }
+ >
<Input
value={repo}
onChange={(e) => setRepo(e.target.value)}
@@ -541,19 +554,19 @@ function WorkloadIdentityForm({
maxLength={200}
autoComplete="off"
/>
- <FormDescription>
- {isGitLab
- ? t("settings.members.workload-identity-project-hint")
- : t("settings.members.workload-identity-repo-hint")}
- </FormDescription>
</FormField>
{/* Allowed Branches/Tags (GitLab only) */}
{isGitLab && (
- <FormField>
- <FormLabel>
- {t("settings.members.workload-identity-allowed-branches-tags")}
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t(
+ "settings.members.workload-identity-allowed-branches-tags"
+ )}
+ </>
+ }
+ >
<select
value={refType}
onChange={(e) => setRefType(e.target.value as RefType)}
@@ -574,12 +587,22 @@ function WorkloadIdentityForm({
{/* Branch / Tag */}
{showBranchField && (
- <FormField>
- <FormLabel>
- {isTagRefType
- ? t("settings.members.workload-identity-tag")
- : t("settings.members.workload-identity-branch")}
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {isTagRefType
+ ? t("settings.members.workload-identity-tag")
+ : t("settings.members.workload-identity-branch")}
+ </>
+ }
+ description={
+ <>
+ {isTagRefType
+ ? t("settings.members.workload-identity-tag-hint")
+ : t("settings.members.workload-identity-branch-hint")}
+ </>
+ }
+ >
<Input
value={branch}
onChange={(e) => setBranch(e.target.value)}
@@ -587,11 +610,6 @@ function WorkloadIdentityForm({
maxLength={200}
autoComplete="off"
/>
- <FormDescription>
- {isTagRefType
- ? t("settings.members.workload-identity-tag-hint")
- : t("settings.members.workload-identity-branch-hint")}
- </FormDescription>
</FormField>
)}
@@ -599,30 +617,30 @@ function WorkloadIdentityForm({
{showAdvanced && (
<div className="flex flex-col gap-y-6 pt-6 border-t">
{/* Issuer URL / GitLab URL */}
- <FormField>
- <FormLabel>
- {isGitLab
+ <FormField
+ title={
+ isGitLab
? t("settings.members.workload-identity-gitlab-url")
- : t("settings.members.workload-identity-issuer")}
- </FormLabel>
+ : t("settings.members.workload-identity-issuer")
+ }
+ description={
+ isGitLab
+ ? t("settings.members.workload-identity-gitlab-url-hint")
+ : undefined
+ }
+ >
<Input
value={issuerUrl}
onChange={(e) => setIssuerUrl(e.target.value)}
maxLength={500}
autoComplete="off"
/>
- {isGitLab && (
- <FormDescription>
- {t("settings.members.workload-identity-gitlab-url-hint")}
- </FormDescription>
- )}
</FormField>
{/* Audience */}
- <FormField>
- <FormLabel>
- {t("settings.members.workload-identity-audience")}
- </FormLabel>
+ <FormField
+ title={<>{t("settings.members.workload-identity-audience")}</>}
+ >
<Input
value={audience}
onChange={(e) => setAudience(e.target.value)}
@@ -632,10 +650,9 @@ function WorkloadIdentityForm({
</FormField>
{/* Subject Pattern */}
- <FormField>
- <FormLabel>
- {t("settings.members.workload-identity-subject")}
- </FormLabel>
+ <FormField
+ title={<>{t("settings.members.workload-identity-subject")}</>}
+ >
<Input
value={subjectPattern}
onChange={(e) => setSubjectPattern(e.target.value)}
diff --git a/frontend/src/react/components/CustomApproval/RuleEditSheet.tsx b/frontend/src/react/components/CustomApproval/RuleEditSheet.tsx
index 106c01666f..db6714435d 100644
--- a/frontend/src/react/components/CustomApproval/RuleEditSheet.tsx
+++ b/frontend/src/react/components/CustomApproval/RuleEditSheet.tsx
@@ -13,6 +13,11 @@ import {
import { ExprEditor } from "@/react/components/ExprEditor";
import { Alert } from "@/react/components/ui/alert";
import { Button } from "@/react/components/ui/button";
+import {
+ FormField,
+ FormFieldGroup,
+ FormTitle,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Sheet,
@@ -172,7 +177,7 @@ export function RuleEditSheet({
<SheetTitle>{t("custom-approval.rule.self")}</SheetTitle>
</SheetHeader>
- <SheetBody className="gap-y-4">
+ <SheetBody>
{/* Fallback hint */}
{isFallback && (
<Alert
@@ -183,106 +188,121 @@ export function RuleEditSheet({
/>
)}
- {/* Template presets (create mode only) */}
- {mode === "create" && (
- <div className="flex flex-col gap-y-2">
- <h3 className="text-sm font-medium text-control">
- {t("custom-approval.approval-flow.template.presets-title")}
- </h3>
- <div className="flex flex-wrap gap-2">
- {templates.map((template, index) => (
- <Button
- key={index}
- variant="outline"
- size="sm"
- disabled={!allowAdmin}
- title={template.description()}
- onClick={() => applyTemplate(template)}
- >
- {template.title()}
- </Button>
- ))}
- </div>
- </div>
- )}
+ <FormFieldGroup>
+ {/* Template presets (create mode only) */}
+ {mode === "create" && (
+ <FormField
+ title={t(
+ "custom-approval.approval-flow.template.presets-title"
+ )}
+ >
+ <div className="flex flex-wrap gap-2">
+ {templates.map((template, index) => (
+ <Button
+ key={index}
+ variant="outline"
+ size="sm"
+ disabled={!allowAdmin}
+ title={template.description()}
+ onClick={() => applyTemplate(template)}
+ >
+ {template.title()}
+ </Button>
+ ))}
+ </div>
+ </FormField>
+ )}
- {/* Title field */}
- <div className="flex flex-col gap-y-2">
- <h3 className="text-sm font-medium text-control">
- {t("common.title")} <span className="text-error">*</span>
- </h3>
- <Input
- value={title}
- placeholder={t("common.title")}
- disabled={!allowAdmin}
- onChange={(e) => setTitle(e.target.value)}
- />
- </div>
+ {/* Title field */}
+ <FormField>
+ <FormTitle id="approval-rule-title-title">
+ {t("common.title")} <span className="text-error">*</span>
+ </FormTitle>
+ <Input
+ id="approval-rule-title"
+ aria-labelledby="approval-rule-title-title"
+ value={title}
+ placeholder={t("common.title")}
+ disabled={!allowAdmin}
+ onChange={(e) => setTitle(e.target.value)}
+ />
+ </FormField>
- {/* Description field */}
- <div className="flex flex-col gap-y-2">
- <h3 className="text-sm font-medium text-control">
- {t("common.description")}
- </h3>
- <Textarea
- value={description}
- placeholder={t("common.description")}
- disabled={!allowAdmin}
- rows={2}
- className="min-h-0 resize-none"
- onChange={(e) => setDescription(e.target.value)}
- />
- </div>
+ {/* Description field */}
+ <FormField>
+ <FormTitle id="approval-rule-description-title">
+ {t("common.description")}
+ </FormTitle>
+ <Textarea
+ id="approval-rule-description"
+ aria-labelledby="approval-rule-description-title"
+ value={description}
+ placeholder={t("common.description")}
+ disabled={!allowAdmin}
+ rows={2}
+ className="min-h-0 resize-none"
+ onChange={(e) => setDescription(e.target.value)}
+ />
+ </FormField>
- {/* Condition editor */}
- <div className="flex flex-1 flex-col gap-y-2">
- <h3 className="text-sm font-medium text-control">
- {t("cel.condition.self")} <span className="text-error">*</span>
- </h3>
- <div className="text-sm text-control-light">
- {t("cel.condition.description-tips")}
- </div>
- <ExprEditor
- expr={conditionExpr}
- readonly={!allowAdmin}
- factorList={factorList}
- optionConfigMap={optionConfigMap}
- onUpdate={setConditionExpr}
- />
- </div>
+ {/* Condition editor */}
+ <FormField
+ title={
+ <>
+ {t("cel.condition.self")}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ description={t("cel.condition.description-tips")}
+ className="flex-1"
+ >
+ <ExprEditor
+ expr={conditionExpr}
+ readonly={!allowAdmin}
+ factorList={factorList}
+ optionConfigMap={optionConfigMap}
+ onUpdate={setConditionExpr}
+ />
+ </FormField>
- {/* Approval flow section */}
- <div className="flex flex-col gap-y-2">
- <div className="flex items-center justify-between">
- <h3 className="text-sm font-medium text-control">
- {t("custom-approval.approval-flow.node.nodes")}
- {!noApprovalRequired && <span className="text-error"> *</span>}
- </h3>
- <div className="flex items-center gap-x-2">
- <Switch
- checked={noApprovalRequired}
- onCheckedChange={handleNoApprovalRequiredChange}
- disabled={!allowAdmin}
- />
- <span className="text-sm text-control-light">
- {t("custom-approval.approval-flow.skip")}
- </span>
- </div>
- </div>
- {!noApprovalRequired && (
- <>
- <div className="text-sm text-control-light">
- {t("custom-approval.approval-flow.node.description")}
+ {/* Approval flow section */}
+ <FormField
+ title={
+ <div className="flex items-center justify-between gap-x-4">
+ <span>
+ {t("custom-approval.approval-flow.node.nodes")}
+ {!noApprovalRequired && (
+ <span className="text-error"> *</span>
+ )}
+ </span>
+ <div className="flex items-center gap-x-2">
+ <Switch
+ checked={noApprovalRequired}
+ onCheckedChange={handleNoApprovalRequiredChange}
+ disabled={!allowAdmin}
+ />
+ <span className="text-sm font-normal text-control-placeholder">
+ {t("custom-approval.approval-flow.skip")}
+ </span>
+ </div>
</div>
+ }
+ description={
+ !noApprovalRequired
+ ? t("custom-approval.approval-flow.node.description")
+ : undefined
+ }
+ >
+ {!noApprovalRequired && (
<ApprovalStepsTable
roles={flow.roles}
editable={allowAdmin}
allowAdmin={allowAdmin}
onRolesChange={(newRoles) => setFlow({ roles: newRoles })}
/>
- </>
- )}
- </div>
+ )}
+ </FormField>
+ </FormFieldGroup>
</SheetBody>
<SheetFooter>
diff --git a/frontend/src/react/components/CustomApproval/RuleEditSheetLayout.test.ts b/frontend/src/react/components/CustomApproval/RuleEditSheetLayout.test.ts
new file mode 100644
index 0000000000..0a858158ea
--- /dev/null
+++ b/frontend/src/react/components/CustomApproval/RuleEditSheetLayout.test.ts
@@ -0,0 +1,28 @@
+import { readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { describe, expect, test } from "vitest";
+
+const componentDir = dirname(fileURLToPath(import.meta.url));
+
+describe("RuleEditSheet layout", () => {
+ test("uses shared form primitives in the approval rule drawer", () => {
+ const source = readFileSync(
+ join(componentDir, "RuleEditSheet.tsx"),
+ "utf8"
+ );
+
+ expect(source).toContain("<FormFieldGroup>");
+ expect(source).toContain("<FormField");
+ expect(source).toContain("FormTitle");
+ expect(source).not.toContain("FormLabel");
+ expect(source).toContain('id="approval-rule-title"');
+ expect(source).toContain('id="approval-rule-description"');
+ expect(source).not.toContain('className="flex flex-col gap-y-2"');
+ expect(source).not.toContain(
+ 'className="text-sm font-medium text-control"'
+ );
+ expect(source).not.toContain('className="textlabel"');
+ expect(source).not.toContain('className="textinfolabel text-sm"');
+ });
+});
diff --git a/frontend/src/react/components/ProjectSidebar.test.tsx b/frontend/src/react/components/ProjectSidebar.test.tsx
index a50884b4fa..1efad758ad 100644
--- a/frontend/src/react/components/ProjectSidebar.test.tsx
+++ b/frontend/src/react/components/ProjectSidebar.test.tsx
@@ -44,6 +44,7 @@ const t = vi.hoisted(
"common.manage": "Manage",
"common.members": options?.count === 2 ? "Members" : "Member",
"common.setting": "Setting",
+ "common.settings": "Settings",
"common.webhooks": "Webhooks",
"database.sync-schema.title": "Sync Schema",
"gitops.self": "GitOps",
@@ -141,6 +142,21 @@ beforeEach(async () => {
});
describe("ProjectSidebar", () => {
+ test("renders the settings route with a plural label", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <ProjectSidebar />
+ );
+ render();
+
+ const settingsLink = Array.from(container.querySelectorAll("a")).find(
+ (link) => link.textContent?.includes("Settings")
+ );
+
+ expect(settingsLink).toBeTruthy();
+
+ unmount();
+ });
+
test("keeps child route labels on one line", () => {
const { container, render, unmount } = renderIntoContainer(
<ProjectSidebar />
diff --git a/frontend/src/react/components/ProjectSidebar.tsx b/frontend/src/react/components/ProjectSidebar.tsx
index 7d38ff180e..0433c0bb88 100644
--- a/frontend/src/react/components/ProjectSidebar.tsx
+++ b/frontend/src/react/components/ProjectSidebar.tsx
@@ -191,7 +191,7 @@ function useSidebarItems(): SidebarItem[] {
],
},
{
- title: t("common.setting"),
+ title: t("common.settings"),
icon: Settings,
path: PROJECT_V1_ROUTE_SETTINGS,
type: "div",
diff --git a/frontend/src/react/components/database/CreateDatabaseSheet.test.tsx b/frontend/src/react/components/database/CreateDatabaseSheet.test.tsx
index 40af2bfea4..ec307744e4 100644
--- a/frontend/src/react/components/database/CreateDatabaseSheet.test.tsx
+++ b/frontend/src/react/components/database/CreateDatabaseSheet.test.tsx
@@ -270,7 +270,7 @@ async function fillDatabaseName(name: string): Promise<void> {
function getTitleInput(): HTMLInputElement {
return container.querySelector(
- "input[placeholder='common.title']"
+ "input[placeholder='create-db.issue-title']"
) as HTMLInputElement;
}
diff --git a/frontend/src/react/components/database/CreateDatabaseSheet.tsx b/frontend/src/react/components/database/CreateDatabaseSheet.tsx
index 471ecc4144..b0599473ed 100644
--- a/frontend/src/react/components/database/CreateDatabaseSheet.tsx
+++ b/frontend/src/react/components/database/CreateDatabaseSheet.tsx
@@ -11,6 +11,12 @@ import {
import { ProjectSelect } from "@/react/components/ProjectSelect";
import { Button } from "@/react/components/ui/button";
import { Combobox } from "@/react/components/ui/combobox";
+import {
+ FormError,
+ FormField,
+ FormFieldGroup,
+ FormTitle,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Sheet,
@@ -316,175 +322,195 @@ export function CreateDatabaseSheet({
<SheetTitle>{t("quick-action.create-db")}</SheetTitle>
</SheetHeader>
- <SheetBody className="gap-y-4">
- {!fixedProjectName && (
- <div>
- <label className="block text-sm font-medium mb-1">
- {t("common.project")} <span className="text-error">*</span>
- </label>
- <ProjectSelect
- value={projectName}
- onChange={(name) => setProjectName(name)}
- portal
- />
- </div>
- )}
-
- {selectedProject && projectIssueLabels.length > 0 && (
- <IssueLabelSelect
- labels={projectIssueLabels}
- selected={issueLabels}
- required={forceIssueLabels}
- onChange={setIssueLabels}
- />
- )}
-
- <div>
- <label className="block text-sm font-medium mb-1">
- {t("common.instance")} <span className="text-error">*</span>
- </label>
- <InstanceSelect
- value={instanceName}
- onChange={handleInstanceChange}
- engines={enginesSupportCreateDatabase()}
- portal
- />
- </div>
+ <SheetBody>
+ <FormFieldGroup>
+ {!fixedProjectName && (
+ <FormField
+ title={
+ <>
+ {t("common.project")} <span className="text-error">*</span>
+ </>
+ }
+ >
+ <ProjectSelect
+ value={projectName}
+ onChange={(name) => setProjectName(name)}
+ portal
+ />
+ </FormField>
+ )}
- <div>
- <label className="block text-sm font-medium mb-1">
- {t("create-db.new-database-name")}{" "}
- <span className="text-error">*</span>
- </label>
- <Input
- value={databaseName}
- onChange={(e) => setDatabaseName(e.target.value)}
- placeholder={t("create-db.new-database-name")}
- className={cn(isReservedName && "border-error")}
- />
- {isReservedName && (
- <p className="mt-1 text-xs text-error">
- {t("create-db.reserved-db-error", { databaseName })}
- </p>
+ {selectedProject && projectIssueLabels.length > 0 && (
+ <IssueLabelSelect
+ labels={projectIssueLabels}
+ selected={issueLabels}
+ required={forceIssueLabels}
+ onChange={setIssueLabels}
+ />
)}
- </div>
- <div className="flex flex-col gap-y-2">
- <label className="block text-sm font-medium">
- {t("common.title")}
- {enforceIssueTitle && <span className="text-error"> *</span>}
- </label>
- <Input
- value={title}
- placeholder={t("common.title")}
- onChange={(e) => {
- const next = e.target.value;
- setTitle(next);
- // Invariant: titleEdited ⇒ title is non-empty user intent.
- // When the user deletes to empty, reset the flag so the
- // auto-fill effect resumes tracking databaseName — otherwise
- // the flag stays sticky and the next auto-fill (first char
- // of a re-typed databaseName) gets frozen by the guard.
- setTitleEdited(next !== "");
- }}
- />
- </div>
+ <FormField
+ title={
+ <>
+ {t("common.instance")} <span className="text-error">*</span>
+ </>
+ }
+ >
+ <InstanceSelect
+ value={instanceName}
+ onChange={handleInstanceChange}
+ engines={enginesSupportCreateDatabase()}
+ portal
+ />
+ </FormField>
- {selectedInstance?.engine === Engine.MONGODB && (
- <div>
- <label className="block text-sm font-medium mb-1">
- {t("create-db.new-collection-name")}{" "}
+ <FormField>
+ <FormTitle id="create-database-name-title">
+ {t("create-db.new-database-name")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
- value={tableName}
- onChange={(e) => setTableName(e.target.value)}
+ id="create-database-name"
+ aria-labelledby="create-database-name-title"
+ value={databaseName}
+ onChange={(e) => setDatabaseName(e.target.value)}
+ placeholder={t("create-db.new-database-name")}
+ className={cn(isReservedName && "border-error")}
/>
- </div>
- )}
-
- {selectedInstance?.engine === Engine.CLICKHOUSE && (
- <div>
- <label className="block text-sm font-medium mb-1">
- {t("create-db.cluster")}
- </label>
+ {isReservedName && (
+ <FormError>
+ {t("create-db.reserved-db-error", { databaseName })}
+ </FormError>
+ )}
+ </FormField>
+
+ <FormField>
+ <FormTitle id="create-database-title-title">
+ {t("create-db.issue-title")}
+ {enforceIssueTitle && <span className="text-error"> *</span>}
+ </FormTitle>
<Input
- value={cluster}
- onChange={(e) => setCluster(e.target.value)}
+ id="create-database-title"
+ aria-labelledby="create-database-title-title"
+ value={title}
+ placeholder={t("create-db.issue-title")}
+ onChange={(e) => {
+ const next = e.target.value;
+ setTitle(next);
+ // Invariant: titleEdited ⇒ title is non-empty user intent.
+ // When the user deletes to empty, reset the flag so the
+ // auto-fill effect resumes tracking databaseName — otherwise
+ // the flag stays sticky and the next auto-fill (first char
+ // of a re-typed databaseName) gets frozen by the guard.
+ setTitleEdited(next !== "");
+ }}
/>
- </div>
- )}
+ </FormField>
+
+ {selectedInstance?.engine === Engine.MONGODB && (
+ <FormField>
+ <FormTitle id="create-database-collection-name-title">
+ {t("create-db.new-collection-name")}{" "}
+ <span className="text-error">*</span>
+ </FormTitle>
+ <Input
+ id="create-database-collection-name"
+ aria-labelledby="create-database-collection-name-title"
+ value={tableName}
+ onChange={(e) => setTableName(e.target.value)}
+ />
+ </FormField>
+ )}
- {requireOwner && instanceName && (
- <div>
- <label className="block text-sm font-medium mb-1">
- {t("create-db.database-owner-name")}{" "}
- <span className="text-error">*</span>
- </label>
+ {selectedInstance?.engine === Engine.CLICKHOUSE && (
+ <FormField>
+ <FormTitle id="create-database-cluster-title">
+ {t("create-db.cluster")}
+ </FormTitle>
+ <Input
+ id="create-database-cluster"
+ aria-labelledby="create-database-cluster-title"
+ value={cluster}
+ onChange={(e) => setCluster(e.target.value)}
+ />
+ </FormField>
+ )}
+
+ {requireOwner && instanceName && (
+ <FormField
+ title={
+ <>
+ {t("create-db.database-owner-name")}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
+ <Combobox
+ value={ownerName}
+ onChange={setOwnerName}
+ placeholder={t("create-db.database-owner-name")}
+ noResultsText={t("common.no-data")}
+ options={instanceRoles.map((role) => ({
+ value: role.roleName,
+ label: role.roleName,
+ }))}
+ />
+ </FormField>
+ )}
+
+ <FormField title={<>{t("common.environment")}</>}>
<Combobox
- value={ownerName}
- onChange={setOwnerName}
- placeholder={t("create-db.database-owner-name")}
+ value={environmentName}
+ onChange={setEnvironmentName}
+ placeholder={t("common.environment")}
noResultsText={t("common.no-data")}
- options={instanceRoles.map((role) => ({
- value: role.roleName,
- label: role.roleName,
+ renderValue={(opt) => (
+ <EnvironmentLabel environmentName={opt.value} />
+ )}
+ options={environments.map((env) => ({
+ value: env.name,
+ label: env.title,
+ render: () => <EnvironmentLabel environmentName={env.name} />,
}))}
/>
- </div>
- )}
-
- <div>
- <label className="block text-sm font-medium mb-1">
- {t("common.environment")}
- </label>
- <Combobox
- value={environmentName}
- onChange={setEnvironmentName}
- placeholder={t("common.environment")}
- noResultsText={t("common.no-data")}
- renderValue={(opt) => (
- <EnvironmentLabel environmentName={opt.value} />
- )}
- options={environments.map((env) => ({
- value: env.name,
- label: env.title,
- render: () => <EnvironmentLabel environmentName={env.name} />,
- }))}
- />
- </div>
-
- {showCharsetCollation && (
- <>
- <div>
- <label className="block text-sm font-medium mb-1">
- {selectedInstance.engine === Engine.POSTGRES
- ? t("db.encoding")
- : t("db.character-set")}
- </label>
- <Input
- value={characterSet}
- onChange={(e) => setCharacterSet(e.target.value)}
- placeholder={defaultCharsetOfEngineV1(
- selectedInstance.engine
- )}
- />
- </div>
- <div>
- <label className="block text-sm font-medium mb-1">
- {t("db.collation")}
- </label>
- <Input
- value={collation}
- onChange={(e) => setCollation(e.target.value)}
- placeholder={
- defaultCollationOfEngineV1(selectedInstance.engine) ||
- t("common.default")
- }
- />
- </div>
- </>
- )}
+ </FormField>
+
+ {showCharsetCollation && (
+ <>
+ <FormField>
+ <FormTitle id="create-database-character-set-title">
+ {selectedInstance.engine === Engine.POSTGRES
+ ? t("db.encoding")
+ : t("db.character-set")}
+ </FormTitle>
+ <Input
+ id="create-database-character-set"
+ aria-labelledby="create-database-character-set-title"
+ value={characterSet}
+ onChange={(e) => setCharacterSet(e.target.value)}
+ placeholder={defaultCharsetOfEngineV1(
+ selectedInstance.engine
+ )}
+ />
+ </FormField>
+ <FormField>
+ <FormTitle id="create-database-collation-title">
+ {t("db.collation")}
+ </FormTitle>
+ <Input
+ id="create-database-collation"
+ aria-labelledby="create-database-collation-title"
+ value={collation}
+ onChange={(e) => setCollation(e.target.value)}
+ placeholder={
+ defaultCollationOfEngineV1(selectedInstance.engine) ||
+ t("common.default")
+ }
+ />
+ </FormField>
+ </>
+ )}
+ </FormFieldGroup>
</SheetBody>
<SheetFooter>
diff --git a/frontend/src/react/components/database/CreateDatabaseSheetLayout.test.ts b/frontend/src/react/components/database/CreateDatabaseSheetLayout.test.ts
new file mode 100644
index 0000000000..697ac5644a
--- /dev/null
+++ b/frontend/src/react/components/database/CreateDatabaseSheetLayout.test.ts
@@ -0,0 +1,26 @@
+import { readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { describe, expect, test } from "vitest";
+
+const componentDir = dirname(fileURLToPath(import.meta.url));
+
+describe("CreateDatabaseSheet layout", () => {
+ test("uses shared form primitives in the create database drawer", () => {
+ const source = readFileSync(
+ join(componentDir, "CreateDatabaseSheet.tsx"),
+ "utf8"
+ );
+
+ expect(source).toContain("<FormFieldGroup>");
+ expect(source).toContain("<FormField");
+ expect(source).toContain("FormTitle");
+ expect(source).not.toContain("FormLabel");
+ expect(source).toContain('id="create-database-name"');
+ expect(source).toContain('id="create-database-title"');
+ expect(source).toContain('t("create-db.issue-title")');
+ expect(source).not.toContain('t("common.title")');
+ expect(source).not.toContain('className="block text-sm font-medium mb-1"');
+ expect(source).not.toContain('className="flex flex-col gap-y-2"');
+ });
+});
diff --git a/frontend/src/react/components/header/ProjectCreateDialog.tsx b/frontend/src/react/components/header/ProjectCreateDialog.tsx
index dade0eddb3..50fc8ab988 100644
--- a/frontend/src/react/components/header/ProjectCreateDialog.tsx
+++ b/frontend/src/react/components/header/ProjectCreateDialog.tsx
@@ -6,6 +6,11 @@ import {
type ResourceIdFieldRef,
} from "@/react/components/ResourceIdField";
import { Button } from "@/react/components/ui/button";
+import {
+ FormField,
+ FormFieldGroup,
+ FormTitle,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Sheet,
@@ -145,14 +150,15 @@ export function ProjectCreateDialog({
</SheetHeader>
<SheetBody>
- <div className="flex flex-col gap-y-6">
- <div>
- <label className="text-base leading-6 font-medium text-control">
+ <FormFieldGroup>
+ <FormField>
+ <FormTitle id="create-project-title-title">
{t("project.create-modal.project-name")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormTitle>
<Input
- className="mt-2 mb-1"
+ id="create-project-title"
+ aria-labelledby="create-project-title-title"
value={title}
maxLength={200}
placeholder={t("project.create-modal.project-name")}
@@ -168,8 +174,8 @@ export function ProjectCreateDialog({
onChange={setResourceId}
onValidationChange={setIsResourceIdValid}
/>
- </div>
- </div>
+ </FormField>
+ </FormFieldGroup>
{isCreating && (
<div className="absolute inset-0 flex items-center justify-center bg-background/50">
diff --git a/frontend/src/react/components/header/ProjectCreateDialogLayout.test.ts b/frontend/src/react/components/header/ProjectCreateDialogLayout.test.ts
new file mode 100644
index 0000000000..8f80177b75
--- /dev/null
+++ b/frontend/src/react/components/header/ProjectCreateDialogLayout.test.ts
@@ -0,0 +1,23 @@
+import { readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { describe, expect, test } from "vitest";
+
+const componentDir = dirname(fileURLToPath(import.meta.url));
+
+describe("ProjectCreateDialog layout", () => {
+ test("uses shared form primitives in the create project drawer", () => {
+ const source = readFileSync(
+ join(componentDir, "ProjectCreateDialog.tsx"),
+ "utf8"
+ );
+
+ expect(source).toContain("<FormFieldGroup>");
+ expect(source).toContain("<FormField>");
+ expect(source).toContain("FormTitle");
+ expect(source).not.toContain("FormLabel");
+ expect(source).toContain('id="create-project-title"');
+ expect(source).not.toContain('className="flex flex-col gap-y-6"');
+ expect(source).not.toContain("<label");
+ });
+});
diff --git a/frontend/src/react/components/instance/DataSourceForm.tsx b/frontend/src/react/components/instance/DataSourceForm.tsx
index b37896894e..f516690eac 100644
--- a/frontend/src/react/components/instance/DataSourceForm.tsx
+++ b/frontend/src/react/components/instance/DataSourceForm.tsx
@@ -6,12 +6,9 @@ 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";
@@ -457,6 +454,17 @@ export function DataSourceForm({
}
}, [passwordType, t]);
+ const secretNameDescription = useMemo(() => {
+ switch (passwordType) {
+ case DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER:
+ return t("instance.external-secret-gcp.secret-name-tips");
+ case DataSourceExternalSecret_SecretType.AZURE_KEY_VAULT:
+ return t("instance.external-secret-azure.secret-name-tips");
+ default:
+ return undefined;
+ }
+ }, [passwordType, t]);
+
const secretKeyLabel = useMemo(() => {
if (passwordType === DataSourceExternalSecret_SecretType.VAULT_KV_V2) {
return t("instance.external-secret-vault.vault-secret-key");
@@ -621,10 +629,14 @@ export function DataSourceForm({
{/* Kerberos config */}
{dataSource.saslConfig?.mechanism?.case === "krbConfig" && (
<>
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>
- Principal <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={
+ <>
+ Principal <span className="text-error">*</span>
+ </>
+ }
+ >
<FormControlRow>
<Input
className="min-w-0 flex-1"
@@ -644,7 +656,9 @@ export function DataSourceForm({
onDataSourceChange(updated);
}}
/>
- <FormControlAffix>/</FormControlAffix>
+ <span className="shrink-0 whitespace-nowrap text-sm leading-5 text-control-light">
+ /
+ </span>
<Input
className="min-w-0 flex-1"
value={
@@ -663,7 +677,9 @@ export function DataSourceForm({
onDataSourceChange(updated);
}}
/>
- <FormControlAffix>@</FormControlAffix>
+ <span className="shrink-0 whitespace-nowrap text-sm leading-5 text-control-light">
+ @
+ </span>
<Input
className="min-w-0 flex-1"
value={
@@ -684,10 +700,14 @@ export function DataSourceForm({
/>
</FormControlRow>
</FormField>
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>
- KDC <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={
+ <>
+ KDC <span className="text-error">*</span>
+ </>
+ }
+ >
<FormControlRow>
<RadioGroup
className="w-fit textlabel gap-x-3"
@@ -734,7 +754,9 @@ export function DataSourceForm({
onDataSourceChange(updated);
}}
/>
- <FormControlAffix>:</FormControlAffix>
+ <span className="shrink-0 whitespace-nowrap text-sm leading-5 text-control-light">
+ :
+ </span>
<Input
className="min-w-0 flex-1"
value={
@@ -760,10 +782,14 @@ export function DataSourceForm({
/>
</FormControlRow>
</FormField>
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>
- Keytab File <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={
+ <>
+ Keytab File <span className="text-error">*</span>
+ </>
+ }
+ >
<div className="mt-3 border-2 border-dashed rounded-lg p-6 text-center">
<input
type="file"
@@ -786,19 +812,23 @@ export function DataSourceForm({
{/* Username field (non-Kerberos, non-Azure IAM) */}
{dataSource.saslConfig?.mechanism?.case !== "krbConfig" &&
!isAzureIAM && (
- <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"
- className="inline-flex items-center gap-x-0.5 text-accent text-xs"
- onClick={() => onOpenInfoPanel("authentication")}
- >
- <Info className="size-3.5" />
- </button>
- )}
- </div>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={
+ <span className="flex items-center gap-x-1">
+ {t("common.username")}
+ {onOpenInfoPanel && hasAuthenticationInfo && (
+ <button
+ type="button"
+ className="inline-flex items-center gap-x-0.5 text-accent text-xs"
+ onClick={() => onOpenInfoPanel("authentication")}
+ >
+ <Info className="size-3.5" />
+ </button>
+ )}
+ </span>
+ }
+ >
<Input
value={dataSource.username}
className="w-full max-w-[48rem]"
@@ -825,11 +855,15 @@ export function DataSourceForm({
{/* AWS Region */}
{isAwsIAM && (
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>
- {t("instance.database-region")}{" "}
- <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={
+ <>
+ {t("instance.database-region")}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
<Input
value={dataSource.region ?? ""}
className="w-full"
@@ -919,8 +953,7 @@ export function DataSourceForm({
{/* Plain password */}
{passwordType ===
DataSourceExternalSecret_SecretType.SECRET_TYPE_UNSPECIFIED && (
- <FormField>
- <FormLabel>{t("common.password")}</FormLabel>
+ <FormField title={<>{t("common.password")}</>}>
<div>
{!isCreating && allowUsingEmptyPassword && (
<label className="flex items-center gap-x-1.5 mb-2 text-sm cursor-pointer">
@@ -970,13 +1003,16 @@ export function DataSourceForm({
{passwordType ===
DataSourceExternalSecret_SecretType.VAULT_KV_V2 && (
<div className="flex flex-col gap-y-4">
- <FormField>
- <FormLabel>
- {t(
- "instance.external-secret-vault.vault-url"
- )}{" "}
- <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t(
+ "instance.external-secret-vault.vault-url"
+ )}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
<Input
value={dataSource.externalSecret.url ?? ""}
required
@@ -995,12 +1031,15 @@ export function DataSourceForm({
}}
/>
</FormField>
- <FormField>
- <FormLabel>
- {t(
- "instance.external-secret-vault.vault-auth-type.self"
- )}
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t(
+ "instance.external-secret-vault.vault-auth-type.self"
+ )}
+ </>
+ }
+ >
<RadioGroup
className="textlabel gap-x-4"
value={String(
@@ -1075,11 +1114,14 @@ export function DataSourceForm({
);
}
return (
- <FormField>
- <FormLabel>
- {tokenLabel}{" "}
- <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {tokenLabel}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
{/* Token source is host-backed for env/file,
which is disallowed in SaaS mode; only
plain is offered there. */}
@@ -1157,13 +1199,16 @@ export function DataSourceForm({
{dataSource.externalSecret.authOption?.case ===
"appRole" && (
<div className="flex flex-col gap-y-4">
- <FormField>
- <FormLabel>
- {t(
- "instance.external-secret-vault.vault-auth-type.approle.role-id"
- )}{" "}
- <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t(
+ "instance.external-secret-vault.vault-auth-type.approle.role-id"
+ )}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
<Input
value={
dataSource.externalSecret.authOption
@@ -1194,13 +1239,16 @@ export function DataSourceForm({
}}
/>
</FormField>
- <FormField>
- <FormLabel>
- {t(
- "instance.external-secret-vault.vault-auth-type.approle.secret-id"
- )}{" "}
- <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t(
+ "instance.external-secret-vault.vault-auth-type.approle.secret-id"
+ )}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
{/* Environment secret id reads from the host,
which is disallowed in SaaS mode; only plain
is offered there. */}
@@ -1288,12 +1336,15 @@ export function DataSourceForm({
</div>
)}
{/* Vault TLS config */}
- <FormField>
- <FormLabel>
- {t(
- "instance.external-secret-vault.vault-tls-config"
- )}
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t(
+ "instance.external-secret-vault.vault-tls-config"
+ )}
+ </>
+ }
+ >
<SslCertificateForm
verify={
!dataSource.externalSecret
@@ -1339,18 +1390,23 @@ export function DataSourceForm({
/>
</FormField>
{/* Engine name */}
- <FormField>
- <FormLabel>
- {t(
- "instance.external-secret-vault.vault-secret-engine-name"
- )}{" "}
- <span className="text-error">*</span>
- </FormLabel>
- <FormDescription>
- {t(
- "instance.external-secret-vault.vault-secret-engine-tips"
- )}
- </FormDescription>
+ <FormField
+ title={
+ <>
+ {t(
+ "instance.external-secret-vault.vault-secret-engine-name"
+ )}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ description={
+ <>
+ {t(
+ "instance.external-secret-vault.vault-secret-engine-tips"
+ )}
+ </>
+ }
+ >
<Input
value={
dataSource.externalSecret.engineName ?? ""
@@ -1377,16 +1433,23 @@ export function DataSourceForm({
{/* Azure Key Vault URL */}
{passwordType ===
DataSourceExternalSecret_SecretType.AZURE_KEY_VAULT && (
- <FormField>
- <FormLabel>
- {t("instance.external-secret-azure.vault-url")}{" "}
- <span className="text-error">*</span>
- </FormLabel>
- <FormDescription>
- {t(
- "instance.external-secret-azure.vault-url-tips"
- )}
- </FormDescription>
+ <FormField
+ title={
+ <>
+ {t(
+ "instance.external-secret-azure.vault-url"
+ )}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ description={
+ <>
+ {t(
+ "instance.external-secret-azure.vault-url-tips"
+ )}
+ </>
+ }
+ >
<Input
value={dataSource.externalSecret.url ?? ""}
required
@@ -1408,27 +1471,15 @@ export function DataSourceForm({
)}
{/* Secret name (common) */}
- <FormField>
- <FormLabel>
- {secretNameLabel}{" "}
- <span className="text-error">*</span>
- </FormLabel>
- {passwordType ===
- DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER && (
- <FormDescription>
- {t(
- "instance.external-secret-gcp.secret-name-tips"
- )}
- </FormDescription>
- )}
- {passwordType ===
- DataSourceExternalSecret_SecretType.AZURE_KEY_VAULT && (
- <FormDescription>
- {t(
- "instance.external-secret-azure.secret-name-tips"
- )}
- </FormDescription>
- )}
+ <FormField
+ title={
+ <>
+ {secretNameLabel}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ description={secretNameDescription}
+ >
<Input
value={dataSource.externalSecret.secretName ?? ""}
required
@@ -1451,11 +1502,14 @@ export function DataSourceForm({
DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER &&
passwordType !==
DataSourceExternalSecret_SecretType.AZURE_KEY_VAULT && (
- <FormField>
- <FormLabel>
- {secretKeyLabel}{" "}
- <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {secretKeyLabel}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
<Input
value={
dataSource.externalSecret.passwordKeyName ??
@@ -1484,10 +1538,14 @@ export function DataSourceForm({
dataSource.redisType ===
DataSource_RedisType.SENTINEL && (
<>
- <FormField>
- <FormLabel>
- Master Name <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ Master Name{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
<Input
value={dataSource.masterName ?? ""}
className="w-full"
@@ -1497,8 +1555,7 @@ export function DataSourceForm({
}
/>
</FormField>
- <FormField>
- <FormLabel>Master Username</FormLabel>
+ <FormField title={<>Master Username</>}>
<Input
value={dataSource.masterUsername ?? ""}
className="w-full"
@@ -1508,8 +1565,7 @@ export function DataSourceForm({
}
/>
</FormField>
- <FormField>
- <FormLabel>Master Password</FormLabel>
+ <FormField title={<>Master Password</>}>
<div>
{!isCreating && allowUsingEmptyPassword && (
<label className="flex items-center gap-x-1.5 mb-2 text-sm cursor-pointer">
@@ -1612,8 +1668,10 @@ export function DataSourceForm({
{/* Snowflake keypair */}
{basicInfo.engine === Engine.SNOWFLAKE && (
<>
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>{t("data-source.ssh.private-key")}</FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={<>{t("data-source.ssh.private-key")}</>}
+ >
<div className="flex gap-x-2 text-sm">
<span className="textinfolabel">
{t("data-source.snowflake-keypair-tip")}
@@ -1633,11 +1691,11 @@ export function DataSourceForm({
}
/>
</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")}
- </FormDescription>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={<>{t("data-source.private-key-passphrase")}</>}
+ description={<>{t("data-source.private-key-passphrase-tip")}</>}
+ >
<Input
value={dataSource.authenticationPrivateKeyPassphrase ?? ""}
type="password"
@@ -1659,20 +1717,26 @@ export function DataSourceForm({
{/* Databricks */}
{basicInfo.engine === Engine.DATABRICKS && (
<>
- <FormField>
- <FormLabel>
- Warehouse ID <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ Warehouse ID <span className="text-error">*</span>
+ </>
+ }
+ >
<Input
value={dataSource.warehouseId ?? ""}
disabled={!allowEdit}
onChange={(e) => update({ warehouseId: e.target.value })}
/>
</FormField>
- <FormField>
- <FormLabel>
- Token <span className="text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ Token <span className="text-error">*</span>
+ </>
+ }
+ >
<Input
type="password"
value={dataSource.updatedToken}
@@ -1694,8 +1758,10 @@ export function DataSourceForm({
{/* MongoDB authentication database */}
{showAuthenticationDatabase && (
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>{t("instance.authentication-database")}</FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={<>{t("instance.authentication-database")}</>}
+ >
<Input
className="w-full"
autoComplete="off"
@@ -1714,8 +1780,10 @@ export function DataSourceForm({
(hasReadonlyReplicaHost || hasReadonlyReplicaPort) && (
<>
{hasReadonlyReplicaHost && (
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>{t("data-source.read-replica-host")}</FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={<>{t("data-source.read-replica-host")}</>}
+ >
<Input
className="w-full"
autoComplete="off"
@@ -1726,8 +1794,10 @@ export function DataSourceForm({
</FormField>
)}
{hasReadonlyReplicaPort && (
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>{t("data-source.read-replica-port")}</FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={<>{t("data-source.read-replica-port")}</>}
+ >
<Input
className="w-full"
autoComplete="off"
@@ -1746,8 +1816,10 @@ export function DataSourceForm({
{/* Database field */}
{showDatabase && (
- <FormField className="sm:col-span-3 sm:col-start-1">
- <FormLabel>{t("common.database")}</FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={<>{t("common.database")}</>}
+ >
<Input
value={dataSource.database ?? ""}
className="w-full"
@@ -1765,21 +1837,23 @@ export function DataSourceForm({
<>
{/* SSL */}
{showSSL && isPasswordAuth && (
- <FormField className="sm:col-span-3 sm:col-start-1">
- <div className="flex items-center justify-start gap-x-2">
- <FormLabel>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={
+ <span className="flex items-center justify-start gap-x-2">
{t("data-source.ssl.connection-security")}
- </FormLabel>
- {onOpenInfoPanel && hasSslInfo && (
- <button
- type="button"
- className="inline-flex items-center gap-x-0.5 text-accent text-xs"
- onClick={() => onOpenInfoPanel("ssl")}
- >
- <Info className="size-3.5" />
- </button>
- )}
- </div>
+ {onOpenInfoPanel && hasSslInfo && (
+ <button
+ type="button"
+ className="inline-flex items-center gap-x-0.5 text-accent text-xs"
+ onClick={() => onOpenInfoPanel("ssl")}
+ >
+ <Info className="size-3.5" />
+ </button>
+ )}
+ </span>
+ }
+ >
<SslCertificateForm
useSsl={dataSource.useSsl}
onUseSslChange={(useSsl) => {
@@ -1889,19 +1963,23 @@ export function DataSourceForm({
{/* SSH */}
{!hideAdvancedFeatures && showSSH && isPasswordAuth && (
- <FormField className="sm:col-span-3 sm:col-start-1">
- <div className="flex flex-row items-center gap-x-1">
- <FormLabel>{t("data-source.ssh-connection")}</FormLabel>
- {onOpenInfoPanel && hasSshInfo && (
- <button
- type="button"
- className="inline-flex items-center gap-x-0.5 text-accent text-xs"
- onClick={() => onOpenInfoPanel("ssh")}
- >
- <Info className="size-3.5" />
- </button>
- )}
- </div>
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={
+ <span className="flex flex-row items-center gap-x-1">
+ {t("data-source.ssh-connection")}
+ {onOpenInfoPanel && hasSshInfo && (
+ <button
+ type="button"
+ className="inline-flex items-center gap-x-0.5 text-accent text-xs"
+ onClick={() => onOpenInfoPanel("ssh")}
+ >
+ <Info className="size-3.5" />
+ </button>
+ )}
+ </span>
+ }
+ >
<SshConnectionForm
value={dataSource}
instance={instance}
@@ -1913,14 +1991,11 @@ export function DataSourceForm({
{/* Extra connection parameters */}
{hasExtraParameters && (
- <FormField className="sm:col-span-3 sm:col-start-1">
- <div className="flex flex-row items-center justify-between">
- <FormLabel>{t("data-source.extra-params.self")}</FormLabel>
- </div>
- <FormDescription>
- {t("data-source.extra-params.description")}
- </FormDescription>
-
+ <FormField
+ className="sm:col-span-3 sm:col-start-1"
+ title={t("data-source.extra-params.self")}
+ description={t("data-source.extra-params.description")}
+ >
<FormControlGroup className="mt-2">
{allowEdit && (
<FormControlRow>
diff --git a/frontend/src/react/components/instance/InstanceFormBody.tsx b/frontend/src/react/components/instance/InstanceFormBody.tsx
index 2e592ba2f0..8d8fe6b28b 100644
--- a/frontend/src/react/components/instance/InstanceFormBody.tsx
+++ b/frontend/src/react/components/instance/InstanceFormBody.tsx
@@ -23,7 +23,6 @@ import { Checkbox } from "@/react/components/ui/checkbox";
import {
FormControlGroup,
FormControlRow,
- FormDescription,
FormField,
FormLabel,
} from "@/react/components/ui/form";
@@ -119,11 +118,14 @@ function SpannerHostInput({
return (
<div className="grid grid-cols-2 gap-x-2 gap-y-1">
- <FormField>
- <FormLabel>
- {t("instance.project-id")}
- <span style={{ color: "red" }}> *</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("instance.project-id")}
+ <span style={{ color: "red" }}> *</span>
+ </>
+ }
+ >
<Input
value={projectId}
required
@@ -137,11 +139,14 @@ function SpannerHostInput({
}}
/>
</FormField>
- <FormField>
- <FormLabel>
- {t("instance.instance-id")}
- <span style={{ color: "red" }}> *</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("instance.instance-id")}
+ <span style={{ color: "red" }}> *</span>
+ </>
+ }
+ >
<Input
value={instanceId}
required
@@ -155,7 +160,7 @@ function SpannerHostInput({
}}
/>
</FormField>
- <FormDescription className="col-span-2">
+ <p className="col-span-2 text-xs leading-4 text-control-light">
{t("instance.find-gcp-project-id-and-instance-id")}{" "}
<a
href="https://docs.bytebase.com/get-started/connect/gcp?source=console"
@@ -166,7 +171,7 @@ function SpannerHostInput({
{t("common.detailed-guide")}
<ExternalLink className="size-4 ml-1" />
</a>
- </FormDescription>
+ </p>
</div>
);
}
@@ -194,11 +199,14 @@ function BigQueryHostInput({
return (
<div className="grid grid-cols-2 gap-x-2 gap-y-1">
- <FormField>
- <FormLabel>
- {t("instance.project-id")}
- <span style={{ color: "red" }}> *</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("instance.project-id")}
+ <span style={{ color: "red" }}> *</span>
+ </>
+ }
+ >
<Input
value={projectId}
required
@@ -217,7 +225,7 @@ function BigQueryHostInput({
}}
/>
</FormField>
- <FormDescription className="col-span-2">
+ <p className="col-span-2 text-xs leading-4 text-control-light">
{t("instance.find-gcp-project-id")}{" "}
<a
href="https://docs.bytebase.com/get-started/connect/gcp?source=console"
@@ -228,7 +236,7 @@ function BigQueryHostInput({
{t("common.detailed-guide")}
<ExternalLink className="size-4 ml-1" />
</a>
- </FormDescription>
+ </p>
</div>
);
}
@@ -344,14 +352,18 @@ function ScanIntervalInput({
if (hideAdvancedFeatures) return null;
return (
- <FormField className="sm:col-span-4 sm:col-start-1">
- <div className="flex items-center gap-x-2">
- <FormLabel>{t("instance.scan-interval.self")}</FormLabel>
- <FeatureBadge feature={PlanFeature.FEATURE_CUSTOM_INSTANCE_SYNC_TIME} />
- </div>
- <FormDescription>
- {t("instance.scan-interval.description")}
- </FormDescription>
+ <FormField
+ className="sm:col-span-4 sm:col-start-1"
+ title={
+ <span className="flex items-center gap-x-2">
+ {t("instance.scan-interval.self")}
+ <FeatureBadge
+ feature={PlanFeature.FEATURE_CUSTOM_INSTANCE_SYNC_TIME}
+ />
+ </span>
+ }
+ description={t("instance.scan-interval.description")}
+ >
<RadioGroup
className="gap-x-6"
value={mode}
@@ -484,15 +496,13 @@ function SyncDatabases({
};
return (
- <FormField className="sm:col-span-4 sm:col-start-1">
- {showLabel && (
- <div className="flex items-center gap-x-2">
- <FormLabel>{t("instance.sync-databases.self")}</FormLabel>
- </div>
- )}
- <FormDescription>
- {t("instance.sync-databases.description")}
- </FormDescription>
+ <FormField
+ className="sm:col-span-4 sm:col-start-1"
+ title={showLabel ? t("instance.sync-databases.self") : undefined}
+ description={
+ showLabel ? t("instance.sync-databases.description") : undefined
+ }
+ >
<div className="flex flex-col gap-y-2">
<label className="flex items-center gap-x-2 cursor-pointer">
<Checkbox
@@ -1251,9 +1261,9 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
/>
) : (
<>
- <FormDescription>
+ <p className="text-xs leading-4 text-control-light">
{t("instance.sentence.console.snowflake")}
- </FormDescription>
+ </p>
<Input
value={basicInfo.externalLink ?? ""}
required
@@ -1339,14 +1349,14 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
{t("instance.sentence.google-cloud-sql.instance-name")}
<span className="text-error"> *</span>
</FormLabel>
- <FormDescription>
+ <p className="text-xs leading-4 text-control-light">
{t(
"instance.sentence.google-cloud-sql.instance-name-tips",
{
instance: "{project-id}:{region}:{instance-name}",
}
)}
- </FormDescription>
+ </p>
</>
) : (
<div className="flex items-center gap-x-1">
@@ -1380,9 +1390,9 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {
onChange={(e) => updateAdminDS({ host: e.target.value })}
/>
{basicInfo.engine === Engine.SNOWFLAKE && (
- <FormDescription className="mt-2">
+ <p className="mt-2 text-xs leading-4 text-control-light">
{t("instance.sentence.proxy.snowflake")}
- </FormDescription>
+ </p>
)}
</>
)}
diff --git a/frontend/src/react/components/instance/SslCertificateForm.tsx b/frontend/src/react/components/instance/SslCertificateForm.tsx
index ab28995a31..0b3d88201b 100644
--- a/frontend/src/react/components/instance/SslCertificateForm.tsx
+++ b/frontend/src/react/components/instance/SslCertificateForm.tsx
@@ -2,7 +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 { FormField } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
SegmentedControl,
@@ -357,8 +357,11 @@ export function SslCertificateForm({
hasStoredValue: boolean,
visibleValue: string
) => (
- <div className="flex items-center gap-x-2">
- <FormLabel>{label}</FormLabel>
+ <div
+ data-slot="form-field-title"
+ className="flex items-center gap-x-2 text-base font-semibold leading-6 text-main"
+ >
+ {label}
{showConfiguredBadge(hasStoredValue, visibleValue) && (
<Badge data-testid="tls-configured-badge" variant="success">
{resolvedConfiguredLabel}
@@ -615,7 +618,9 @@ export function SslCertificateForm({
onCheckedChange={(val) => onVerifyChange?.(val)}
disabled={disabled}
/>
- <FormLabel>{resolvedVerifyLabel}</FormLabel>
+ <span className="text-base font-semibold leading-6 text-main">
+ {resolvedVerifyLabel}
+ </span>
{showTooltip && (
<Tooltip
content={t("data-source.ssl.verify-certificate-tooltip")}
@@ -652,8 +657,7 @@ export function SslCertificateForm({
)}
<div className="flex flex-col gap-y-2">
{showCaSourceUi && (
- <FormField>
- <FormLabel>{t("data-source.ssl.ca-source.self")}</FormLabel>
+ <FormField title={<>{t("data-source.ssl.ca-source.self")}</>}>
<CaSourceSelector
value={resolvedCaSource}
onChange={onCaSourceChange!}
@@ -673,10 +677,9 @@ export function SslCertificateForm({
</legend>
<div className="flex flex-col gap-y-2">
{showClientCertSourceUi && (
- <FormField>
- <FormLabel>
- {t("data-source.ssl.client-cert-source.self")}
- </FormLabel>
+ <FormField
+ title={<>{t("data-source.ssl.client-cert-source.self")}</>}
+ >
<ClientCertSourceSelector
value={clientIdentitySource}
onChange={onClientCertSourceChange!}
@@ -709,7 +712,9 @@ export function SslCertificateForm({
onCheckedChange={(val) => onUseSslChange?.(val)}
disabled={disabled}
/>
- <FormLabel>{t("data-source.ssl-connection")}</FormLabel>
+ <span className="text-base font-semibold leading-6 text-main">
+ {t("data-source.ssl-connection")}
+ </span>
</div>
)}
@@ -723,8 +728,7 @@ export function SslCertificateForm({
<>
<div className="flex flex-col gap-y-2">
{showCaSourceUi && (
- <FormField>
- <FormLabel>{t("data-source.ssl.ca-source.self")}</FormLabel>
+ <FormField title={<>{t("data-source.ssl.ca-source.self")}</>}>
<CaSourceSelector
value={resolvedCaSource}
onChange={onCaSourceChange!}
@@ -739,10 +743,11 @@ export function SslCertificateForm({
{showKeyAndCertFields && (
<div className="flex flex-col gap-y-2">
{showClientCertSourceUi && (
- <FormField>
- <FormLabel>
- {t("data-source.ssl.client-cert-source.self")}
- </FormLabel>
+ <FormField
+ title={
+ <>{t("data-source.ssl.client-cert-source.self")}</>
+ }
+ >
<ClientCertSourceSelector
value={resolvedClientCertSource}
onChange={onClientCertSourceChange!}
diff --git a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.test.tsx b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.test.tsx
index ce870e0c55..bcdfdf6b78 100644
--- a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.test.tsx
+++ b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.test.tsx
@@ -24,6 +24,7 @@ const mocks = vi.hoisted(() => ({
routerResolve: vi.fn(() => ({ fullPath: "/projects/proj1/issues/123" })),
// Captures the multi picker's server-search callback (undefined pre-fix).
dbOnSearch: undefined as ((q: string) => void) | undefined,
+ maximumRequestExpirationSeconds: undefined as number | undefined,
}));
vi.mock("react-i18next", () => ({
@@ -44,10 +45,14 @@ vi.mock("@/react/stores/app", () => {
const state = () => ({
fetchDatabases: mocks.fetchDatabases,
notify: mocks.pushNotification,
- // Consumed by useWorkspaceSQLEditorTheme (via useActiveSQLEditorTheme,
- // which drives the drawer's Monaco theme). Empty profile resolves to the
- // default theme.
- getWorkspaceProfile: () => ({}),
+ // Consumed by useWorkspaceSQLEditorTheme and expiration policy handling.
+ // Empty profile resolves to the default SQL Editor theme and no cap.
+ getWorkspaceProfile: () => ({
+ maximumRequestExpiration:
+ mocks.maximumRequestExpirationSeconds === undefined
+ ? undefined
+ : { seconds: BigInt(mocks.maximumRequestExpirationSeconds) },
+ }),
// Consumed by the shared DatabaseSelect (rendered by the drawer's picker).
workspaceResourceName: () => "workspaces/-",
getDatabaseByName: () => ({ name: "" }),
@@ -371,6 +376,7 @@ const setupMocks = () => {
mocks.fetchDatabases.mockResolvedValue({ databases: [], nextPageToken: "" });
// vi.clearAllMocks() does not reset a plain hoisted property.
mocks.dbOnSearch = undefined;
+ mocks.maximumRequestExpirationSeconds = undefined;
};
beforeEach(async () => {
@@ -391,6 +397,25 @@ afterEach(() => {
});
describe("AccessGrantRequestDrawer", () => {
+ test("shows the workspace maximum expiration hint when SQL access grants are capped", () => {
+ mocks.maximumRequestExpirationSeconds = 30 * 24 * 60 * 60;
+ const onClose = vi.fn();
+ const { container, render, unmount } = renderIntoContainer(
+ <AccessGrantRequestDrawer
+ targets={["instances/inst1/databases/mydb"]}
+ query="SELECT id FROM orders"
+ onClose={onClose}
+ />
+ );
+ render();
+
+ expect(container.textContent).toContain(
+ "project.members.request-role.max-expiration-hint"
+ );
+
+ unmount();
+ });
+
test("renders with pre-filled targets, query, unmask when passed as props", () => {
const onClose = vi.fn();
const { container, render, unmount } = renderIntoContainer(
diff --git a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
index 06b23b90a0..cb37728cbf 100644
--- a/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
+++ b/frontend/src/react/components/sql-editor/AccessGrantRequestDrawer.tsx
@@ -25,12 +25,7 @@ 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 { FormError, FormField } from "@/react/components/ui/form";
import {
Sheet,
SheetBody,
@@ -307,11 +302,14 @@ function AccessGrantRequestDrawerInner({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Databases */}
- <FormField>
- <FormLabel>
- {t("common.databases")}
- <span className="text-error ml-0.5">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.databases")}
+ <span className="text-error ml-0.5">*</span>
+ </>
+ }
+ >
<DatabaseSelect
multiple
value={targets}
@@ -321,11 +319,14 @@ function AccessGrantRequestDrawerInner({
</FormField>
{/* Statement */}
- <FormField>
- <FormLabel>
- {t("common.statement")}
- <span className="text-error ml-0.5">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.statement")}
+ <span className="text-error ml-0.5">*</span>
+ </>
+ }
+ >
<Alert
variant="info"
description={t("sql-editor.only-select-allowed")}
@@ -353,8 +354,7 @@ function AccessGrantRequestDrawerInner({
</FormField>
{/* Unmask */}
- <FormField>
- <FormLabel>{t("sql-editor.grant-type-unmask")}</FormLabel>
+ <FormField title={<>{t("sql-editor.grant-type-unmask")}</>}>
<label className="flex items-center gap-2 cursor-pointer">
<Checkbox
checked={unmask}
@@ -365,8 +365,7 @@ function AccessGrantRequestDrawerInner({
</FormField>
{/* Export */}
- <FormField>
- <FormLabel>{t("sql-editor.grant-type-export")}</FormLabel>
+ <FormField title={<>{t("sql-editor.grant-type-export")}</>}>
<label className="flex items-center gap-2 cursor-pointer">
<Checkbox
checked={exportResult}
@@ -377,11 +376,21 @@ function AccessGrantRequestDrawerInner({
</FormField>
{/* Expiration */}
- <FormField>
- <FormLabel>
- {t("common.expiration")}
- <span className="text-error ml-0.5">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.expiration")}
+ <span className="text-error ml-0.5">*</span>
+ </>
+ }
+ description={
+ maximumExpirationDays !== undefined
+ ? t("project.members.request-role.max-expiration-hint", {
+ days: maximumExpirationDays,
+ })
+ : undefined
+ }
+ >
<Combobox
value={String(duration)}
onChange={(val) => setDuration(Number(val))}
@@ -396,13 +405,6 @@ function AccessGrantRequestDrawerInner({
maxDate={maxDatetime}
/>
)}
- {maximumExpirationDays !== undefined && (
- <FormDescription>
- {t("project.members.request-role.max-expiration-hint", {
- days: maximumExpirationDays,
- })}
- </FormDescription>
- )}
{expirationIsInPast && (
<FormError>
{t("project.members.request-role.expiration-must-be-future")}
@@ -418,11 +420,14 @@ function AccessGrantRequestDrawerInner({
</FormField>
{/* Reason */}
- <FormField>
- <FormLabel>
- {t("common.reason")}
- <span className="text-error ml-0.5">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.reason")}
+ <span className="text-error ml-0.5">*</span>
+ </>
+ }
+ >
<Textarea
value={reason}
onChange={(e) => setReason(e.target.value)}
diff --git a/frontend/src/react/components/ui/form.test.tsx b/frontend/src/react/components/ui/form.test.tsx
index 9c3708db20..afe99292a8 100644
--- a/frontend/src/react/components/ui/form.test.tsx
+++ b/frontend/src/react/components/ui/form.test.tsx
@@ -1,26 +1,29 @@
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
import * as stylex from "@stylexjs/stylex";
import { act, createElement, type ReactElement } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, test } from "vitest";
import {
- FormControlAffix,
FormControlGroup,
FormControlRow,
+ FormError,
+ FormField,
FormFieldGroup,
- FormFieldRow,
- FormInlineAffix,
- FormMessage,
+ FormSection,
+ FormTitle,
} from "./form";
import {
- formControlAffixStyle,
formControlGroupStyle,
formControlRowStyle,
+ formErrorStyle,
formFieldGroupStyle,
- formFieldRowStyle,
- formInlineAffixStyle,
- formMessageStyle,
+ formFieldTitleStyle,
+ formSectionStyle,
} from "./styles.stylex";
+const formSource = readFileSync(join(import.meta.dirname, "form.tsx"), "utf8");
+
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
).IS_REACT_ACT_ENVIRONMENT = true;
@@ -42,78 +45,62 @@ const renderIntoContainer = (element: ReactElement) => {
};
};
-describe("FormMessage", () => {
+describe("FormError", () => {
afterEach(() => {
document.body.innerHTML = "";
});
test("renders field validation messages as alert text", () => {
const { container, unmount } = renderIntoContainer(
- createElement(FormMessage, null, "Title is required")
+ createElement(FormError, null, "Title is required")
);
- const message = container.querySelector('[data-slot="form-message"]');
+ const message = container.querySelector('[data-slot="form-error"]');
expect(message?.getAttribute("role")).toBe("alert");
expect(message?.textContent).toBe("Title is required");
expect(message?.className).toContain(
- stylex.props(formMessageStyle()).className ?? ""
+ stylex.props(formErrorStyle()).className ?? ""
);
unmount();
});
- test("renders field groups and horizontal field rows with shared spacing", () => {
+ test("renders field groups with shared spacing", () => {
const { container, unmount } = renderIntoContainer(
createElement(
FormFieldGroup,
null,
- createElement(
- FormFieldRow,
- null,
- createElement("label", null, "Environment"),
- createElement("input", { "aria-label": "Environment" })
- )
+ createElement(FormField, {
+ title: "Environment",
+ })
)
);
const group = container.querySelector('[data-slot="form-field-group"]');
- const row = container.querySelector('[data-slot="form-field-row"]');
expect(group?.className).toContain(
stylex.props(formFieldGroupStyle()).className ?? ""
);
- expect(row?.className).toContain(
- stylex.props(formFieldRowStyle()).className ?? ""
- );
- expect(row?.children).toHaveLength(2);
+ expect(group?.children).toHaveLength(1);
unmount();
});
- test("renders inline affix controls with non-shrinking affix text", () => {
+ test("renders form titles with the visual title style", () => {
const { container, unmount } = renderIntoContainer(
createElement(
- FormInlineAffix,
+ FormField,
null,
- createElement("input", { "aria-label": "Email local part" }),
- createElement(FormControlAffix, null, "@"),
- createElement(FormControlAffix, null, "example.com")
+ createElement(FormTitle, null, "Database name")
)
);
- const affix = container.querySelector('[data-slot="form-inline-affix"]');
- const affixText = container.querySelector(
- '[data-slot="form-control-affix"]'
+ const title = container.querySelector('[data-slot="form-field-title"]');
+ expect(title?.textContent).toBe("Database name");
+ expect(title?.className).toContain(
+ stylex.props(formFieldTitleStyle()).className ?? ""
);
- expect(affix?.className).toContain(
- stylex.props(formInlineAffixStyle()).className ?? ""
- );
- expect(affixText?.className).toContain(
- stylex.props(formControlAffixStyle()).className ?? ""
- );
- expect(affix?.textContent).toBe("@example.com");
-
unmount();
});
});
@@ -153,3 +140,123 @@ describe("Form control layouts", () => {
unmount();
});
});
+
+describe("Form section layouts", () => {
+ afterEach(() => {
+ document.body.innerHTML = "";
+ });
+
+ test("renders settings form sections with shared title and content slots", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(
+ FormSection,
+ { id: "general", title: "General" },
+ createElement(
+ FormFieldGroup,
+ null,
+ createElement(FormField, {
+ title: "Default landing page",
+ description: "Choose the first screen after signing in.",
+ })
+ )
+ )
+ );
+
+ const section = container.querySelector('[data-slot="form-section"]');
+ const title = container.querySelector('[data-slot="form-section-title"]');
+ const content = container.querySelector(
+ '[data-slot="form-section-content"]'
+ );
+ const fieldTitle = container.querySelector(
+ '[data-slot="form-field-title"]'
+ );
+ const fieldHeader = container.querySelector(
+ '[data-slot="form-field-header"]'
+ );
+ const fieldDescription = container.querySelector(
+ '[data-slot="form-field-description"]'
+ );
+
+ expect(section?.getAttribute("id")).toBe("general");
+ expect(section?.className).toContain(
+ stylex.props(formSectionStyle()).className ?? ""
+ );
+ expect(title?.getAttribute("role")).toBe("heading");
+ expect(title?.getAttribute("aria-level")).toBe("2");
+ expect(title?.textContent).toBe("General");
+ expect(content?.textContent).toBe(
+ "Default landing pageChoose the first screen after signing in."
+ );
+ expect(fieldHeader).not.toBeNull();
+ expect(fieldTitle?.textContent).toBe("Default landing page");
+ expect(fieldDescription?.textContent).toBe(
+ "Choose the first screen after signing in."
+ );
+ expect(section?.textContent).toBe(
+ "GeneralDefault landing pageChoose the first screen after signing in."
+ );
+
+ unmount();
+ });
+
+ test("renders complex section title nodes without nesting them in h2", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(
+ FormSection,
+ {
+ title: createElement(
+ "span",
+ { className: "inline-flex" },
+ "Announcement",
+ createElement("span", null, "Badge")
+ ),
+ },
+ createElement("div", null, "Content")
+ )
+ );
+
+ const title = container.querySelector('[data-slot="form-section-title"]');
+
+ expect(title?.getAttribute("role")).toBe("heading");
+ expect(title?.getAttribute("aria-level")).toBe("2");
+ expect(title?.querySelector("h2")).toBeNull();
+ expect(title?.textContent).toBe("AnnouncementBadge");
+
+ unmount();
+ });
+
+ test("does not expose legacy header composition primitives", () => {
+ expect(formSource).not.toContain("function FormSectionHeader");
+ expect(formSource).not.toContain("function FormSectionTitle");
+ expect(formSource).not.toContain("function FormSectionContent");
+ expect(formSource).not.toContain("function FormFieldHeader");
+ expect(formSource).not.toContain("function FormFieldTitle");
+ expect(formSource).not.toContain("function FormFieldSubtitle");
+ expect(formSource).not.toContain("function FormHelperText");
+ expect(formSource).not.toContain("function FormMessage");
+ expect(formSource).not.toContain("function FormControlAffix");
+ expect(formSource).not.toContain("function FormInlineAffix");
+ expect(formSource).not.toContain("function FormFieldRow");
+ });
+
+ test("documents every exposed API with a usage example", () => {
+ const exportedApis = [
+ "FormControlGroup",
+ "FormControlRow",
+ "FormError",
+ "FormField",
+ "FormFieldGroup",
+ "FormLabel",
+ "FormSection",
+ "FormTitle",
+ ];
+
+ for (const api of exportedApis) {
+ expect(formSource, api).toMatch(
+ new RegExp(
+ String.raw`/\*\*[\s\S]*?@example[\s\S]*?\*/\nfunction ${api}\b`
+ )
+ );
+ }
+ });
+});
diff --git a/frontend/src/react/components/ui/form.tsx b/frontend/src/react/components/ui/form.tsx
index bbe828d293..07732ec7fc 100644
--- a/frontend/src/react/components/ui/form.tsx
+++ b/frontend/src/react/components/ui/form.tsx
@@ -1,62 +1,103 @@
import * as stylex from "@stylexjs/stylex";
-import type { ComponentProps } from "react";
+import type { ComponentProps, ReactNode } from "react";
import { cn } from "@/react/lib/utils";
import {
- formControlAffixStyle,
formControlGroupStyle,
formControlRowStyle,
- formDescriptionStyle,
formErrorStyle,
+ formFieldDescriptionStyle,
formFieldGroupStyle,
- formFieldRowStyle,
+ formFieldHeaderStyle,
formFieldStyle,
- formInlineAffixStyle,
+ formFieldTitleStyle,
formLabelStyle,
- formMessageStyle,
+ formSectionContentStyle,
+ formSectionHeaderStyle,
+ formSectionStyle,
+ formSectionTitleStyle,
} from "./styles.stylex";
-function FormField({ className, ref, style, ...props }: ComponentProps<"div">) {
- const stylexProps = stylex.props(formFieldStyle());
- return (
- <div
- ref={ref}
- data-slot="form-field"
- className={cn(stylexProps.className, className)}
- style={{ ...stylexProps.style, ...style }}
- {...props}
- />
- );
+interface FormFieldProps extends Omit<ComponentProps<"div">, "title"> {
+ title?: ReactNode;
+ description?: ReactNode;
}
-function FormFieldGroup({
+/**
+ * Groups one logical form field with its optional title, description, control,
+ * and validation feedback.
+ *
+ * @example
+ * ```tsx
+ * <FormField title={fieldTitle} description={fieldDescription}>
+ * <Input value={name} onChange={(event) => setName(event.target.value)} />
+ * {error && <FormError>{error}</FormError>}
+ * </FormField>
+ * ```
+ */
+function FormField({
+ children,
className,
+ description,
ref,
style,
+ title,
...props
-}: ComponentProps<"div">) {
- const stylexProps = stylex.props(formFieldGroupStyle());
+}: FormFieldProps) {
+ const fieldStylexProps = stylex.props(formFieldStyle());
+ const headerStylexProps = stylex.props(formFieldHeaderStyle());
+ const descriptionStylexProps = stylex.props(formFieldDescriptionStyle());
+ const hasHeader = title !== undefined || description !== undefined;
+
return (
<div
ref={ref}
- data-slot="form-field-group"
- className={cn(stylexProps.className, className)}
- style={{ ...stylexProps.style, ...style }}
+ data-slot="form-field"
+ className={cn(fieldStylexProps.className, className)}
+ style={{ ...fieldStylexProps.style, ...style }}
{...props}
- />
+ >
+ {hasHeader && (
+ <div
+ data-slot="form-field-header"
+ className={headerStylexProps.className}
+ style={headerStylexProps.style}
+ >
+ {title !== undefined && <FormTitle>{title}</FormTitle>}
+ {description !== undefined && (
+ <div
+ data-slot="form-field-description"
+ className={descriptionStylexProps.className}
+ style={descriptionStylexProps.style}
+ >
+ {description}
+ </div>
+ )}
+ </div>
+ )}
+ {children}
+ </div>
);
}
-function FormFieldRow({
- className,
- ref,
- style,
- ...props
-}: ComponentProps<"div">) {
- const stylexProps = stylex.props(formFieldRowStyle());
+/**
+ * Renders the visual title for a form field. Prefer `FormField title` for
+ * ordinary fields, and use `FormTitle` directly when the title row contains
+ * custom layout or actions.
+ *
+ * @example
+ * ```tsx
+ * <FormField>
+ * <FormTitle>{fieldTitle}</FormTitle>
+ * <Input value={name} onChange={handleNameChange} />
+ * </FormField>
+ * ```
+ */
+function FormTitle({ className, ref, style, ...props }: ComponentProps<"div">) {
+ const stylexProps = stylex.props(formFieldTitleStyle());
return (
<div
ref={ref}
- data-slot="form-field-row"
+ data-slot="form-field-title"
className={cn(stylexProps.className, className)}
style={{ ...stylexProps.style, ...style }}
{...props}
@@ -64,17 +105,32 @@ function FormFieldRow({
);
}
-function FormControlGroup({
+/**
+ * Stacks related form fields inside a section or dialog.
+ *
+ * @example
+ * ```tsx
+ * <FormFieldGroup>
+ * <FormField title={nameTitle}>
+ * <Input value={name} onChange={handleNameChange} />
+ * </FormField>
+ * <FormField title={descriptionTitle}>
+ * <Input value={description} onChange={handleDescriptionChange} />
+ * </FormField>
+ * </FormFieldGroup>
+ * ```
+ */
+function FormFieldGroup({
className,
ref,
style,
...props
}: ComponentProps<"div">) {
- const stylexProps = stylex.props(formControlGroupStyle());
+ const stylexProps = stylex.props(formFieldGroupStyle());
return (
<div
ref={ref}
- data-slot="form-control-group"
+ data-slot="form-field-group"
className={cn(stylexProps.className, className)}
style={{ ...stylexProps.style, ...style }}
{...props}
@@ -82,35 +138,96 @@ function FormControlGroup({
);
}
-function FormControlRow({
+interface FormSectionProps extends Omit<ComponentProps<"section">, "title"> {
+ title: ReactNode;
+}
+
+/**
+ * Wraps a settings page section with a consistent section heading and content
+ * column.
+ *
+ * @example
+ * ```tsx
+ * <FormSection id="general" title={sectionTitle}>
+ * <FormFieldGroup>
+ * <FormField title={fieldTitle}>
+ * <Input value={name} onChange={handleNameChange} />
+ * </FormField>
+ * </FormFieldGroup>
+ * </FormSection>
+ * ```
+ */
+function FormSection({
+ children,
className,
ref,
style,
+ title,
...props
-}: ComponentProps<"div">) {
- const stylexProps = stylex.props(formControlRowStyle());
+}: FormSectionProps) {
+ const sectionStylexProps = stylex.props(formSectionStyle());
+ const headerStylexProps = stylex.props(formSectionHeaderStyle());
+ const titleStylexProps = stylex.props(formSectionTitleStyle());
+ const contentStylexProps = stylex.props(formSectionContentStyle());
+
return (
- <div
+ <section
ref={ref}
- data-slot="form-control-row"
- className={cn(stylexProps.className, className)}
- style={{ ...stylexProps.style, ...style }}
+ data-slot="form-section"
+ className={cn(sectionStylexProps.className, className)}
+ style={{ ...sectionStylexProps.style, ...style }}
{...props}
- />
+ >
+ <div
+ data-slot="form-section-header"
+ className={headerStylexProps.className}
+ style={headerStylexProps.style}
+ >
+ <div
+ role="heading"
+ aria-level={2}
+ data-slot="form-section-title"
+ className={titleStylexProps.className}
+ style={titleStylexProps.style}
+ >
+ {title}
+ </div>
+ </div>
+ <div
+ data-slot="form-section-content"
+ className={contentStylexProps.className}
+ style={contentStylexProps.style}
+ >
+ {children}
+ </div>
+ </section>
);
}
-function FormInlineAffix({
+/**
+ * Stacks multiple control rows that belong to the same field.
+ *
+ * @example
+ * ```tsx
+ * <FormControlGroup>
+ * <FormControlRow>
+ * <Input value={key} onChange={handleKeyChange} />
+ * <Input value={value} onChange={handleValueChange} />
+ * </FormControlRow>
+ * </FormControlGroup>
+ * ```
+ */
+function FormControlGroup({
className,
ref,
style,
...props
}: ComponentProps<"div">) {
- const stylexProps = stylex.props(formInlineAffixStyle());
+ const stylexProps = stylex.props(formControlGroupStyle());
return (
<div
ref={ref}
- data-slot="form-inline-affix"
+ data-slot="form-control-group"
className={cn(stylexProps.className, className)}
style={{ ...stylexProps.style, ...style }}
{...props}
@@ -118,17 +235,29 @@ function FormInlineAffix({
);
}
-function FormControlAffix({
+/**
+ * Aligns controls horizontally inside a field.
+ *
+ * @example
+ * ```tsx
+ * <FormControlRow>
+ * <Input value={parameter.name} onChange={handleNameChange} />
+ * <Input value={parameter.value} onChange={handleValueChange} />
+ * <Button type="button" onClick={handleRemove}>{removeLabel}</Button>
+ * </FormControlRow>
+ * ```
+ */
+function FormControlRow({
className,
ref,
style,
...props
-}: ComponentProps<"span">) {
- const stylexProps = stylex.props(formControlAffixStyle());
+}: ComponentProps<"div">) {
+ const stylexProps = stylex.props(formControlRowStyle());
return (
- <span
+ <div
ref={ref}
- data-slot="form-control-affix"
+ data-slot="form-control-row"
className={cn(stylexProps.className, className)}
style={{ ...stylexProps.style, ...style }}
{...props}
@@ -136,6 +265,17 @@ function FormControlAffix({
);
}
+/**
+ * Renders a semantic label for a native or shared control.
+ *
+ * @example
+ * ```tsx
+ * <FormField>
+ * <FormLabel htmlFor="database-name">{databaseLabel}</FormLabel>
+ * <Input id="database-name" value={database} onChange={handleDatabaseChange} />
+ * </FormField>
+ * ```
+ */
function FormLabel({
className,
htmlFor,
@@ -156,24 +296,17 @@ function FormLabel({
);
}
-function FormDescription({
- className,
- ref,
- style,
- ...props
-}: ComponentProps<"p">) {
- const stylexProps = stylex.props(formDescriptionStyle());
- return (
- <p
- ref={ref}
- data-slot="form-description"
- className={cn(stylexProps.className, className)}
- style={{ ...stylexProps.style, ...style }}
- {...props}
- />
- );
-}
-
+/**
+ * Renders validation text for a field. Use it for blocking errors only.
+ *
+ * @example
+ * ```tsx
+ * <FormField title={fieldTitle}>
+ * <Input value={name} onChange={handleNameChange} />
+ * {nameError && <FormError>{nameError}</FormError>}
+ * </FormField>
+ * ```
+ */
function FormError({
className,
ref,
@@ -194,36 +327,13 @@ function FormError({
);
}
-function FormMessage({
- className,
- ref,
- role = "alert",
- style,
- ...props
-}: ComponentProps<"p">) {
- const stylexProps = stylex.props(formMessageStyle());
- return (
- <p
- ref={ref}
- role={role}
- data-slot="form-message"
- className={cn(stylexProps.className, className)}
- style={{ ...stylexProps.style, ...style }}
- {...props}
- />
- );
-}
-
export {
- FormControlAffix,
FormControlGroup,
FormControlRow,
- FormDescription,
FormError,
FormField,
FormFieldGroup,
- FormFieldRow,
- FormInlineAffix,
FormLabel,
- FormMessage,
+ FormSection,
+ FormTitle,
};
diff --git a/frontend/src/react/components/ui/styles.stylex.test.tsx b/frontend/src/react/components/ui/styles.stylex.test.tsx
index 5d63f4a487..7e0de2ae65 100644
--- a/frontend/src/react/components/ui/styles.stylex.test.tsx
+++ b/frontend/src/react/components/ui/styles.stylex.test.tsx
@@ -1,3 +1,4 @@
+import { readFileSync } from "node:fs";
import * as stylex from "@stylexjs/stylex";
import { act, createElement, type ReactElement } from "react";
import { createRoot } from "react-dom/client";
@@ -5,17 +6,13 @@ import { afterEach, describe, expect, test } from "vitest";
import { Button } from "./button";
import { Combobox } from "./combobox";
import {
- FormControlAffix,
FormControlGroup,
FormControlRow,
- FormDescription,
FormError,
FormField,
FormFieldGroup,
- FormFieldRow,
- FormInlineAffix,
FormLabel,
- FormMessage,
+ FormTitle,
} from "./form";
import { Input } from "./input";
import { NumberInput } from "./number-input";
@@ -25,17 +22,13 @@ import {
controlMinHeightStyle,
controlMultilineSizeStyle,
controlSizeStyle,
- formControlAffixStyle,
formControlGroupStyle,
formControlRowStyle,
- formDescriptionStyle,
formErrorStyle,
formFieldGroupStyle,
- formFieldRowStyle,
formFieldStyle,
- formInlineAffixStyle,
+ formFieldTitleStyle,
formLabelStyle,
- formMessageStyle,
interactiveRowStyle,
listRowIconStyle,
listRowPrimaryTextStyle,
@@ -84,6 +77,19 @@ const expectClasses = (className: string | undefined, expected: string) => {
}
};
+const styleSource = readFileSync(
+ "src/react/components/ui/styles.stylex.ts",
+ "utf8"
+);
+
+const extractStyleBlock = (styleName: string) => {
+ const match = styleSource.match(
+ new RegExp(`\\n ${styleName}: \\{([\\s\\S]*?)\\n \\},`)
+ );
+ expect(match, `${styleName} style block should exist`).not.toBeNull();
+ return match?.[1] ?? "";
+};
+
describe("StyleX common UI style contracts", () => {
afterEach(() => {
document.body.innerHTML = "";
@@ -99,15 +105,10 @@ describe("StyleX common UI style contracts", () => {
test("returns StyleX props for shared form, menu, and list row styles", () => {
expectStyleXClass(stylex.props(formFieldStyle()).className);
expectStyleXClass(stylex.props(formFieldGroupStyle()).className);
- expectStyleXClass(stylex.props(formFieldRowStyle()).className);
expectStyleXClass(stylex.props(formControlGroupStyle()).className);
expectStyleXClass(stylex.props(formControlRowStyle()).className);
- expectStyleXClass(stylex.props(formInlineAffixStyle()).className);
- expectStyleXClass(stylex.props(formControlAffixStyle()).className);
expectStyleXClass(stylex.props(formLabelStyle()).className);
- expectStyleXClass(stylex.props(formDescriptionStyle()).className);
expectStyleXClass(stylex.props(formErrorStyle()).className);
- expectStyleXClass(stylex.props(formMessageStyle()).className);
expectStyleXClass(stylex.props(menuRowStyle("md")).className);
expectStyleXClass(stylex.props(listRowStyle("sm")).className);
expectStyleXClass(stylex.props(listRowIconStyle()).className);
@@ -127,6 +128,15 @@ describe("StyleX common UI style contracts", () => {
);
});
+ test("keeps form labels visually distinct from field titles", () => {
+ const labelStyle = extractStyleBlock("label");
+
+ expect(labelStyle).toContain('color: "rgb(var(--color-control))"');
+ expect(labelStyle).toContain("fontSize: 14");
+ expect(labelStyle).toContain("fontWeight: 500");
+ expect(labelStyle).toContain('lineHeight: "20px"');
+ });
+
test("keeps list row state separate from menu row state", () => {
expectClasses(
listRowStateClassName,
@@ -170,8 +180,8 @@ describe("StyleX common UI style contracts", () => {
const textarea = renderIntoContainer(
createElement(Textarea, { size: "lg" })
);
- const formMessage = renderIntoContainer(
- createElement(FormMessage, null, "Title is required.")
+ const formError = renderIntoContainer(
+ createElement(FormError, null, "Title is required.")
);
const controlGroup = renderIntoContainer(
createElement(
@@ -184,24 +194,9 @@ describe("StyleX common UI style contracts", () => {
createElement(
FormFieldGroup,
null,
- createElement(
- FormFieldRow,
- null,
- createElement(FormLabel, null, "Environment"),
- createElement(Input)
- )
- )
- );
- const inlineAffix = renderIntoContainer(
- createElement(
- FormInlineAffix,
- null,
- createElement(Input),
- createElement(FormControlAffix, null, "@"),
- createElement(FormControlAffix, null, "example.com")
+ createElement(FormField, { title: "Environment" }, createElement(Input))
)
);
-
expectClasses(
button.container.querySelector("button")?.className,
"h-7 px-2 text-xs leading-4 gap-1"
@@ -232,9 +227,8 @@ describe("StyleX common UI style contracts", () => {
stylex.props(controlMultilineSizeStyle("lg")).className ?? ""
);
expectClasses(
- formMessage.container.querySelector('[data-slot="form-message"]')
- ?.className,
- stylex.props(formMessageStyle()).className ?? ""
+ formError.container.querySelector('[data-slot="form-error"]')?.className,
+ stylex.props(formErrorStyle()).className ?? ""
);
expectClasses(
controlGroup.container.querySelector('[data-slot="form-control-group"]')
@@ -251,32 +245,15 @@ describe("StyleX common UI style contracts", () => {
?.className,
stylex.props(formFieldGroupStyle()).className ?? ""
);
- expectClasses(
- fieldGroup.container.querySelector('[data-slot="form-field-row"]')
- ?.className,
- stylex.props(formFieldRowStyle()).className ?? ""
- );
- expectClasses(
- inlineAffix.container.querySelector('[data-slot="form-inline-affix"]')
- ?.className,
- stylex.props(formInlineAffixStyle()).className ?? ""
- );
- expectClasses(
- inlineAffix.container.querySelector('[data-slot="form-control-affix"]')
- ?.className,
- stylex.props(formControlAffixStyle()).className ?? ""
- );
-
button.unmount();
input.unmount();
segmentedControl.unmount();
select.unmount();
numberInput.unmount();
textarea.unmount();
- formMessage.unmount();
+ formError.unmount();
controlGroup.unmount();
fieldGroup.unmount();
- inlineAffix.unmount();
});
test("applies shared menu row contract to combobox option rows", () => {
@@ -322,9 +299,9 @@ describe("StyleX common UI style contracts", () => {
const form = renderIntoContainer(
createElement(
FormField,
- null,
- createElement(FormLabel, null, "Project"),
- createElement(FormDescription, null, "Select a project."),
+ { description: "Select a project.", title: "Project" },
+ createElement(FormTitle, null, "Database name"),
+ createElement(FormLabel, { htmlFor: "project" }, "Project"),
createElement(FormError, null, "Project is required.")
)
);
@@ -333,13 +310,17 @@ describe("StyleX common UI style contracts", () => {
form.container.firstElementChild?.className,
stylex.props(formFieldStyle()).className ?? ""
);
+ expectClasses(
+ form.container.querySelector("[data-slot='form-field-title']")?.className,
+ stylex.props(formFieldTitleStyle()).className ?? ""
+ );
expectClasses(
form.container.querySelector("label")?.className,
stylex.props(formLabelStyle()).className ?? ""
);
expectClasses(
- form.container.querySelector("[data-slot='form-description']")?.className,
- stylex.props(formDescriptionStyle()).className ?? ""
+ form.container.querySelector("[data-slot='form-field']")?.className,
+ stylex.props(formFieldStyle()).className ?? ""
);
expectClasses(
form.container.querySelector("[data-slot='form-error']")?.className,
diff --git a/frontend/src/react/components/ui/styles.stylex.ts b/frontend/src/react/components/ui/styles.stylex.ts
index c6ce8fa8c9..bf20cf3372 100644
--- a/frontend/src/react/components/ui/styles.stylex.ts
+++ b/frontend/src/react/components/ui/styles.stylex.ts
@@ -196,13 +196,6 @@ export function controlMultilineSizeStyle(size: ControlSize) {
}
const formStyles = stylex.create({
- affix: {
- color: "rgb(var(--color-control-light))",
- flexShrink: 0,
- fontSize: 14,
- lineHeight: "20px",
- whiteSpace: "nowrap",
- },
controlGroup: {
display: "flex",
flexDirection: "column",
@@ -224,18 +217,21 @@ const formStyles = stylex.create({
flexDirection: "column",
rowGap: 24,
},
- fieldRow: {
- alignItems: "center",
- columnGap: 16,
- display: "grid",
- gridTemplateColumns: "minmax(10rem, 14rem) minmax(0, 1fr)",
- },
- inlineAffix: {
- alignItems: "center",
- columnGap: 4,
+ fieldHeader: {
display: "flex",
- minWidth: 0,
- width: "100%",
+ flexDirection: "column",
+ rowGap: 0,
+ },
+ fieldTitle: {
+ color: "rgb(var(--color-main))",
+ fontSize: 16,
+ fontWeight: 600,
+ lineHeight: "24px",
+ },
+ fieldDescription: {
+ color: "rgb(var(--color-control-placeholder))",
+ fontSize: 14,
+ lineHeight: "20px",
},
label: {
alignItems: "center",
@@ -246,16 +242,39 @@ const formStyles = stylex.create({
fontWeight: 500,
lineHeight: "20px",
},
- description: {
- color: "rgb(var(--color-control-light))",
- fontSize: 12,
- lineHeight: "16px",
- },
error: {
color: "rgb(var(--color-error))",
fontSize: 12,
lineHeight: "16px",
},
+ section: {
+ paddingBlock: 24,
+ rowGap: 16,
+ "@media (min-width: 1024px)": {
+ display: "flex",
+ rowGap: 0,
+ },
+ },
+ sectionContent: {
+ flex: 1,
+ marginTop: 16,
+ "@media (min-width: 1024px)": {
+ marginTop: 0,
+ paddingInline: 16,
+ },
+ },
+ sectionHeader: {
+ textAlign: "left",
+ "@media (min-width: 1024px)": {
+ width: "25%",
+ },
+ },
+ sectionTitle: {
+ color: "rgb(var(--color-main))",
+ fontSize: 24,
+ fontWeight: 700,
+ lineHeight: "32px",
+ },
});
export function formFieldStyle() {
@@ -266,18 +285,10 @@ export function formLabelStyle() {
return formStyles.label;
}
-export function formDescriptionStyle() {
- return formStyles.description;
-}
-
export function formErrorStyle() {
return formStyles.error;
}
-export function formMessageStyle() {
- return formStyles.error;
-}
-
export function formControlGroupStyle() {
return formStyles.controlGroup;
}
@@ -290,16 +301,32 @@ export function formFieldGroupStyle() {
return formStyles.fieldGroup;
}
-export function formFieldRowStyle() {
- return formStyles.fieldRow;
+export function formFieldHeaderStyle() {
+ return formStyles.fieldHeader;
+}
+
+export function formFieldTitleStyle() {
+ return formStyles.fieldTitle;
+}
+
+export function formFieldDescriptionStyle() {
+ return formStyles.fieldDescription;
+}
+
+export function formSectionStyle() {
+ return formStyles.section;
+}
+
+export function formSectionHeaderStyle() {
+ return formStyles.sectionHeader;
}
-export function formInlineAffixStyle() {
- return formStyles.inlineAffix;
+export function formSectionTitleStyle() {
+ return formStyles.sectionTitle;
}
-export function formControlAffixStyle() {
- return formStyles.affix;
+export function formSectionContentStyle() {
+ return formStyles.sectionContent;
}
const stickyActionFooterStyles = stylex.create({
diff --git a/frontend/src/react/pages/project/ProjectSettingsPage.tsx b/frontend/src/react/pages/project/ProjectSettingsPage.tsx
index 64f726a92d..0273fc4232 100644
--- a/frontend/src/react/pages/project/ProjectSettingsPage.tsx
+++ b/frontend/src/react/pages/project/ProjectSettingsPage.tsx
@@ -1,7 +1,14 @@
import { create } from "@bufbuild/protobuf";
import { cloneDeep, isEqual } from "lodash-es";
import { ShieldCheck, TriangleAlert, X } from "lucide-react";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import {
+ type ReactNode,
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import { useTranslation } from "react-i18next";
import { FeatureBadge } from "@/react/components/FeatureBadge";
import { LabelListEditor } from "@/react/components/LabelListEditor";
@@ -14,6 +21,12 @@ import {
DialogContent,
DialogTitle,
} from "@/react/components/ui/dialog";
+import {
+ FormControlRow,
+ FormField,
+ FormFieldGroup,
+ FormSection,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { NumberInput } from "@/react/components/ui/number-input";
import { StickyActionFooter } from "@/react/components/ui/sticky-action-footer";
@@ -658,23 +671,22 @@ export function ProjectSettingsPage() {
{/* ============================================================= */}
{/* Section 1: General */}
{/* ============================================================= */}
- <div className="pb-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">{t("common.general")}</h1>
- </div>
- <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
- <PermissionGuard
- permissions={["bb.projects.update"]}
- project={project}
- display="block"
- >
- <form className="w-full flex flex-col gap-y-4">
- <div>
- <div className="font-medium">
- {t("common.name")} <span className="text-error">*</span>
- </div>
+ <FormSection title={t("common.general")}>
+ <PermissionGuard
+ permissions={["bb.projects.update"]}
+ project={project}
+ display="block"
+ >
+ <form className="w-full">
+ <FormFieldGroup>
+ <FormField
+ title={
+ <>
+ {t("common.name")} <span className="text-error">*</span>
+ </>
+ }
+ >
<Input
- className="mt-1"
value={title}
onChange={(e) => setTitle(e.target.value)}
disabled={
@@ -684,114 +696,101 @@ export function ProjectSettingsPage() {
}
required
/>
- <div className="mt-1">
- <ResourceIdField
- readonly
- value={extractProjectResourceName(project.name)}
- resourceName={t("common.project")}
- />
- </div>
- </div>
+ <ResourceIdField
+ readonly
+ value={extractProjectResourceName(project.name)}
+ resourceName={t("common.project")}
+ />
+ </FormField>
{/* Project Labels */}
- <div>
- <div className="font-medium">
- {t("project.settings.project-labels.self")}
- </div>
- <div className="text-sm text-control-light mb-3">
- {t("project.settings.project-labels.description")}
- </div>
+ <FormField
+ title={t("project.settings.project-labels.self")}
+ description={t("project.settings.project-labels.description")}
+ >
<LabelListEditor
kvList={labelKVList}
onChange={setLabelKVList}
readonly={!canUpdateProject}
onErrorsChange={setLabelErrors}
/>
- </div>
- </form>
- </PermissionGuard>
- </div>
- </div>
+ </FormField>
+ </FormFieldGroup>
+ </form>
+ </PermissionGuard>
+ </FormSection>
{/* ============================================================= */}
{/* Section 2: Security & Policy */}
{/* ============================================================= */}
- <div className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">
- {t("settings.sidebar.security-and-policy")}
- </h1>
- </div>
- <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
- <div className="w-full flex flex-col justify-start items-start gap-y-6">
- {/* SQL Review + Max Rows: gated on bb.policies.get */}
- {canGetPolicies && (
- <>
- {/* SQL Review */}
- {hasWorkspacePermissionV2("bb.reviewConfigs.get") && (
- <div className="flex flex-col gap-y-2">
- <label className="font-medium">
- {t("sql-review.title")}
- </label>
- <div>
- {pendingReviewPolicy ? (
- <div className="inline-flex items-center gap-x-2">
- <Switch
- checked={enforceReview}
- onCheckedChange={setEnforceReview}
- disabled={
- !hasWorkspacePermissionV2(
- "bb.reviewConfigs.update"
- )
- }
- />
- <span
- className="text-sm font-medium text-accent cursor-pointer hover:underline"
- onClick={() =>
- router.push({
- name: WORKSPACE_ROUTE_SQL_REVIEW_DETAIL,
- params: {
- sqlReviewPolicySlug:
- sqlReviewPolicySlug(pendingReviewPolicy),
- },
- })
- }
- >
- {pendingReviewPolicy.name}
- </span>
- {canUpdatePolicies && (
- <Button
- variant="ghost"
- size="sm"
- onClick={() => {
- setPendingReviewPolicy(undefined);
- setEnforceReview(false);
- }}
- >
- <X className="size-4" />
- </Button>
- )}
- </div>
- ) : (
- <Button
- variant="outline"
+ <FormSection title={t("settings.sidebar.security-and-policy")}>
+ <FormFieldGroup>
+ {/* SQL Review + Max Rows: gated on bb.policies.get */}
+ {canGetPolicies && (
+ <>
+ {/* SQL Review */}
+ {hasWorkspacePermissionV2("bb.reviewConfigs.get") && (
+ <FormField title={t("sql-review.title")}>
+ <div>
+ {pendingReviewPolicy ? (
+ <FormControlRow>
+ <Switch
+ checked={enforceReview}
+ onCheckedChange={setEnforceReview}
disabled={
- !canUpdatePolicies ||
- !hasWorkspacePermissionV2("bb.reviewConfigs.list")
+ !hasWorkspacePermissionV2(
+ "bb.reviewConfigs.update"
+ )
+ }
+ />
+ <span
+ className="text-sm font-medium text-accent cursor-pointer hover:underline"
+ onClick={() =>
+ router.push({
+ name: WORKSPACE_ROUTE_SQL_REVIEW_DETAIL,
+ params: {
+ sqlReviewPolicySlug:
+ sqlReviewPolicySlug(pendingReviewPolicy),
+ },
+ })
}
- onClick={() => setShowReviewDialog(true)}
>
- {t("sql-review.configure-policy")}
- </Button>
- )}
- </div>
+ {pendingReviewPolicy.name}
+ </span>
+ {canUpdatePolicies && (
+ <Button
+ variant="ghost"
+ size="sm"
+ onClick={() => {
+ setPendingReviewPolicy(undefined);
+ setEnforceReview(false);
+ }}
+ >
+ <X className="size-4" />
+ </Button>
+ )}
+ </FormControlRow>
+ ) : (
+ <Button
+ variant="outline"
+ disabled={
+ !canUpdatePolicies ||
+ !hasWorkspacePermissionV2("bb.reviewConfigs.list")
+ }
+ onClick={() => setShowReviewDialog(true)}
+ >
+ {t("sql-review.configure-policy")}
+ </Button>
+ )}
</div>
- )}
+ </FormField>
+ )}
- {/* Maximum SQL Result Rows */}
- <div>
- <p className="font-medium flex flex-row justify-start items-center">
- <span className="mr-2">
+ {/* Maximum SQL Result Rows */}
+ <FormField
+ title={
+ <FormControlRow className="w-auto">
+ <span>
{t(
"settings.general.workspace.maximum-sql-result.rows.self"
)}
@@ -799,359 +798,333 @@ export function ProjectSettingsPage() {
<FeatureBadge
feature={PlanFeature.FEATURE_QUERY_POLICY}
/>
- </p>
- <p className="text-sm text-control-placeholder mt-1">
+ </FormControlRow>
+ }
+ description={
+ <>
{t(
"settings.general.workspace.maximum-sql-result.rows.description"
)}{" "}
<span className="font-semibold">
{t("settings.general.workspace.no-limit")}
</span>
- </p>
- <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">
- <NumberInput
- className="w-60"
- min={0}
- value={maxRows}
- onValueChange={setMaxRows}
- disabled={!hasQueryPolicyFeature || !canUpdatePolicies}
- />
- <span className="text-sm text-control-light">
- {t(
- "settings.general.workspace.maximum-sql-result.rows.rows"
- )}
- </span>
- </div>
- </div>
- </>
- )}
+ </>
+ }
+ >
+ <FormControlRow>
+ <NumberInput
+ className="w-60"
+ min={0}
+ value={maxRows}
+ onValueChange={setMaxRows}
+ disabled={!hasQueryPolicyFeature || !canUpdatePolicies}
+ />
+ <span className="text-sm text-control-light">
+ {t(
+ "settings.general.workspace.maximum-sql-result.rows.rows"
+ )}
+ </span>
+ </FormControlRow>
+ </FormField>
+ </>
+ )}
- {/* Allow Request Role */}
- <div>
- <div className="flex items-center gap-x-2">
- <Switch
- checked={allowRequestRole}
- onCheckedChange={setAllowRequestRole}
- disabled={!canUpdateProject}
- />
- <span className="text-sm font-medium">
- {t(
- "project.settings.issue-related.allow-request-role.self"
- )}
- </span>
- <ApprovalFlowIndicator
- source={WorkspaceApprovalSetting_Rule_Source.REQUEST_ROLE}
- />
- </div>
- <div className="mt-1 text-sm text-control-placeholder">
- {t(
- "project.settings.issue-related.allow-request-role.description"
- )}
- </div>
- </div>
+ {/* Allow Request Role */}
+ <ToggleRow
+ checked={allowRequestRole}
+ onCheckedChange={setAllowRequestRole}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.allow-request-role.self"
+ )}
+ description={t(
+ "project.settings.issue-related.allow-request-role.description"
+ )}
+ trailing={
+ <ApprovalFlowIndicator
+ source={WorkspaceApprovalSetting_Rule_Source.REQUEST_ROLE}
+ />
+ }
+ />
- {/* Allow JIT Access */}
- <div>
- <div className="flex items-center gap-x-2">
- <Switch
- checked={allowJustInTimeAccess}
- onCheckedChange={setAllowJustInTimeAccess}
- disabled={!canUpdateProject}
- />
- <span className="text-sm font-medium">
- {t("project.settings.issue-related.allow-jit.self")}
- </span>
- <ApprovalFlowIndicator
- source={WorkspaceApprovalSetting_Rule_Source.REQUEST_ACCESS}
- />
- </div>
- <div className="mt-1 text-sm text-control-placeholder">
- {t("project.settings.issue-related.allow-jit.description")}
- </div>
- </div>
- </div>
- </div>
- </div>
+ {/* Allow JIT Access */}
+ <ToggleRow
+ checked={allowJustInTimeAccess}
+ onCheckedChange={setAllowJustInTimeAccess}
+ disabled={!canUpdateProject}
+ label={t("project.settings.issue-related.allow-jit.self")}
+ description={t(
+ "project.settings.issue-related.allow-jit.description"
+ )}
+ trailing={
+ <ApprovalFlowIndicator
+ source={WorkspaceApprovalSetting_Rule_Source.REQUEST_ACCESS}
+ />
+ }
+ />
+ </FormFieldGroup>
+ </FormSection>
{/* ============================================================= */}
{/* Section 3: Issue-Related */}
{/* ============================================================= */}
- <div id="issue-related" className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">
- {t("project.settings.issue-related.self")}
- </h1>
- </div>
- <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
- <div className="w-full flex flex-col justify-start items-start gap-y-6">
- {/* Issue Labels */}
- <div className="flex flex-col gap-y-2">
- <div className="font-medium">
- {t("project.settings.issue-related.labels.self")}
- <div className="text-sm text-control-light font-normal">
- {t("project.settings.issue-related.labels.description")}
- </div>
- </div>
- <div className="flex flex-wrap items-center gap-2">
- {issueLabels.map((label, index) => (
- <span
- key={index}
- className="inline-flex h-9 items-center gap-x-2 border border-control-border rounded-sm px-1 py-1"
- >
- <input
- type="color"
- value={
- label.color ? colorToHex(label.color) : "#4f46e5"
- }
- onChange={(e) =>
- updateIssueLabelColor(index, e.target.value)
- }
- disabled={!canUpdateProject}
- className="w-5 h-6 rounded-sm cursor-pointer border-0 p-0"
- />
- <span className="text-sm">{label.value}</span>
- {canUpdateProject && (
- <button
- type="button"
- className="text-control-light hover:text-main"
- onClick={() => removeIssueLabel(index)}
- >
- <X className="size-3" />
- </button>
- )}
- </span>
- ))}
- {canUpdateProject && (
- <div className="inline-flex items-center gap-x-1">
- <Input
- className="w-48"
- placeholder={t(
- "project.settings.issue-related.labels.placeholder"
- )}
- value={newLabelValue}
- onChange={(e) => setNewLabelValue(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- e.preventDefault();
- addIssueLabel();
- }
- }}
- />
- <Button
- variant="outline"
- size="md"
- onClick={addIssueLabel}
- disabled={!newLabelValue.trim()}
+ <FormSection
+ id="issue-related"
+ title={t("project.settings.issue-related.self")}
+ >
+ <FormFieldGroup>
+ {/* Issue Labels */}
+ <FormField
+ title={t("project.settings.issue-related.labels.self")}
+ description={t(
+ "project.settings.issue-related.labels.description"
+ )}
+ >
+ <div className="flex flex-wrap items-center gap-2">
+ {issueLabels.map((label, index) => (
+ <span
+ key={index}
+ className="inline-flex h-9 items-center gap-x-2 border border-control-border rounded-sm px-1 py-1"
+ >
+ <input
+ type="color"
+ value={label.color ? colorToHex(label.color) : "#4f46e5"}
+ onChange={(e) =>
+ updateIssueLabelColor(index, e.target.value)
+ }
+ disabled={!canUpdateProject}
+ className="w-5 h-6 rounded-sm cursor-pointer border-0 p-0"
+ />
+ <span className="text-sm">{label.value}</span>
+ {canUpdateProject && (
+ <button
+ type="button"
+ className="text-control-light hover:text-main"
+ onClick={() => removeIssueLabel(index)}
>
- {t("common.add")}
- </Button>
- </div>
- )}
- </div>
+ <X className="size-3" />
+ </button>
+ )}
+ </span>
+ ))}
+ {canUpdateProject && (
+ <div className="inline-flex items-center gap-x-1">
+ <Input
+ className="w-48"
+ placeholder={t(
+ "project.settings.issue-related.labels.placeholder"
+ )}
+ value={newLabelValue}
+ onChange={(e) => setNewLabelValue(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ addIssueLabel();
+ }
+ }}
+ />
+ <Button
+ variant="outline"
+ size="md"
+ onClick={addIssueLabel}
+ disabled={!newLabelValue.trim()}
+ >
+ {t("common.add")}
+ </Button>
+ </div>
+ )}
</div>
+ </FormField>
- {/* Boolean toggles */}
- <ToggleRow
- checked={forceIssueLabels}
- onCheckedChange={setForceIssueLabels}
- disabled={!canUpdateProject || issueLabels.length === 0}
- label={t(
- "project.settings.issue-related.labels.force-issue-labels.self"
- )}
- description={t(
- "project.settings.issue-related.labels.force-issue-labels.description"
- )}
- warning={
- canUpdateProject && issueLabels.length === 0
- ? t(
- "project.settings.issue-related.labels.force-issue-labels.warning"
- )
- : undefined
- }
- />
- <ToggleRow
- checked={enforceIssueTitle}
- onCheckedChange={setEnforceIssueTitle}
- disabled={!canUpdateProject}
- label={t(
- "project.settings.issue-related.enforce-issue-title.self"
- )}
- description={t(
- "project.settings.issue-related.enforce-issue-title.description"
- )}
- />
- <ToggleRow
- checked={enforceSqlReview}
- onCheckedChange={setEnforceSqlReview}
- disabled={!canUpdateProject}
- label={t(
- "project.settings.issue-related.enforce-sql-review.self"
- )}
- description={t(
- "project.settings.issue-related.enforce-sql-review.description"
- )}
- />
- <ToggleRow
- checked={allowSelfApproval}
- onCheckedChange={setAllowSelfApproval}
- disabled={!canUpdateProject}
- label={t(
- "project.settings.issue-related.allow-self-approval.self"
- )}
- description={t(
- "project.settings.issue-related.allow-self-approval.description"
- )}
- />
- <ToggleRow
- checked={requireIssueApproval}
- onCheckedChange={setRequireIssueApproval}
- disabled={!canUpdateProject}
- label={t(
- "project.settings.issue-related.require-issue-approval.self"
- )}
- description={t(
- "project.settings.issue-related.require-issue-approval.description"
- )}
- />
- <ToggleRow
- checked={requirePlanCheckNoError}
- onCheckedChange={setRequirePlanCheckNoError}
- disabled={!canUpdateProject}
- label={t(
- "project.settings.issue-related.require-plan-check-no-error.self"
- )}
- description={t(
- "project.settings.issue-related.require-plan-check-no-error.description"
- )}
- />
- <ToggleRow
- checked={postgresDatabaseTenantMode}
- onCheckedChange={setPostgresDatabaseTenantMode}
- disabled={!canUpdateProject}
- label={t(
- "project.settings.issue-related.postgres-database-tenant-mode.self"
- )}
- description={t(
- "project.settings.issue-related.postgres-database-tenant-mode.description"
- )}
- />
+ {/* Boolean toggles */}
+ <ToggleRow
+ checked={forceIssueLabels}
+ onCheckedChange={setForceIssueLabels}
+ disabled={!canUpdateProject || issueLabels.length === 0}
+ label={t(
+ "project.settings.issue-related.labels.force-issue-labels.self"
+ )}
+ description={t(
+ "project.settings.issue-related.labels.force-issue-labels.description"
+ )}
+ warning={
+ canUpdateProject && issueLabels.length === 0
+ ? t(
+ "project.settings.issue-related.labels.force-issue-labels.warning"
+ )
+ : undefined
+ }
+ />
+ <ToggleRow
+ checked={enforceIssueTitle}
+ onCheckedChange={setEnforceIssueTitle}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.enforce-issue-title.self"
+ )}
+ description={t(
+ "project.settings.issue-related.enforce-issue-title.description"
+ )}
+ />
+ <ToggleRow
+ checked={enforceSqlReview}
+ onCheckedChange={setEnforceSqlReview}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.enforce-sql-review.self"
+ )}
+ description={t(
+ "project.settings.issue-related.enforce-sql-review.description"
+ )}
+ />
+ <ToggleRow
+ checked={allowSelfApproval}
+ onCheckedChange={setAllowSelfApproval}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.allow-self-approval.self"
+ )}
+ description={t(
+ "project.settings.issue-related.allow-self-approval.description"
+ )}
+ />
+ <ToggleRow
+ checked={requireIssueApproval}
+ onCheckedChange={setRequireIssueApproval}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.require-issue-approval.self"
+ )}
+ description={t(
+ "project.settings.issue-related.require-issue-approval.description"
+ )}
+ />
+ <ToggleRow
+ checked={requirePlanCheckNoError}
+ onCheckedChange={setRequirePlanCheckNoError}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.require-plan-check-no-error.self"
+ )}
+ description={t(
+ "project.settings.issue-related.require-plan-check-no-error.description"
+ )}
+ />
+ <ToggleRow
+ checked={postgresDatabaseTenantMode}
+ onCheckedChange={setPostgresDatabaseTenantMode}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.postgres-database-tenant-mode.self"
+ )}
+ description={t(
+ "project.settings.issue-related.postgres-database-tenant-mode.description"
+ )}
+ />
- {/* Numeric inputs */}
- <NumericRow
- label={t("project.settings.issue-related.max-retries.self")}
- description={t(
- "project.settings.issue-related.max-retries.description"
- )}
- value={maxRetries}
- onChange={setMaxRetries}
- disabled={!canUpdateProject}
- suffix="Times"
- />
- <NumericRow
- label={t(
- "project.settings.issue-related.ci-sampling-size.self"
- )}
- description={t(
- "project.settings.issue-related.ci-sampling-size.description"
- )}
- value={ciSamplingSize}
- onChange={setCiSamplingSize}
- disabled={!canUpdateProject}
- />
- <NumericRow
- label={t(
- "project.settings.issue-related.parallel_tasks_per_rollout.self"
- )}
- description={t(
- "project.settings.issue-related.parallel_tasks_per_rollout.description"
- )}
- value={parallelTasksPerRollout}
- onChange={setParallelTasksPerRollout}
- disabled={!canUpdateProject}
- />
- </div>
- </div>
- </div>
+ {/* Numeric inputs */}
+ <NumericRow
+ label={t("project.settings.issue-related.max-retries.self")}
+ description={t(
+ "project.settings.issue-related.max-retries.description"
+ )}
+ value={maxRetries}
+ onChange={setMaxRetries}
+ disabled={!canUpdateProject}
+ suffix="Times"
+ />
+ <NumericRow
+ label={t("project.settings.issue-related.ci-sampling-size.self")}
+ description={t(
+ "project.settings.issue-related.ci-sampling-size.description"
+ )}
+ value={ciSamplingSize}
+ onChange={setCiSamplingSize}
+ disabled={!canUpdateProject}
+ />
+ <NumericRow
+ label={t(
+ "project.settings.issue-related.parallel_tasks_per_rollout.self"
+ )}
+ description={t(
+ "project.settings.issue-related.parallel_tasks_per_rollout.description"
+ )}
+ value={parallelTasksPerRollout}
+ onChange={setParallelTasksPerRollout}
+ disabled={!canUpdateProject}
+ />
+ </FormFieldGroup>
+ </FormSection>
{/* ============================================================= */}
{/* Section 4: Danger Zone */}
{/* ============================================================= */}
- <div className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">{t("common.danger-zone")}</h1>
- </div>
- <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
- <div className="border border-error-alpha bg-error-alpha rounded-sm divide-y divide-error-alpha">
- {/* Archive / Restore */}
- <div className="p-6 flex items-start justify-between gap-x-6">
- {project.state === State.ACTIVE ? (
- <>
- <div className="flex-1">
- <h4 className="font-medium text-main">
- {t("common.archive-resource", {
- type: t("common.project"),
- })}
- </h4>
- <p className="text-sm text-control-light mt-1">
- {t("common.archive-description", {
- name: project.title || project.name,
- })}
- </p>
- </div>
- <Button
- variant="outline"
- disabled={!canDelete || executing}
- onClick={() => setDangerAction("archive")}
- >
- {t("common.archive")}
- </Button>
- </>
- ) : project.state === State.DELETED ? (
- <>
- <div className="flex-1">
- <h4 className="font-medium text-main">
- {t("project.settings.restore.title")}
- </h4>
- <p className="text-sm text-control-light mt-1">
- {t("project.settings.restore.btn-text")}
- </p>
- </div>
- <Button
- variant="outline"
- disabled={!canUndelete || executing}
- onClick={() => setDangerAction("restore")}
- >
- {t("common.restore")}
- </Button>
- </>
- ) : null}
- </div>
-
- {/* Delete */}
- <div className="p-6 flex items-start justify-between gap-x-6">
- <div className="flex-1">
- <h4 className="font-medium text-error">
- {t("common.delete-resource", {
+ <FormSection title={t("common.danger-zone")}>
+ <div className="border border-error-alpha bg-error-alpha rounded-sm divide-y divide-error-alpha">
+ {/* Archive / Restore */}
+ <div className="p-6 flex items-start justify-between gap-x-6">
+ {project.state === State.ACTIVE ? (
+ <>
+ <FormField
+ className="flex-1"
+ title={t("common.archive-resource", {
type: t("common.project"),
})}
- </h4>
- <p className="text-sm text-control-light mt-1">
- {t("common.delete-resource-description", {
+ description={t("common.archive-description", {
name: project.title || project.name,
})}
- </p>
- </div>
- <Button
- variant="destructive"
- disabled={!canDelete || executing}
- onClick={() => setDangerAction("delete")}
- >
- {t("common.delete")}
- </Button>
- </div>
+ />
+ <Button
+ variant="outline"
+ disabled={!canDelete || executing}
+ onClick={() => setDangerAction("archive")}
+ >
+ {t("common.archive")}
+ </Button>
+ </>
+ ) : project.state === State.DELETED ? (
+ <>
+ <FormField
+ className="flex-1"
+ title={t("project.settings.restore.title")}
+ description={t("project.settings.restore.btn-text")}
+ />
+ <Button
+ variant="outline"
+ disabled={!canUndelete || executing}
+ onClick={() => setDangerAction("restore")}
+ >
+ {t("common.restore")}
+ </Button>
+ </>
+ ) : null}
+ </div>
+
+ {/* Delete */}
+ <div className="p-6 flex items-start justify-between gap-x-6">
+ <FormField
+ className="flex-1"
+ title={
+ <span className="text-error">
+ {t("common.delete-resource", {
+ type: t("common.project"),
+ })}
+ </span>
+ }
+ description={t("common.delete-resource-description", {
+ name: project.title || project.name,
+ })}
+ />
+ <Button
+ variant="destructive"
+ disabled={!canDelete || executing}
+ onClick={() => setDangerAction("delete")}
+ >
+ {t("common.delete")}
+ </Button>
</div>
</div>
- </div>
+ </FormSection>
{/* ============================================================= */}
{/* Save / Cancel Bar */}
@@ -1297,6 +1270,7 @@ function ToggleRow({
disabled,
label,
description,
+ trailing,
warning,
}: {
checked: boolean;
@@ -1304,25 +1278,29 @@ function ToggleRow({
disabled: boolean;
label: string;
description: string;
+ trailing?: ReactNode;
warning?: string;
}) {
return (
- <div>
- <div className="flex items-center gap-x-2">
- <Switch
- checked={checked}
- onCheckedChange={onCheckedChange}
- disabled={disabled}
- />
- <span className="text-sm font-medium">{label}</span>
- {warning && (
- <Tooltip content={warning}>
- <TriangleAlert className="size-4 text-warning" />
- </Tooltip>
- )}
- </div>
- <div className="mt-1 text-sm text-control-placeholder">{description}</div>
- </div>
+ <FormField
+ title={
+ <FormControlRow>
+ <Switch
+ checked={checked}
+ onCheckedChange={onCheckedChange}
+ disabled={disabled}
+ />
+ <span className="text-sm font-medium">{label}</span>
+ {trailing}
+ {warning && (
+ <Tooltip content={warning}>
+ <TriangleAlert className="size-4 text-warning" />
+ </Tooltip>
+ )}
+ </FormControlRow>
+ }
+ description={description}
+ />
);
}
@@ -1342,10 +1320,8 @@ function NumericRow({
suffix?: string;
}) {
return (
- <div>
- <p className="text-sm font-medium">{label}</p>
- <p className="mb-3 text-sm text-control-placeholder">{description}</p>
- <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">
+ <FormField title={label} description={description}>
+ <FormControlRow>
<NumberInput
className="w-60"
min={0}
@@ -1354,7 +1330,7 @@ function NumericRow({
disabled={disabled}
/>
{suffix && <span className="text-sm text-control-light">{suffix}</span>}
- </div>
- </div>
+ </FormControlRow>
+ </FormField>
);
}
diff --git a/frontend/src/react/pages/project/ProjectSettingsPageLayout.test.ts b/frontend/src/react/pages/project/ProjectSettingsPageLayout.test.ts
new file mode 100644
index 0000000000..e01a256bcc
--- /dev/null
+++ b/frontend/src/react/pages/project/ProjectSettingsPageLayout.test.ts
@@ -0,0 +1,22 @@
+import { readFileSync } from "node:fs";
+import { join } from "node:path";
+import { describe, expect, test } from "vitest";
+
+const pageSource = readFileSync(
+ join(import.meta.dirname, "ProjectSettingsPage.tsx"),
+ "utf8"
+);
+
+describe("ProjectSettingsPage layout", () => {
+ test("uses shared form primitives for settings sections and fields", () => {
+ expect(pageSource).toContain("@/react/components/ui/form");
+ expect(pageSource).toContain("FormSection");
+ expect(pageSource).toContain("FormFieldGroup");
+ expect(pageSource).toContain("<FormField");
+ expect(pageSource).toContain("FormControlRow");
+ expect(pageSource).toContain('className="divide-y divide-block-border"');
+ expect(pageSource).not.toContain('className="py-6 lg:flex"');
+ expect(pageSource).not.toContain('className="pb-6 lg:flex"');
+ expect(pageSource).not.toContain('className="flex-1 mt-4 lg:px-4 lg:mt-0"');
+ });
+});
diff --git a/frontend/src/react/pages/settings/EnvironmentsPage.tsx b/frontend/src/react/pages/settings/EnvironmentsPage.tsx
index 7b2e1db3e0..447987a5ab 100644
--- a/frontend/src/react/pages/settings/EnvironmentsPage.tsx
+++ b/frontend/src/react/pages/settings/EnvironmentsPage.tsx
@@ -30,6 +30,7 @@ import {
import { useTranslation } from "react-i18next";
import { FeatureAttention } from "@/react/components/FeatureAttention";
import { FeatureBadge } from "@/react/components/FeatureBadge";
+import { LearnMoreLink } from "@/react/components/LearnMoreLink";
import { PermissionGuard } from "@/react/components/PermissionGuard";
import { ResourceIdField } from "@/react/components/ResourceIdField";
import { RouterLink } from "@/react/components/RouterLink";
@@ -48,11 +49,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/react/components/ui/dropdown-menu";
-import {
- FormDescription,
- FormField,
- FormLabel,
-} from "@/react/components/ui/form";
+import { FormField } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Sheet,
@@ -790,24 +787,27 @@ function EnvironmentDetail({
<div className="flex-1 px-4">
<div className="flex flex-col gap-y-6">
{/* Name section */}
- <FormField>
- <div className="flex items-center gap-x-2">
- <input
- type="color"
- value={editColor}
- disabled={!canEdit}
- onChange={(e) => onColorChange(e.target.value)}
- className={cn(
- "size-6 shrink-0 appearance-none rounded-xs border border-control-border bg-transparent p-0",
- "[&::-webkit-color-swatch-wrapper]:p-0 [&::-webkit-color-swatch]:rounded-xs [&::-webkit-color-swatch]:border-0 [&::-moz-color-swatch]:rounded-xs [&::-moz-color-swatch]:border-0",
- "cursor-pointer"
- )}
- />
- <FormLabel>
- {t("common.environment-name")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
- </div>
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
+ <input
+ type="color"
+ value={editColor}
+ disabled={!canEdit}
+ onChange={(e) => onColorChange(e.target.value)}
+ className={cn(
+ "size-6 shrink-0 appearance-none rounded-xs border border-control-border bg-transparent p-0",
+ "[&::-webkit-color-swatch-wrapper]:p-0 [&::-webkit-color-swatch]:rounded-xs [&::-webkit-color-swatch]:border-0 [&::-moz-color-swatch]:rounded-xs [&::-moz-color-swatch]:border-0",
+ "cursor-pointer"
+ )}
+ />
+ <span>
+ {t("common.environment-name")}
+ <span className="ml-0.5 text-error">*</span>
+ </span>
+ </span>
+ }
+ >
<Input
value={editTitle}
disabled={!canEdit}
@@ -821,24 +821,23 @@ function EnvironmentDetail({
</FormField>
{/* Tier section */}
- <FormField>
- <div className="gap-y-1">
- <FormLabel>
+ <FormField
+ title={
+ <>
{t("policy.environment-tier.name")}
<FeatureBadge feature={PlanFeature.FEATURE_ENVIRONMENT_TIERS} />
- </FormLabel>
- <FormDescription>
+ </>
+ }
+ description={
+ <>
{t("policy.environment-tier.description", { newline: "\n" })}
- <a
+ <LearnMoreLink
href="https://docs.bytebase.com/change-database/environment-policy/overview/?source=console#environment-tier"
- target="_blank"
- rel="noopener noreferrer"
- className="ml-1 text-accent hover:underline"
- >
- {t("common.learn-more")}
- </a>
- </FormDescription>
- </div>
+ className="ml-1 text-accent"
+ />
+ </>
+ }
+ >
<label className="inline-flex items-center gap-x-2 cursor-pointer">
<Checkbox
checked={editProtected}
@@ -858,30 +857,29 @@ function EnvironmentDetail({
{/* Rollout policy section */}
{canGetPolicy && rolloutPolicy && (
- <FormField>
- <div className="gap-y-1">
- <div className="flex items-baseline gap-x-2">
- <FormLabel>{t("policy.rollout.name")}</FormLabel>
+ <FormField
+ title={
+ <span className="flex items-baseline gap-x-2">
+ {t("policy.rollout.name")}
{policyChanged && (
<span className="textlabeltip">
{t("policy.rollout.tip")}
</span>
)}
- </div>
- <FormDescription>
+ </span>
+ }
+ description={
+ <>
{t("policy.rollout.info", {
permission: "bb.taskRuns.create",
})}
- <a
+ <LearnMoreLink
href="https://docs.bytebase.com/change-database/environment-policy/rollout-policy/?source=console"
- target="_blank"
- rel="noopener noreferrer"
- className="ml-1 text-accent hover:underline"
- >
- {t("common.learn-more")}
- </a>
- </FormDescription>
- </div>
+ className="ml-1 text-accent"
+ />
+ </>
+ }
+ >
<RolloutPolicyConfig
policy={rolloutPolicy}
onChange={setRolloutPolicy}
@@ -1095,23 +1093,26 @@ function CreateSheet({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Name */}
- <FormField>
- <div className="flex items-center gap-x-2">
- <input
- type="color"
- value={color}
- onChange={(e) => onColorChange(e.target.value)}
- className={cn(
- "size-6 shrink-0 appearance-none rounded-xs border border-control-border bg-transparent p-0",
- "[&::-webkit-color-swatch-wrapper]:p-0 [&::-webkit-color-swatch]:rounded-xs [&::-webkit-color-swatch]:border-0 [&::-moz-color-swatch]:rounded-xs [&::-moz-color-swatch]:border-0",
- "cursor-pointer"
- )}
- />
- <FormLabel>
- {t("common.environment-name")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
- </div>
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
+ <input
+ type="color"
+ value={color}
+ onChange={(e) => onColorChange(e.target.value)}
+ className={cn(
+ "size-6 shrink-0 appearance-none rounded-xs border border-control-border bg-transparent p-0",
+ "[&::-webkit-color-swatch-wrapper]:p-0 [&::-webkit-color-swatch]:rounded-xs [&::-webkit-color-swatch]:border-0 [&::-moz-color-swatch]:rounded-xs [&::-moz-color-swatch]:border-0",
+ "cursor-pointer"
+ )}
+ />
+ <span>
+ {t("common.environment-name")}
+ <span className="ml-0.5 text-error">*</span>
+ </span>
+ </span>
+ }
+ >
<Input
value={title}
onChange={(e) => setTitle(e.target.value)}
@@ -1128,11 +1129,18 @@ function CreateSheet({
</FormField>
{/* Tier */}
- <FormField>
- <FormLabel>{t("policy.environment-tier.name")}</FormLabel>
- <FormDescription>
- {t("policy.environment-tier.description", { newline: "\n" })}
- </FormDescription>
+ <FormField
+ title={<>{t("policy.environment-tier.name")}</>}
+ description={
+ <>
+ {t("policy.environment-tier.description", { newline: "\n" })}
+ <LearnMoreLink
+ href="https://docs.bytebase.com/change-database/environment-policy/overview/?source=console#environment-tier"
+ className="ml-1 text-accent"
+ />
+ </>
+ }
+ >
<label className="inline-flex items-center gap-x-2 cursor-pointer">
<Checkbox
checked={isProtected}
@@ -1150,15 +1158,20 @@ function CreateSheet({
</FormField>
{/* Rollout Policy */}
- <FormField>
- <div className="gap-y-1">
- <FormLabel>{t("policy.rollout.name")}</FormLabel>
- <FormDescription>
+ <FormField
+ title={<>{t("policy.rollout.name")}</>}
+ description={
+ <>
{t("policy.rollout.info", {
permission: "bb.taskRuns.create",
})}
- </FormDescription>
- </div>
+ <LearnMoreLink
+ href="https://docs.bytebase.com/change-database/environment-policy/rollout-policy/?source=console"
+ className="ml-1 text-accent"
+ />
+ </>
+ }
+ >
<RolloutPolicyConfig
policy={rolloutPolicy}
onChange={setRolloutPolicy}
diff --git a/frontend/src/react/pages/settings/GlobalMaskingPage.test.tsx b/frontend/src/react/pages/settings/GlobalMaskingPage.test.tsx
index ed90395463..82b26ce533 100644
--- a/frontend/src/react/pages/settings/GlobalMaskingPage.test.tsx
+++ b/frontend/src/react/pages/settings/GlobalMaskingPage.test.tsx
@@ -150,6 +150,7 @@ vi.mock("@bufbuild/protobuf", () => ({
vi.mock("lucide-react", () => ({
ChevronDown: () => createElement("span", {}),
ChevronUp: () => createElement("span", {}),
+ ExternalLink: () => createElement("span", {}),
ListOrdered: () => createElement("span", {}),
Pencil: () => createElement("span", {}),
Plus: () => createElement("span", {}),
diff --git a/frontend/src/react/pages/settings/GlobalMaskingPage.tsx b/frontend/src/react/pages/settings/GlobalMaskingPage.tsx
index e93cd41e0a..b03b62829d 100644
--- a/frontend/src/react/pages/settings/GlobalMaskingPage.tsx
+++ b/frontend/src/react/pages/settings/GlobalMaskingPage.tsx
@@ -20,6 +20,7 @@ import {
} from "@/plugins/cel";
import { ExprEditor, type OptionConfig } from "@/react/components/ExprEditor";
import { FeatureAttention } from "@/react/components/FeatureAttention";
+import { LearnMoreLink } from "@/react/components/LearnMoreLink";
import { Alert } from "@/react/components/ui/alert";
import { Button } from "@/react/components/ui/button";
import { Input } from "@/react/components/ui/input";
@@ -626,14 +627,10 @@ export function GlobalMaskingPage() {
{/* Description */}
<div className="textinfolabel">
{t("settings.sensitive-data.global-rules.description")}{" "}
- <a
+ <LearnMoreLink
href="https://docs.bytebase.com/security/data-masking/overview/?source=console"
- target="_blank"
- rel="noopener noreferrer"
className="text-accent hover:underline"
- >
- {t("common.learn-more")}
- </a>
+ />
</div>
{/* Empty state */}
diff --git a/frontend/src/react/pages/settings/GroupsPage.test.tsx b/frontend/src/react/pages/settings/GroupsPage.test.tsx
index 2a750b3eb3..55ed3d216d 100644
--- a/frontend/src/react/pages/settings/GroupsPage.test.tsx
+++ b/frontend/src/react/pages/settings/GroupsPage.test.tsx
@@ -330,9 +330,7 @@ describe("GroupsPage create group sheet", () => {
"input[maxlength='200']"
) as HTMLInputElement;
const titleField = titleInput.closest('[data-slot="form-field"]');
- const titleMessage = titleField?.querySelector(
- '[data-slot="form-message"]'
- );
+ const titleMessage = titleField?.querySelector('[data-slot="form-error"]');
expect(titleMessage?.getAttribute("role")).toBe("alert");
expect(titleMessage?.textContent).toBe(
diff --git a/frontend/src/react/pages/settings/GroupsPage.tsx b/frontend/src/react/pages/settings/GroupsPage.tsx
index 655e80ac99..16226f7f7d 100644
--- a/frontend/src/react/pages/settings/GroupsPage.tsx
+++ b/frontend/src/react/pages/settings/GroupsPage.tsx
@@ -26,13 +26,9 @@ import {
import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
import {
- FormControlAffix,
- FormDescription,
+ FormError,
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";
@@ -916,15 +912,16 @@ function GroupForm({
)}
{/* Email */}
- <FormField>
- <FormLabel>
- {t("settings.members.groups.form.email")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
- <FormDescription>
- {t("settings.members.groups.form.email-tips")}
- </FormDescription>
- <FormInlineAffix>
+ <FormField
+ title={
+ <>
+ {t("settings.members.groups.form.email")}
+ <span className="ml-0.5 text-error">*</span>
+ </>
+ }
+ description={<>{t("settings.members.groups.form.email-tips")}</>}
+ >
+ <div className="flex min-w-0 w-full items-center gap-x-1">
<Input
value={isEditMode ? email : email.split("@")[0]}
className="min-w-0 flex-1"
@@ -933,9 +930,13 @@ function GroupForm({
/>
{!isEditMode && domainOptions.length > 0 && (
<>
- <FormControlAffix>@</FormControlAffix>
+ <span className="shrink-0 whitespace-nowrap text-sm leading-5 text-control-light">
+ @
+ </span>
{domainOptions.length === 1 ? (
- <FormControlAffix>{domainOptions[0]}</FormControlAffix>
+ <span className="shrink-0 whitespace-nowrap text-sm leading-5 text-control-light">
+ {domainOptions[0]}
+ </span>
) : (
<select
value={selectedDomain}
@@ -952,18 +953,21 @@ function GroupForm({
)}
</>
)}
- </FormInlineAffix>
+ </div>
{emailErrorMessage && errorMessage === emailErrorMessage && (
- <FormMessage>{emailErrorMessage}</FormMessage>
+ <FormError>{emailErrorMessage}</FormError>
)}
</FormField>
{/* Title */}
- <FormField>
- <FormLabel>
- {t("settings.members.groups.form.title")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("settings.members.groups.form.title")}
+ <span className="ml-0.5 text-error">*</span>
+ </>
+ }
+ >
<Input
value={title}
onChange={(e) => setTitle(e.target.value)}
@@ -971,15 +975,14 @@ function GroupForm({
disabled={!allowEdit}
/>
{titleErrorMessage && errorMessage === titleErrorMessage && (
- <FormMessage>{titleErrorMessage}</FormMessage>
+ <FormError>{titleErrorMessage}</FormError>
)}
</FormField>
{/* Description */}
- <FormField>
- <FormLabel>
- {t("settings.members.groups.form.description")}
- </FormLabel>
+ <FormField
+ title={<>{t("settings.members.groups.form.description")}</>}
+ >
<Input
value={description}
onChange={(e) => setDescription(e.target.value)}
@@ -989,8 +992,7 @@ function GroupForm({
</FormField>
{/* Members */}
- <FormField>
- <FormLabel>{t("common.members", { count: 2 })}</FormLabel>
+ <FormField title={<>{t("common.members", { count: 2 })}</>}>
<div className="flex flex-col gap-y-2">
{members.map((member, index) => (
<div key={index} className="flex items-center gap-x-2">
@@ -1051,7 +1053,7 @@ function GroupForm({
)}
</div>
{memberErrorMessage && errorMessage === memberErrorMessage && (
- <FormMessage>{memberErrorMessage}</FormMessage>
+ <FormError>{memberErrorMessage}</FormError>
)}
</FormField>
</FormFieldGroup>
diff --git a/frontend/src/react/pages/settings/IDPsPage.tsx b/frontend/src/react/pages/settings/IDPsPage.tsx
index 91ff128ecf..0af4460694 100644
--- a/frontend/src/react/pages/settings/IDPsPage.tsx
+++ b/frontend/src/react/pages/settings/IDPsPage.tsx
@@ -30,6 +30,11 @@ import {
DialogContent,
DialogTitle,
} from "@/react/components/ui/dialog";
+import {
+ FormField,
+ FormFieldGroup,
+ FormTitle,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
@@ -484,13 +489,15 @@ function ProviderConfigForm({
if (providerType === IdentityProviderType.OAUTH2) {
return (
- <div className="flex flex-col gap-y-6">
+ <FormFieldGroup>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-oauth2-client-id-title">
Client ID <span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oauth2-client-id"
+ aria-labelledby="sso-oauth2-client-id-title"
value={configForOAuth2.clientId}
onChange={(e) =>
onUpdateOAuth2({
@@ -500,12 +507,14 @@ function ProviderConfigForm({
}
placeholder="e.g. 6655asd77895265aa110ac0d3"
/>
- </div>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ </FormField>
+ <FormField>
+ <FormTitle id="sso-oauth2-client-secret-title">
Client Secret <span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oauth2-client-secret"
+ aria-labelledby="sso-oauth2-client-secret-title"
type="password"
value={configForOAuth2.clientSecret}
onChange={(e) =>
@@ -516,49 +525,55 @@ function ProviderConfigForm({
}
placeholder="e.g. 5bbezxc3972ca304de70c5d70a6aa932asd8"
/>
- </div>
+ </FormField>
</div>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-oauth2-auth-url-title">
{t("settings.sso.form.auth-url")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oauth2-auth-url"
+ aria-labelledby="sso-oauth2-auth-url-title"
value={configForOAuth2.authUrl}
onChange={(e) =>
onUpdateOAuth2({ ...configForOAuth2, authUrl: e.target.value })
}
placeholder={t("settings.sso.form.auth-url-placeholder")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.auth-url-description")}
- </p>
- </div>
+ </span>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-oauth2-token-url-title">
{t("settings.sso.form.token-url")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oauth2-token-url"
+ aria-labelledby="sso-oauth2-token-url-title"
value={configForOAuth2.tokenUrl}
onChange={(e) =>
onUpdateOAuth2({ ...configForOAuth2, tokenUrl: e.target.value })
}
placeholder={t("settings.sso.form.token-url-placeholder")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.token-url-description")}
- </p>
- </div>
+ </span>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-oauth2-user-info-url-title">
{t("settings.sso.form.user-info-url")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oauth2-user-info-url"
+ aria-labelledby="sso-oauth2-user-info-url-title"
value={configForOAuth2.userInfoUrl}
onChange={(e) =>
onUpdateOAuth2({
@@ -568,31 +583,36 @@ function ProviderConfigForm({
}
placeholder={t("settings.sso.form.user-info-url-placeholder")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.user-info-url-description")}
- </p>
- </div>
+ </span>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-oauth2-scopes-title">
{t("settings.sso.form.scopes")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oauth2-scopes"
+ aria-labelledby="sso-oauth2-scopes-title"
value={scopesString}
onChange={(e) => onUpdateScopes(e.target.value)}
placeholder={t("settings.sso.form.scopes-placeholder")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.scopes-description")}
- </p>
- </div>
-
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-3">
- {t("settings.sso.form.authentication-style")}{" "}
- <span className="text-error">*</span>
- </label>
+ </span>
+ </FormField>
+
+ <FormField
+ title={
+ <>
+ {t("settings.sso.form.authentication-style")}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
<RadioGroup
className="flex-col items-stretch gap-y-3"
value={String(configForOAuth2.authStyle)}
@@ -632,12 +652,9 @@ function ProviderConfigForm({
</div>
</RadioGroupItem>
</RadioGroup>
- </div>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-3">
- {t("settings.sso.form.security-options")}
- </label>
+ <FormField title={<>{t("settings.sso.form.security-options")}</>}>
<label className="flex items-center gap-x-2 cursor-pointer">
<Checkbox
checked={configForOAuth2.skipTlsVerify}
@@ -650,51 +667,57 @@ function ProviderConfigForm({
/>
<span>{t("settings.sso.form.skip-tls-verification")}</span>
</label>
- <p className="text-sm text-gray-600 mt-1 ml-6">
+ <span className="text-sm text-control-placeholder ml-6">
{t("settings.sso.form.skip-tls-warning")}
- </p>
- </div>
- </div>
+ </span>
+ </FormField>
+ </FormFieldGroup>
);
}
if (providerType === IdentityProviderType.OIDC) {
return (
- <div className="flex flex-col gap-y-6">
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormFieldGroup>
+ <FormField>
+ <FormTitle id="sso-oidc-issuer-title">
Issuer URL <span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oidc-issuer"
+ aria-labelledby="sso-oidc-issuer-title"
value={configForOIDC.issuer}
onChange={(e) =>
onUpdateOIDC({ ...configForOIDC, issuer: e.target.value })
}
placeholder={t("settings.sso.form.issuer-url-placeholder")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.issuer-url-description")}
- </p>
- </div>
+ </span>
+ </FormField>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-oidc-client-id-title">
Client ID <span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oidc-client-id"
+ aria-labelledby="sso-oidc-client-id-title"
value={configForOIDC.clientId}
onChange={(e) =>
onUpdateOIDC({ ...configForOIDC, clientId: e.target.value })
}
placeholder="e.g. 6655asd77895265aa110ac0d3"
/>
- </div>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ </FormField>
+ <FormField>
+ <FormTitle id="sso-oidc-client-secret-title">
Client Secret <span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oidc-client-secret"
+ aria-labelledby="sso-oidc-client-secret-title"
type="password"
value={configForOIDC.clientSecret}
onChange={(e) =>
@@ -705,29 +728,34 @@ function ProviderConfigForm({
}
placeholder="e.g. 5bbezxc3972ca304de70c5d70a6aa932asd8"
/>
- </div>
+ </FormField>
</div>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-oidc-scopes-title">
{t("settings.sso.form.scopes")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-oidc-scopes"
+ aria-labelledby="sso-oidc-scopes-title"
value={scopesString}
onChange={(e) => onUpdateScopes(e.target.value)}
placeholder={t("settings.sso.form.scopes-placeholder-oidc")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.openid-scopes-description")}
- </p>
- </div>
-
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-3">
- {t("settings.sso.form.authentication-style")}{" "}
- <span className="text-error">*</span>
- </label>
+ </span>
+ </FormField>
+
+ <FormField
+ title={
+ <>
+ {t("settings.sso.form.authentication-style")}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
<RadioGroup
className="flex-col items-stretch gap-y-3"
value={String(configForOIDC.authStyle)}
@@ -767,12 +795,9 @@ function ProviderConfigForm({
</div>
</RadioGroupItem>
</RadioGroup>
- </div>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-3">
- {t("settings.sso.form.security-options")}
- </label>
+ <FormField title={<>{t("settings.sso.form.security-options")}</>}>
<label className="flex items-center gap-x-2 cursor-pointer">
<Checkbox
checked={configForOIDC.skipTlsVerify}
@@ -785,35 +810,39 @@ function ProviderConfigForm({
/>
<span>{t("settings.sso.form.skip-tls-verification")}</span>
</label>
- <p className="text-sm text-gray-600 mt-1 ml-6">
+ <span className="text-sm text-control-placeholder ml-6">
{t("settings.sso.form.skip-tls-warning")}
- </p>
- </div>
- </div>
+ </span>
+ </FormField>
+ </FormFieldGroup>
);
}
if (providerType === IdentityProviderType.LDAP) {
return (
- <div className="flex flex-col gap-y-6">
+ <FormFieldGroup>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
- <div className="md:col-span-2">
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField className="md:col-span-2">
+ <FormTitle id="sso-ldap-host-title">
Host <span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-ldap-host"
+ aria-labelledby="sso-ldap-host-title"
value={configForLDAP.host}
onChange={(e) =>
onUpdateLDAP({ ...configForLDAP, host: e.target.value })
}
placeholder={t("settings.sso.form.host-placeholder")}
/>
- </div>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ </FormField>
+ <FormField>
+ <FormTitle id="sso-ldap-port-title">
Port <span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-ldap-port"
+ aria-labelledby="sso-ldap-port-title"
type="number"
value={configForLDAP.port}
onChange={(e) =>
@@ -826,32 +855,36 @@ function ProviderConfigForm({
max={65535}
placeholder="389"
/>
- </div>
+ </FormField>
</div>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-ldap-bind-dn-title">
{t("settings.sso.form.bind-dn")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-ldap-bind-dn"
+ aria-labelledby="sso-ldap-bind-dn-title"
value={configForLDAP.bindDn}
onChange={(e) =>
onUpdateLDAP({ ...configForLDAP, bindDn: e.target.value })
}
placeholder={t("settings.sso.form.bind-dn-placeholder")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.bind-dn-description")}
- </p>
- </div>
+ </span>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-ldap-bind-password-title">
{t("settings.sso.form.bind-password")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-ldap-bind-password"
+ aria-labelledby="sso-ldap-bind-password-title"
type="password"
value={configForLDAP.bindPassword}
onChange={(e) =>
@@ -862,47 +895,54 @@ function ProviderConfigForm({
}
placeholder="••••••••"
/>
- </div>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-ldap-base-dn-title">
{t("settings.sso.form.base-dn")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-ldap-base-dn"
+ aria-labelledby="sso-ldap-base-dn-title"
value={configForLDAP.baseDn}
onChange={(e) =>
onUpdateLDAP({ ...configForLDAP, baseDn: e.target.value })
}
placeholder={t("settings.sso.form.base-dn-placeholder")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.base-dn-description")}
- </p>
- </div>
+ </span>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormField>
+ <FormTitle id="sso-ldap-user-filter-title">
{t("settings.sso.form.user-filter")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-ldap-user-filter"
+ aria-labelledby="sso-ldap-user-filter-title"
value={configForLDAP.userFilter}
onChange={(e) =>
onUpdateLDAP({ ...configForLDAP, userFilter: e.target.value })
}
placeholder={t("settings.sso.form.user-filter-placeholder")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.user-filter-description")}
- </p>
- </div>
-
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-3">
- {t("settings.sso.form.security-protocol")}{" "}
- <span className="text-error">*</span>
- </label>
+ </span>
+ </FormField>
+
+ <FormField
+ title={
+ <>
+ {t("settings.sso.form.security-protocol")}{" "}
+ <span className="text-error">*</span>
+ </>
+ }
+ >
<RadioGroup
className="flex-col items-stretch gap-y-3"
value={String(configForLDAP.securityProtocol)}
@@ -960,12 +1000,9 @@ function ProviderConfigForm({
</div>
</RadioGroupItem>
</RadioGroup>
- </div>
+ </FormField>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-3">
- {t("settings.sso.form.security-options")}
- </label>
+ <FormField title={<>{t("settings.sso.form.security-options")}</>}>
<label className="flex items-center gap-x-2 cursor-pointer">
<Checkbox
checked={configForLDAP.skipTlsVerify}
@@ -978,11 +1015,11 @@ function ProviderConfigForm({
/>
<span>{t("settings.sso.form.skip-tls-verification")}</span>
</label>
- <p className="text-sm text-gray-600 mt-1 ml-6">
+ <span className="text-sm text-control-placeholder ml-6">
{t("settings.sso.form.skip-tls-warning")}
- </p>
- </div>
- </div>
+ </span>
+ </FormField>
+ </FormFieldGroup>
);
}
@@ -1005,62 +1042,70 @@ function FieldMappingForm({
const { t } = useTranslation();
return (
- <div className="flex flex-col gap-y-6">
- <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
- <Input
- value={fieldMapping.identifier}
- onChange={(e) =>
- onChange({ ...fieldMapping, identifier: e.target.value })
- }
- placeholder={t("settings.sso.form.identifier-placeholder")}
- />
- <div className="flex items-center text-base">
- <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
- <p className="flex items-center font-semibold text-gray-800">
- {t("settings.sso.form.identifier")}
- <span className="ml-0.5 text-error">*</span>
- <span
- className="ml-1"
- title={t("settings.sso.form.identifier-tips")}
- >
- <Info className="w-4 h-4 text-blue-500" />
- </span>
- </p>
+ <FormFieldGroup>
+ <FormField>
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.identifier}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, identifier: e.target.value })
+ }
+ placeholder={t("settings.sso.form.identifier-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="flex items-center font-semibold text-gray-800">
+ {t("settings.sso.form.identifier")}
+ <span className="ml-0.5 text-error">*</span>
+ <span
+ className="ml-1"
+ title={t("settings.sso.form.identifier-tips")}
+ >
+ <Info className="w-4 h-4 text-blue-500" />
+ </span>
+ </p>
+ </div>
</div>
- </div>
+ </FormField>
- <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
- <Input
- value={fieldMapping.displayName}
- onChange={(e) =>
- onChange({ ...fieldMapping, displayName: e.target.value })
- }
- placeholder={t("settings.sso.form.display-name-placeholder")}
- />
- <div className="flex items-center text-base">
- <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
- <p className="font-semibold text-gray-800">
- {t("settings.sso.form.display-name")}
- </p>
+ <FormField>
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.displayName}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, displayName: e.target.value })
+ }
+ placeholder={t("settings.sso.form.display-name-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="font-semibold text-gray-800">
+ {t("settings.sso.form.display-name")}
+ </p>
+ </div>
</div>
- </div>
+ </FormField>
- <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
- <Input
- value={fieldMapping.phone}
- onChange={(e) => onChange({ ...fieldMapping, phone: e.target.value })}
- placeholder={t("settings.sso.form.phone-placeholder")}
- />
- <div className="flex items-center text-base">
- <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
- <p className="font-semibold text-gray-800">
- {t("settings.sso.form.phone")}
- </p>
+ <FormField>
+ <div className="grid grid-cols-[256px_1fr] gap-4 items-center">
+ <Input
+ value={fieldMapping.phone}
+ onChange={(e) =>
+ onChange({ ...fieldMapping, phone: e.target.value })
+ }
+ placeholder={t("settings.sso.form.phone-placeholder")}
+ />
+ <div className="flex items-center text-base">
+ <ArrowRight className="mx-2 h-5 w-5 text-gray-400" />
+ <p className="font-semibold text-gray-800">
+ {t("settings.sso.form.phone")}
+ </p>
+ </div>
</div>
- </div>
+ </FormField>
{providerType === IdentityProviderType.OIDC && (
- <>
+ <FormField>
<div className="grid grid-cols-[256px_1fr] gap-4 items-center">
<Input
value={fieldMapping.groups}
@@ -1076,12 +1121,12 @@ function FieldMappingForm({
</p>
</div>
</div>
- <p className="text-sm text-gray-600">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.groups-description")}
- </p>
- </>
+ </span>
+ </FormField>
)}
- </div>
+ </FormFieldGroup>
);
}
@@ -1812,13 +1857,15 @@ function CreateWizardDrawer({
{t("settings.sso.form.general-setting-description")}
</p>
</div>
- <div className="max-w-2xl mx-auto flex flex-col gap-y-6 w-full">
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ <FormFieldGroup className="max-w-2xl mx-auto w-full">
+ <FormField>
+ <FormTitle id="sso-create-name-title">
{t("settings.sso.form.name")}{" "}
<span className="text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="sso-create-name"
+ aria-labelledby="sso-create-name-title"
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder={t("settings.sso.form.name-description")}
@@ -1834,22 +1881,24 @@ function CreateWizardDrawer({
onChange={setResourceId}
onValidationChange={setResourceIdValid}
/>
- </div>
- <div>
- <label className="block text-base font-semibold text-gray-800 mb-2">
+ </FormField>
+ <FormField>
+ <FormTitle id="sso-create-domain-title">
{t("settings.sso.form.domain")}
- </label>
+ </FormTitle>
<Input
+ id="sso-create-domain"
+ aria-labelledby="sso-create-domain-title"
value={domain}
onChange={(e) => setDomain(e.target.value)}
disabled={selectedTemplate?.domainDisabled}
placeholder={t("settings.sso.form.domain-description")}
/>
- <p className="text-sm text-gray-600 mt-1">
+ <span className="text-sm text-control-placeholder">
{t("settings.sso.form.domain-optional-hint")}
- </p>
- </div>
- </div>
+ </span>
+ </FormField>
+ </FormFieldGroup>
</div>
)}
diff --git a/frontend/src/react/pages/settings/IDPsPageLayout.test.ts b/frontend/src/react/pages/settings/IDPsPageLayout.test.ts
new file mode 100644
index 0000000000..ed3153f97e
--- /dev/null
+++ b/frontend/src/react/pages/settings/IDPsPageLayout.test.ts
@@ -0,0 +1,51 @@
+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 getFunctionSource = (source: string, name: string, nextMarker: string) =>
+ source.slice(source.indexOf(`function ${name}`), source.indexOf(nextMarker));
+
+describe("IDPsPage create SSO layout", () => {
+ test("uses shared form primitives in the create SSO form steps", () => {
+ const source = readFileSync(join(sectionDir, "IDPsPage.tsx"), "utf8");
+ const providerConfigSource = getFunctionSource(
+ source,
+ "ProviderConfigForm",
+ "// ============================================================\n// FieldMappingForm"
+ );
+ const fieldMappingSource = getFunctionSource(
+ source,
+ "FieldMappingForm",
+ "// ============================================================\n// CreateWizardDrawer"
+ );
+ const createWizardSource = getFunctionSource(
+ source,
+ "CreateWizardDrawer",
+ "// ============================================================\n// IDPsPage"
+ );
+
+ for (const formSource of [
+ providerConfigSource,
+ fieldMappingSource,
+ createWizardSource,
+ ]) {
+ expect(formSource).toContain("FormField");
+ expect(formSource).not.toContain(
+ 'className="block text-base font-semibold text-gray-800'
+ );
+ }
+
+ expect(createWizardSource).toContain("<FormFieldGroup");
+ expect(createWizardSource).toContain("FormTitle");
+ expect(createWizardSource).not.toContain("FormLabel");
+ expect(createWizardSource).toContain('id="sso-create-name"');
+ expect(createWizardSource).toContain('id="sso-create-domain"');
+ expect(providerConfigSource).toContain("FormFieldGroup");
+ expect(providerConfigSource).toContain("FormTitle");
+ expect(providerConfigSource).not.toContain("FormLabel");
+ expect(fieldMappingSource).toContain("FormFieldGroup");
+ });
+});
diff --git a/frontend/src/react/pages/settings/IMPage.tsx b/frontend/src/react/pages/settings/IMPage.tsx
index 9502d67774..654d94ce35 100644
--- a/frontend/src/react/pages/settings/IMPage.tsx
+++ b/frontend/src/react/pages/settings/IMPage.tsx
@@ -15,13 +15,10 @@ import feishuIcon from "@/assets/im/feishu.webp";
import slackIcon from "@/assets/im/slack.png";
import teamsIcon from "@/assets/im/teams.svg";
import wecomIcon from "@/assets/im/wecom.png";
+import { LearnMoreLink } from "@/react/components/LearnMoreLink";
import { PermissionGuard } from "@/react/components/PermissionGuard";
import { Button } from "@/react/components/ui/button";
-import {
- FormField,
- FormFieldGroup,
- FormLabel,
-} from "@/react/components/ui/form";
+import { FormField, FormFieldGroup } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Select,
@@ -457,8 +454,7 @@ export function IMPage() {
<FormFieldGroup className="mt-4 gap-y-4">
{item.fields.map((field) => (
- <FormField key={field.key}>
- <FormLabel>{field.label}</FormLabel>
+ <FormField key={field.key} title={<>{field.label}</>}>
<Input
disabled={!allowEdit}
placeholder={t("common.sensitive-placeholder")}
@@ -528,14 +524,10 @@ function Description() {
return (
<div className="textinfolabel">
{t("settings.im-integration.description")}{" "}
- <a
+ <LearnMoreLink
href="https://docs.bytebase.com/change-database/webhook?source=console"
- target="_blank"
- rel="noopener noreferrer"
className="text-accent hover:underline"
- >
- {t("common.learn-more")} &gt;
- </a>
+ />
</div>
);
}
diff --git a/frontend/src/react/pages/settings/LearnMoreLinkLayout.test.ts b/frontend/src/react/pages/settings/LearnMoreLinkLayout.test.ts
new file mode 100644
index 0000000000..34023a0033
--- /dev/null
+++ b/frontend/src/react/pages/settings/LearnMoreLinkLayout.test.ts
@@ -0,0 +1,44 @@
+import { readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { describe, expect, test } from "vitest";
+
+const settingsDir = dirname(fileURLToPath(import.meta.url));
+
+function readSettingsPage(filename: string) {
+ return readFileSync(join(settingsDir, filename), "utf8");
+}
+
+describe("settings learn more links", () => {
+ test("uses LearnMoreLink instead of hand-written common.learn-more anchors", () => {
+ const migratedPages = [
+ "EnvironmentsPage.tsx",
+ "IMPage.tsx",
+ "GlobalMaskingPage.tsx",
+ ];
+
+ for (const filename of migratedPages) {
+ const source = readSettingsPage(filename);
+
+ expect(source).toContain("LearnMoreLink");
+ expect(source).not.toContain('{t("common.learn-more")}');
+ expect(source).not.toContain('{t("common.learn-more")} &gt;');
+ }
+ });
+
+ test("adds environment policy learn more links to both page and drawer", () => {
+ const source = readSettingsPage("EnvironmentsPage.tsx");
+
+ expect(source.match(/<LearnMoreLink/g)?.length).toBe(4);
+ expect(
+ source.match(
+ /https:\/\/docs\.bytebase\.com\/change-database\/environment-policy\/overview\/\?source=console#environment-tier/g
+ )?.length
+ ).toBe(2);
+ expect(
+ source.match(
+ /https:\/\/docs\.bytebase\.com\/change-database\/environment-policy\/rollout-policy\/\?source=console/g
+ )?.length
+ ).toBe(2);
+ });
+});
diff --git a/frontend/src/react/pages/settings/MCPPage.test.ts b/frontend/src/react/pages/settings/MCPPage.test.ts
new file mode 100644
index 0000000000..5a2c1121d9
--- /dev/null
+++ b/frontend/src/react/pages/settings/MCPPage.test.ts
@@ -0,0 +1,20 @@
+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));
+
+describe("MCPPage layout", () => {
+ test("uses the CLI command input layout for the first prompt example", () => {
+ const source = readFileSync(join(sectionDir, "MCPPage.tsx"), "utf8");
+
+ const inputIndex = source.indexOf("value={firstPromptExample}");
+ const copyIndex = source.indexOf("CopyButton content={firstPromptExample}");
+
+ expect(inputIndex).toBeGreaterThan(-1);
+ expect(copyIndex).toBeGreaterThan(inputIndex);
+ expect(source).toContain('className="flex-1 font-mono"');
+ expect(source).not.toContain("<code className=");
+ });
+});
diff --git a/frontend/src/react/pages/settings/MCPPage.tsx b/frontend/src/react/pages/settings/MCPPage.tsx
index 4f9429c3aa..ac4671ca18 100644
--- a/frontend/src/react/pages/settings/MCPPage.tsx
+++ b/frontend/src/react/pages/settings/MCPPage.tsx
@@ -179,19 +179,22 @@ export function MCPPage() {
{/* Section 3: Your First Prompt */}
<div className="flex flex-col gap-y-3">
<div className="flex flex-col gap-y-1">
- <div className="flex items-center gap-x-2">
- <h3 className="text-base font-medium">
- {t("settings.mcp.first-prompt.title")}
- </h3>
- <CopyButton content={firstPromptExample} size="sm" />
- </div>
+ <h3 className="text-base font-medium">
+ {t("settings.mcp.first-prompt.title")}
+ </h3>
<p className="text-sm text-control-light">
{t("settings.mcp.first-prompt.description")}
</p>
</div>
- <code className="text-sm bg-gray-100 px-3 py-2 rounded-xs">
- {firstPromptExample}
- </code>
+ <div className="flex items-center gap-x-2">
+ <Input
+ readOnly
+ value={firstPromptExample}
+ className="flex-1 font-mono"
+ onClick={(e) => (e.target as HTMLInputElement).select()}
+ />
+ <CopyButton content={firstPromptExample} size="sm" />
+ </div>
</div>
</div>
);
diff --git a/frontend/src/react/pages/settings/MembersPage.tsx b/frontend/src/react/pages/settings/MembersPage.tsx
index 3d3ac3da14..3a62e7e83b 100644
--- a/frontend/src/react/pages/settings/MembersPage.tsx
+++ b/frontend/src/react/pages/settings/MembersPage.tsx
@@ -42,12 +42,7 @@ 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 { FormError, FormField } 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";
@@ -992,11 +987,14 @@ function DatabaseResourceSection({
];
return (
- <FormField>
- <FormLabel>
- {t("common.databases")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.databases")}
+ <span className="ml-0.5 text-error">*</span>
+ </>
+ }
+ >
<RadioGroup
className="gap-x-4"
value={mode}
@@ -1185,8 +1183,7 @@ function ProjectRoleBindingForm({
)}
{/* Role select */}
- <FormField>
- <FormLabel>{t("settings.members.assign-role")}</FormLabel>
+ <FormField title={<>{t("settings.members.assign-role")}</>}>
<RoleSelect
value={form.role ? [form.role] : []}
onChange={(roles) => handleRoleChange(roles[0] ?? "")}
@@ -1197,8 +1194,7 @@ function ProjectRoleBindingForm({
{/* Permissions display */}
{permissions.length > 0 && (
- <FormField>
- <FormLabel>{t("common.permissions")}</FormLabel>
+ <FormField title={<>{t("common.permissions")}</>}>
<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) => (
@@ -1215,13 +1211,16 @@ function ProjectRoleBindingForm({
)}
{/* Reason */}
- <FormField>
- <FormLabel>
- {t("common.reason")}{" "}
- <span className="text-control-light font-normal">
- ({t("common.optional")})
- </span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.reason")}{" "}
+ <span className="text-control-light font-normal">
+ ({t("common.optional")})
+ </span>
+ </>
+ }
+ >
<textarea
className="w-full rounded-xs border border-control-border bg-transparent px-3 py-2 text-sm resize-none"
rows={2}
@@ -1259,8 +1258,7 @@ function ProjectRoleBindingForm({
{/* Environments (conditional on role) */}
{envKind && (
- <FormField>
- <FormLabel>{t("common.environments")}</FormLabel>
+ <FormField title={<>{t("common.environments")}</>}>
<DDLWarningCallout type="drawer" kind={envKind} />
<EnvironmentSelect
multiple
@@ -1272,11 +1270,21 @@ function ProjectRoleBindingForm({
)}
{/* Expiration */}
- <FormField>
- <FormLabel>
- {t("common.expiration")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.expiration")}
+ <span className="ml-0.5 text-error">*</span>
+ </>
+ }
+ description={
+ maximumRequestExpirationDays !== undefined
+ ? t("project.members.request-role.max-expiration-hint", {
+ days: maximumRequestExpirationDays,
+ })
+ : undefined
+ }
+ >
<div className="flex flex-wrap gap-1.5">
{/* "Never" is only offered when the workspace sets no cap. */}
{maximumRequestExpirationDays === undefined && (
@@ -1316,13 +1324,6 @@ function ProjectRoleBindingForm({
maxDate={maxDatetime}
/>
)}
- {maximumRequestExpirationDays !== undefined && (
- <FormDescription>
- {t("project.members.request-role.max-expiration-hint", {
- days: maximumRequestExpirationDays,
- })}
- </FormDescription>
- )}
{expirationIsInPast && (
<FormError>
{t("project.members.request-role.expiration-must-be-future")}
@@ -1336,11 +1337,11 @@ function ProjectRoleBindingForm({
</FormError>
)}
{!form.expirationCustom && form.expirationTimestampInMS && (
- <FormDescription>
+ <p className="text-xs leading-4 text-control-light">
{t("project.members.expires-at", {
date: formatExpirationDate(form.expirationTimestampInMS),
})}
- </FormDescription>
+ </p>
)}
</FormField>
</div>
@@ -1957,10 +1958,9 @@ function EditMemberRoleDrawer({
/>
)}
{/* Member input */}
- <FormField>
- <FormLabel>
- {t("settings.members.select-account", { count: 1 })}
- </FormLabel>
+ <FormField
+ title={<>{t("settings.members.select-account", { count: 1 })}</>}
+ >
{isEditMode ? (
<Input value={member.binding} disabled />
) : (
@@ -1985,10 +1985,9 @@ function EditMemberRoleDrawer({
/>
</div>
) : (
- <FormField>
- <FormLabel>
- {t("settings.members.select-role", { count: 2 })}
- </FormLabel>
+ <FormField
+ title={<>{t("settings.members.select-role", { count: 2 })}</>}
+ >
<RoleSelect
value={selectedRoles}
onChange={setSelectedRoles}
diff --git a/frontend/src/react/pages/settings/RequestRoleSheet.test.tsx b/frontend/src/react/pages/settings/RequestRoleSheet.test.tsx
index ab120db02e..da71f6c85e 100644
--- a/frontend/src/react/pages/settings/RequestRoleSheet.test.tsx
+++ b/frontend/src/react/pages/settings/RequestRoleSheet.test.tsx
@@ -202,6 +202,7 @@ const mocks = vi.hoisted(() => ({
createIssue: vi.fn(),
pushNotification: vi.fn(),
currentUser: { name: "users/[email protected]", email: "[email protected]" },
+ maximumRequestExpirationSeconds: undefined as number | undefined,
}));
vi.mock("@/connect", () => ({
@@ -230,7 +231,12 @@ vi.mock("@/react/stores/app", () => ({
: [],
}),
// Migrated off the Pinia useSettingV1Store mock.
- getWorkspaceProfile: () => ({ maximumRequestExpiration: undefined }),
+ getWorkspaceProfile: () => ({
+ maximumRequestExpiration:
+ mocks.maximumRequestExpirationSeconds === undefined
+ ? undefined
+ : { seconds: BigInt(mocks.maximumRequestExpirationSeconds) },
+ }),
}),
}));
@@ -255,6 +261,7 @@ beforeEach(() => {
mocks.createIssue.mockResolvedValue({
name: "projects/foo/issues/1",
});
+ mocks.maximumRequestExpirationSeconds = undefined;
container = document.createElement("div");
document.body.appendChild(container);
root = createRoot(container);
@@ -335,6 +342,16 @@ beforeEach(async () => {
});
describe("RequestRoleSheet — enforceIssueTitle (BYT-9310)", () => {
+ it("shows the workspace maximum expiration hint when role requests are capped", async () => {
+ mocks.maximumRequestExpirationSeconds = 30 * 24 * 60 * 60;
+
+ await renderSheet(false);
+
+ expect(container.textContent).toContain(
+ "project.members.request-role.max-expiration-hint"
+ );
+ });
+
it("Submit is enabled with empty reason when enforceIssueTitle is false", async () => {
await renderSheet(false);
await selectRole("roles/projectOwner");
diff --git a/frontend/src/react/pages/settings/RequestRoleSheet.tsx b/frontend/src/react/pages/settings/RequestRoleSheet.tsx
index 66203653fb..325822826a 100644
--- a/frontend/src/react/pages/settings/RequestRoleSheet.tsx
+++ b/frontend/src/react/pages/settings/RequestRoleSheet.tsx
@@ -26,12 +26,7 @@ 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 { FormError, FormField } from "@/react/components/ui/form";
import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
import {
Sheet,
@@ -504,11 +499,14 @@ function RequestRoleForm({
}
/>
)}
- <FormField>
- <FormLabel>
- {t("common.role.self")}
- <span className="text-error ml-0.5">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.role.self")}
+ <span className="text-error ml-0.5">*</span>
+ </>
+ }
+ >
<RoleSelect
scope="project"
multiple={false}
@@ -532,11 +530,14 @@ function RequestRoleForm({
</FormError>
)}
</FormField>
- <FormField>
- <FormLabel>
- {t("common.reason")}
- {reasonRequired && <span className="text-error ml-0.5">*</span>}
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.reason")}
+ {reasonRequired && <span className="text-error ml-0.5">*</span>}
+ </>
+ }
+ >
<Textarea
value={reason}
onChange={(e) => setReason(e.target.value)}
@@ -545,11 +546,14 @@ function RequestRoleForm({
/>
</FormField>
{showDatabases && (
- <FormField>
- <FormLabel>
- {t("common.databases")}
- <span className="text-error ml-0.5">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.databases")}
+ <span className="text-error ml-0.5">*</span>
+ </>
+ }
+ >
<RadioGroup
className="gap-x-4"
value={databaseMode}
@@ -586,8 +590,7 @@ function RequestRoleForm({
</FormField>
)}
{envKind && (
- <FormField>
- <FormLabel>{t("common.environments")}</FormLabel>
+ <FormField title={<>{t("common.environments")}</>}>
<DDLWarningCallout type="drawer" kind={envKind} />
<EnvironmentSelect
multiple
@@ -597,26 +600,29 @@ function RequestRoleForm({
/>
</FormField>
)}
- <FormField>
- <FormLabel>
- {t("common.expiration")}
- {expirationRequired && (
- <span className="text-error ml-0.5">*</span>
- )}
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.expiration")}
+ {expirationRequired && (
+ <span className="text-error ml-0.5">*</span>
+ )}
+ </>
+ }
+ description={
+ maximumRequestExpirationDays !== undefined
+ ? t("project.members.request-role.max-expiration-hint", {
+ days: maximumRequestExpirationDays,
+ })
+ : undefined
+ }
+ >
<ExpirationPicker
value={expirationTimestamp}
onChange={setExpirationTimestamp}
minDate={minDatetime}
maxDate={maxDatetime}
/>
- {maximumRequestExpirationDays !== undefined && (
- <FormDescription>
- {t("project.members.request-role.max-expiration-hint", {
- days: maximumRequestExpirationDays,
- })}
- </FormDescription>
- )}
{expirationIsInPast && (
<FormError>
{t("project.members.request-role.expiration-must-be-future")}
diff --git a/frontend/src/react/pages/settings/RolesPage.tsx b/frontend/src/react/pages/settings/RolesPage.tsx
index 90c145ea03..7547be851c 100644
--- a/frontend/src/react/pages/settings/RolesPage.tsx
+++ b/frontend/src/react/pages/settings/RolesPage.tsx
@@ -27,6 +27,11 @@ import {
DialogContent,
DialogTitle,
} from "@/react/components/ui/dialog";
+import {
+ FormField,
+ FormFieldGroup,
+ FormTitle,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { SearchInput } from "@/react/components/ui/search-input";
import {
@@ -525,14 +530,16 @@ function RoleSheet({
</SheetHeader>
<SheetBody>
- <div className="flex flex-col gap-y-5">
+ <FormFieldGroup>
{/* Title */}
- <div className="flex flex-col gap-y-1.5">
- <label className="text-sm font-medium text-main">
+ <FormField>
+ <FormTitle id="role-sheet-title-title">
{t("role.title")}
<span className="ml-0.5 text-error">*</span>
- </label>
+ </FormTitle>
<Input
+ id="role-sheet-title"
+ aria-labelledby="role-sheet-title-title"
value={editRole.title}
onChange={(e) => handleTitleChange(e.target.value)}
placeholder={t("role.setting.title-placeholder")}
@@ -563,14 +570,16 @@ function RoleSheet({
readonly
/>
)}
- </div>
+ </FormField>
{/* Description */}
- <div className="flex flex-col gap-y-1.5">
- <label className="text-sm font-medium text-main">
+ <FormField>
+ <FormTitle id="role-sheet-description-title">
{t("common.description")}
- </label>
+ </FormTitle>
<Textarea
+ id="role-sheet-description"
+ aria-labelledby="role-sheet-description-title"
value={editRole.description}
onChange={(e) => handleDescriptionChange(e.target.value)}
placeholder={t("role.setting.description-placeholder")}
@@ -578,27 +587,28 @@ function RoleSheet({
disabled={isBuiltin}
className="min-h-[80px]"
/>
- </div>
+ </FormField>
{/* Permissions */}
- <div className="flex flex-col gap-y-2">
- <div className="flex items-center justify-between">
- <label className="text-sm font-medium text-main">
- {t("common.permissions")}
- <span className="ml-0.5 text-error">*</span>
- </label>
- {!isBuiltin && (
- <Button
- variant="outline"
- size="sm"
- onClick={() => setShowImportModal(true)}
- >
- <Plus className="w-4 h-4 mr-1" />
- {t("role.import-from-role")}
- </Button>
- )}
- </div>
-
+ <FormField>
+ <FormTitle>
+ <div className="flex items-center justify-between gap-x-4">
+ <span>
+ {t("common.permissions")}
+ <span className="ml-0.5 text-error">*</span>
+ </span>
+ {!isBuiltin && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => setShowImportModal(true)}
+ >
+ <Plus className="w-4 h-4 mr-1" />
+ {t("role.import-from-role")}
+ </Button>
+ )}
+ </div>
+ </FormTitle>
{missedBasicPermissions.length > 0 && !isBuiltin && (
<Alert
variant="error"
@@ -626,8 +636,8 @@ function RoleSheet({
onChange={handlePermissionsChange}
disabled={isBuiltin}
/>
- </div>
- </div>
+ </FormField>
+ </FormFieldGroup>
</SheetBody>
{!isBuiltin && (
diff --git a/frontend/src/react/pages/settings/RolesPageLayout.test.ts b/frontend/src/react/pages/settings/RolesPageLayout.test.ts
new file mode 100644
index 0000000000..af5e1d37f9
--- /dev/null
+++ b/frontend/src/react/pages/settings/RolesPageLayout.test.ts
@@ -0,0 +1,30 @@
+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));
+
+describe("RolesPage drawer layout", () => {
+ test("uses shared form primitives in the role sheet", () => {
+ const source = readFileSync(join(sectionDir, "RolesPage.tsx"), "utf8");
+ const roleSheetSource = source.slice(
+ source.indexOf("function RoleSheet"),
+ source.indexOf(
+ "// ============================================================\n// RolesPage"
+ )
+ );
+
+ expect(roleSheetSource).toContain("<FormFieldGroup>");
+ expect(roleSheetSource).toContain("<FormField");
+ expect(roleSheetSource).toContain("FormTitle");
+ expect(roleSheetSource).toContain('id="role-sheet-title"');
+ expect(roleSheetSource).toContain('id="role-sheet-description"');
+ expect(roleSheetSource).not.toContain("FormLabel");
+ expect(roleSheetSource).not.toContain('className="textlabel"');
+ expect(roleSheetSource).not.toContain(
+ 'className="text-sm font-medium text-main"'
+ );
+ expect(roleSheetSource).not.toContain('className="flex flex-col gap-y-5"');
+ });
+});
diff --git a/frontend/src/react/pages/settings/ServiceAccountsPage.tsx b/frontend/src/react/pages/settings/ServiceAccountsPage.tsx
index 51cfb7f0fb..c28fcc05e6 100644
--- a/frontend/src/react/pages/settings/ServiceAccountsPage.tsx
+++ b/frontend/src/react/pages/settings/ServiceAccountsPage.tsx
@@ -9,7 +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 { FormField } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Sheet,
@@ -566,8 +566,7 @@ function ServiceAccountForm({
<SheetBody>
<div className="flex flex-col gap-y-6">
{/* Name */}
- <FormField>
- <FormLabel>{t("common.name")}</FormLabel>
+ <FormField title={<>{t("common.name")}</>}>
<Input
autoComplete="off"
value={title}
@@ -578,11 +577,14 @@ function ServiceAccountForm({
</FormField>
{/* Email */}
- <FormField>
- <FormLabel>
- {t("common.email")}
- <span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ <FormField
+ title={
+ <>
+ {t("common.email")}
+ <span className="ml-0.5 text-error">*</span>
+ </>
+ }
+ >
{isEditMode ? (
<Input value={serviceAccount?.email ?? ""} disabled />
) : (
@@ -609,8 +611,7 @@ function ServiceAccountForm({
"bb.projects.setIamPolicy"
)
: hasWorkspacePermissionV2("bb.workspaces.setIamPolicy")) && (
- <FormField>
- <FormLabel>{t("settings.members.table.roles")}</FormLabel>
+ <FormField title={<>{t("settings.members.table.roles")}</>}>
<RoleSelect
value={roles}
onChange={setRoles}
diff --git a/frontend/src/react/pages/settings/SubscriptionPage.tsx b/frontend/src/react/pages/settings/SubscriptionPage.tsx
index d6a40e8ca6..db5423331d 100644
--- a/frontend/src/react/pages/settings/SubscriptionPage.tsx
+++ b/frontend/src/react/pages/settings/SubscriptionPage.tsx
@@ -6,8 +6,14 @@ import { useTranslation } from "react-i18next";
import { subscriptionServiceClientConnect } from "@/connect";
import { silentContextKey } from "@/connect/context-key";
import { InstanceAssignmentSheet } from "@/react/components/InstanceAssignmentSheet";
+import { LearnMoreLink } from "@/react/components/LearnMoreLink";
import { Badge } from "@/react/components/ui/badge";
import { Button } from "@/react/components/ui/button";
+import {
+ FormField,
+ FormFieldGroup,
+ FormLabel,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { Textarea } from "@/react/components/ui/textarea";
import {
@@ -276,21 +282,23 @@ export function SubscriptionPage({
{/* Workspace ID (self-hosted only) */}
{!isSaaSMode && (
<>
- <div>
- <label className="flex items-center gap-x-2">
- <span className="text-main">
- {t("settings.general.workspace.id")}
- </span>
- </label>
- <div className="mb-3 text-sm text-control-placeholder">
- {t("settings.general.workspace.id-description")}
- </div>
- <div className="mb-4 flex items-center gap-x-2">
+ <FormField
+ title={t("settings.general.workspace.id")}
+ description={t("settings.general.workspace.id-description")}
+ >
+ <div className="flex items-center gap-x-2">
<Input
+ id="subscription-workspace-id"
readOnly
value={workspaceId}
onClick={(e) => (e.target as HTMLInputElement).select()}
/>
+ <FormLabel
+ htmlFor="subscription-workspace-id"
+ className="sr-only"
+ >
+ {t("settings.general.workspace.id")}
+ </FormLabel>
<Button
variant="ghost"
size="sm"
@@ -305,7 +313,7 @@ export function SubscriptionPage({
</span>
)}
</div>
- </div>
+ </FormField>
<hr className="my-6 border-t border-block-border" />
</>
)}
@@ -317,51 +325,52 @@ export function SubscriptionPage({
{/* Self-hosted: Upload license */}
{!isSaaSMode && isSelfHostLicense && (
- <div className="w-full mt-4 flex flex-col">
- <label className="flex items-center gap-x-2">
- <span className="text-main">
+ <FormFieldGroup className="mt-4">
+ <FormField
+ title={t("subscription.upload-license")}
+ description={
+ <>
+ {t("subscription.description")} {t("subscription.plan-compare")}{" "}
+ <LearnMoreLink
+ href="https://www.bytebase.com/pricing?source=console"
+ className="text-accent"
+ />
+ {showTrial && allowManage && (
+ <Button
+ variant="link"
+ size="sm"
+ className="ml-1"
+ onClick={onRequireEnterprise}
+ >
+ {t("subscription.plan.try")}
+ </Button>
+ )}
+ </>
+ }
+ >
+ <FormLabel htmlFor="subscription-license" className="sr-only">
{t("subscription.upload-license")}
- </span>
- </label>
- <div className="mb-3 text-sm text-control-placeholder">
- {t("subscription.description")} {t("subscription.plan-compare")}{" "}
- <a
- href="https://www.bytebase.com/pricing?source=console"
- target="_blank"
- rel="noopener noreferrer"
- className="text-accent hover:underline"
- >
- {t("common.learn-more")} &gt;
- </a>
- {showTrial && allowManage && (
+ </FormLabel>
+ <Textarea
+ id="subscription-license"
+ value={license}
+ onChange={(e: ChangeEvent<HTMLTextAreaElement>) =>
+ setLicense(e.target.value)
+ }
+ disabled={!allowManage}
+ placeholder={t("common.sensitive-placeholder")}
+ />
+ <div className="ml-auto mt-3">
<Button
- variant="link"
- size="sm"
- className="ml-1"
- onClick={onRequireEnterprise}
+ disabled={disabled || !allowManage}
+ onClick={handleUpload}
+ className="capitalize"
>
- {t("subscription.plan.try")}
+ {t("subscription.upload-license")}
</Button>
- )}
- </div>
- <Textarea
- value={license}
- onChange={(e: ChangeEvent<HTMLTextAreaElement>) =>
- setLicense(e.target.value)
- }
- disabled={!allowManage}
- placeholder={t("common.sensitive-placeholder")}
- />
- <div className="ml-auto mt-3">
- <Button
- disabled={disabled || !allowManage}
- onClick={handleUpload}
- className="capitalize"
- >
- {t("subscription.upload-license")}
- </Button>
- </div>
- </div>
+ </div>
+ </FormField>
+ </FormFieldGroup>
)}
{!hasUnifiedInstanceLicense && (
<InstanceAssignmentSheet
diff --git a/frontend/src/react/pages/settings/SubscriptionPageLayout.test.ts b/frontend/src/react/pages/settings/SubscriptionPageLayout.test.ts
new file mode 100644
index 0000000000..faa655d45c
--- /dev/null
+++ b/frontend/src/react/pages/settings/SubscriptionPageLayout.test.ts
@@ -0,0 +1,34 @@
+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));
+
+describe("SubscriptionPage layout", () => {
+ test("uses shared form primitives for self-hosted subscription fields", () => {
+ const source = readFileSync(
+ join(sectionDir, "SubscriptionPage.tsx"),
+ "utf8"
+ );
+
+ expect(source).toContain("FormFieldGroup");
+ expect(source).toContain("<FormField");
+ expect(source).toContain("LearnMoreLink");
+ expect(source).toContain(
+ 'href="https://www.bytebase.com/pricing?source=console"'
+ );
+ expect(source).toContain('htmlFor="subscription-workspace-id"');
+ expect(source).toContain('id="subscription-workspace-id"');
+ expect(source).toContain('htmlFor="subscription-license"');
+ expect(source).toContain('id="subscription-license"');
+ expect(source).not.toContain(
+ '<label className="flex items-center gap-x-2">'
+ );
+ expect(source).not.toContain(
+ 'className="mb-3 text-sm text-control-placeholder"'
+ );
+ expect(source).not.toContain('rel="noopener noreferrer"');
+ expect(source).not.toContain('{t("common.learn-more")} &gt;');
+ });
+});
diff --git a/frontend/src/react/pages/settings/UsersPage.tsx b/frontend/src/react/pages/settings/UsersPage.tsx
index b318a3c346..20121dba51 100644
--- a/frontend/src/react/pages/settings/UsersPage.tsx
+++ b/frontend/src/react/pages/settings/UsersPage.tsx
@@ -20,12 +20,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 {
- FormDescription,
- FormError,
- FormField,
- FormLabel,
-} from "@/react/components/ui/form";
+import { FormError, FormField, FormTitle } from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { SearchInput } from "@/react/components/ui/search-input";
import {
@@ -753,8 +748,10 @@ function UserForm({
<div className="flex flex-col gap-y-6">
{/* Name */}
<FormField>
- <FormLabel>{t("common.name")}</FormLabel>
+ <FormTitle id="user-form-name-title">{t("common.name")}</FormTitle>
<Input
+ id="user-form-name"
+ aria-labelledby="user-form-name-title"
value={title}
onChange={(e) => setTitle(e.target.value)}
placeholder={t("common.name")}
@@ -765,11 +762,13 @@ function UserForm({
{/* Email */}
<FormField>
- <FormLabel>
+ <FormTitle id="user-form-email-title">
{t("common.email")}
<span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ </FormTitle>
<Input
+ id="user-form-email"
+ aria-labelledby="user-form-email-title"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
@@ -780,18 +779,22 @@ function UserForm({
{/* Roles */}
{hasWorkspacePermissionV2("bb.workspaces.setIamPolicy") && (
<FormField>
- <FormLabel>{t("settings.members.table.roles")}</FormLabel>
+ <FormTitle>{t("settings.members.table.roles")}</FormTitle>
<RoleSelect value={roles} onChange={setRoles} disabled={false} />
</FormField>
)}
{/* Phone */}
<FormField>
- <FormLabel>{t("settings.profile.phone")}</FormLabel>
- <FormDescription>
+ <FormTitle id="user-form-phone-title">
+ {t("settings.profile.phone")}
+ </FormTitle>
+ <span className="text-sm text-control-placeholder">
{t("settings.profile.phone-tips")}
- </FormDescription>
+ </span>
<Input
+ id="user-form-phone"
+ aria-labelledby="user-form-phone-title"
type="tel"
value={phone}
onChange={(e) => setPhone(e.target.value)}
@@ -803,12 +806,14 @@ function UserForm({
{/* Password */}
<div className="flex flex-col gap-y-6">
<FormField>
- <FormLabel>
+ <FormTitle id="user-form-password-title">
{t("settings.profile.password")}
<span className="ml-0.5 text-error">*</span>
- </FormLabel>
+ </FormTitle>
<span
- className={`flex items-center gap-x-1 textinfolabel text-sm ${passwordHint ? "text-error" : ""}`}
+ className={`flex items-center gap-x-1 text-sm text-control-placeholder ${
+ passwordHint ? "text-error" : ""
+ }`}
>
{t("settings.profile.password-hint")}
<Tooltip
@@ -830,8 +835,10 @@ function UserForm({
<CircleAlert className="w-4 cursor-help" />
</Tooltip>
</span>
- <div className="mt-1 relative flex items-center">
+ <div className="relative mt-1 flex w-full items-center">
<Input
+ id="user-form-password"
+ aria-labelledby="user-form-password-title"
type={showPassword ? "text" : "password"}
value={password}
onChange={(e) => setPassword(e.target.value)}
@@ -855,12 +862,14 @@ function UserForm({
</FormField>
<FormField>
- <FormLabel>
+ <FormTitle id="user-form-password-confirm-title">
{t("settings.profile.password-confirm")}
<span className="ml-0.5 text-error">*</span>
- </FormLabel>
- <div className="mt-1 relative flex items-center">
+ </FormTitle>
+ <div className="relative mt-1 flex w-full items-center">
<Input
+ id="user-form-password-confirm"
+ aria-labelledby="user-form-password-confirm-title"
type={showPassword ? "text" : "password"}
value={passwordConfirm}
onChange={(e) => setPasswordConfirm(e.target.value)}
diff --git a/frontend/src/react/pages/settings/UsersPageLayout.test.ts b/frontend/src/react/pages/settings/UsersPageLayout.test.ts
new file mode 100644
index 0000000000..5a2241c9e3
--- /dev/null
+++ b/frontend/src/react/pages/settings/UsersPageLayout.test.ts
@@ -0,0 +1,43 @@
+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));
+
+describe("UsersPage drawer layout", () => {
+ test("keeps the password hint aligned in the compact drawer field", () => {
+ const source = readFileSync(join(sectionDir, "UsersPage.tsx"), "utf8");
+
+ const passwordTitleIndex = source.indexOf('id="user-form-password-title"');
+ const passwordHintIndex = source.indexOf(
+ 't("settings.profile.password-hint")'
+ );
+ const hintRowIndex = source.indexOf("<span\n className");
+ const hintRowClassIndex = source.indexOf(
+ "flex items-center gap-x-1 text-sm text-control-placeholder",
+ hintRowIndex
+ );
+ const hintErrorIndex = source.indexOf('passwordHint ? "text-error" : ""');
+ const passwordInputIndex = source.indexOf(
+ 'className="relative mt-1 flex w-full items-center"'
+ );
+
+ expect(passwordTitleIndex).toBeGreaterThan(-1);
+ expect(passwordHintIndex).toBeGreaterThan(-1);
+ expect(passwordTitleIndex).toBeLessThan(passwordHintIndex);
+ expect(hintRowIndex).toBeGreaterThan(-1);
+ expect(hintRowClassIndex).toBeGreaterThan(hintRowIndex);
+ expect(hintRowClassIndex).toBeLessThan(passwordHintIndex);
+ expect(hintErrorIndex).toBeGreaterThan(hintRowClassIndex);
+ expect(hintErrorIndex).toBeLessThan(passwordHintIndex);
+ expect(passwordInputIndex).toBeGreaterThan(passwordHintIndex);
+ expect(source).not.toContain(
+ 'description={\n <>\n {t("settings.profile.password-hint")}'
+ );
+ expect(source).toContain("FormTitle");
+ expect(source).not.toContain("FormLabel");
+ expect(source).not.toContain("textlabel");
+ expect(source).not.toContain("textinfolabel");
+ });
+});
diff --git a/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx b/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx
index 0434baf8b3..0722241316 100644
--- a/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx
+++ b/frontend/src/react/pages/settings/general/AIAugmentationSection.tsx
@@ -15,7 +15,11 @@ 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 {
+ FormField,
+ FormFieldGroup,
+ FormSection,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import {
Select,
@@ -61,7 +65,7 @@ export const AIAugmentationSection = forwardRef<
AIAugmentationSectionProps
>(function AIAugmentationSection({ title, onDirtyChange }, ref) {
const { t } = useTranslation();
- const containerRef = useRef<HTMLDivElement>(null);
+ const containerRef = useRef<HTMLElement>(null);
const { isSaaSMode } = useServerState();
const canEdit = hasWorkspacePermissionV2("bb.settings.set") && !isSaaSMode;
@@ -210,18 +214,10 @@ export const AIAugmentationSection = forwardRef<
};
return (
- <div id="ai" ref={containerRef} className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <div className="flex items-center gap-x-2">
- <h1 className="text-2xl font-bold">{title}</h1>
- </div>
- </div>
- <ComponentPermissionGuard
- permissions={["bb.settings.get"]}
- className="flex-1"
- >
+ <FormSection id="ai" ref={containerRef} title={title}>
+ <ComponentPermissionGuard permissions={["bb.settings.get"]}>
<PermissionGuard permissions={["bb.settings.set"]} display="block">
- <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <FormFieldGroup>
{isSaaSMode ? (
<Alert
variant="info"
@@ -232,40 +228,39 @@ export const AIAugmentationSection = forwardRef<
) : (
<>
{/* Enable toggle */}
- <div>
- <div className="flex items-center gap-x-2">
- <Checkbox
- checked={state.enabled}
- disabled={!canEdit}
- onCheckedChange={(checked) => toggleEnabled(checked)}
- />
- <span className="text-base font-semibold">
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
+ <Checkbox
+ checked={state.enabled}
+ disabled={!canEdit}
+ onCheckedChange={(checked) => toggleEnabled(checked)}
+ />
{t(
"settings.general.workspace.ai-assistant.enable-ai-assistant"
)}
</span>
- </div>
- <div className="mt-1 mb-3 text-sm text-control-placeholder">
- {t("settings.general.workspace.ai-assistant.description")}{" "}
- <LearnMoreLink
- href="https://docs.bytebase.com/ai-assistant?source=console"
- className="text-accent text-sm ml-1"
- />
- </div>
- </div>
+ }
+ description={
+ <>
+ {t("settings.general.workspace.ai-assistant.description")}{" "}
+ <LearnMoreLink
+ href="https://docs.bytebase.com/ai-assistant?source=console"
+ className="text-accent text-sm ml-1"
+ />
+ </>
+ }
+ />
{/* Collapsible fields when enabled */}
{state.enabled && (
<>
{/* Provider */}
- <div>
- <label className="flex items-center gap-x-2 mb-2">
- <span className="text-base font-semibold">
- {t(
- "settings.general.workspace.ai-assistant.provider.self"
- )}
- </span>
- </label>
+ <FormField
+ title={t(
+ "settings.general.workspace.ai-assistant.provider.self"
+ )}
+ >
<Select
value={String(state.provider)}
disabled={!canEdit}
@@ -286,44 +281,39 @@ export const AIAugmentationSection = forwardRef<
))}
</SelectContent>
</Select>
- </div>
+ </FormField>
{/* API Key */}
- <div>
- <label className="flex items-center gap-x-2">
- <span className="text-base font-semibold">
- {t(
- "settings.general.workspace.ai-assistant.api-key.self"
- )}
- </span>
- </label>
- <div className="mb-3 text-sm text-control-placeholder">
- {t(
- "settings.general.workspace.ai-assistant.api-key.description",
- {
- viewDoc: "__LINK__",
- interpolation: { escapeValue: false },
- }
- )
- .split("__LINK__")
- .map((part, i) => (
- <span key={i}>
- {part}
- {i === 0 && (
- <a
- href={providerDefault.apiKeyDoc}
- className="normal-link"
- target="_blank"
- rel="noopener noreferrer"
- >
- {t(
- "settings.general.workspace.ai-assistant.api-key.find-my-key"
- )}
- </a>
- )}
- </span>
- ))}
- </div>
+ <FormField
+ title={t(
+ "settings.general.workspace.ai-assistant.api-key.self"
+ )}
+ description={t(
+ "settings.general.workspace.ai-assistant.api-key.description",
+ {
+ viewDoc: "__LINK__",
+ interpolation: { escapeValue: false },
+ }
+ )
+ .split("__LINK__")
+ .map((part, i) => (
+ <span key={i}>
+ {part}
+ {i === 0 && (
+ <a
+ href={providerDefault.apiKeyDoc}
+ className="normal-link"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ {t(
+ "settings.general.workspace.ai-assistant.api-key.find-my-key"
+ )}
+ </a>
+ )}
+ </span>
+ ))}
+ >
<Input
value={state.apiKey}
disabled={!canEdit}
@@ -334,47 +324,40 @@ export const AIAugmentationSection = forwardRef<
setState((s) => ({ ...s, apiKey: e.target.value }))
}
/>
- </div>
+ </FormField>
{/* Endpoint */}
- <div>
- <label className="flex items-center gap-x-2">
- <span className="text-base font-semibold">
- {t(
- "settings.general.workspace.ai-assistant.endpoint.self"
- )}
- </span>
- </label>
- <div className="mb-3 text-sm text-control-placeholder">
- {t(
- "settings.general.workspace.ai-assistant.endpoint.description"
- )}
- </div>
+ <FormField
+ title={t(
+ "settings.general.workspace.ai-assistant.endpoint.self"
+ )}
+ description={t(
+ "settings.general.workspace.ai-assistant.endpoint.description"
+ )}
+ >
<Input
value={state.endpoint}
required
disabled={!canEdit}
placeholder={providerDefault.endpoint}
onChange={(e) =>
- setState((s) => ({ ...s, endpoint: e.target.value }))
+ setState((s) => ({
+ ...s,
+ endpoint: e.target.value,
+ }))
}
/>
- </div>
+ </FormField>
{/* Model */}
- <div>
- <label className="flex items-center gap-x-2">
- <span className="text-base font-semibold">
- {t(
- "settings.general.workspace.ai-assistant.model.self"
- )}
- </span>
- </label>
- <div className="mb-3 text-sm text-control-placeholder">
- {t(
- "settings.general.workspace.ai-assistant.model.description"
- )}
- </div>
+ <FormField
+ title={t(
+ "settings.general.workspace.ai-assistant.model.self"
+ )}
+ description={t(
+ "settings.general.workspace.ai-assistant.model.description"
+ )}
+ >
<Input
value={state.model}
required
@@ -383,7 +366,7 @@ export const AIAugmentationSection = forwardRef<
setState((s) => ({ ...s, model: e.target.value }))
}
/>
- </div>
+ </FormField>
</>
)}
</>
@@ -391,6 +374,6 @@ export const AIAugmentationSection = forwardRef<
</FormFieldGroup>
</PermissionGuard>
</ComponentPermissionGuard>
- </div>
+ </FormSection>
);
});
diff --git a/frontend/src/react/pages/settings/general/AccountSection.tsx b/frontend/src/react/pages/settings/general/AccountSection.tsx
index 3b074361b0..bc6a4f5621 100644
--- a/frontend/src/react/pages/settings/general/AccountSection.tsx
+++ b/frontend/src/react/pages/settings/general/AccountSection.tsx
@@ -18,7 +18,11 @@ import {
usePermissionCheck,
} from "@/react/components/PermissionGuard";
import { Checkbox } from "@/react/components/ui/checkbox";
-import { FormFieldGroup } from "@/react/components/ui/form";
+import {
+ FormField,
+ FormFieldGroup,
+ FormSection,
+} 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";
@@ -415,55 +419,55 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
const disabled = !allowEdit;
return (
- <div id="account" className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">{title}</h1>
- </div>
+ <FormSection id="account" title={title}>
<PermissionGuard
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <FormFieldGroup>
{/* Sub-section 1: Disallow signup (non-SaaS only) */}
{!isSaaSMode && (
<>
- <div className="mt-4 lg:mt-0">
- <div className="flex items-center gap-x-2">
- <Checkbox
- checked={toggleState.disallowSignup}
- disabled={disabled || !hasDisallowSignupFeature}
- onCheckedChange={(checked) =>
- setToggleState((s) => ({
- ...s,
- disallowSignup: checked,
- }))
- }
- />
- <span className="text-base font-semibold">
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
+ <Checkbox
+ checked={toggleState.disallowSignup}
+ disabled={disabled || !hasDisallowSignupFeature}
+ onCheckedChange={(checked) =>
+ setToggleState((s) => ({
+ ...s,
+ disallowSignup: checked,
+ }))
+ }
+ />
{t("settings.general.workspace.disallow-signup.enable")}
+ <FeatureBadge
+ feature={
+ PlanFeature.FEATURE_DISALLOW_SELF_SERVICE_SIGNUP
+ }
+ />
</span>
- <FeatureBadge
- feature={PlanFeature.FEATURE_DISALLOW_SELF_SERVICE_SIGNUP}
- />
- </div>
- <div className="mt-1 mb-3 text-sm text-gray-400">
- {t(
- "settings.general.workspace.disallow-signup.description"
- )}
- </div>
- </div>
- <hr className="my-6" />
+ }
+ description={t(
+ "settings.general.workspace.disallow-signup.description"
+ )}
+ />
+ <hr className="my-1" />
</>
)}
{/* Sub-section 2: Password Restriction */}
- <div className="mt-4 lg:mt-0">
- <p className="text-base font-semibold flex flex-row justify-start items-center mb-2 gap-x-2">
- {t("settings.general.workspace.password-restriction.self")}
- <FeatureBadge
- feature={PlanFeature.FEATURE_PASSWORD_RESTRICTIONS}
- />
- </p>
+ <FormField
+ title={
+ <span className="flex flex-row justify-start items-center gap-x-2">
+ {t("settings.general.workspace.password-restriction.self")}
+ <FeatureBadge
+ feature={PlanFeature.FEATURE_PASSWORD_RESTRICTIONS}
+ />
+ </span>
+ }
+ >
<div className="flex flex-col gap-y-3">
<div className="flex items-center">
<Input
@@ -621,54 +625,54 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
</span>
</label>
</div>
- </div>
+ </FormField>
- <hr className="my-6" />
+ <hr className="my-1" />
{/* Sub-section 3: Require 2FA */}
<div className="flex flex-col gap-y-7">
- <div className="mt-4 lg:mt-0">
- <div className="flex items-center gap-x-2">
- <Checkbox
- checked={toggleState.requireMfa}
- disabled={disabled || !has2FAFeature}
- onCheckedChange={(checked) =>
- setToggleState((s) => ({
- ...s,
- requireMfa: checked,
- }))
- }
- />
- <span className="text-base font-semibold">
- {t("settings.general.workspace.require-2fa.enable")}
- </span>
- <FeatureBadge feature={PlanFeature.FEATURE_TWO_FA} />
- </div>
- <div className="mt-1 text-sm text-gray-400">
- {t("settings.general.workspace.require-2fa.description")}
- </div>
- </div>
-
- {/* Sub-section 4: Disallow password signin (non-SaaS only) */}
- {!isSaaSMode && (
- <div className="lg:mt-0">
- <div className="flex items-center gap-x-2">
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
<Checkbox
- checked={toggleState.disallowPasswordSignin}
- disabled={
- disabled ||
- !hasDisallowPasswordSigninFeature ||
- (!toggleState.disallowPasswordSignin &&
- !existActiveIdentityProvider)
- }
+ checked={toggleState.requireMfa}
+ disabled={disabled || !has2FAFeature}
onCheckedChange={(checked) =>
setToggleState((s) => ({
...s,
- disallowPasswordSignin: checked,
+ requireMfa: checked,
}))
}
/>
- <span className="text-base font-semibold flex items-center gap-x-2">
+ {t("settings.general.workspace.require-2fa.enable")}
+ <FeatureBadge feature={PlanFeature.FEATURE_TWO_FA} />
+ </span>
+ }
+ description={t(
+ "settings.general.workspace.require-2fa.description"
+ )}
+ />
+
+ {/* Sub-section 4: Disallow password signin (non-SaaS only) */}
+ {!isSaaSMode && (
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
+ <Checkbox
+ checked={toggleState.disallowPasswordSignin}
+ disabled={
+ disabled ||
+ !hasDisallowPasswordSigninFeature ||
+ (!toggleState.disallowPasswordSignin &&
+ !existActiveIdentityProvider)
+ }
+ onCheckedChange={(checked) =>
+ setToggleState((s) => ({
+ ...s,
+ disallowPasswordSignin: checked,
+ }))
+ }
+ />
{t(
"settings.general.workspace.disallow-password-signin.enable"
)}
@@ -687,34 +691,33 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
</span>
)}
</span>
- </div>
- <div className="mt-1 text-sm text-gray-400">
- {t(
- "settings.general.workspace.disallow-password-signin.description"
- )}
- </div>
- </div>
+ }
+ description={t(
+ "settings.general.workspace.disallow-password-signin.description"
+ )}
+ />
)}
{/* Sub-section 5: Allow email-code signin (non-SaaS only; requires EMAIL setting).
Hidden in production until the email configuration UI is built. */}
{!isSaaSMode && isDev() && (
- <div className="lg:mt-0">
- <div className="flex items-center gap-x-2">
- <Checkbox
- checked={toggleState.allowEmailCodeSignin}
- disabled={
- disabled ||
- (!toggleState.allowEmailCodeSignin && !hasEmailSetting)
- }
- onCheckedChange={(checked) =>
- setToggleState((s) => ({
- ...s,
- allowEmailCodeSignin: checked,
- }))
- }
- />
- <span className="text-base font-semibold flex items-center gap-x-2">
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
+ <Checkbox
+ checked={toggleState.allowEmailCodeSignin}
+ disabled={
+ disabled ||
+ (!toggleState.allowEmailCodeSignin &&
+ !hasEmailSetting)
+ }
+ onCheckedChange={(checked) =>
+ setToggleState((s) => ({
+ ...s,
+ allowEmailCodeSignin: checked,
+ }))
+ }
+ />
{t(
"settings.general.workspace.allow-email-code-signin.enable"
)}
@@ -729,35 +732,32 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
</span>
)}
</span>
- </div>
- <div className="mt-1 text-sm text-gray-400">
- {t(
- "settings.general.workspace.allow-email-code-signin.description"
- )}
- </div>
- </div>
+ }
+ description={t(
+ "settings.general.workspace.allow-email-code-signin.description"
+ )}
+ />
)}
</div>
- <hr className="my-6" />
+ <hr className="my-1" />
{/* Sub-section 5: Token Duration */}
{/* Access Token Duration */}
- <div className="mb-7 mt-4 lg:mt-0">
- <p className="text-base font-semibold flex flex-row justify-start items-center gap-x-2">
- <span>
+ <FormField
+ title={
+ <span className="flex flex-row justify-start items-center gap-x-2">
{t("settings.general.workspace.access-token-duration.self")}
+ <FeatureBadge
+ feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}
+ />
</span>
- <FeatureBadge
- feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}
- />
- </p>
- <p className="text-sm text-gray-400 mt-1">
- {t(
- "settings.general.workspace.access-token-duration.description"
- )}
- </p>
- <div className="mt-3 flex flex-row justify-start items-center gap-x-4">
+ }
+ description={t(
+ "settings.general.workspace.access-token-duration.description"
+ )}
+ >
+ <div className="flex flex-row justify-start items-center gap-x-4">
<NumberInput
className="w-24"
value={tokenState.accessTokenDuration}
@@ -798,24 +798,23 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
</RadioGroupItem>
</RadioGroup>
</div>
- </div>
+ </FormField>
{/* Refresh Token Duration */}
- <div className="mb-7 mt-4 lg:mt-0">
- <p className="text-base font-semibold flex flex-row justify-start items-center gap-x-2">
- <span>
+ <FormField
+ title={
+ <span className="flex flex-row justify-start items-center gap-x-2">
{t("settings.general.workspace.refresh-token-duration.self")}
+ <FeatureBadge
+ feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}
+ />
</span>
- <FeatureBadge
- feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}
- />
- </p>
- <p className="text-sm text-gray-400 mt-1">
- {t(
- "settings.general.workspace.refresh-token-duration.description"
- )}
- </p>
- <div className="mt-3 flex flex-row justify-start items-center gap-x-4">
+ }
+ description={t(
+ "settings.general.workspace.refresh-token-duration.description"
+ )}
+ >
+ <div className="flex flex-row justify-start items-center gap-x-4">
<NumberInput
className="w-24"
value={tokenState.refreshTokenDuration}
@@ -860,29 +859,32 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
</RadioGroupItem>
</RadioGroup>
</div>
- </div>
+ </FormField>
{/* Inactive Session Timeout */}
- <div className="mt-4 lg:mt-0">
- <p className="text-base font-semibold flex flex-row justify-start items-center gap-x-2">
- <span>
+ <FormField
+ title={
+ <span className="flex flex-row justify-start items-center gap-x-2">
{t(
"settings.general.workspace.inactive-session-timeout.self"
)}
+ <FeatureBadge
+ feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}
+ />
</span>
- <FeatureBadge
- feature={PlanFeature.FEATURE_TOKEN_DURATION_CONTROL}
- />
- </p>
- <p className="text-sm text-gray-400 mt-1">
- {t(
- "settings.general.workspace.inactive-session-timeout.description"
- )}{" "}
- <span className="font-semibold">
- {t("settings.general.workspace.no-limit")}
- </span>
- </p>
- <div className="mt-3 flex flex-row justify-start items-center gap-x-4">
+ }
+ description={
+ <>
+ {t(
+ "settings.general.workspace.inactive-session-timeout.description"
+ )}{" "}
+ <span className="font-semibold">
+ {t("settings.general.workspace.no-limit")}
+ </span>
+ </>
+ }
+ >
+ <div className="flex flex-row justify-start items-center gap-x-4">
<NumberInput
className="w-24"
value={tokenState.inactiveTimeout}
@@ -899,10 +901,10 @@ export const AccountSection = forwardRef<SectionHandle, AccountSectionProps>(
)}
</span>
</div>
- </div>
+ </FormField>
</FormFieldGroup>
</PermissionGuard>
- </div>
+ </FormSection>
);
}
);
diff --git a/frontend/src/react/pages/settings/general/AnnouncementSection.tsx b/frontend/src/react/pages/settings/general/AnnouncementSection.tsx
index d25c31a5ac..9524d215df 100644
--- a/frontend/src/react/pages/settings/general/AnnouncementSection.tsx
+++ b/frontend/src/react/pages/settings/general/AnnouncementSection.tsx
@@ -26,10 +26,10 @@ import { ColorInput } from "@/react/components/ui/color-input";
import {
FormControlGroup,
FormControlRow,
- FormDescription,
FormField,
FormFieldGroup,
FormLabel,
+ FormSection,
} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { SegmentedControl } from "@/react/components/ui/segmented-control";
@@ -168,32 +168,31 @@ export const AnnouncementSection = forwardRef<
state.text || t("settings.general.workspace.announcement-text.placeholder");
return (
- <div id="announcement" className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <div className="flex items-center gap-x-2">
- <h1 className="text-2xl font-bold">{title}</h1>
+ <FormSection
+ id="announcement"
+ title={
+ <span className="inline-flex items-center gap-x-2">
+ {title}
<FeatureBadge
feature={PlanFeature.FEATURE_DASHBOARD_ANNOUNCEMENT}
clickable
/>
- </div>
- </div>
+ </span>
+ }
+ >
<PermissionGuard
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <FormFieldGroup>
{/* 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>
-
+ <FormField
+ className="gap-y-3"
+ title={t("settings.general.workspace.announcement-theme.self")}
+ description={t(
+ "settings.general.workspace.announcement-theme.description"
+ )}
+ >
<SegmentedControl
ariaLabel={t(
"settings.general.workspace.announcement-theme.self"
@@ -259,10 +258,7 @@ export const AnnouncementSection = forwardRef<
)}
</FormField>
- <FormField className="gap-y-2">
- <p className="text-sm font-medium text-control">
- {t("common.preview")}
- </p>
+ <FormField title={t("common.preview")}>
<AnnouncementBanner
text={previewText}
link={state.link}
@@ -274,13 +270,12 @@ export const AnnouncementSection = forwardRef<
</FormField>
{/* 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>
+ <FormField
+ title={t("settings.general.workspace.announcement-text.self")}
+ description={t(
+ "settings.general.workspace.announcement-text.description"
+ )}
+ >
<Input
value={state.text}
className="w-full"
@@ -295,10 +290,7 @@ export const AnnouncementSection = forwardRef<
</FormField>
{/* Extra link */}
- <FormField>
- <FormLabel className="text-base font-semibold">
- {t("settings.general.workspace.extra-link.self")}
- </FormLabel>
+ <FormField title={t("settings.general.workspace.extra-link.self")}>
<Input
value={state.link}
className="w-full"
@@ -313,6 +305,6 @@ export const AnnouncementSection = forwardRef<
</FormField>
</FormFieldGroup>
</PermissionGuard>
- </div>
+ </FormSection>
);
});
diff --git a/frontend/src/react/pages/settings/general/AuditLogSection.tsx b/frontend/src/react/pages/settings/general/AuditLogSection.tsx
index c5153be6a1..cb228c5073 100644
--- a/frontend/src/react/pages/settings/general/AuditLogSection.tsx
+++ b/frontend/src/react/pages/settings/general/AuditLogSection.tsx
@@ -11,7 +11,11 @@ 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 {
+ FormField,
+ FormFieldGroup,
+ FormSection,
+} 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";
@@ -76,58 +80,60 @@ export const AuditLogSection = forwardRef<SectionHandle, AuditLogSectionProps>(
}, [state, onDirtyChange]);
return (
- <div id="audit-log-stdout" className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <div className="flex items-center gap-x-2">
- <h1 className="text-2xl font-bold">{title}</h1>
+ <FormSection
+ id="audit-log-stdout"
+ title={
+ <span className="inline-flex items-center gap-x-2">
+ {title}
<FeatureBadge feature={PlanFeature.FEATURE_AUDIT_LOG} />
- </div>
- </div>
- <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ </span>
+ }
+ >
+ <FormFieldGroup>
{/* Audit log stdout toggle */}
- <label className="flex items-start gap-x-3 cursor-pointer">
- <Checkbox
- checked={state.enableAuditLogStdout}
- className="mt-1"
- disabled={!allowEdit || !hasAuditLogFeature}
- onCheckedChange={(checked) =>
- setState((s) => ({
- ...s,
- enableAuditLogStdout: checked,
- }))
- }
- />
- <div className="flex flex-col gap-1">
- <div className="text-base font-semibold">
+ <FormField
+ title={
+ <span className="flex items-start gap-x-3">
+ <Checkbox
+ checked={state.enableAuditLogStdout}
+ className="mt-1"
+ disabled={!allowEdit || !hasAuditLogFeature}
+ onCheckedChange={(checked) =>
+ setState((s) => ({
+ ...s,
+ enableAuditLogStdout: checked,
+ }))
+ }
+ />
{t("settings.general.workspace.audit-log-stdout.enable")}
- </div>
- <div className="textinfolabel">
- {t("settings.general.workspace.audit-log-stdout.description")}
- </div>
- </div>
- </label>
+ </span>
+ }
+ description={t(
+ "settings.general.workspace.audit-log-stdout.description"
+ )}
+ />
{/* Debug mode toggle */}
- <label className="flex items-start gap-x-3 cursor-pointer">
- <Checkbox
- checked={state.enableDebug}
- className="mt-1"
- disabled={!allowEdit}
- onCheckedChange={(checked) =>
- setState((s) => ({
- ...s,
- enableDebug: checked,
- }))
- }
- />
- <div className="flex flex-col gap-1">
- <div className="text-base font-semibold">
+ <FormField
+ title={
+ <span className="flex items-start gap-x-3">
+ <Checkbox
+ checked={state.enableDebug}
+ className="mt-1"
+ disabled={!allowEdit}
+ onCheckedChange={(checked) =>
+ setState((s) => ({
+ ...s,
+ enableDebug: checked,
+ }))
+ }
+ />
{t("settings.general.workspace.enable-debug.enable")}
- </div>
- </div>
- </label>
+ </span>
+ }
+ />
</FormFieldGroup>
- </div>
+ </FormSection>
);
}
);
diff --git a/frontend/src/react/pages/settings/general/BrandingSection.tsx b/frontend/src/react/pages/settings/general/BrandingSection.tsx
index c2cba6e60a..57dfe70ea6 100644
--- a/frontend/src/react/pages/settings/general/BrandingSection.tsx
+++ b/frontend/src/react/pages/settings/general/BrandingSection.tsx
@@ -16,7 +16,11 @@ import {
usePermissionCheck,
} from "@/react/components/PermissionGuard";
import { Button } from "@/react/components/ui/button";
-import { FormFieldGroup } from "@/react/components/ui/form";
+import {
+ FormField,
+ FormFieldGroup,
+ FormSection,
+} 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";
@@ -172,46 +176,37 @@ export const BrandingSection = forwardRef<SectionHandle, BrandingSectionProps>(
const uploadDisabled = !canEdit || !hasBrandingFeature;
return (
- <div id="branding" className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">{title}</h1>
- </div>
+ <FormSection id="branding" title={title}>
<PermissionGuard permissions={["bb.workspaces.update"]} display="block">
- <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <FormFieldGroup>
{/* Workspace ID */}
- <div>
- <label className="text-base font-semibold">
- {t("settings.general.workspace.id")}
- </label>
- <Input value={workspaceID} disabled className="mt-1" />
- </div>
+ <FormField title={t("settings.general.workspace.id")}>
+ <Input value={workspaceID} disabled />
+ </FormField>
{/* Workspace Title */}
- <div>
- <label className="text-base font-semibold">
- {t("settings.general.workspace.title")}
- </label>
+ <FormField title={t("settings.general.workspace.title")}>
<Input
value={localTitle}
onChange={(e) => setLocalTitle(e.target.value)}
disabled={!canEdit}
- className="mt-1"
/>
- </div>
+ </FormField>
{/* Logo */}
- <div>
- <div className="mb-4 mt-4 lg:mt-0">
- <div className="flex items-center gap-x-2 text-base font-semibold">
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
{t("settings.general.workspace.logo")}
<FeatureBadge
feature={PlanFeature.FEATURE_CUSTOM_LOGO}
clickable
/>
- </div>
- <p className="mb-3 text-sm text-gray-400">
- {t("settings.general.workspace.logo-aspect")}
- </p>
+ </span>
+ }
+ description={t("settings.general.workspace.logo-aspect")}
+ >
+ <div>
<div
className={`flex justify-center border-2 border-gray-300 border-dashed rounded-xs relative h-48 transition-all ${
dropActive ? "bg-gray-300 opacity-100" : ""
@@ -275,10 +270,10 @@ export const BrandingSection = forwardRef<SectionHandle, BrandingSectionProps>(
</Button>
</div>
)}
- </div>
+ </FormField>
</FormFieldGroup>
</PermissionGuard>
- </div>
+ </FormSection>
);
}
);
diff --git a/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts b/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts
index 2032fc88e3..3cd7d262bf 100644
--- a/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts
+++ b/frontend/src/react/pages/settings/general/GeneralPageLayout.test.ts
@@ -18,12 +18,21 @@ const configurableSections = [
] as const;
describe("GeneralPage section layout", () => {
- test("uses the shared field group wrapper for configurable section content", () => {
+ test("uses merged form section layout for configurable sections", () => {
for (const file of configurableSections) {
const source = readFileSync(join(sectionDir, file), "utf8");
+ expect(source, file).toContain("@/react/components/ui/form");
+ expect(source, file).not.toContain("@/react/components/ui/form.v2");
+ expect(source, file).toContain("FormSection");
expect(source, file).toContain("FormFieldGroup");
- expect(source, file).toContain('className="flex-1 mt-4 lg:px-4 lg:mt-0"');
+ expect(source, file).not.toContain("FormSectionHeader");
+ expect(source, file).not.toContain("FormSectionTitle");
+ expect(source, file).not.toContain("FormSectionContent");
+ expect(source, file).not.toContain(
+ 'className="flex-1 mt-4 lg:px-4 lg:mt-0"'
+ );
+ expect(source, file).not.toContain('className="py-6 lg:flex"');
}
});
@@ -34,4 +43,50 @@ describe("GeneralPage section layout", () => {
expect(source).toContain("RadioGroupItem");
expect(source).not.toContain(`type=${JSON.stringify("radio")}`);
});
+
+ test("uses merged form field props for migrated field headings", () => {
+ for (const file of configurableSections) {
+ const source = readFileSync(join(sectionDir, file), "utf8");
+
+ expect(source, file).toContain("<FormField");
+ expect(source, file).not.toContain("FormFieldHeader");
+ expect(source, file).not.toContain("FormFieldTitle");
+ expect(source, file).not.toContain("FormFieldSubtitle");
+ expect(source, file).not.toContain(
+ '<FormLabel className="text-base font-semibold">'
+ );
+ expect(source, file).not.toContain("text-base font-semibold");
+ expect(source, file).not.toContain("text-sm font-medium text-control");
+ }
+ });
+
+ test("keeps domain restriction checkbox text wired to the checkbox", () => {
+ const source = readFileSync(
+ join(sectionDir, "SecuritySection.tsx"),
+ "utf8"
+ );
+ const membersRestrictionIndex = source.indexOf(
+ "settings.general.workspace.domain-restriction.members-restriction.self"
+ );
+ const membersRestrictionBlock = source.slice(
+ Math.max(0, membersRestrictionIndex - 1400),
+ membersRestrictionIndex + 800
+ );
+
+ expect(membersRestrictionIndex).toBeGreaterThan(0);
+ expect(membersRestrictionBlock).toContain(
+ '<div className="flex items-start gap-x-2">'
+ );
+ expect(membersRestrictionBlock).toContain("<Checkbox");
+ expect(membersRestrictionBlock).toContain("aria-labelledby");
+ expect(membersRestrictionBlock).toContain("aria-describedby");
+ expect(membersRestrictionBlock).toContain("toggleDomainRestriction");
+ expect(membersRestrictionBlock).toContain(
+ "settings.general.workspace.domain-restriction.members-restriction.description"
+ );
+ expect(membersRestrictionBlock).not.toContain("<label");
+ expect(membersRestrictionBlock).not.toContain(
+ '<span className="flex items-start gap-x-2">'
+ );
+ });
});
diff --git a/frontend/src/react/pages/settings/general/GeneralSection.tsx b/frontend/src/react/pages/settings/general/GeneralSection.tsx
index 9de33452d6..0edcf686ff 100644
--- a/frontend/src/react/pages/settings/general/GeneralSection.tsx
+++ b/frontend/src/react/pages/settings/general/GeneralSection.tsx
@@ -22,10 +22,9 @@ import {
DialogTitle,
} from "@/react/components/ui/dialog";
import {
- FormDescription,
FormField,
FormFieldGroup,
- FormLabel,
+ FormSection,
} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { RadioGroup, RadioGroupItem } from "@/react/components/ui/radio-group";
@@ -130,108 +129,108 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(
};
return (
- <div className="pb-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <div className="flex items-center gap-x-2">
- <h1 className="text-2xl font-bold">{title}</h1>
- </div>
- </div>
- <PermissionGuard
- permissions={["bb.settings.setWorkspaceProfile"]}
- display="block"
- >
- <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
- {/* Database change mode */}
- <FormField>
- <div className="mb-4 text-base font-semibold">
- {t("settings.general.workspace.default-landing-page.self")}
- </div>
- <RadioGroup
- className="flex-col items-stretch gap-4"
- value={String(state.databaseChangeMode)}
- onValueChange={(value) =>
- setState((s) => ({
- ...s,
- databaseChangeMode: Number(value),
- }))
- }
+ <>
+ <FormSection title={title}>
+ <PermissionGuard
+ permissions={["bb.settings.setWorkspaceProfile"]}
+ display="block"
+ >
+ <FormFieldGroup>
+ {/* Database change mode */}
+ <FormField
+ title={t(
+ "settings.general.workspace.default-landing-page.self"
+ )}
+ className="gap-y-4"
>
- <RadioGroupItem
- value={String(DatabaseChangeMode.PIPELINE)}
- disabled={!canEdit}
- className="items-start gap-x-3"
- contentClassName="flex flex-col gap-1"
- radioClassName="mt-1"
+ <RadioGroup
+ className="flex-col items-stretch gap-4"
+ value={String(state.databaseChangeMode)}
+ onValueChange={(value) =>
+ setState((s) => ({
+ ...s,
+ databaseChangeMode: Number(value),
+ }))
+ }
>
- <div className="flex flex-col gap-1">
- <div className="textinfo font-semibold">
- {t(
- "settings.general.workspace.default-landing-page.workspace.self"
- )}
+ <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(
+ "settings.general.workspace.default-landing-page.workspace.self"
+ )}
+ </div>
+ <div className="textinfolabel">
+ {t(
+ "settings.general.workspace.default-landing-page.workspace.description"
+ )}
+ </div>
</div>
- <div className="textinfolabel">
- {t(
- "settings.general.workspace.default-landing-page.workspace.description"
- )}
+ </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(
+ "settings.general.workspace.default-landing-page.sql-editor.self"
+ )}
+ </div>
+ <div className="textinfolabel">
+ {t(
+ "settings.general.workspace.default-landing-page.sql-editor.description"
+ )}
+ </div>
</div>
- </div>
- </RadioGroupItem>
- <RadioGroupItem
- value={String(DatabaseChangeMode.EDITOR)}
- disabled={!canEdit}
- className="items-start gap-x-3"
- contentClassName="flex flex-col gap-1"
- radioClassName="mt-1"
+ </RadioGroupItem>
+ </RadioGroup>
+ </FormField>
+
+ {/* External URL — hidden in SaaS/cloud mode */}
+ {!isSaaSMode && (
+ <FormField
+ title={t("settings.general.workspace.external-url.self")}
+ description={
+ <>
+ {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 className="flex flex-col gap-1">
- <div className="textinfo font-semibold">
- {t(
- "settings.general.workspace.default-landing-page.sql-editor.self"
+ {externalUrlFromFlag && (
+ <Alert
+ variant="info"
+ description={t(
+ "settings.general.workspace.external-url.cannot-edit-flag"
)}
- </div>
- <div className="textinfolabel">
- {t(
- "settings.general.workspace.default-landing-page.sql-editor.description"
- )}
- </div>
- </div>
- </RadioGroupItem>
- </RadioGroup>
- </FormField>
-
- {/* External URL — hidden in SaaS/cloud mode */}
- {!isSaaSMode && (
- <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"
- />
- </FormDescription>
- {externalUrlFromFlag && (
- <Alert
- variant="info"
- description={t(
- "settings.general.workspace.external-url.cannot-edit-flag"
- )}
+ />
+ )}
+ <Input
+ value={state.externalUrl}
+ className="w-full"
+ disabled={!canEdit || externalUrlFromFlag}
+ onChange={(e) =>
+ setState((s) => ({ ...s, externalUrl: e.target.value }))
+ }
/>
- )}
- <Input
- value={state.externalUrl}
- className="w-full"
- disabled={!canEdit || externalUrlFromFlag}
- onChange={(e) =>
- setState((s) => ({ ...s, externalUrl: e.target.value }))
- }
- />
- </FormField>
- )}
- </FormFieldGroup>
- </PermissionGuard>
+ </FormField>
+ )}
+ </FormFieldGroup>
+ </PermissionGuard>
+ </FormSection>
{/* Modal after switching to Editor mode */}
{showModal && (
@@ -263,7 +262,7 @@ export const GeneralSection = forwardRef<SectionHandle, GeneralSectionProps>(
</DialogContent>
</Dialog>
)}
- </div>
+ </>
);
}
);
diff --git a/frontend/src/react/pages/settings/general/ProductImprovementSection.tsx b/frontend/src/react/pages/settings/general/ProductImprovementSection.tsx
index d14c640dfb..769c177edf 100644
--- a/frontend/src/react/pages/settings/general/ProductImprovementSection.tsx
+++ b/frontend/src/react/pages/settings/general/ProductImprovementSection.tsx
@@ -9,7 +9,11 @@ import {
} from "react";
import { useTranslation } from "react-i18next";
import { Checkbox } from "@/react/components/ui/checkbox";
-import { FormFieldGroup } from "@/react/components/ui/form";
+import {
+ FormField,
+ FormFieldGroup,
+ FormSection,
+} from "@/react/components/ui/form";
import { useAppStore } from "@/react/stores/app";
import type { SectionHandle } from "./useSettingSection";
@@ -68,33 +72,30 @@ export const ProductImprovementSection = forwardRef<
}, [state, onDirtyChange]);
return (
- <div id="product-improvement" className="py-6 lg:flex">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">{title}</h1>
- </div>
- <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}
- className="mt-1"
- disabled={!allowEdit}
- onCheckedChange={(checked) =>
- setState((s) => ({
- ...s,
- enableMetricCollection: checked,
- }))
- }
- />
- <div className="flex flex-col gap-1">
- <div className="text-base font-semibold">
+ <FormSection id="product-improvement" title={title}>
+ <FormFieldGroup>
+ <FormField
+ title={
+ <span className="flex items-start gap-x-3">
+ <Checkbox
+ checked={state.enableMetricCollection}
+ className="mt-1"
+ disabled={!allowEdit}
+ onCheckedChange={(checked) =>
+ setState((s) => ({
+ ...s,
+ enableMetricCollection: checked,
+ }))
+ }
+ />
{t("settings.general.workspace.product-improvement.participate")}
- </div>
- <div className="textinfolabel">
- {t("settings.general.workspace.product-improvement.description")}
- </div>
- </div>
- </label>
+ </span>
+ }
+ description={t(
+ "settings.general.workspace.product-improvement.description"
+ )}
+ />
</FormFieldGroup>
- </div>
+ </FormSection>
);
});
diff --git a/frontend/src/react/pages/settings/general/SQLEditorSection.tsx b/frontend/src/react/pages/settings/general/SQLEditorSection.tsx
index 56d86bcc16..01c48ba4de 100644
--- a/frontend/src/react/pages/settings/general/SQLEditorSection.tsx
+++ b/frontend/src/react/pages/settings/general/SQLEditorSection.tsx
@@ -34,7 +34,11 @@ 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 {
+ FormField,
+ FormFieldGroup,
+ FormSection,
+} from "@/react/components/ui/form";
import { NumberInput } from "@/react/components/ui/number-input";
import { SegmentedControl } from "@/react/components/ui/segmented-control";
import {
@@ -417,67 +421,68 @@ export const SQLEditorSection = forwardRef<
};
return (
- <div id="security" className="py-6 lg:flex gap-y-4 lg:gap-y-0">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">{title}</h1>
- </div>
- <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <FormSection id="security" title={title}>
+ <FormFieldGroup>
{/* Data Export toggle */}
<PermissionGuard permissions={["bb.policies.update"]} display="block">
- <div className="w-full inline-flex items-center gap-x-2">
- <Checkbox
- checked={!state.disableExport}
- disabled={!canUpdatePolicy || !hasQueryPolicyFeature}
- onCheckedChange={(checked) =>
- handleToggle("disableExport", !checked)
- }
- />
- <span className="text-base font-semibold">
- {t("settings.general.workspace.data-export")}
- </span>
- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
- </div>
+ <FormField
+ title={
+ <span className="w-full inline-flex items-center gap-x-2">
+ <Checkbox
+ checked={!state.disableExport}
+ disabled={!canUpdatePolicy || !hasQueryPolicyFeature}
+ onCheckedChange={(checked) =>
+ handleToggle("disableExport", !checked)
+ }
+ />
+ {t("settings.general.workspace.data-export")}
+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
+ </span>
+ }
+ />
</PermissionGuard>
{/* Data Copy toggle */}
<PermissionGuard permissions={["bb.policies.update"]} display="block">
- <div className="w-full inline-flex items-center gap-x-2">
- <Checkbox
- checked={!state.disableCopyData}
- disabled={!canUpdatePolicy || !hasRestrictCopyingDataFeature}
- onCheckedChange={(checked) =>
- handleToggle("disableCopyData", !checked)
- }
- />
- <span className="text-base font-semibold">
- {t("settings.general.workspace.data-copy")}
- </span>
- <FeatureBadge feature={PlanFeature.FEATURE_RESTRICT_COPYING_DATA} />
- </div>
+ <FormField
+ title={
+ <span className="w-full inline-flex items-center gap-x-2">
+ <Checkbox
+ checked={!state.disableCopyData}
+ disabled={!canUpdatePolicy || !hasRestrictCopyingDataFeature}
+ onCheckedChange={(checked) =>
+ handleToggle("disableCopyData", !checked)
+ }
+ />
+ {t("settings.general.workspace.data-copy")}
+ <FeatureBadge
+ feature={PlanFeature.FEATURE_RESTRICT_COPYING_DATA}
+ />
+ </span>
+ }
+ />
</PermissionGuard>
{/* Allow Admin Data Source toggle */}
<PermissionGuard permissions={["bb.policies.update"]} display="block">
- <div>
- <div className="w-full inline-flex items-center gap-x-2">
- <Checkbox
- checked={state.allowAdminDataSource}
- disabled={!canUpdatePolicy || !hasQueryPolicyFeature}
- onCheckedChange={(checked) =>
- handleToggle("allowAdminDataSource", checked)
- }
- />
- <span className="text-base font-semibold">
+ <FormField
+ title={
+ <span className="w-full inline-flex items-center gap-x-2">
+ <Checkbox
+ checked={state.allowAdminDataSource}
+ disabled={!canUpdatePolicy || !hasQueryPolicyFeature}
+ onCheckedChange={(checked) =>
+ handleToggle("allowAdminDataSource", checked)
+ }
+ />
{t("settings.general.workspace.allow-admin-data-source.self")}
+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
</span>
- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
- </div>
- <span className="mt-1 text-sm text-gray-400">
- {t(
- "settings.general.workspace.allow-admin-data-source.description"
- )}
- </span>
- </div>
+ }
+ description={t(
+ "settings.general.workspace.allow-admin-data-source.description"
+ )}
+ />
</PermissionGuard>
{/* Maximum SQL Result Size (MB) */}
@@ -486,25 +491,28 @@ export const SQLEditorSection = forwardRef<
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <div>
- <p className="text-base font-semibold flex flex-row justify-start items-center">
- <span className="mr-2">
+ <FormField
+ title={
+ <span className="flex flex-row justify-start items-center gap-x-2">
{t("settings.general.workspace.maximum-sql-result.size.self")}
+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
</span>
- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
- </p>
- <p className="text-sm text-gray-400 mt-1">
- {t(
- "settings.general.workspace.maximum-sql-result.size.description"
- )}{" "}
- <span className="font-semibold! textinfolabel">
+ }
+ description={
+ <>
{t(
- "settings.general.workspace.maximum-sql-result.size.default",
- { limit: DEFAULT_MAX_RESULT_SIZE_IN_MB }
- )}
- </span>
- </p>
- <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">
+ "settings.general.workspace.maximum-sql-result.size.description"
+ )}{" "}
+ <span className="font-semibold! textinfolabel">
+ {t(
+ "settings.general.workspace.maximum-sql-result.size.default",
+ { limit: DEFAULT_MAX_RESULT_SIZE_IN_MB }
+ )}
+ </span>
+ </>
+ }
+ >
+ <div className="w-full flex flex-row justify-start items-center gap-4">
<NumberInput
className="w-60"
value={state.maximumResultSize}
@@ -516,28 +524,31 @@ export const SQLEditorSection = forwardRef<
suffix="MB"
/>
</div>
- </div>
+ </FormField>
</PermissionGuard>
)}
{/* Maximum SQL Result Rows */}
<PermissionGuard permissions={["bb.policies.update"]} display="block">
- <div>
- <p className="text-base font-semibold flex flex-row justify-start items-center">
- <span className="mr-2">
+ <FormField
+ title={
+ <span className="flex flex-row justify-start items-center gap-x-2">
{t("settings.general.workspace.maximum-sql-result.rows.self")}
+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
</span>
- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
- </p>
- <p className="text-sm text-gray-400 mt-1">
- {t(
- "settings.general.workspace.maximum-sql-result.rows.description"
- )}{" "}
- <span className="font-semibold! textinfolabel">
- {t("settings.general.workspace.no-limit")}
- </span>
- </p>
- <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">
+ }
+ description={
+ <>
+ {t(
+ "settings.general.workspace.maximum-sql-result.rows.description"
+ )}{" "}
+ <span className="font-semibold! textinfolabel">
+ {t("settings.general.workspace.no-limit")}
+ </span>
+ </>
+ }
+ >
+ <div className="w-full flex flex-row justify-start items-center gap-4">
<NumberInput
className="w-60"
value={state.maximumResultRows}
@@ -550,7 +561,7 @@ export const SQLEditorSection = forwardRef<
)}
/>
</div>
- </div>
+ </FormField>
</PermissionGuard>
{/* Query Timeout (seconds) */}
@@ -558,22 +569,25 @@ export const SQLEditorSection = forwardRef<
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <div>
- <p className="text-base font-semibold flex flex-row justify-start items-center">
- <span className="mr-2">
+ <FormField
+ title={
+ <span className="flex flex-row justify-start items-center gap-x-2">
{t("settings.general.workspace.query-data-policy.timeout.self")}
+ <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
</span>
- <FeatureBadge feature={PlanFeature.FEATURE_QUERY_POLICY} />
- </p>
- <p className="text-sm text-gray-400 mt-1">
- {t(
- "settings.general.workspace.query-data-policy.timeout.description"
- )}{" "}
- <span className="font-semibold! textinfolabel">
- {t("settings.general.workspace.no-limit")}
- </span>
- </p>
- <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">
+ }
+ description={
+ <>
+ {t(
+ "settings.general.workspace.query-data-policy.timeout.description"
+ )}{" "}
+ <span className="font-semibold! textinfolabel">
+ {t("settings.general.workspace.no-limit")}
+ </span>
+ </>
+ }
+ >
+ <div className="w-full flex flex-row justify-start items-center gap-4">
<NumberInput
className="w-60"
value={state.maxQueryTimeInSeconds}
@@ -588,7 +602,7 @@ export const SQLEditorSection = forwardRef<
)}
/>
</div>
- </div>
+ </FormField>
</PermissionGuard>
{/* SQL Editor theme — dev-only until the feature ships. */}
@@ -596,16 +610,12 @@ export const SQLEditorSection = forwardRef<
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <div className="flex flex-col gap-y-3">
- <div>
- <p className="text-base font-semibold">
- {t("settings.general.workspace.sql-editor-theme.self")}
- </p>
- <p className="text-sm text-gray-400 mt-1">
- {t("settings.general.workspace.sql-editor-theme.description")}
- </p>
- </div>
-
+ <FormField
+ title={t("settings.general.workspace.sql-editor-theme.self")}
+ description={t(
+ "settings.general.workspace.sql-editor-theme.description"
+ )}
+ >
<SegmentedControl
ariaLabel={t("settings.general.workspace.sql-editor-theme.self")}
disabled={!canSetWorkspaceProfile}
@@ -636,15 +646,12 @@ export const SQLEditorSection = forwardRef<
/>
)}
- <div className="flex flex-col gap-y-2">
- <p className="text-sm font-medium text-control">
- {t("common.preview")}
- </p>
+ <FormField title={t("common.preview")}>
<ThemePreview theme={previewTheme} />
- </div>
- </div>
+ </FormField>
+ </FormField>
</PermissionGuard>
</FormFieldGroup>
- </div>
+ </FormSection>
);
});
diff --git a/frontend/src/react/pages/settings/general/SecuritySection.tsx b/frontend/src/react/pages/settings/general/SecuritySection.tsx
index 1d0f7552b8..4b4ca30350 100644
--- a/frontend/src/react/pages/settings/general/SecuritySection.tsx
+++ b/frontend/src/react/pages/settings/general/SecuritySection.tsx
@@ -7,6 +7,7 @@ import {
type KeyboardEvent,
useCallback,
useEffect,
+ useId,
useImperativeHandle,
useState,
} from "react";
@@ -17,7 +18,11 @@ import {
usePermissionCheck,
} from "@/react/components/PermissionGuard";
import { Checkbox } from "@/react/components/ui/checkbox";
-import { FormFieldGroup } from "@/react/components/ui/form";
+import {
+ FormField,
+ FormFieldGroup,
+ FormSection,
+} from "@/react/components/ui/form";
import { Input } from "@/react/components/ui/input";
import { usePlanFeature } from "@/react/hooks/useAppState";
import { useAppStore } from "@/react/stores/app";
@@ -87,6 +92,10 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(
const [domainInput, setDomainInput] = useState("");
const validDomains = state.domains.filter((d) => !!d);
+ const canToggleDomainRestriction =
+ canEdit && validDomains.length > 0 && hasDomainRestrictionFeature;
+ const membersRestrictionLabelId = useId();
+ const membersRestrictionDescriptionId = useId();
const isDirty = useCallback(() => {
if (domainInput.trim()) return true;
@@ -196,6 +205,22 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(
}
};
+ const toggleDomainRestriction = () => {
+ if (!canToggleDomainRestriction) return;
+ setState((prev) => ({
+ ...prev,
+ enableRestriction: !prev.enableRestriction,
+ }));
+ };
+
+ const handleDomainRestrictionTextKeyDown = (
+ e: KeyboardEvent<HTMLDivElement>
+ ) => {
+ if (e.key !== "Enter" && e.key !== " ") return;
+ e.preventDefault();
+ toggleDomainRestriction();
+ };
+
const removeDomain = (index: number) => {
setState((prev) => {
const newDomains = prev.domains.filter((_, i) => i !== index);
@@ -210,53 +235,45 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(
};
return (
- <div id="security" className="py-6 lg:flex gap-y-4 lg:gap-y-0">
- <div className="text-left lg:w-1/4">
- <h1 className="text-2xl font-bold">{title}</h1>
- </div>
+ <FormSection id="security" title={title}>
<PermissionGuard
permissions={["bb.settings.setWorkspaceProfile"]}
display="block"
>
- <FormFieldGroup className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <FormFieldGroup>
{/* Watermark */}
- <div>
- <div className="flex items-center gap-x-2">
- <Checkbox
- checked={state.enableWatermark}
- disabled={!canEdit || !hasWatermarkFeature}
- onCheckedChange={(checked) =>
- setState((prev) => ({
- ...prev,
- enableWatermark: checked,
- }))
- }
- />
- <span className="text-base font-semibold">
+ <FormField
+ title={
+ <span className="flex items-center gap-x-2">
+ <Checkbox
+ checked={state.enableWatermark}
+ disabled={!canEdit || !hasWatermarkFeature}
+ onCheckedChange={(checked) =>
+ setState((prev) => ({
+ ...prev,
+ enableWatermark: checked,
+ }))
+ }
+ />
{t("settings.general.workspace.watermark.enable")}
+ <FeatureBadge feature={PlanFeature.FEATURE_WATERMARK} />
</span>
- <FeatureBadge feature={PlanFeature.FEATURE_WATERMARK} />
- </div>
- <div className="mt-1 text-sm text-gray-400">
- {t("settings.general.workspace.watermark.description")}
- </div>
- </div>
+ }
+ description={t(
+ "settings.general.workspace.watermark.description"
+ )}
+ />
{/* Maximum Role Expiration */}
- <div>
- <p className="text-base font-semibold flex flex-row justify-start items-center">
- <span className="mr-2">
- {t(
- "settings.general.workspace.maximum-request-expiration.self"
- )}
- </span>
- </p>
- <p className="text-sm text-gray-400 mt-1">
- {t(
- "settings.general.workspace.maximum-request-expiration.description"
- )}
- </p>
- <div className="mt-3 w-full flex flex-row">
+ <FormField
+ title={t(
+ "settings.general.workspace.maximum-request-expiration.self"
+ )}
+ description={t(
+ "settings.general.workspace.maximum-request-expiration.description"
+ )}
+ >
+ <div className="w-full flex flex-row">
<div className="flex items-center gap-4">
<div className="relative w-60">
<Input
@@ -301,22 +318,17 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(
</label>
</div>
</div>
- </div>
+ </FormField>
{/* Domain Restriction */}
- <div>
- <h3
- id="domain-restriction"
- className="text-base font-semibold flex flex-row justify-start items-center"
- >
- <span className="mr-2">
- {t("settings.general.workspace.domain-restriction.self")}
- </span>
- </h3>
- <p className="text-sm text-gray-400 mt-1">
- {t("settings.general.workspace.domain-restriction.description")}
- </p>
- <div className="w-full flex flex-col gap-2 mt-2">
+ <FormField
+ id="domain-restriction"
+ title={t("settings.general.workspace.domain-restriction.self")}
+ description={t(
+ "settings.general.workspace.domain-restriction.description"
+ )}
+ >
+ <div className="w-full flex flex-col gap-2">
{/* Domain tags + input */}
<div className="flex flex-wrap items-center gap-2">
<Input
@@ -351,46 +363,60 @@ export const SecuritySection = forwardRef<SectionHandle, SecuritySectionProps>(
{/* Enforce restriction checkbox */}
<div className="w-full flex flex-row justify-between items-center">
- <label className="flex items-start gap-x-2">
- <Checkbox
- checked={state.enableRestriction}
- className="mt-1"
- disabled={
- !canEdit ||
- validDomains.length === 0 ||
- !hasDomainRestrictionFeature
- }
- onCheckedChange={(checked) =>
- setState((prev) => ({
- ...prev,
- enableRestriction: checked,
- }))
- }
- />
- <div>
- <div className="text-base font-semibold flex items-center gap-x-2">
- {t(
- "settings.general.workspace.domain-restriction.members-restriction.self"
- )}
- <FeatureBadge
- feature={
- PlanFeature.FEATURE_USER_EMAIL_DOMAIN_RESTRICTION
+ <FormField
+ title={
+ <div className="flex items-start gap-x-2">
+ <Checkbox
+ aria-describedby={membersRestrictionDescriptionId}
+ aria-labelledby={membersRestrictionLabelId}
+ checked={state.enableRestriction}
+ className="mt-1"
+ disabled={!canToggleDomainRestriction}
+ onCheckedChange={(checked) =>
+ setState((prev) => ({
+ ...prev,
+ enableRestriction: checked,
+ }))
}
/>
+ <div
+ className="flex flex-col gap-y-0"
+ role="button"
+ tabIndex={canToggleDomainRestriction ? 0 : -1}
+ onClick={toggleDomainRestriction}
+ onKeyDown={handleDomainRestrictionTextKeyDown}
+ >
+ <span
+ id={membersRestrictionLabelId}
+ className="flex items-center gap-x-2"
+ >
+ {t(
+ "settings.general.workspace.domain-restriction.members-restriction.self"
+ )}
+ <FeatureBadge
+ feature={
+ PlanFeature.FEATURE_USER_EMAIL_DOMAIN_RESTRICTION
+ }
+ />
+ </span>
+ <span
+ id={membersRestrictionDescriptionId}
+ className="block text-sm font-normal text-control-placeholder"
+ >
+ {t(
+ "settings.general.workspace.domain-restriction.members-restriction.description"
+ )}
+ </span>
+ </div>
</div>
- <p className="text-sm text-gray-400 leading-tight">
- {t(
- "settings.general.workspace.domain-restriction.members-restriction.description"
- )}
- </p>
- </div>
- </label>
+ }
+ />
</div>
</div>
- </div>
+ </FormField>
</FormFieldGroup>
</PermissionGuard>
- </div>
+ </FormSection>
);
}
);