Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
refactor: ux consistency (#21056)
ecmadao28583c6f5af5
diff --git a/frontend/src/components/BytebaseLogo.tsx b/frontend/src/components/BytebaseLogo.tsxindex aecfc31606..b46a8c7b6b 100644--- a/frontend/src/components/BytebaseLogo.tsx+++ b/frontend/src/components/BytebaseLogo.tsx@@ -31,7 +31,12 @@ export function BytebaseLogo({const builtinLogo = builtinTheme === "dark" ? logoFullDark : logoFull;const content = (- <span className="h-full w-full select-none flex flex-row justify-center items-center">+ <span+ className={cn(+ "h-full w-full select-none flex flex-row justify-center items-center",+ customLogo ? "" : "px-1 py-0.5"+ )}+ >{customLogo ? (<imgsrc={customLogo}diff --git a/frontend/src/components/DatabaseGroupForm.test.tsx b/frontend/src/components/DatabaseGroupForm.test.tsxnew file mode 100644index 0000000000..0683c2bd7d--- /dev/null+++ b/frontend/src/components/DatabaseGroupForm.test.tsx@@ -0,0 +1,118 @@+import type { ReactElement } from "react";+import { act } from "react";+import { createRoot } from "react-dom/client";+import { beforeEach, describe, expect, test, vi } from "vitest";+import type { Project } from "@/types/proto-es/v1/project_service_pb";++(+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+).IS_REACT_ACT_ENVIRONMENT = true;++vi.mock("react-i18next", () => ({+ initReactI18next: { type: "3rdParty", init: () => {} },+ useTranslation: () => ({ t: (key: string) => key }),+}));++vi.mock("@/components/ExprEditor", () => ({+ ExprEditor: () => <div data-testid="expr-editor" />,+}));++vi.mock("@/components/MatchedDatabaseView", () => ({+ MatchedDatabaseView: () => <div data-testid="matched-database-view" />,+}));++vi.mock("@/components/ResourceIdField", () => ({+ ResourceIdField: () => <div data-testid="resource-id-field" />,+}));++vi.mock("@/stores", () => ({+ pushNotification: vi.fn(),+}));++vi.mock("@/stores/app", () => ({+ useAppStore: {+ getState: () => ({+ createDatabaseGroup: vi.fn(),+ getOrFetchDBGroupByName: vi.fn(),+ updateDatabaseGroup: vi.fn(),+ }),+ },+}));++let DatabaseGroupForm: typeof import("./DatabaseGroupForm").DatabaseGroupForm;++const renderIntoContainer = (element: ReactElement) => {+ const container = document.createElement("div");+ const root = createRoot(container);++ return {+ container,+ render: () =>+ act(() => {+ root.render(element);+ }),+ unmount: () =>+ act(() => {+ root.unmount();+ }),+ };+};++beforeEach(async () => {+ ({ DatabaseGroupForm } = await import("./DatabaseGroupForm"));+});++describe("DatabaseGroupForm", () => {+ test("keeps condition editor and database preview close on wide screens", () => {+ const { container, render, unmount } = renderIntoContainer(+ <DatabaseGroupForm+ readonly={false}+ project={{ name: "projects/sample" } as Project}+ onDismiss={vi.fn()}+ />+ );++ render();++ const exprEditor = container.querySelector('[data-testid="expr-editor"]');+ const databasePreview = container.querySelector(+ '[data-testid="matched-database-view"]'+ );+ expect(exprEditor).toBeTruthy();+ expect(databasePreview).toBeTruthy();++ const conditionColumn = exprEditor?.parentElement;+ const databaseColumn = databasePreview?.parentElement;+ const layout = conditionColumn?.parentElement;+ expect(layout?.className).toContain("xl:flex-row");+ expect(layout?.className).toContain("xl:gap-x-8");+ expect(conditionColumn?.className).toContain("xl:w-fit");+ expect(databaseColumn?.className).toContain("xl:w-[28rem]");++ unmount();+ });++ test("aligns form content and sticky footer to its parent", () => {+ const { container, render, unmount } = renderIntoContainer(+ <DatabaseGroupForm+ readonly={false}+ project={{ name: "projects/sample" } as Project}+ onDismiss={vi.fn()}+ />+ );++ render();++ const exprEditor = container.querySelector('[data-testid="expr-editor"]');+ const content = exprEditor?.closest(".flex-1.mb-6");+ expect(content?.className).not.toContain("px-4");++ const footerContent = container.querySelector(+ '[data-slot="sticky-action-footer-content"]'+ );+ expect(footerContent?.className).not.toContain("px-4");+ expect(footerContent?.className).not.toContain("sm:px-6");++ unmount();+ });+});diff --git a/frontend/src/components/DatabaseGroupForm.tsx b/frontend/src/components/DatabaseGroupForm.tsxindex bae4887869..3986136af0 100644--- a/frontend/src/components/DatabaseGroupForm.tsx+++ b/frontend/src/components/DatabaseGroupForm.tsx@@ -198,7 +198,7 @@ export function DatabaseGroupForm({return (<div className={`flex-1 flex flex-col ${className ?? ""}`}>- <div className="flex-1 mb-6 px-4">+ <div className="flex-1 mb-6"><div className="w-full"><p className="font-medium text-main mb-2">{t("common.name")}</p><Input@@ -223,8 +223,8 @@ export function DatabaseGroupForm({<hr className="my-6" />- <div className="w-full grid grid-cols-5 gap-x-6">- <div className="col-span-3">+ <div className="flex w-full flex-col gap-y-6 xl:flex-row xl:items-start xl:gap-x-8">+ <div className="max-w-full xl:w-fit"><p className="pl-1 font-medium text-main mb-2">{t("database-group.condition.self")}</p>@@ -236,7 +236,7 @@ export function DatabaseGroupForm({onUpdate={setExpr}/></div>- <div className="col-span-2">+ <div className="w-full xl:w-[28rem]"><MatchedDatabaseViewproject={project.name}expr={expr}@@ -248,7 +248,7 @@ export function DatabaseGroupForm({{!readonly && (<StickyActionFooter- className="pt-4 pb-2"+ contentPadding={false}left={<Button appearance="outline" onClick={onDismiss}>{t("common.cancel")}diff --git a/frontend/src/components/instance/InfoPanel.i18n.test.tsx b/frontend/src/components/instance/InfoPanel.i18n.test.tsxindex f4982e79cd..b81f56740e 100644--- a/frontend/src/components/instance/InfoPanel.i18n.test.tsx+++ b/frontend/src/components/instance/InfoPanel.i18n.test.tsx@@ -140,4 +140,19 @@ describe("InfoPanel i18n", () => {unmount();});++ test("renders sync database guidance from locale keys", async () => {+ const { InfoPanelContent } = await import("./InfoPanel");+ const { container, render, unmount } = renderIntoContainer(+ <InfoPanelContent engine={Engine.POSTGRES} section="sync-databases" />+ );++ render();++ expect(container.querySelector("p")?.textContent).toBe(+ "instance.info.sync-databases.content"+ );++ unmount();+ });});diff --git a/frontend/src/components/instance/InfoPanel.tsx b/frontend/src/components/instance/InfoPanel.tsxindex 29f6123191..40a2dc37c6 100644--- a/frontend/src/components/instance/InfoPanel.tsx+++ b/frontend/src/components/instance/InfoPanel.tsx@@ -212,6 +212,8 @@ function getSnippetContentTranslation(return t("instance.info.postgresql.ssh.content");case "instance.info.postgresql.ssl.content":return t("instance.info.postgresql.ssl.content");+ case "instance.info.sync-databases.content":+ return t("instance.info.sync-databases.content");}const exhaustive: never = key;return exhaustive;diff --git a/frontend/src/components/instance/InstanceFormBody.test.ts b/frontend/src/components/instance/InstanceFormBody.test.tsindex f94664487c..c0885f737e 100644--- a/frontend/src/components/instance/InstanceFormBody.test.ts+++ b/frontend/src/components/instance/InstanceFormBody.test.ts@@ -59,7 +59,8 @@ describe("InstanceFormBody", () => {expect(source).not.toContain("instance.sync-databases.project-self");expect(source).not.toContain("showLabel && !hasProjectContext");- expect(source).toContain("title={showLabel");+ expect(source).toContain("title=");+ expect(source).toContain("showLabel ? (");expect(source).toContain("instance.sync-databases.description");expect(source).toContain('t("instance.sync-databases.self")');expect(source).toContain("instance.sync-databases.project-description");@@ -76,6 +77,33 @@ describe("InstanceFormBody", () => {expect(source).toContain('rel="noopener noreferrer"');});+ test("offers sync-all database details from the create instance form", () => {+ const source = readFileSync(+ join(process.cwd(), "src/components/instance/InstanceFormBody.tsx"),+ "utf-8"+ );+ const titleIndex = source.indexOf('t("instance.sync-databases.self")');+ const infoTriggerIndex = source.indexOf(+ 'onOpenInfoPanel("sync-databases")'+ );+ const descriptionIndex = source.indexOf(+ 't("instance.sync-databases.description")'+ );+ const checkboxIndex = source.indexOf("<Checkbox", descriptionIndex);++ expect(source).toContain(+ "onOpenInfoPanel?: (section: InfoSection) => void"+ );+ expect(source).toContain("onOpenInfoPanel={onOpenInfoPanel}");+ expect(source).toContain(+ 'className="inline-flex size-4 shrink-0 items-center justify-center text-accent leading-none"'+ );+ expect(source).toContain('<Info className="size-3.5" />');+ expect(infoTriggerIndex).toBeGreaterThan(titleIndex);+ expect(infoTriggerIndex).toBeLessThan(descriptionIndex);+ expect(infoTriggerIndex).toBeLessThan(checkboxIndex);+ });+test("lets users load more database sync options", () => {const source = readFileSync(join(process.cwd(), "src/components/instance/InstanceFormBody.tsx"),diff --git a/frontend/src/components/instance/InstanceFormBody.tsx b/frontend/src/components/instance/InstanceFormBody.tsxindex 31f63b2192..95a8f7f28e 100644--- a/frontend/src/components/instance/InstanceFormBody.tsx+++ b/frontend/src/components/instance/InstanceFormBody.tsx@@ -478,6 +478,7 @@ function SyncDatabases({showLabel,allowEdit,projectName,+ onOpenInfoPanel,syncDatabases,onSyncDatabasesChange,}: {@@ -485,6 +486,7 @@ function SyncDatabases({showLabel: boolean;allowEdit: boolean;projectName?: string;+ onOpenInfoPanel?: (section: InfoSection) => void;syncDatabases?: SyncDatabasesMessage;onSyncDatabasesChange: (databases: string[], syncAll: boolean) => void;}) {@@ -601,7 +603,22 @@ function SyncDatabases({return (<FormFieldclassName="sm:col-span-4 sm:col-start-1"- title={showLabel ? t("instance.sync-databases.self") : undefined}+ title={+ showLabel ? (+ <span className="flex items-center gap-x-1">+ {t("instance.sync-databases.self")}+ {onOpenInfoPanel && (+ <button+ type="button"+ className="inline-flex size-4 shrink-0 items-center justify-center text-accent leading-none"+ onClick={() => onOpenInfoPanel("sync-databases")}+ >+ <Info className="size-3.5" />+ </button>+ )}+ </span>+ ) : undefined+ }description={showLabel ? t("instance.sync-databases.description") : undefined}@@ -1775,6 +1792,7 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {isCreating ? allowEdit && !!allowCreate : allowEdit}projectName={routeProjectName}+ onOpenInfoPanel={onOpenInfoPanel}syncDatabases={basicInfo.syncDatabases}onSyncDatabasesChange={handleChangeSyncDatabases}/>diff --git a/frontend/src/components/instance/InstanceFormButtons.test.tsx b/frontend/src/components/instance/InstanceFormButtons.test.tsxindex c2a467afe7..fd96e3867a 100644--- a/frontend/src/components/instance/InstanceFormButtons.test.tsx+++ b/frontend/src/components/instance/InstanceFormButtons.test.tsx@@ -416,7 +416,11 @@ describe("InstanceFormButtons", () => {expect(mocks.routerPush).toHaveBeenCalledWith({name: "workspace.instance.detail",params: { instanceId: "prod" },- query: { syncingInstance: "prod" },+ query: {+ syncingInstance: "prod",+ intro: "prepare-database",+ tip: "transfer-databases-to-project",+ },hash: "databases",});diff --git a/frontend/src/components/instance/InstanceFormButtons.tsx b/frontend/src/components/instance/InstanceFormButtons.tsxindex 0b6982b849..2da0ac2402 100644--- a/frontend/src/components/instance/InstanceFormButtons.tsx+++ b/frontend/src/components/instance/InstanceFormButtons.tsx@@ -10,10 +10,12 @@ import {PROJECT_V1_ROUTE_DATABASES,} from "@/app/router/handles";import {+ PREPARE_DATABASE_PRODUCT_INTRO,+ PREPARE_DATABASE_TRANSFER_TIP,PRODUCT_INTRO_QUERY_KEY,+ PRODUCT_INTRO_TIP_QUERY_KEY,PROJECT_INSTANCE_SYNCED_PRODUCT_INTRO,} from "@/lib/productIntro";-import { cn } from "@/lib/utils";import { pushNotification } from "@/stores";import { useAppStore } from "@/stores/app";import { projectNamePrefix } from "@/stores/modules/v1/common";@@ -283,7 +285,11 @@ export function InstanceFormButtons({router.push({name: INSTANCE_ROUTE_DETAIL,params: { instanceId },- query: { syncingInstance: instanceId },+ query: {+ syncingInstance: instanceId,+ [PRODUCT_INTRO_QUERY_KEY]: PREPARE_DATABASE_PRODUCT_INTRO,+ [PRODUCT_INTRO_TIP_QUERY_KEY]: PREPARE_DATABASE_TRANSFER_TIP,+ },hash: "databases",});}@@ -626,7 +632,7 @@ export function InstanceFormButtons({<>{connectionFailureDialog}<StickyActionFooter- className={cn("mt-4", className)}+ className={className}left={<Buttonappearance="outline"diff --git a/frontend/src/components/instance/info-content.ts b/frontend/src/components/instance/info-content.tsindex 4b93e8ad6c..d5daa19b4f 100644--- a/frontend/src/components/instance/info-content.ts+++ b/frontend/src/components/instance/info-content.ts@@ -7,7 +7,8 @@ export type InfoSection =| "authentication"| "ssl"| "ssh"- | "database";+ | "database"+ | "sync-databases";export type InfoSnippetContentKey =| "instance.info.mongodb.authentication.content"@@ -21,7 +22,8 @@ export type InfoSnippetContentKey =| "instance.info.postgresql.authentication.content"| "instance.info.postgresql.host.content"| "instance.info.postgresql.ssh.content"- | "instance.info.postgresql.ssl.content";+ | "instance.info.postgresql.ssl.content"+ | "instance.info.sync-databases.content";export type InfoSnippetLinkTitleKey =| "instance.info.configure-database-user.link"@@ -209,11 +211,17 @@ const engineContentMap: Partial<[Engine.MONGODB]: mongodbContent,};+const sharedContent: Partial<Record<InfoSection, InfoSnippet>> = {+ "sync-databases": {+ contentKey: "instance.info.sync-databases.content",+ },+};+export const getInfoContent = (engine: Engine,section: InfoSection): InfoSnippet | undefined => {- return engineContentMap[engine]?.[section];+ return engineContentMap[engine]?.[section] ?? sharedContent[section];};export const hasInfoContent = (engine: Engine, section: InfoSection): boolean =>diff --git a/frontend/src/components/sql-review/ResourceLink.test.tsx b/frontend/src/components/sql-review/ResourceLink.test.tsxindex 32389343d3..6fe470bb96 100644--- a/frontend/src/components/sql-review/ResourceLink.test.tsx+++ b/frontend/src/components/sql-review/ResourceLink.test.tsx@@ -88,6 +88,7 @@ beforeEach(async () => {mocks.useEnvironment.mockReturnValue({name: "environments/prod",title: "Prod",+ color: "#123456",tags: { protected: "protected" },});mocks.usePlanFeature.mockReturnValue(true);@@ -114,6 +115,13 @@ describe("ResourceLink", () => {expect(links[0].className).toContain("normal-link");expect(links[0].textContent).toContain("Prod");expect(links[0].querySelector("svg")).toBeTruthy();+ const environmentBadge = links[0].querySelector<HTMLElement>(+ "span[style]"+ );+ expect(environmentBadge?.style.backgroundColor).toBe(+ "rgba(18, 52, 86, 0.1)"+ );+ expect(environmentBadge?.style.color).toBe("rgb(18, 52, 86)");expect(links[1].className).toContain("normal-link");expect(links[1].textContent).toContain("Sample project");@@ -134,6 +142,26 @@ describe("ResourceLink", () => {unmount();});+ test("keeps resource type labels outside resource anchors", () => {+ const { container, render, unmount } = renderIntoContainer(+ <div>+ <ResourceLink resource="environments/prod" />+ <ResourceLink resource="projects/sample" />+ </div>+ );++ render();++ const links = [...container.querySelectorAll("a")];+ expect(links).toHaveLength(2);+ expect(links[0].textContent).toBe("Prod");+ expect(links[1].textContent).toBe("Sample project");+ expect(container.textContent).toContain("common.environment:");+ expect(container.textContent).toContain("common.project:");++ unmount();+ });+test("passes through link attributes for inline project links", () => {const { container, render, unmount } = renderIntoContainer(<ResourceLinkdiff --git a/frontend/src/components/sql-review/ResourceLink.tsx b/frontend/src/components/sql-review/ResourceLink.tsxindex 5ce2626011..9e8b21dadc 100644--- a/frontend/src/components/sql-review/ResourceLink.tsx+++ b/frontend/src/components/sql-review/ResourceLink.tsx@@ -1,14 +1,12 @@-import { ShieldAlert } from "lucide-react";import { useTranslation } from "react-i18next";+import { EnvironmentLabel } from "@/components/EnvironmentLabel";import { ProjectLabel } from "@/components/ProjectLabel";import { RouterLink, type RouterLinkProps } from "@/components/RouterLink";-import { useEnvironment, usePlanFeature } from "@/hooks/useAppState";import { cn } from "@/lib/utils";import {environmentNamePrefix,projectNamePrefix,} from "@/stores/modules/v1/common";-import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";type ResourceLinkAnchorProps = Pick<RouterLinkProps,@@ -23,16 +21,51 @@ export function ResourceLink({resource: string;showResourceType?: boolean;} & ResourceLinkAnchorProps) {+ const { t } = useTranslation();+if (resource.startsWith(environmentNamePrefix)) {- return (- <EnvironmentResourceLink- resource={resource}- showResourceType={showResourceType}+ const environmentLink = (+ <RouterLink{...linkProps}- />+ to={{ path: `/${resource}` }}+ className={cn(+ "inline-flex items-center gap-x-1 normal-link",+ linkProps.className+ )}+ >+ <EnvironmentLabel environmentName={resource} />+ </RouterLink>);++ if (showResourceType) {+ return (+ <span className="inline-flex min-w-0 max-w-full items-center gap-x-1">+ <span className="text-control-light text-xs">+ {t("common.environment")}:+ </span>+ {environmentLink}+ </span>+ );+ }+ return environmentLink;}+if (resource.startsWith(projectNamePrefix)) {+ if (showResourceType) {+ return (+ <span className="inline-flex min-w-0 max-w-full items-center gap-x-1">+ <span className="text-control-light text-xs">+ {t("common.project")}:+ </span>+ <ProjectLabel+ projectName={resource}+ link={true}+ showResourceType={false}+ {...linkProps}+ />+ </span>+ );+ }return (<ProjectLabelprojectName={resource}@@ -44,37 +77,3 @@ export function ResourceLink({}return <span className={linkProps.className}>{resource}</span>;}--function EnvironmentResourceLink({- resource,- showResourceType,- className,- ...linkProps-}: {- resource: string;- showResourceType: boolean;-} & ResourceLinkAnchorProps) {- const { t } = useTranslation();- const environment = useEnvironment(resource);- const hasEnvTierFeature = usePlanFeature(- PlanFeature.FEATURE_ENVIRONMENT_TIERS- );- const isProtected =- hasEnvTierFeature && environment.tags?.protected === "protected";-- return (- <RouterLink- {...linkProps}- to={{ path: `/${resource}` }}- className={cn("inline-flex items-center gap-x-1 normal-link", className)}- >- {showResourceType && (- <span className="text-control-light text-xs mr-0.5">- {t("common.environment")}:- </span>- )}- <span>{environment.title || resource}</span>- {isProtected && <ShieldAlert className="w-3.5 h-3.5 shrink-0" />}- </RouterLink>- );-}diff --git a/frontend/src/components/sql-review/ReviewCreation.test.tsx b/frontend/src/components/sql-review/ReviewCreation.test.tsxindex 265ba2581b..f7a4179fff 100644--- a/frontend/src/components/sql-review/ReviewCreation.test.tsx+++ b/frontend/src/components/sql-review/ReviewCreation.test.tsx@@ -202,6 +202,32 @@ const validMySQLRule: RuleTemplateV2 = {};describe("ReviewCreation", () => {+ test("uses shared form fields for basic information", () => {+ const { container, render, unmount } = renderIntoContainer(+ <ReviewCreation selectedRuleList={[]} selectedResources={[]} />+ );++ render();++ expect(+ container.querySelector('[data-slot="form-field-group"]')+ ).toBeTruthy();+ const formField = container.querySelector('[data-slot="form-field"]');+ expect(formField).toBeTruthy();+ expect(formField?.querySelector('[aria-label="resource-id"]')).toBeTruthy();+ expect(formField?.textContent).toContain(+ "sql-review.create.basic-info.display-name"+ );+ expect(formField?.textContent).toContain(+ "sql-review.create.basic-info.display-name-label"+ );+ expect(+ container.querySelector('[data-testid="template-selector"]')+ ).toBeTruthy();++ unmount();+ });+test("starts from scratch with an empty rule list in create mode", () => {const { container, render, unmount } = renderIntoContainer(<ReviewCreation selectedRuleList={[]} selectedResources={[]} />diff --git a/frontend/src/components/sql-review/ReviewCreation.tsx b/frontend/src/components/sql-review/ReviewCreation.tsxindex bbd869cb08..4595cc2ca4 100644--- a/frontend/src/components/sql-review/ReviewCreation.tsx+++ b/frontend/src/components/sql-review/ReviewCreation.tsx@@ -11,7 +11,9 @@ import {} from "@/app/router/handles";import { ResourceIdField } from "@/components/ResourceIdField";import { Button } from "@/components/ui/button";+import { FormField, FormFieldGroup } from "@/components/ui/form";import { Input } from "@/components/ui/input";+import { StepIndicator } from "@/components/ui/step-indicator";import { StickyActionFooter } from "@/components/ui/sticky-action-footer";import { useUnsavedChangesGuard } from "@/hooks/useUnsavedChangesGuard";import {@@ -342,80 +344,57 @@ export function ReviewCreation({[store, t]);- // --- Step indicators ----const steps = [- { label: t("sql-review.create.basic-info.name") },- { label: t("sql-review.create.configure-rule.name") },+ { title: t("sql-review.create.basic-info.name") },+ { title: t("sql-review.create.configure-rule.name") },];return (<div className="w-full h-full flex flex-col">{/* Step bar */}<div className="sticky top-0 z-10 bg-background border-b px-4 pb-4">- <div className="flex items-center gap-x-2">- {steps.map((step, index) => (- <div key={index} className="flex items-center gap-x-2">- {index > 0 && <div className="w-8 h-px bg-control-border" />}- <div- className={`flex items-center gap-x-2 px-3 py-1.5 rounded-full text-sm font-medium ${- index === currentStep- ? "bg-accent text-accent-text"- : index < currentStep- ? "bg-success/10 text-success"- : "bg-control-bg text-control-light"- }`}- >- <span className="inline-flex items-center justify-center size-5 rounded-full text-xs bg-background/20">- {index + 1}- </span>- {step.label}- </div>- </div>- ))}- </div>+ <StepIndicator steps={steps} currentIndex={currentStep} /></div>{/* Step content */}<div className="flex-1 overflow-y-auto p-4">{currentStep === STEP_BASIC_INFO && (- <div className="flex flex-col gap-y-4 max-w-2xl">- <div className="flex flex-col gap-y-2 max-w-2xl">- {/* Display name */}- <div>- <label className="textlabel">- {t("sql-review.create.basic-info.display-name")}- <span className="text-error ml-0.5">*</span>- </label>- <p className="mt-1 textinfolabel">- {t("sql-review.create.basic-info.display-name-label")}- </p>+ <div className="max-w-2xl">+ <FormFieldGroup>+ <FormField+ title={+ <>+ {t("sql-review.create.basic-info.display-name")}+ <span className="text-error ml-0.5">*</span>+ </>+ }+ description={t(+ "sql-review.create.basic-info.display-name-label"+ )}+ ><Input- className="mt-2"value={policyName}onChange={(e) => setPolicyName(e.target.value)}/>- </div>- {/* Resource ID */}- <ResourceIdField- value={resourceId}- resourceName={t("sql-review.review-policy")}- resourceTitle={policyName}- suffix- readonly={!!policy}- onChange={setResourceId}- validate={validateResourceId}+ <ResourceIdField+ value={resourceId}+ resourceName={t("sql-review.review-policy")}+ resourceTitle={policyName}+ suffix+ readonly={!!policy}+ onChange={setResourceId}+ validate={validateResourceId}+ />+ </FormField>++ <TemplateSelector+ selectedTemplateId={+ pendingApplyTemplate?.id ?? selectedTemplateId+ }+ onSelectTemplate={tryApplyTemplate}/>- </div>-- {/* Template selector */}- <TemplateSelector- selectedTemplateId={- pendingApplyTemplate?.id ?? selectedTemplateId- }- onSelectTemplate={tryApplyTemplate}- />+ </FormFieldGroup></div>)}diff --git a/frontend/src/components/sql-review/RuleComponents.test.tsx b/frontend/src/components/sql-review/RuleComponents.test.tsxindex 7112adc6b0..cb4354e3cd 100644--- a/frontend/src/components/sql-review/RuleComponents.test.tsx+++ b/frontend/src/components/sql-review/RuleComponents.test.tsx@@ -195,12 +195,87 @@ describe("RuleEditDialog", () => {unmount();});+ test("uses shared form fields in the edit dialog body", () => {+ const { container, render, unmount } = renderIntoContainer(+ <RuleEditDialog+ rule={maximumSQLSizeRule()}+ disabled={false}+ onUpdateRule={vi.fn()}+ onCancel={vi.fn()}+ />+ );++ render();++ const formFields = container.querySelectorAll('[data-slot="form-field"]');+ expect(formFields.length).toBeGreaterThanOrEqual(2);+ expect(container.textContent).toContain("sql-review.level.name");+ expect(container.textContent).toContain(+ "sql-review.rule.BUILTIN_STATEMENT_MAXIMUM_SQL_SIZE.component.number.title"+ );++ unmount();+ });++ test("disables update when maximum SQL size is not positive", () => {+ const { container, render, unmount } = renderIntoContainer(+ <RuleEditDialog+ rule={maximumSQLSizeRule()}+ disabled={false}+ onUpdateRule={vi.fn()}+ onCancel={vi.fn()}+ />+ );++ render();++ const input = container.querySelector<HTMLInputElement>(+ 'input[type="number"]'+ );+ expect(input).toBeTruthy();++ act(() => {+ const valueSetter = Object.getOwnPropertyDescriptor(+ HTMLInputElement.prototype,+ "value"+ )?.set;+ valueSetter?.call(input, "0");+ input!.dispatchEvent(new Event("input", { bubbles: true }));+ input!.dispatchEvent(new Event("change", { bubbles: true }));+ });++ const updateButton = [...container.querySelectorAll("button")].find(+ (button) => button.textContent === "common.update"+ );+ expect(updateButton).toBeTruthy();+ expect(updateButton).toBeDisabled();++ unmount();+ });++ test("uses shared form rows for rule config payload controls", () => {+ const { container, render, unmount } = renderIntoContainer(+ <RuleConfig rule={maximumSQLSizeRule()} disabled={false} />+ );++ render();++ expect(+ container.querySelector('[data-slot="form-field-group"]')+ ).toBeTruthy();+ expect(container.querySelector('[data-slot="form-field"]')).toBeTruthy();+ expect(+ container.querySelector('[data-slot="form-control-row"]')+ ).toBeTruthy();++ unmount();+ });+test("adds top spacing before the editable string-array input", () => {const { container, render, unmount } = renderIntoContainer(<RuleConfigrule={tableDenyListRule(["id"])}disabled={false}- size="medium"/>);@@ -215,7 +290,7 @@ describe("RuleEditDialog", () => {test("renders read-only string-array labels with visible chip backgrounds", () => {const { container, render, unmount } = renderIntoContainer(- <RuleConfig rule={tableDenyListRule(["id"])} disabled size="small" />+ <RuleConfig rule={tableDenyListRule(["id"])} disabled />);render();@@ -232,7 +307,7 @@ describe("RuleEditDialog", () => {test("renders maximum SQL size in MB instead of raw bytes", () => {const { container, render, unmount } = renderIntoContainer(- <RuleConfig rule={maximumSQLSizeRule()} disabled={false} size="medium" />+ <RuleConfig rule={maximumSQLSizeRule()} disabled={false} />);render();diff --git a/frontend/src/components/sql-review/RuleComponents.tsx b/frontend/src/components/sql-review/RuleComponents.tsxindex d414aa1b03..fe445ba2a7 100644--- a/frontend/src/components/sql-review/RuleComponents.tsx+++ b/frontend/src/components/sql-review/RuleComponents.tsx@@ -6,6 +6,11 @@ import { Badge } from "@/components/ui/badge";import { Button } from "@/components/ui/button";import { Checkbox } from "@/components/ui/checkbox";import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";+import {+ FormControlRow,+ FormField,+ FormFieldGroup,+} from "@/components/ui/form";import { Input } from "@/components/ui/input";import { Tooltip } from "@/components/ui/tooltip";import i18n from "@/lib/i18n";@@ -137,7 +142,6 @@ export function RuleLevelBadge({ level, suffix }: RuleLevelBadgeProps) {interface RuleConfigProps {rule: RuleTemplateV2;disabled: boolean;- size: "small" | "medium";payloadRef?: React.MutableRefObject<PayloadValueType[]>;onPayloadChange?: (payload: PayloadValueType[]) => void;}@@ -161,7 +165,6 @@ function configTooltip(export function RuleConfig({rule,disabled,- size,payloadRef,onPayloadChange,}: RuleConfigProps) {@@ -190,39 +193,40 @@ export function RuleConfig({};return (- <div className="flex flex-col gap-y-4">+ <FormFieldGroup>{rule.componentList.map((config, index) => (- <div key={index} className="flex flex-col gap-y-1">- {config.payload.type !== "BOOLEAN" && (- <div className="flex items-center gap-x-1">- <p- className={`font-medium ${size !== "small" ? "text-lg text-control mb-2" : ""}`}- >- {configTitle(rule, config)}- </p>- {configTooltip(rule, config) && (- <Tooltip content={configTooltip(rule, config)}>- <CircleHelpIcon className="w-4 h-4" />- </Tooltip>- )}- </div>- )}-+ <FormField+ key={config.key}+ title={+ config.payload.type !== "BOOLEAN" ? (+ <div className="flex items-center gap-x-1">+ <p className="font-medium">{configTitle(rule, config)}</p>+ {configTooltip(rule, config) && (+ <Tooltip content={configTooltip(rule, config)}>+ <CircleHelpIcon className="w-4 h-4" />+ </Tooltip>+ )}+ </div>+ ) : undefined+ }+ >{config.payload.type === "STRING" && (<Inputvalue={(payload[index] as string) ?? ""}disabled={disabled}placeholder={`${config.payload.default}`}+ autoComplete="off"onChange={(e) => updatePayload(index, e.target.value)}/>)}{config.payload.type === "NUMBER" && (- <div className="flex items-center gap-x-2">+ <FormControlRow><Inputtype="number"value={(payload[index] as number) ?? 0}disabled={disabled}+ autoComplete="off"placeholder={`${config.payload.default}`}step={config.payload.unit ? "any" : undefined}onChange={(e) => updatePayload(index, Number(e.target.value))}@@ -232,11 +236,11 @@ export function RuleConfig({{config.payload.unit}</span>)}- </div>+ </FormControlRow>)}{config.payload.type === "BOOLEAN" && (- <label className="flex items-center gap-x-2">+ <FormControlRow><Checkboxchecked={(payload[index] as boolean) ?? false}disabled={disabled}@@ -248,7 +252,7 @@ export function RuleConfig({<CircleHelpIcon className="w-4 h-4" /></Tooltip>)}- </label>+ </FormControlRow>)}{config.payload.type === "STRING_ARRAY" &&@@ -269,9 +273,9 @@ export function RuleConfig({onChange={(val) => updatePayload(index, val)}/>)}- </div>+ </FormField>))}- </div>+ </FormFieldGroup>);}@@ -340,6 +344,7 @@ function StringArrayInput({<InputclassName="mt-2 min-w-[20rem] flex-1"value={inputValue}+ autoComplete="off"onChange={(e) => setInputValue(e.target.value)}onKeyDown={handleKeyDown}/>@@ -442,27 +447,30 @@ export function RuleEditDialog({</div></div>- <RuleLevelSwitch- level={level}- disabled={disabled}- editable={!disabled}- onLevelChange={setLevel}- />-{localization.description && (<p className="text-sm text-control-placeholder">{localization.description}</p>)}- {rule.componentList.length > 0 && (- <RuleConfig- rule={rule}- disabled={disabled}- size="medium"- onPayloadChange={setPayload}- />- )}+ <FormFieldGroup>+ <FormField title={t("sql-review.level.name")}>+ <RuleLevelSwitch+ level={level}+ disabled={disabled}+ editable={!disabled}+ onLevelChange={setLevel}+ />+ </FormField>++ {rule.componentList.length > 0 && (+ <RuleConfig+ rule={rule}+ disabled={disabled}+ onPayloadChange={setPayload}+ />+ )}+ </FormFieldGroup><div className="flex justify-end gap-x-2"><Button appearance="outline" onClick={onCancel}>diff --git a/frontend/src/components/sql-review/RuleTable.test.tsx b/frontend/src/components/sql-review/RuleTable.test.tsxindex fc26adbdc0..9711606324 100644--- a/frontend/src/components/sql-review/RuleTable.test.tsx+++ b/frontend/src/components/sql-review/RuleTable.test.tsx@@ -5,7 +5,11 @@ import { beforeEach, describe, expect, test, vi } from "vitest";import { getRuleKey } from "@/lib/sql-review/utils";import { Engine } from "@/types/proto-es/v1/common_pb";import type { RuleTemplateV2 } from "@/types/sqlReview";-import { getRuleLocalization, ruleTemplateMapV2 } from "@/types/sqlReview";+import {+ getRuleLocalization,+ ruleTemplateMapV2,+ ruleTypeToString,+} from "@/types/sqlReview";(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }@@ -113,6 +117,10 @@ vi.mock("@/components/ui/tabs", () => ({),}));+vi.mock("@/components/ui/tooltip", () => ({+ Tooltip: ({ children }: { children: React.ReactNode }) => children,+}));+vi.mock("./RuleComponents", () => ({RuleConfig: () => <div data-testid="rule-config" />,RuleEditDialog: () => <div data-testid="rule-edit-dialog" />,@@ -179,6 +187,30 @@ describe("RuleTable", () => {].slice(0, 20) as RuleTemplateV2[],},];+ const getRuleWithPayload = () => {+ const rule = ruleList[0].ruleList.find(+ (rule) => rule.componentList.length > 0+ );+ if (!rule) {+ throw new Error("expected a SQL review rule with payload");+ }+ return rule;+ };+ const getRuleWithoutPayload = () => {+ const rule = ruleList[0].ruleList.find((rule) => {+ if (rule.componentList.length > 0) {+ return false;+ }+ return !!getRuleLocalization(+ ruleTypeToString(rule.type),+ rule.engine+ ).description;+ });+ if (!rule) {+ throw new Error("expected a SQL review rule without payload");+ }+ return rule;+ };test("opening one edit dialog does not rerender every visible rule row", () => {const { container, render, unmount } = renderIntoContainer(@@ -191,10 +223,11 @@ describe("RuleTable", () => {const levelSwitchRenderCountAfterInitialRender =mocks.ruleLevelSwitch.mock.calls.length;- const editButton = [...container.querySelectorAll("button")].find(- (button) => button.textContent === "common.edit"+ const editButton = container.querySelector<HTMLButtonElement>(+ 'button[aria-label="common.edit"]');expect(editButton).toBeTruthy();+ expect(editButton?.textContent).toBe("");act(() => {editButton!.dispatchEvent(new MouseEvent("click", { bubbles: true }));@@ -213,9 +246,124 @@ describe("RuleTable", () => {unmount();});+ test("desktop rule row uses compact edit action and aligned expanded details", () => {+ const rule = getRuleWithPayload();+ const { container, render, unmount } = renderIntoContainer(+ <RuleTable+ ruleList={[{ value: "all", label: "All", ruleList: [rule] }]}+ editable+ />+ );++ render();++ const editButton = container.querySelector<HTMLButtonElement>(+ 'tbody tr[data-sql-review-rule-view="desktop"] button[aria-label="common.edit"]'+ );+ expect(editButton).toBeTruthy();+ expect(editButton?.className).toContain("size-7");+ expect(editButton?.textContent).toBe("");+ expect(editButton?.className).not.toContain("border");++ const deleteButton = container.querySelector<HTMLButtonElement>(+ 'tbody tr[data-sql-review-rule-view="desktop"] button[aria-label="common.delete"]'+ );+ expect(deleteButton).toBeTruthy();+ expect(deleteButton?.className).toContain("size-7");+ expect(deleteButton?.textContent).toBe("");+ expect(deleteButton?.className).not.toContain("border");+ expect(editButton?.parentElement?.className).toContain("gap-x-1");+ const expandCell = container.querySelector(+ 'tbody tr[data-sql-review-rule-view="desktop"] td:first-child'+ );+ expect(expandCell?.className).toContain("align-top");+ expect(expandCell?.className).toContain("pt-4");++ const levelCell = container.querySelector(+ 'tbody tr[data-sql-review-rule-view="desktop"] td:nth-child(3)'+ );+ expect(levelCell?.className).toContain("align-top");+ expect(levelCell?.className).toContain("pt-4");++ const operationsCell = container.querySelector(+ 'tbody tr[data-sql-review-rule-view="desktop"] td:nth-child(4)'+ );+ expect(operationsCell?.className).toContain("align-top");+ expect(operationsCell?.className).toContain("pt-4");++ const title = container.querySelector(+ 'tbody tr[data-sql-review-rule-view="desktop"] td:nth-child(2) span'+ );+ expect(title?.className).toContain("font-semibold");+ expect(title?.className).toContain("text-base");+ expect(title?.className).toContain("text-main");++ const description = container.querySelector(+ 'tbody tr[data-sql-review-rule-view="desktop"] td:nth-child(2) p'+ );+ expect(description).toBeTruthy();+ expect(description?.className).toContain("text-sm");+ expect(description?.className).toContain("leading-5");+ expect(description?.className).toContain("text-control-light");++ const expandButton = container.querySelector<HTMLButtonElement>(+ "tbody tr[data-sql-review-rule-view='desktop'] td:first-child button"+ );+ expect(expandButton).toBeTruthy();+ act(() => {+ expandButton!.dispatchEvent(new MouseEvent("click", { bubbles: true }));+ });++ const rows = container.querySelectorAll("tbody tr");+ const detailRow = rows[1];+ expect(detailRow?.className).toContain("bg-control-bg/20");++ const detailCells = detailRow?.querySelectorAll("td");+ expect(detailCells).toHaveLength(2);+ expect(detailCells?.[0]?.textContent).toBe("");+ expect(detailCells?.[1]?.getAttribute("colspan")).toBe("3");+ expect(detailCells?.[1]?.className).toContain("px-4");+ expect(detailCells?.[1]?.className).not.toContain("px-10");+ expect(+ detailCells?.[1]?.querySelector('[data-testid="rule-config"]')+ ).toBeTruthy();+ expect(detailCells?.[1]?.querySelector("p")).toBeFalsy();++ unmount();+ });++ test("desktop rule row only expands rules with payload", () => {+ const rule = getRuleWithoutPayload();+ const { container, render, unmount } = renderIntoContainer(+ <RuleTable+ ruleList={[{ value: "all", label: "All", ruleList: [rule] }]}+ editable+ />+ );++ render();++ expect(+ container.querySelector(+ 'tbody tr[data-sql-review-rule-view="desktop"] td:nth-child(2) p'+ )+ ).toBeTruthy();+ expect(+ container.querySelector(+ "tbody tr[data-sql-review-rule-view='desktop'] td:first-child button"+ )+ ).toBeFalsy();++ unmount();+ });+test("expanding one rule does not rerender every visible rule row", () => {+ const rule = getRuleWithPayload();const { container, render, unmount } = renderIntoContainer(- <RuleTable ruleList={ruleList} editable />+ <RuleTable+ ruleList={[{ value: "all", label: "All", ruleList: [rule] }]}+ editable+ />);render();diff --git a/frontend/src/components/sql-review/RuleTable.tsx b/frontend/src/components/sql-review/RuleTable.tsxindex f3e601bde0..d889e29eec 100644--- a/frontend/src/components/sql-review/RuleTable.tsx+++ b/frontend/src/components/sql-review/RuleTable.tsx@@ -19,6 +19,7 @@ import {TableRow,} from "@/components/ui/table";import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";+import { Tooltip } from "@/components/ui/tooltip";import { getRuleKey } from "@/lib/sql-review/utils";import { cn } from "@/lib/utils";import type { Engine } from "@/types/proto-es/v1/common_pb";@@ -447,10 +448,12 @@ function RuleTableRow({() => getRuleLocalization(ruleTypeToString(rule.type), rule.engine),[rule.engine, rule.type]);- const expandable = !!(loc.description || rule.componentList.length > 0);+ const expandable = rule.componentList.length > 0;const colSpan =2 + (supportSelect ? 1 : 0) + (hideLevel ? 0 : 1) + (supportSelect ? 0 : 1);+ const leadingCellCount = 1 + (supportSelect ? 1 : 0);+ const detailColSpan = colSpan - leadingCellCount;const updateLevel = (level: SQLReviewRule_Level) => {onRuleUpsert?.(rule, { level });@@ -461,11 +464,11 @@ function RuleTableRow({};useEffect(() => {- if (focusRuleSignal === undefined) {+ if (focusRuleSignal === undefined || !expandable) {return;}setExpanded(true);- }, [focusRuleSignal]);+ }, [focusRuleSignal, expandable]);return (<>@@ -479,7 +482,10 @@ function RuleTableRow({)}onClick={supportSelect ? onToggleRule : undefined}>- <TableCell className="w-8" onClick={(e) => e.stopPropagation()}>+ <TableCell+ className="w-8 align-top pt-4"+ onClick={(e) => e.stopPropagation()}+ >{expandable && (<buttontype="button"@@ -495,28 +501,43 @@ function RuleTableRow({)}</TableCell>{supportSelect && (- <TableCell className="w-8" onClick={(e) => e.stopPropagation()}>+ <TableCell+ className="w-8 align-top pt-4"+ onClick={(e) => e.stopPropagation()}+ ><Checkboxchecked={isSelected}onCheckedChange={() => onToggleRule()}/></TableCell>)}- <TableCell>- <div className="flex items-center gap-x-2">- <span>{loc.title}</span>- <a- href={`https://docs.bytebase.com/sql-review/review-rules#${rule.type}`}- target="_blank"- rel="noopener noreferrer"- className="flex items-center text-control-light hover:text-control"- >- <ExternalLink className="w-4 h-4" />- </a>+ <TableCell className="align-top">+ <div className="flex flex-col gap-y-1">+ <div className="flex items-center gap-x-2">+ <span className="font-semibold text-base text-main">+ {loc.title}+ </span>+ <a+ href={`https://docs.bytebase.com/sql-review/review-rules#${rule.type}`}+ target="_blank"+ rel="noopener noreferrer"+ className="flex items-center text-control-light hover:text-control"+ >+ <ExternalLink className="w-4 h-4" />+ </a>+ </div>+ {loc.description && (+ <p className="max-w-5xl text-sm leading-5 text-control-light">+ {loc.description}+ </p>+ )}</div></TableCell>{!hideLevel && (- <TableCell onClick={(e) => e.stopPropagation()}>+ <TableCell+ className="align-top pt-4"+ onClick={(e) => e.stopPropagation()}+ ><RuleLevelSwitchlevel={rule.level}disabled={!editable}@@ -525,47 +546,48 @@ function RuleTableRow({</TableCell>)}{!supportSelect && (- <TableCell onClick={(e) => e.stopPropagation()}>- <div className="flex items-center justify-end gap-x-2">- <Button- appearance="outline"- size="sm"- onClick={() => setEditing(true)}- >- {editable ? t("common.edit") : t("common.view")}- </Button>- {editable && !isBuiltinRule(rule) && (+ <TableCell+ className="align-top pt-4"+ onClick={(e) => e.stopPropagation()}+ >+ <div className="flex items-center justify-end gap-x-1">+ <Tooltip content={editable ? t("common.edit") : t("common.view")}><Button- variant="destructive"- appearance="outline"+ appearance="secondary"size="sm"- onClick={() => onRuleRemove?.(rule)}+ className="size-7 p-0 text-control hover:text-accent"+ aria-label={editable ? t("common.edit") : t("common.view")}+ onClick={() => setEditing(true)}>- {t("common.delete")}+ <Pencil className="size-4" /></Button>+ </Tooltip>+ {editable && !isBuiltinRule(rule) && (+ <Tooltip content={t("common.delete")}>+ <Button+ variant="destructive"+ appearance="secondary"+ size="sm"+ className="size-7 p-0 text-error hover:bg-error/10 hover:text-error"+ aria-label={t("common.delete")}+ onClick={() => onRuleRemove?.(rule)}+ >+ <Trash2 className="size-4" />+ </Button>+ </Tooltip>)}</div></TableCell>)}</TableRow>- {expanded && (- <TableRow>- <TableCell- colSpan={colSpan}- className={cn(- "px-10 bg-control-bg/40",- highlighted && "bg-error/5"- )}- >- {loc.description && (- <p className="text-control-light">{loc.description}</p>- )}- {rule.componentList.length > 0 && loc.description && (- <hr className="my-4 border-control-border" />- )}- {rule.componentList.length > 0 && (- <RuleConfig rule={rule} disabled size="small" />- )}+ {expanded && expandable && (+ <TableRow+ className={cn("bg-control-bg/20", highlighted && "bg-error/5")}+ >+ <TableCell />+ {supportSelect && <TableCell />}+ <TableCell colSpan={detailColSpan} className="px-4 py-4 pr-10">+ <RuleConfig rule={rule} disabled /></TableCell></TableRow>)}diff --git a/frontend/src/components/sql-review/TemplateSelector.test.tsx b/frontend/src/components/sql-review/TemplateSelector.test.tsxindex 8a9c99e552..5f480d4ea3 100644--- a/frontend/src/components/sql-review/TemplateSelector.test.tsx+++ b/frontend/src/components/sql-review/TemplateSelector.test.tsx@@ -117,6 +117,22 @@ beforeEach(async () => {});describe("TemplateSelector", () => {+ test("uses shared form field for the selector title", () => {+ const { container, render, unmount } = renderIntoContainer(+ <TemplateSelector onSelectTemplate={vi.fn()} />+ );++ render();++ const formField = container.querySelector('[data-slot="form-field"]');+ expect(formField).toBeTruthy();+ expect(+ formField?.querySelector('[data-slot="form-field-title"]')?.textContent+ ).toContain("sql-review.create.basic-info.choose-template");++ unmount();+ });+test("renders review templates as semantic buttons", () => {const onSelectTemplate = vi.fn();const { container, render, unmount } = renderIntoContainer(diff --git a/frontend/src/components/sql-review/TemplateSelector.tsx b/frontend/src/components/sql-review/TemplateSelector.tsxindex 95c954d9d5..d8e49d12a7 100644--- a/frontend/src/components/sql-review/TemplateSelector.tsx+++ b/frontend/src/components/sql-review/TemplateSelector.tsx@@ -3,6 +3,7 @@ import { useEffect, useMemo } from "react";import { useTranslation } from "react-i18next";import { EnvironmentLabel } from "@/components/EnvironmentLabel";import { Badge } from "@/components/ui/badge";+import { FormField } from "@/components/ui/form";import { Separator } from "@/components/ui/separator";import { useProjectByName } from "@/hooks/useProjectByName";import { rulesToTemplate } from "@/lib/sql-review/utils";@@ -92,87 +93,91 @@ export function TemplateSelector({template.id === selectedTemplateId;return (- <div className="flex flex-col gap-y-2">- <p className="textlabel">- {t("sql-review.create.basic-info.choose-template")}- {required && <span className="text-error"> *</span>}- </p>-- {reviewPolicyTemplateList.length > 0 && (+ <FormField+ title={<>- <div className="flex flex-wrap gap-4">- {reviewPolicyTemplateList.map((template) => (- <button- type="button"- key={template.id}- aria-pressed={isSelected(template)}- className={cn(- "relative flex w-full cursor-pointer flex-col rounded-sm border border-control-border px-6 py-4 text-left transition-colors sm:max-w-xs",- "hover:bg-control-bg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",- isSelected(template) && "bg-control-bg"- )}- onClick={() => onSelectTemplate(template)}- >- <div className="text-left flex flex-col gap-y-2">- <span className="text-base font-medium">- {template.review?.name}- </span>- <div className="flex flex-wrap gap-2">- {template.review?.resources.map((resource) => (- <ResourceBadge key={resource} resource={resource} />- ))}- </div>- <p className="text-sm">- <span className="mr-2">- {t("sql-review.enabled-rules")}:- </span>- <span>{template.ruleList.length}</span>- </p>- </div>- {isSelected(template) && (- <CheckCircle className="absolute right-3 top-3 size-7 text-accent" />- )}- </button>- ))}- </div>-- <Separator className="my-2" />+ {t("sql-review.create.basic-info.choose-template")}+ {required && <span className="text-error ml-0.5">*</span>}</>- )}-- <div className="flex flex-wrap gap-4">- {builtInTemplateList.map((template) => (- <button- type="button"- key={template.id}- aria-pressed={isSelected(template)}- className={cn(- "relative flex w-full cursor-pointer flex-col rounded-sm border border-control-border px-6 py-4 text-left transition-colors sm:max-w-xs",- "hover:bg-control-bg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",- isSelected(template) && "bg-control-bg"- )}- onClick={() => onSelectTemplate(template)}- >- <div className="text-left flex flex-col gap-y-2">- <span className="text-base font-medium">- {t(`sql-review.template.${template.id.split(".").join("-")}`)}- </span>- <p className="text-sm text-control-light">- {t(- `sql-review.template.${template.id.split(".").join("-")}-desc`- )}- </p>- <p className="text-sm">- <span className="mr-2">{t("sql-review.enabled-rules")}:</span>- <span>{template.ruleList.length}</span>- </p>+ }+ >+ <div className="flex flex-col gap-y-2">+ {reviewPolicyTemplateList.length > 0 && (+ <>+ <div className="flex flex-wrap gap-4">+ {reviewPolicyTemplateList.map((template) => (+ <button+ type="button"+ key={template.id}+ aria-pressed={isSelected(template)}+ className={cn(+ "relative flex w-full cursor-pointer flex-col rounded-sm border border-control-border px-6 py-4 text-left transition-colors sm:max-w-xs",+ "hover:bg-control-bg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",+ isSelected(template) && "bg-control-bg"+ )}+ onClick={() => onSelectTemplate(template)}+ >+ <div className="text-left flex flex-col gap-y-2">+ <span className="text-base font-medium">+ {template.review?.name}+ </span>+ <div className="flex flex-wrap gap-2">+ {template.review?.resources.map((resource) => (+ <ResourceBadge key={resource} resource={resource} />+ ))}+ </div>+ <p className="text-sm">+ <span className="mr-2">+ {t("sql-review.enabled-rules")}:+ </span>+ <span>{template.ruleList.length}</span>+ </p>+ </div>+ {isSelected(template) && (+ <CheckCircle className="absolute right-3 top-3 size-7 text-accent" />+ )}+ </button>+ ))}</div>- {isSelected(template) && (- <CheckCircle className="absolute right-3 top-3 size-7 text-accent" />- )}- </button>- ))}++ <Separator className="my-2" />+ </>+ )}++ <div className="flex flex-wrap gap-4">+ {builtInTemplateList.map((template) => (+ <button+ type="button"+ key={template.id}+ aria-pressed={isSelected(template)}+ className={cn(+ "relative flex w-full cursor-pointer flex-col rounded-sm border border-control-border px-6 py-4 text-left transition-colors sm:max-w-xs",+ "hover:bg-control-bg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",+ isSelected(template) && "bg-control-bg"+ )}+ onClick={() => onSelectTemplate(template)}+ >+ <div className="text-left flex flex-col gap-y-2">+ <span className="text-base font-medium">+ {t(`sql-review.template.${template.id.split(".").join("-")}`)}+ </span>+ <p className="text-sm text-control-light">+ {t(+ `sql-review.template.${template.id.split(".").join("-")}-desc`+ )}+ </p>+ <p className="text-sm">+ <span className="mr-2">{t("sql-review.enabled-rules")}:</span>+ <span>{template.ruleList.length}</span>+ </p>+ </div>+ {isSelected(template) && (+ <CheckCircle className="absolute right-3 top-3 size-7 text-accent" />+ )}+ </button>+ ))}+ </div></div>- </div>+ </FormField>);}diff --git a/frontend/src/components/ui/step-indicator.test.tsx b/frontend/src/components/ui/step-indicator.test.tsxnew file mode 100644index 0000000000..ef23de7305--- /dev/null+++ b/frontend/src/components/ui/step-indicator.test.tsx@@ -0,0 +1,58 @@+import type { ReactElement } from "react";+import { act } from "react";+import { createRoot } from "react-dom/client";+import { describe, expect, test } from "vitest";+import { StepIndicator } from "./step-indicator";++(+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+).IS_REACT_ACT_ENVIRONMENT = true;++const renderIntoContainer = (element: ReactElement) => {+ const container = document.createElement("div");+ const root = createRoot(container);++ act(() => {+ root.render(element);+ });++ return {+ container,+ unmount: () =>+ act(() => {+ root.unmount();+ }),+ };+};++describe("StepIndicator", () => {+ test("marks reached steps with accent and future steps as muted", () => {+ const { container, unmount } = renderIntoContainer(+ <StepIndicator+ currentIndex={1}+ steps={[+ { title: "First" },+ { title: "Second" },+ { title: "Third" },+ ]}+ />+ );++ const labels = [...container.querySelectorAll("li span")];+ expect(labels.map((label) => label.textContent)).toEqual([+ "First",+ "Second",+ "Third",+ ]);+ expect(labels[0].className).toContain("text-accent");+ expect(labels[1].className).toContain("text-accent");+ expect(labels[2].className).toContain("text-control-light");+ expect(container.querySelector("svg")).toBeTruthy();+ expect(container.textContent).not.toContain("1");+ expect(container.textContent).toContain("2");+ expect(container.textContent).toContain("3");+ expect(container.querySelectorAll(".bg-control-border")).toHaveLength(2);++ unmount();+ });+});diff --git a/frontend/src/components/ui/step-indicator.tsx b/frontend/src/components/ui/step-indicator.tsxnew file mode 100644index 0000000000..882a1c5797--- /dev/null+++ b/frontend/src/components/ui/step-indicator.tsx@@ -0,0 +1,66 @@+import { Check } from "lucide-react";+import type { ReactNode } from "react";+import { cn } from "@/lib/utils";++export type StepIndicatorStep = {+ title: ReactNode;+ key?: string | number;+};++export function StepIndicator({+ steps,+ currentIndex,+ currentKey,+ className,+}: {+ readonly steps: StepIndicatorStep[];+ readonly currentIndex?: number;+ readonly currentKey?: string | number;+ readonly className?: string;+}) {+ const activeIndex =+ currentIndex ??+ (currentKey === undefined+ ? 0+ : steps.findIndex((step) => step.key === currentKey));++ return (+ <ol+ data-slot="step-indicator"+ className={cn(+ "flex flex-wrap items-center gap-x-2 gap-y-1 px-0.5",+ className+ )}+ >+ {steps.map((step, index) => {+ const isReached = activeIndex >= 0 && index <= activeIndex;+ const isCompleted = activeIndex >= 0 && index < activeIndex;+ return (+ <li key={step.key ?? index} className="flex items-center gap-x-2">+ {index > 0 && <div className="w-8 h-px bg-control-border" />}+ <div className="flex items-center gap-x-2">+ <div+ className={cn(+ "flex size-6 items-center justify-center rounded-full text-xs font-medium",+ isReached+ ? "bg-accent text-accent-text"+ : "bg-control-bg-hover text-control-light"+ )}+ >+ {isCompleted ? <Check className="size-3.5" /> : index + 1}+ </div>+ <span+ className={cn(+ "text-sm",+ isReached ? "text-accent font-medium" : "text-control-light"+ )}+ >+ {step.title}+ </span>+ </div>+ </li>+ );+ })}+ </ol>+ );+}diff --git a/frontend/src/components/ui/sticky-action-footer.test.tsx b/frontend/src/components/ui/sticky-action-footer.test.tsxindex 78e421ec6c..b62d99933e 100644--- a/frontend/src/components/ui/sticky-action-footer.test.tsx+++ b/frontend/src/components/ui/sticky-action-footer.test.tsx@@ -73,12 +73,17 @@ describe("StickyActionFooter", () => {);expect(content?.firstElementChild).toBe(left);expect(content?.lastElementChild).toBe(right);+ expect(content?.className).toContain("gap-x-2");+ expect(content?.className).toContain("gap-y-2");expect(left?.textContent).toBe("Cancel");+ expect(left?.className).toContain("gap-x-2");+ expect(left?.className).toContain("gap-y-2");expect(left?.className).toContain(stylex.props(stickyActionFooterSideStyle()).className ?? "");expect(right?.textContent).toBe("TestSave");expect(right?.className).toContain("gap-x-2");+ expect(right?.className).toContain("gap-y-2");expect(right?.className).toContain(stylex.props(stickyActionFooterSideStyle(),@@ -88,4 +93,23 @@ describe("StickyActionFooter", () => {unmount();});++ test("allows callers to align footer content with the surrounding page edge", () => {+ const { container, unmount } = renderIntoContainer(+ createElement(StickyActionFooter, {+ contentPadding: false,+ left: createElement("button", { type: "button" }, "Cancel"),+ right: createElement("button", { type: "button" }, "Save"),+ })+ );++ const content = container.querySelector(+ '[data-slot="sticky-action-footer-content"]'+ );++ expect(content).not.toHaveClass("px-4");+ expect(content).not.toHaveClass("sm:px-6");++ unmount();+ });});diff --git a/frontend/src/components/ui/sticky-action-footer.tsx b/frontend/src/components/ui/sticky-action-footer.tsxindex de43642d41..907a245bca 100644--- a/frontend/src/components/ui/sticky-action-footer.tsx+++ b/frontend/src/components/ui/sticky-action-footer.tsx@@ -10,6 +10,8 @@ import {type StickyActionFooterProps = Readonly<ComponentProps<"div"> & {+ contentClassName?: string;+ contentPadding?: boolean;left?: ReactNode;right?: ReactNode;leftClassName?: string;@@ -19,6 +21,8 @@ type StickyActionFooterProps = Readonly<function StickyActionFooter({className,+ contentClassName,+ contentPadding = true,left,leftClassName,right,@@ -49,19 +53,32 @@ function StickyActionFooter({><divdata-slot="sticky-action-footer-content"- className={cn("px-4 sm:px-6", contentStylexProps.className)}+ className={cn(+ "gap-x-2 gap-y-2",+ contentPadding && "px-4 sm:px-6",+ contentStylexProps.className,+ contentClassName+ )}style={contentStylexProps.style}><divdata-slot="sticky-action-footer-left"- className={cn(leftStylexProps.className, leftClassName)}+ className={cn(+ "flex-wrap gap-x-2 gap-y-2",+ leftStylexProps.className,+ leftClassName+ )}style={leftStylexProps.style}>{left}</div><divdata-slot="sticky-action-footer-right"- className={cn("gap-x-2", rightStylexProps.className, rightClassName)}+ className={cn(+ "flex-wrap gap-x-2 gap-y-2",+ rightStylexProps.className,+ rightClassName+ )}style={rightStylexProps.style}>{right}diff --git a/frontend/src/lib/sql-review/utils.ts b/frontend/src/lib/sql-review/utils.tsindex e082a3d6b7..85b5178998 100644--- a/frontend/src/lib/sql-review/utils.ts+++ b/frontend/src/lib/sql-review/utils.ts@@ -106,6 +106,11 @@ export const getRuleMapValidationErrorTitle = (ruleTypeToString(error.rule.type),error.rule.engine).title;+ if (error.type === "INVALID_NUMBER") {+ return i18n.t("sql-review.validation.number-positive", {+ rule: ruleTitle,+ });+ }return i18n.t("sql-review.validation.string-array-required", {rule: ruleTitle,});diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex b4ec463f7b..979db110cb 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1144,6 +1144,9 @@},"ssl-tls-connection": {"link": "SSL/TLS Connection"+ },+ "sync-databases": {+ "content": "When enabled, Bytebase discovers and syncs every database in this instance during creation. Disable it if you only want to sync selected databases now; you can sync more databases later from the instance page."}},"info-panel": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex c7981ae6fd..70200bfa46 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1144,6 +1144,9 @@},"ssl-tls-connection": {"link": "Conexión SSL/TLS"+ },+ "sync-databases": {+ "content": "Cuando está activado, Bytebase descubre y sincroniza todas las bases de datos de esta instancia durante la creación. Desactívelo si ahora solo quiere sincronizar bases de datos seleccionadas; puede sincronizar más bases de datos más tarde desde la página de la instancia."}},"info-panel": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 35c7a8d0f3..0d6f1c69f9 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1144,6 +1144,9 @@},"ssl-tls-connection": {"link": "SSL/TLS 接続"+ },+ "sync-databases": {+ "content": "有効にすると、Bytebase は作成時にこのインスタンス内のすべてのデータベースを検出して同期します。今は選択したデータベースだけを同期する場合は無効にしてください。後でインスタンスページから追加のデータベースを同期できます。"}},"info-panel": {diff --git a/frontend/src/locales/sql-review/en-US.json b/frontend/src/locales/sql-review/en-US.jsonindex 8955506a21..0f5eb3ea30 100644--- a/frontend/src/locales/sql-review/en-US.json+++ b/frontend/src/locales/sql-review/en-US.json@@ -741,6 +741,7 @@},"title": "SQL Review","validation": {+ "number-positive": "Enter a positive number for {{rule}}.","rule-required": "Select at least one rule.","string-array-required": "Add at least one value for {{rule}}."}diff --git a/frontend/src/locales/sql-review/es-ES.json b/frontend/src/locales/sql-review/es-ES.jsonindex 6478d634e2..4589038b39 100644--- a/frontend/src/locales/sql-review/es-ES.json+++ b/frontend/src/locales/sql-review/es-ES.json@@ -741,6 +741,7 @@},"title": "Revisión de SQL","validation": {+ "number-positive": "Ingrese un número positivo para {{rule}}.","rule-required": "Seleccione al menos una regla.","string-array-required": "Agregue al menos un valor para {{rule}}."}diff --git a/frontend/src/locales/sql-review/ja-JP.json b/frontend/src/locales/sql-review/ja-JP.jsonindex 2cd927e398..be0d6d2471 100644--- a/frontend/src/locales/sql-review/ja-JP.json+++ b/frontend/src/locales/sql-review/ja-JP.json@@ -741,6 +741,7 @@},"title": "SQL レビューポリシー","validation": {+ "number-positive": "{{rule}} には正の数を入力してください。","rule-required": "少なくとも 1 つのルールを選択してください。","string-array-required": "{{rule}} に少なくとも 1 つの値を追加してください。"}diff --git a/frontend/src/locales/sql-review/vi-VN.json b/frontend/src/locales/sql-review/vi-VN.jsonindex 4edbff10eb..a8cfdd4eb2 100644--- a/frontend/src/locales/sql-review/vi-VN.json+++ b/frontend/src/locales/sql-review/vi-VN.json@@ -741,6 +741,7 @@},"title": "Đánh giá SQL","validation": {+ "number-positive": "Nhập số dương cho {{rule}}.","rule-required": "Chọn ít nhất một quy tắc.","string-array-required": "Thêm ít nhất một giá trị cho {{rule}}."}diff --git a/frontend/src/locales/sql-review/zh-CN.json b/frontend/src/locales/sql-review/zh-CN.jsonindex 9607ffc82f..af41561746 100644--- a/frontend/src/locales/sql-review/zh-CN.json+++ b/frontend/src/locales/sql-review/zh-CN.json@@ -741,6 +741,7 @@},"title": "SQL 审核策略","validation": {+ "number-positive": "请为 {{rule}} 输入一个正数。","rule-required": "请选择至少一条规则。","string-array-required": "请为 {{rule}} 添加至少一个值。"}diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex abb9864093..de96c3d556 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -1144,6 +1144,9 @@},"ssl-tls-connection": {"link": "Kết nối SSL/TLS"+ },+ "sync-databases": {+ "content": "Khi bật, Bytebase sẽ phát hiện và đồng bộ tất cả cơ sở dữ liệu trong phiên bản này khi tạo. Tắt tùy chọn này nếu bây giờ bạn chỉ muốn đồng bộ các cơ sở dữ liệu đã chọn; bạn có thể đồng bộ thêm cơ sở dữ liệu sau từ trang phiên bản."}},"info-panel": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex c06fb1ca07..6f82d3bdf3 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1144,6 +1144,9 @@},"ssl-tls-connection": {"link": "SSL/TLS 连接"+ },+ "sync-databases": {+ "content": "启用后,Bytebase 会在创建实例时发现并同步该实例中的所有数据库。如果现在只想同步选中的数据库,请关闭此选项;之后仍可在实例页面同步更多数据库。"}},"info-panel": {diff --git a/frontend/src/modules/sql-editor/components/ResultView/DetailPanel.tsx b/frontend/src/modules/sql-editor/components/ResultView/DetailPanel.tsxindex d5dcca68c8..9a5b511ada 100644--- a/frontend/src/modules/sql-editor/components/ResultView/DetailPanel.tsx+++ b/frontend/src/modules/sql-editor/components/ResultView/DetailPanel.tsx@@ -360,6 +360,7 @@ export function DetailPanel({ rows, columns }: DetailPanelProps) {className="h-7 min-w-0 flex-1 border-0 px-2 text-sm focus:ring-0"placeholder={t("sql-editor.result-detail.search")}value={searchQuery}+ autoComplete="off"onChange={(event) => setSearchQuery(event.target.value)}onKeyDown={handleSearchKeyDown}/>diff --git a/frontend/src/routes/auth/SetupPage.test.tsx b/frontend/src/routes/auth/SetupPage.test.tsxindex c565e41127..01ea5f167c 100644--- a/frontend/src/routes/auth/SetupPage.test.tsx+++ b/frontend/src/routes/auth/SetupPage.test.tsx@@ -58,6 +58,12 @@ vi.mock("@/components/auth/AuthFooter", () => ({AuthFooter: () => null,}));+vi.mock("@/components/BytebaseLogo", () => ({+ BytebaseLogo: ({ className }: { className?: string }) => (+ <div className={className} data-testid="bytebase-logo" />+ ),+}));+vi.mock("@/components/ComponentPermissionGuard", () => ({ComponentPermissionGuard: ({ children }: { children: React.ReactNode }) =>children,@@ -134,6 +140,23 @@ beforeEach(async () => {});describe("SetupPage", () => {+ test("shows the Bytebase logo above setup steps", async () => {+ const { container, render, unmount } = renderIntoContainer(<SetupPage />);+ render();+ await flushPromises();++ const logo = container.querySelector('[data-testid="bytebase-logo"]');+ const stepIndicator = container.querySelector(+ '[data-slot="step-indicator"]'+ );+ expect(logo).toBeTruthy();+ expect(logo?.compareDocumentPosition(stepIndicator as Node)).toBe(+ Node.DOCUMENT_POSITION_FOLLOWING+ );++ unmount();+ });+test("finishes setup by navigating to the workspace landing page", async () => {const { container, render, unmount } = renderIntoContainer(<SetupPage />);render();diff --git a/frontend/src/routes/auth/SetupPage.tsx b/frontend/src/routes/auth/SetupPage.tsxindex b392fa4973..4366e363e2 100644--- a/frontend/src/routes/auth/SetupPage.tsx+++ b/frontend/src/routes/auth/SetupPage.tsx@@ -10,6 +10,7 @@ import {WORKSPACE_ROUTE_LANDING,} from "@/app/router/handles";import { AuthFooter } from "@/components/auth/AuthFooter";+import { BytebaseLogo } from "@/components/BytebaseLogo";import { ComponentPermissionGuard } from "@/components/ComponentPermissionGuard";import {ResourceIdField,@@ -18,6 +19,7 @@ import {import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";+import { StepIndicator } from "@/components/ui/step-indicator";import { useAppFeature } from "@/hooks/useAppState";import { useAppStore } from "@/stores/app";import { projectNamePrefix } from "@/stores/modules/v1/common";@@ -192,24 +194,13 @@ function SetupWizard() {},[t]);+ const stepItems = steps.map((title) => ({ title }));return (<div className="w-full mx-auto max-w-2xl py-6 px-4 flex flex-col gap-4">+ <BytebaseLogo className="mx-auto mb-6 h-14 max-w-64" /><div className="sticky top-0 bg-white z-10 pb-4 border-b border-control-border">- <ol className="flex items-center gap-x-4 text-sm">- {steps.map((label, i) => (- <li- key={label}- className={- i === currentStep- ? "text-accent font-medium"- : "text-control-light"- }- >- {i + 1}. {label}- </li>- ))}- </ol>+ <StepIndicator steps={stepItems} currentIndex={currentStep} /></div>{currentStep === 0 && (diff --git a/frontend/src/routes/auth/SignupPage.test.tsx b/frontend/src/routes/auth/SignupPage.test.tsxnew file mode 100644index 0000000000..920c2a2309--- /dev/null+++ b/frontend/src/routes/auth/SignupPage.test.tsx@@ -0,0 +1,108 @@+import type { ReactElement } from "react";+import { act } from "react";+import { createRoot } from "react-dom/client";+import { beforeEach, describe, expect, test, vi } from "vitest";++(+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+).IS_REACT_ACT_ENVIRONMENT = true;++const mocks = vi.hoisted(() => ({+ activeUserCount: 0,+ currentRoute: {+ value: { query: {} as Record<string, string | undefined> },+ },+ loadServerInfo: vi.fn(),+ replace: vi.fn(),+ signup: vi.fn(),+}));++vi.mock("@/app/router", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/app/router")>()),+ router: {+ currentRoute: mocks.currentRoute,+ replace: mocks.replace,+ },+}));++vi.mock("@/stores/app", () => {+ const getState = () => ({+ activeUserCount: () => mocks.activeUserCount,+ loadServerInfo: mocks.loadServerInfo,+ serverInfo: {+ restriction: {+ disallowSignup: false,+ },+ },+ signup: mocks.signup,+ });+ return {+ useAppStore: Object.assign(+ (selector?: (state: ReturnType<typeof getState>) => unknown) =>+ selector ? selector(getState()) : getState(),+ { getState }+ ),+ };+});++vi.mock("@/utils", () => ({+ isValidEmail: (value: string) => /\S+@\S+\.\S+/.test(value),+}));++vi.mock("react-i18next", () => ({+ initReactI18next: { type: "3rdParty", init: () => {} },+ useTranslation: () => ({+ t: (key: string) => key,+ }),+ Trans: ({ i18nKey }: { i18nKey: string }) => i18nKey,+}));++vi.mock("@/components/BytebaseLogo", () => ({+ BytebaseLogo: ({ className }: { className?: string }) => (+ <div className={className} data-testid="bytebase-logo" />+ ),+}));++vi.mock("@/components/auth/AuthFooter", () => ({+ AuthFooter: () => null,+}));++let SignupPage: typeof import("./SignupPage").SignupPage;++const renderIntoContainer = (element: ReactElement) => {+ const container = document.createElement("div");+ const root = createRoot(container);+ return {+ container,+ render: () => {+ act(() => {+ root.render(element);+ });+ },+ unmount: () =>+ act(() => {+ root.unmount();+ }),+ };+};++beforeEach(async () => {+ vi.clearAllMocks();+ mocks.activeUserCount = 0;+ ({ SignupPage } = await import("./SignupPage"));+});++describe("SignupPage", () => {+ test("renders the admin setup title with the normal left-aligned heading layout", () => {+ const { container, render, unmount } = renderIntoContainer(<SignupPage />);+ render();++ const heading = container.querySelector("h2");+ expect(heading?.textContent).toBe("auth.sign-up.admin-title");+ expect(heading?.className).toContain("text-main");+ expect(heading?.querySelector("p")).toBeNull();+ expect(heading?.querySelector(".text-center")).toBeNull();++ unmount();+ });+});diff --git a/frontend/src/routes/auth/SignupPage.tsx b/frontend/src/routes/auth/SignupPage.tsxindex 6c60340412..614c09a928 100644--- a/frontend/src/routes/auth/SignupPage.tsx+++ b/frontend/src/routes/auth/SignupPage.tsx@@ -105,26 +105,24 @@ export function SignupPage() {return (<>- <div className="h-full flex flex-col justify-center mx-auto w-full max-w-sm">+ <div className="h-full flex flex-col justify-center gap-y-4 mx-auto w-full max-w-sm"><div>- <BytebaseLogo className="mx-auto mb-8" />+ <BytebaseLogo className="mx-auto" /><h2 className="text-2xl leading-9 font-medium text-main mt-4">{needAdminSetup ? (- <p className="text-accent font-semibold text-center">- <Trans- i18nKey="auth.sign-up.admin-title"- components={{- account: <span className="text-accent font-semibold" />,- }}- />- </p>+ <Trans+ i18nKey="auth.sign-up.admin-title"+ components={{+ account: <span />,+ }}+ />) : (<span>{t("auth.sign-up.title")}</span>)}</h2></div>- <div className="mt-8">+ <div><form className="flex flex-col gap-y-6 mt-6" onSubmit={trySignup}><div><labeldiff --git a/frontend/src/routes/project/ProjectDatabaseGroupCreatePage.tsx b/frontend/src/routes/project/ProjectDatabaseGroupCreatePage.tsxindex 9c93d5a3fd..7ae24a38c0 100644--- a/frontend/src/routes/project/ProjectDatabaseGroupCreatePage.tsx+++ b/frontend/src/routes/project/ProjectDatabaseGroupCreatePage.tsx@@ -19,17 +19,18 @@ export function ProjectDatabaseGroupCreatePage({if (!project) return null;return (- <DatabaseGroupForm- className="py-4 h-full"- readonly={false}- project={project}- onDismiss={() => router.back()}- onCreated={(databaseGroupName) => {- router.push({- name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,- params: { databaseGroupName },- });- }}- />+ <div className="min-h-full flex-1 relative flex flex-col px-4 pt-4">+ <DatabaseGroupForm+ readonly={false}+ project={project}+ onDismiss={() => router.back()}+ onCreated={(databaseGroupName) => {+ router.push({+ name: PROJECT_V1_ROUTE_DATABASE_GROUP_DETAIL,+ params: { databaseGroupName },+ });+ }}+ />+ </div>);}diff --git a/frontend/src/routes/project/ProjectMaskingExemptionCreatePage.tsx b/frontend/src/routes/project/ProjectMaskingExemptionCreatePage.tsxindex ba9c0f6597..527f67e2bd 100644--- a/frontend/src/routes/project/ProjectMaskingExemptionCreatePage.tsx+++ b/frontend/src/routes/project/ProjectMaskingExemptionCreatePage.tsx@@ -302,7 +302,6 @@ export function ProjectMaskingExemptionCreatePage({{/* Footer */}<StickyActionFooter- className="py-3"left={<Button appearance="outline" onClick={onDismiss}>{t("common.cancel")}diff --git a/frontend/src/routes/project/ProjectSettingsPage.tsx b/frontend/src/routes/project/ProjectSettingsPage.tsxindex 9927833aaf..3a06db3050 100644--- a/frontend/src/routes/project/ProjectSettingsPage.tsx+++ b/frontend/src/routes/project/ProjectSettingsPage.tsx@@ -1127,6 +1127,7 @@ export function ProjectSettingsPage() {{/* ============================================================= */}{allowEdit && isDirty && (<StickyActionFooter+ contentPadding={false}left={<Button appearance="outline" onClick={revert}>{t("common.cancel")}diff --git a/frontend/src/routes/project/ProjectSyncSchemaPage.tsx b/frontend/src/routes/project/ProjectSyncSchemaPage.tsxindex 7367f6a75d..4489194985 100644--- a/frontend/src/routes/project/ProjectSyncSchemaPage.tsx+++ b/frontend/src/routes/project/ProjectSyncSchemaPage.tsx@@ -46,6 +46,7 @@ import {SheetHeader,SheetTitle,} from "@/components/ui/sheet";+import { StepIndicator } from "@/components/ui/step-indicator";import { useClickOutside } from "@/hooks/useClickOutside";import { useEscapeKey } from "@/hooks/useEscapeKey";import { useProjectByName } from "@/hooks/useProjectByName";@@ -526,50 +527,6 @@ export function ProjectSyncSchemaPage({ projectId }: { projectId: string }) {);}-// ============================================================-// StepIndicator-// ============================================================--function StepIndicator({- steps,- currentIndex,-}: {- steps: { title: string }[];- currentIndex: number;-}) {- return (- <div className="flex items-center gap-x-2 px-0.5">- {steps.map((step, i) => (- <div key={i} className="flex items-center gap-x-2">- {i > 0 && <div className="w-8 h-px bg-control-border" />}- <div className="flex items-center gap-x-2">- <div- className={cn(- "size-6 rounded-full flex items-center justify-center text-xs font-medium",- i <= currentIndex- ? "bg-accent text-accent-text"- : "bg-control-bg-hover text-control-light"- )}- >- {i + 1}- </div>- <span- className={cn(- "text-sm",- i <= currentIndex- ? "text-accent font-medium"- : "text-control-light"- )}- >- {step.title}- </span>- </div>- </div>- ))}- </div>- );-}-// ============================================================// SourceSchemaStep// ============================================================diff --git a/frontend/src/routes/project/ProjectWebhookForm.tsx b/frontend/src/routes/project/ProjectWebhookForm.tsxindex cb10a46fd5..9472fd3dd3 100644--- a/frontend/src/routes/project/ProjectWebhookForm.tsx+++ b/frontend/src/routes/project/ProjectWebhookForm.tsx@@ -524,7 +524,6 @@ export function ProjectWebhookForm({{/* Footer */}<StickyActionFooter- className="w-full"left={create ? (<Button appearance="outline" onClick={cancel}>diff --git a/frontend/src/routes/project/database-detail/revision/ImportRevisionSheet.tsx b/frontend/src/routes/project/database-detail/revision/ImportRevisionSheet.tsxindex dfb9439afa..6e98cca2e0 100644--- a/frontend/src/routes/project/database-detail/revision/ImportRevisionSheet.tsx+++ b/frontend/src/routes/project/database-detail/revision/ImportRevisionSheet.tsx@@ -23,6 +23,10 @@ import {SheetHeader,SheetTitle,} from "@/components/ui/sheet";+import {+ StepIndicator,+ type StepIndicatorStep,+} from "@/components/ui/step-indicator";import { cn } from "@/lib/utils";import { pushNotification } from "@/stores";import { useAppStore } from "@/stores/app";@@ -369,7 +373,10 @@ export function ImportRevisionSheet({<SheetTitle>{t("database.revision.import-revision")}</SheetTitle></SheetHeader><SheetBody className="gap-y-4">- <StepIndicator source={selectedSource} currentStep={currentStep} />+ <ImportRevisionStepIndicator+ source={selectedSource}+ currentStep={currentStep}+ />{currentStep === Step.SELECT_SOURCE && (<SourceSelectorselectedSource={selectedSource}@@ -480,50 +487,41 @@ export function ImportRevisionSheet({);}-function StepIndicator({+function ImportRevisionStepIndicator({source,currentStep,}: {- source: "release" | "local";- currentStep: Step;+ readonly source: "release" | "local";+ readonly currentStep: Step;}) {const { t } = useTranslation();- const steps =+ const steps: StepIndicatorStep[] =source === "release"? [- [Step.SELECT_SOURCE, t("database.revision.select-source")],- [Step.SELECT_RELEASE, t("database.revision.select-release")],- [Step.SELECT_FILES, t("database.revision.select-files")],+ {+ key: Step.SELECT_SOURCE,+ title: t("database.revision.select-source"),+ },+ {+ key: Step.SELECT_RELEASE,+ title: t("database.revision.select-release"),+ },+ {+ key: Step.SELECT_FILES,+ title: t("database.revision.select-files"),+ },]: [- [Step.SELECT_SOURCE, t("database.revision.select-source")],- [Step.UPLOAD_FILES, t("database.revision.upload-files")],+ {+ key: Step.SELECT_SOURCE,+ title: t("database.revision.select-source"),+ },+ {+ key: Step.UPLOAD_FILES,+ title: t("database.revision.upload-files"),+ },];- return (- <ol className="flex flex-wrap items-center gap-x-2 gap-y-1 text-sm">- {steps.map(([step, label], index) => (- <li key={step} className="flex items-center gap-x-2">- <span- className={cn(- "inline-flex size-6 items-center justify-center rounded-full border text-xs",- step === currentStep- ? "border-accent bg-accent text-accent-text"- : "border-control-border text-control-light"- )}- >- {index + 1}- </span>- <span- className={- step === currentStep ? "text-control" : "text-control-light"- }- >- {label}- </span>- </li>- ))}- </ol>- );+ return <StepIndicator steps={steps} currentKey={currentStep} />;}function SourceSelector({diff --git a/frontend/src/routes/workspace/CreateInstancePage.tsx b/frontend/src/routes/workspace/CreateInstancePage.tsxindex bc2dc76479..3f5be0da5d 100644--- a/frontend/src/routes/workspace/CreateInstancePage.tsx+++ b/frontend/src/routes/workspace/CreateInstancePage.tsx@@ -125,6 +125,7 @@ function CreateInstanceFormInner() {ssl: t("data-source.ssl-connection"),ssh: t("data-source.ssh-connection"),database: t("common.database"),+ "sync-databases": t("instance.sync-databases.sync-all"),};return titleMap[activeInfoSection] ?? "";}, [activeInfoSection, t]);diff --git a/frontend/src/routes/workspace/EnvironmentsPage.tsx b/frontend/src/routes/workspace/EnvironmentsPage.tsxindex eb679e978a..26a68906fa 100644--- a/frontend/src/routes/workspace/EnvironmentsPage.tsx+++ b/frontend/src/routes/workspace/EnvironmentsPage.tsx@@ -849,7 +849,6 @@ function EnvironmentDetail({{/* Sticky bottom buttons */}{canEdit && hasChanges && (<StickyActionFooter- className="-bottom-2 bg-white"left={<Button appearance="outline" onClick={revert}>{t("common.cancel")}diff --git a/frontend/src/routes/workspace/IDPsPage.tsx b/frontend/src/routes/workspace/IDPsPage.tsxindex 1fa279d43f..6546ba81f9 100644--- a/frontend/src/routes/workspace/IDPsPage.tsx+++ b/frontend/src/routes/workspace/IDPsPage.tsx@@ -39,6 +39,7 @@ import {SheetHeader,SheetTitle,} from "@/components/ui/sheet";+import { StepIndicator } from "@/components/ui/step-indicator";import {Table,TableBody,@@ -1659,40 +1660,10 @@ function CreateWizardDrawer({<SheetBody className="px-6 py-6"><div className="flex flex-col gap-y-6">{/* Step indicators */}- <div className="flex items-center gap-x-2">- {stepLabels.map((label, i) => {- const stepNum = i + 1;- const isActive = stepNum === currentStep;- const isComplete = stepNum < currentStep;- return (- <div key={i} className="flex items-center gap-x-2">- {i > 0 && (- <div- className={`w-8 h-px ${isComplete ? "bg-accent" : "bg-gray-300"}`}- />- )}- <div className="flex items-center gap-x-1.5">- <div- className={`w-7 h-7 rounded-full flex items-center justify-center text-xs font-medium ${- isActive- ? "bg-accent text-white"- : isComplete- ? "bg-accent/20 text-accent"- : "bg-gray-200 text-gray-500"- }`}- >- {stepNum}- </div>- <span- className={`text-sm ${isActive ? "font-medium text-main" : "text-gray-500"}`}- >- {label}- </span>- </div>- </div>- );- })}- </div>+ <StepIndicator+ steps={stepLabels.map((title) => ({ title }))}+ currentIndex={currentStep - 1}+ />{/* Step content */}<div className="bg-white rounded-sm border border-gray-200 px-6 pt-6 pb-10">diff --git a/frontend/src/routes/workspace/InstanceDetailPage.test.tsx b/frontend/src/routes/workspace/InstanceDetailPage.test.tsxindex 9739ae72f2..c8f1236eed 100644--- a/frontend/src/routes/workspace/InstanceDetailPage.test.tsx+++ b/frontend/src/routes/workspace/InstanceDetailPage.test.tsx@@ -153,18 +153,31 @@ vi.mock("@/components/database", () => ({DatabaseBatchOperationsBar: () => null,DatabaseTable: ({onDatabasesChange,+ selectionColumnIntroTarget,}: {onDatabasesChange?: (databases: Database[]) => void;+ selectionColumnIntroTarget?: string;}) => {useEffect(() => {onDatabasesChange?.(mocks.databases);}, [onDatabasesChange]);- return <div />;+ return (+ <div+ data-selection-column-intro-target={selectionColumnIntroTarget ?? ""}+ />+ );},LabelEditorSheet: () => null,TransferProjectSheet: () => null,}));+vi.mock("@/lib/productIntro", () => ({+ PREPARE_DATABASE_PRODUCT_INTRO: "prepare-database",+ PREPARE_DATABASE_TRANSFER_TIP: "transfer-databases-to-project",+ PRODUCT_INTRO_TIP_QUERY_KEY: "tip",+ useProductIntro: vi.fn(),+}));+import { InstanceDetailPage } from "./InstanceDetailPage";let container: HTMLDivElement;@@ -231,4 +244,21 @@ describe("InstanceDetailPage", () => {"db.instance-databases-synced-title");});++ it("highlights the database selection column for the post-sync transfer guide", async () => {+ mocks.location.search =+ "?syncingInstance=prod&intro=prepare-database&tip=transfer-databases-to-project";+ mocks.projects = [+ { name: "projects/default" },+ { name: "projects/app" },+ ] as Project[];++ await render(<InstanceDetailPage instanceId="prod" />);++ expect(+ container+ .querySelector("[data-selection-column-intro-target]")+ ?.getAttribute("data-selection-column-intro-target")+ ).toBe("prepare-database");+ });});diff --git a/frontend/src/routes/workspace/InstanceDetailPage.tsx b/frontend/src/routes/workspace/InstanceDetailPage.tsxindex 6452199754..a69603eb25 100644--- a/frontend/src/routes/workspace/InstanceDetailPage.tsx+++ b/frontend/src/routes/workspace/InstanceDetailPage.tsx@@ -35,6 +35,12 @@ import { Button } from "@/components/ui/button";import { Tabs, TabsList, TabsPanel, TabsTrigger } from "@/components/ui/tabs";import { useUnsavedChangesGuard } from "@/hooks/useUnsavedChangesGuard";import type { DatabaseFilter } from "@/lib/databaseFilter";+import {+ PREPARE_DATABASE_PRODUCT_INTRO,+ PREPARE_DATABASE_TRANSFER_TIP,+ PRODUCT_INTRO_TIP_QUERY_KEY,+ useProductIntro,+} from "@/lib/productIntro";import { pushNotification } from "@/stores";import { useAppStore } from "@/stores/app";import {@@ -126,10 +132,17 @@ export function InstanceDetailPage({ instanceId }: { instanceId: string }) {setSelectedNames(new Set());}, []);- const syncingInstanceId = useMemo(() => {- const query = new URLSearchParams(location.search);- return query.get("syncingInstance") || undefined;- }, [location.search]);+ const locationQuery = useMemo(+ () => new URLSearchParams(location.search),+ [location.search]+ );+ const syncingInstanceId = useMemo(+ () => locationQuery.get("syncingInstance") || undefined,+ [locationQuery]+ );+ const showPrepareDatabaseTip =+ locationQuery.get(PRODUCT_INTRO_TIP_QUERY_KEY) ===+ PREPARE_DATABASE_TRANSFER_TIP;useEffect(() => {if (!syncingInstanceId || visibleDatabases.length > 0) {@@ -502,6 +515,14 @@ export function InstanceDetailPage({ instanceId }: { instanceId: string }) {syncingRefreshExhausted;const showPostSyncTransferAction =!!syncingInstanceId && visibleDatabases.length > 0 && hasUserProject;+ const shouldShowTransferIntro =+ showPrepareDatabaseTip && showPostSyncTransferAction;+ useProductIntro({+ id: PREPARE_DATABASE_PRODUCT_INTRO,+ title: t("workspace-setup-guide.intro.transfer-title"),+ description: t("workspace-setup-guide.intro.transfer-description"),+ disabled: !shouldShowTransferIntro,+ });const syncingInstanceName = syncingInstanceId? `${instanceNamePrefix}${syncingInstanceId}`: undefined;@@ -665,6 +686,11 @@ export function InstanceDetailPage({ instanceId }: { instanceId: string }) {onSelectedNamesChange={setSelectedNames}onDatabasesChange={setVisibleDatabases}refreshToken={refreshToken}+ selectionColumnIntroTarget={+ shouldShowTransferIntro+ ? PREPARE_DATABASE_PRODUCT_INTRO+ : undefined+ }/>{/* Batch operations bar is fixed within the visible main content. */}<DatabaseBatchOperationsBardiff --git a/frontend/src/routes/workspace/SQLReviewDetailPage.test.tsx b/frontend/src/routes/workspace/SQLReviewDetailPage.test.tsxnew file mode 100644index 0000000000..c8ceaa7502--- /dev/null+++ b/frontend/src/routes/workspace/SQLReviewDetailPage.test.tsx@@ -0,0 +1,175 @@+import type { ReactElement, ReactNode } from "react";+import { act } from "react";+import { createRoot } from "react-dom/client";+import { beforeEach, describe, expect, test, vi } from "vitest";++(+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+).IS_REACT_ACT_ENVIRONMENT = true;++const mocks = vi.hoisted(() => ({+ getOrFetchReviewPolicyByName: vi.fn(),+ getReviewPolicyByName: vi.fn(),+ removeReviewPolicy: vi.fn(),+ replace: vi.fn(),+ upsertReviewPolicy: vi.fn(),+}));++vi.mock("react-i18next", () => ({+ initReactI18next: { type: "3rdParty", init: () => {} },+ useTranslation: () => ({ t: (key: string) => key }),+}));++vi.mock("@/app/router", () => ({+ router: {+ replace: mocks.replace,+ },+}));++vi.mock("@/components/PermissionGuard", () => ({+ PermissionGuard: ({ children }: { children: ReactNode }) => children,+}));++vi.mock("@/components/sql-review/Panels", () => ({+ AttachResourcesPanel: () => null,+}));++vi.mock("@/components/sql-review/ResourceLink", () => ({+ ResourceLink: ({ resource }: { resource: string }) => <span>{resource}</span>,+}));++vi.mock("@/components/sql-review/RuleTable", () => ({+ RuleTableWithFilter: ({+ onRuleUpsert,+ }: {+ onRuleUpsert: (rule: { engine: number; type: number }, update: object) => void;+ }) => (+ <button+ type="button"+ onClick={() => onRuleUpsert({ engine: 1, type: 1 }, { level: 2 })}+ >+ Change rule+ </button>+ ),+}));++vi.mock("@/components/sql-review/TabsByEngine", () => ({+ TabsByEngine: ({+ children,+ }: {+ children: (ruleList: unknown[], engine: number) => ReactNode;+ }) => <div>{children([], 1)}</div>,+}));++vi.mock("@/stores", () => ({+ pushNotification: vi.fn(),+}));++vi.mock("@/stores/sqlReview", () => ({+ useSQLReviewStore: Object.assign(+ () => ({+ getReviewPolicyByName: mocks.getReviewPolicyByName,+ removeReviewPolicy: mocks.removeReviewPolicy,+ upsertReviewPolicy: mocks.upsertReviewPolicy,+ }),+ {+ getState: () => ({+ getOrFetchReviewPolicyByName: mocks.getOrFetchReviewPolicyByName,+ }),+ }+ ),+}));++vi.mock("@/utils", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@/utils")>()),+ hasWorkspacePermissionV2: vi.fn(() => true),+ setDocumentTitle: vi.fn(),+ sqlReviewNameFromSlug: (slug: string) => slug,+}));++let SQLReviewDetailPage: typeof import("./SQLReviewDetailPage").SQLReviewDetailPage;++const renderIntoContainer = (element: ReactElement) => {+ const container = document.createElement("div");+ document.body.appendChild(container);+ const root = createRoot(container);++ act(() => {+ root.render(element);+ });++ return {+ container,+ unmount: () =>+ act(() => {+ root.unmount();+ container.remove();+ }),+ };+};++beforeEach(async () => {+ vi.clearAllMocks();+ mocks.getReviewPolicyByName.mockReturnValue({+ id: "policy-1",+ enforce: true,+ name: "Sample SQL Review Config",+ ruleList: [],+ resources: ["projects/sample"],+ });+ ({ SQLReviewDetailPage } = await import("./SQLReviewDetailPage"));+});++describe("SQLReviewDetailPage", () => {+ test("keeps changed-rule actions at the bottom without extra side inset", () => {+ const { container, unmount } = renderIntoContainer(+ <SQLReviewDetailPage sqlReviewPolicySlug="policy-1" />+ );++ expect(container.firstElementChild).toHaveClass(+ "flex",+ "h-full",+ "min-h-0",+ "flex-col",+ "overflow-hidden"+ );++ act(() => {+ [...container.querySelectorAll("button")]+ .find((button) => button.textContent === "Change rule")+ ?.dispatchEvent(new MouseEvent("click", { bubbles: true }));+ });++ const footer = container.querySelector('[data-slot="sticky-action-footer"]');+ const scrollContent = container.querySelector(+ '[data-slot="sql-review-detail-content"]'+ );+ const content = container.querySelector(+ '[data-slot="sticky-action-footer-content"]'+ );++ expect(scrollContent).toHaveClass("min-h-0", "flex-1", "overflow-y-auto");+ expect(footer?.previousElementSibling).toBe(scrollContent);+ expect(footer).toHaveClass("shrink-0");+ expect(footer).not.toHaveClass("mt-4");+ expect(footer).not.toHaveClass("mt-auto");+ expect(content).toHaveClass("px-4", "sm:px-6", "gap-x-2", "gap-y-2");++ unmount();+ });++ test("keeps the delete policy action at its natural button width", () => {+ const { container, unmount } = renderIntoContainer(+ <SQLReviewDetailPage sqlReviewPolicySlug="policy-1" />+ );++ const deleteButton = [...container.querySelectorAll("button")].find(+ (button) => button.textContent === "sql-review.delete"+ );++ expect(deleteButton).toHaveClass("self-start");+ expect(deleteButton).not.toHaveClass("w-full");++ unmount();+ });+});diff --git a/frontend/src/routes/workspace/SQLReviewDetailPage.tsx b/frontend/src/routes/workspace/SQLReviewDetailPage.tsxindex 37082591be..86dedde036 100644--- a/frontend/src/routes/workspace/SQLReviewDetailPage.tsx+++ b/frontend/src/routes/workspace/SQLReviewDetailPage.tsx@@ -242,149 +242,157 @@ export function SQLReviewDetailPage({}return (- <div className="px-4 py-4">- {/* Disabled warning */}- {!reviewPolicy.enforce && (- <Alert- variant="warning"- className="mb-4"- description={t("sql-review.disabled")}- />- )}-- {/* Header: title + actions */}- <div className="flex flex-col gap-y-2 items-start md:items-center gap-x-2 justify-center md:flex-row">- {editingTitle ? (- <Input- className="flex-1 text-xl font-bold"- defaultValue={reviewPolicy.name}- autoFocus- onBlur={(e) => changeName(e.target.value)}- onKeyDown={(e) => {- if (e.key === "Enter")- changeName((e.target as HTMLInputElement).value);- }}+ <div className="flex h-full min-h-0 flex-col overflow-hidden">+ <div+ data-slot="sql-review-detail-content"+ className="min-h-0 flex-1 overflow-y-auto px-4 py-4"+ >+ {/* Disabled warning */}+ {!reviewPolicy.enforce && (+ <Alert+ variant="warning"+ className="mb-4"+ description={t("sql-review.disabled")}/>- ) : (- <h1- className="flex-1 text-xl font-bold truncate cursor-text px-0.5"- onClick={() => {- if (hasUpdatePermission) {- setEditingTitle(true);- }- }}- >- {reviewPolicy.name}- </h1>)}- <div className="flex gap-x-2">- <PermissionGuard permissions={["bb.reviewConfigs.update"]}>- {reviewPolicy.enforce ? (++ {/* Header: title + actions */}+ <div className="flex flex-col gap-y-2 items-start md:items-center gap-x-2 justify-center md:flex-row">+ {editingTitle ? (+ <Input+ className="flex-1 text-xl font-bold"+ defaultValue={reviewPolicy.name}+ autoFocus+ onBlur={(e) => changeName(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === "Enter")+ changeName((e.target as HTMLInputElement).value);+ }}+ />+ ) : (+ <h1+ className="flex-1 text-xl font-bold truncate cursor-text px-0.5"+ onClick={() => {+ if (hasUpdatePermission) {+ setEditingTitle(true);+ }+ }}+ >+ {reviewPolicy.name}+ </h1>+ )}+ <div className="flex gap-x-2">+ <PermissionGuard permissions={["bb.reviewConfigs.update"]}>+ {reviewPolicy.enforce ? (+ <Button+ appearance="outline"+ disabled={!hasUpdatePermission}+ onClick={() => setShowDisableModal(true)}+ >+ {t("common.disable")}+ </Button>+ ) : (+ <Button+ appearance="outline"+ disabled={!hasUpdatePermission}+ onClick={() => setShowEnableModal(true)}+ >+ {t("common.enable")}+ </Button>+ )}+ </PermissionGuard>+ <PermissionGuard permissions={["bb.policies.update"]}><Buttonappearance="outline"- disabled={!hasUpdatePermission}- onClick={() => setShowDisableModal(true)}+ disabled={!hasWorkspacePermissionV2("bb.policies.update")}+ onClick={() => setShowResourcePanel(true)}>- {t("common.disable")}+ {t("sql-review.attach-resource.change-resources")}</Button>- ) : (+ </PermissionGuard>+ <PermissionGuard permissions={["bb.reviewConfigs.update"]}><Button- appearance="outline"disabled={!hasUpdatePermission}- onClick={() => setShowEnableModal(true)}+ onClick={() => setEditMode(true)}>- {t("common.enable")}+ {t("sql-review.create.configure-rule.change-template")}</Button>+ </PermissionGuard>+ </div>+ </div>++ {/* Attached resources */}+ <div className="mt-4 flex flex-col gap-y-4">+ {reviewPolicy.resources.length === 0 && (+ <Alert+ variant="warning"+ description={+ <div className="flex items-center justify-between">+ <div>+ <p className="font-medium">+ {t("sql-review.attach-resource.no-linked-resources")}+ </p>+ <p className="text-sm mt-1">+ {t("sql-review.attach-resource.label")}+ </p>+ </div>+ <Button+ appearance="outline"+ size="sm"+ onClick={() => setShowResourcePanel(true)}+ >+ {t("sql-review.attach-resource.self")}+ </Button>+ </div>+ }+ />+ )}+ <div className="flex flex-wrap gap-y-2 gap-x-2">+ {reviewPolicy.resources.map((resource) => (+ <Badge key={resource} variant="default">+ <ResourceLink resource={resource} />+ </Badge>+ ))}+ </div>+ </div>++ {/* Rules by engine */}+ <div className="mt-5">+ <TabsByEngine ruleMapByEngine={ruleMapByEngine}>+ {(ruleList, engine) => (+ <RuleTableWithFilter+ engine={engine}+ ruleList={ruleList}+ editable={hasUpdatePermission}+ onRuleUpsert={markChange}+ onRuleRemove={removeRule}+ />)}- </PermissionGuard>- <PermissionGuard permissions={["bb.policies.update"]}>+ </TabsByEngine>+ </div>++ <div data-slot="sql-review-detail-bottom-actions" className="mt-6">+ {/* Delete button */}+ <hr className="mb-6" />+ <PermissionGuard permissions={["bb.reviewConfigs.delete"]}><Button+ variant="destructive"appearance="outline"- disabled={!hasWorkspacePermissionV2("bb.policies.update")}- onClick={() => setShowResourcePanel(true)}- >- {t("sql-review.attach-resource.change-resources")}- </Button>- </PermissionGuard>- <PermissionGuard permissions={["bb.reviewConfigs.update"]}>- <Button- disabled={!hasUpdatePermission}- onClick={() => setEditMode(true)}+ className="self-start"+ disabled={!hasDeletePermission}+ onClick={() => setShowDeleteConfirm(true)}>- {t("sql-review.create.configure-rule.change-template")}+ <Trash2 className="w-4 h-4 mr-1" />+ {t("sql-review.delete")}</Button></PermissionGuard></div></div>- {/* Attached resources */}- <div className="mt-4 flex flex-col gap-y-4">- {reviewPolicy.resources.length === 0 && (- <Alert- variant="warning"- description={- <div className="flex items-center justify-between">- <div>- <p className="font-medium">- {t("sql-review.attach-resource.no-linked-resources")}- </p>- <p className="text-sm mt-1">- {t("sql-review.attach-resource.label")}- </p>- </div>- <Button- appearance="outline"- size="sm"- onClick={() => setShowResourcePanel(true)}- >- {t("sql-review.attach-resource.self")}- </Button>- </div>- }- />- )}- <div className="flex flex-wrap gap-y-2 gap-x-2">- {reviewPolicy.resources.map((resource) => (- <Badge key={resource} variant="default">- <ResourceLink resource={resource} />- </Badge>- ))}- </div>- </div>-- {/* Rules by engine */}- <div className="mt-5">- <TabsByEngine ruleMapByEngine={ruleMapByEngine}>- {(ruleList, engine) => (- <RuleTableWithFilter- engine={engine}- ruleList={ruleList}- editable={hasUpdatePermission}- onRuleUpsert={markChange}- onRuleRemove={removeRule}- />- )}- </TabsByEngine>- </div>-- {/* Delete button */}- <hr className="my-6" />- <PermissionGuard permissions={["bb.reviewConfigs.delete"]}>- <Button- variant="destructive"- appearance="outline"- disabled={!hasDeletePermission}- onClick={() => setShowDeleteConfirm(true)}- >- <Trash2 className="w-4 h-4 mr-1" />- {t("sql-review.delete")}- </Button>- </PermissionGuard>-{/* Sticky save bar when rules changed */}{rulesUpdated && (<StickyActionFooter- className="mt-4 py-2 border-control-border"+ className="shrink-0 border-control-border"left={<Button appearance="outline" onClick={onCancelChanges}>{t("common.cancel")}diff --git a/frontend/src/routes/workspace/general/GeneralPage.tsx b/frontend/src/routes/workspace/general/GeneralPage.tsxindex 5e4379b500..c43da2dea3 100644--- a/frontend/src/routes/workspace/general/GeneralPage.tsx+++ b/frontend/src/routes/workspace/general/GeneralPage.tsx@@ -222,6 +222,7 @@ export function GeneralPage() {{isDirty && (<StickyActionFooter+ contentPadding={false}left={<Button appearance="outline" onClick={handleRevert}>{t("common.cancel")}diff --git a/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.tsx b/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.tsxindex c10000ffdd..975df20800 100644--- a/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.tsx+++ b/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.tsx@@ -1,7 +1,6 @@import { create } from "@bufbuild/protobuf";import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";import type { ConnectError } from "@connectrpc/connect";-import { Check } from "lucide-react";import { QRCodeSVG } from "qrcode.react";import { useCallback, useEffect, useRef, useState } from "react";import { useTranslation } from "react-i18next";@@ -13,6 +12,7 @@ import {import { LearnMoreLink } from "@/components/LearnMoreLink";import { Button } from "@/components/ui/button";import { OtpInput } from "@/components/ui/otp-input";+import { StepIndicator } from "@/components/ui/step-indicator";import { useCurrentUser } from "@/hooks/useAppState";import { pushNotification } from "@/stores";import { useAppStore } from "@/stores/app";@@ -216,8 +216,8 @@ export function TwoFactorSetupPage({ cancelAction }: TwoFactorSetupPageProps) {: recoveryCodesDownloaded;const steps = [- t("two-factor.setup-steps.setup-auth-app.self"),- t("two-factor.setup-steps.download-recovery-codes.self"),+ { title: t("two-factor.setup-steps.setup-auth-app.self") },+ { title: t("two-factor.setup-steps.download-recovery-codes.self") },];return (@@ -231,33 +231,11 @@ export function TwoFactorSetupPage({ cancelAction }: TwoFactorSetupPageProps) {</p>{/* Step indicator */}- <div className="flex items-center gap-x-4 mb-8">- {steps.map((title, index) => (- <div key={index} className="flex items-center gap-x-2">- <div- className={`flex items-center justify-center w-7 h-7 rounded-full text-sm font-medium ${- index < currentStep- ? "bg-accent text-white"- : index === currentStep- ? "bg-accent text-white"- : "bg-gray-200 text-gray-600"- }`}- >- {index < currentStep ? <Check className="w-4 h-4" /> : index + 1}- </div>- <span- className={`text-sm font-medium ${- index === currentStep ? "text-accent" : "text-gray-500"- }`}- >- {title}- </span>- {index < steps.length - 1 && (- <div className="w-12 h-px bg-gray-300 ml-2" />- )}- </div>- ))}- </div>+ <StepIndicator+ className="mb-8"+ steps={steps}+ currentIndex={currentStep}+ />{/* Step content */}{currentStep === SETUP_AUTH_APP_STEP && (diff --git a/frontend/src/types/sqlReview.test.ts b/frontend/src/types/sqlReview.test.tsindex 64d7de4ece..b479234fdd 100644--- a/frontend/src/types/sqlReview.test.ts+++ b/frontend/src/types/sqlReview.test.ts@@ -239,6 +239,28 @@ describe("convertRuleMapToPolicyRuleList", () => {],});+ const numberRule = (+ type: SQLReviewRule_Type,+ value: number+ ): RuleTemplateV2 => ({+ type,+ category: "BUILTIN",+ engine: Engine.MYSQL,+ level: SQLReviewRule_Level.ERROR,+ componentList: [+ {+ key: "number",+ payload: {+ type: "NUMBER",+ default: 2,+ value,+ unit: "MB",+ factor: 1024 * 1024,+ },+ },+ ],+ });+const requiredStringArrayRuleTypes = [SQLReviewRule_Type.COLUMN_REQUIRED,SQLReviewRule_Type.COLUMN_TYPE_DISALLOW_LIST,@@ -271,6 +293,59 @@ describe("convertRuleMapToPolicyRuleList", () => {});});+ test("reports non-positive number payloads after unit conversion", () => {+ const ruleMap = new Map([+ [+ Engine.MYSQL,+ new Map([+ [+ SQLReviewRule_Type.BUILTIN_STATEMENT_MAXIMUM_SQL_SIZE,+ numberRule(+ SQLReviewRule_Type.BUILTIN_STATEMENT_MAXIMUM_SQL_SIZE,+ 0+ ),+ ],+ ]),+ ],+ ]);++ expect(validateRuleMapByEngine(ruleMap)).toMatchObject({+ type: "INVALID_NUMBER",+ rule: { type: SQLReviewRule_Type.BUILTIN_STATEMENT_MAXIMUM_SQL_SIZE },+ });+ });++ test("allows zero number payloads for naming rules", () => {+ const rule: RuleTemplateV2 = {+ type: SQLReviewRule_Type.NAMING_TABLE,+ category: "NAMING",+ engine: Engine.MYSQL,+ level: SQLReviewRule_Level.ERROR,+ componentList: [+ {+ key: "format",+ payload: {+ type: "STRING",+ default: "^[a-z]+(_[a-z]+)*$",+ },+ },+ {+ key: "max-length",+ payload: {+ type: "NUMBER",+ default: 0,+ value: 0,+ },+ },+ ],+ };+ const ruleMap = new Map([+ [Engine.MYSQL, new Map([[SQLReviewRule_Type.NAMING_TABLE, rule]])],+ ]);++ expect(validateRuleMapByEngine(ruleMap)).toBeUndefined();+ });+test("keeps configured table DDL and DML deny-list rules valid", () => {const ruleMap = new Map([[diff --git a/frontend/src/types/sqlReview.ts b/frontend/src/types/sqlReview.tsindex cc87d6ede8..6e0983bb41 100644--- a/frontend/src/types/sqlReview.ts+++ b/frontend/src/types/sqlReview.ts@@ -763,7 +763,8 @@ export const convertRuleMapToPolicyRuleList = (export type RuleMapValidationError =| { type: "EMPTY_RULE_LIST" }- | { type: "EMPTY_STRING_ARRAY"; rule: RuleTemplateV2 };+ | { type: "EMPTY_STRING_ARRAY"; rule: RuleTemplateV2 }+ | { type: "INVALID_NUMBER"; rule: RuleTemplateV2 };const nonEmptyStringArrayRuleTypeList = new Set<SQLReviewRule_Type>([SQLReviewRule_Type.COLUMN_REQUIRED,@@ -788,6 +789,12 @@ export const validateRuleMapByEngine = (if (hasEmptyRequiredStringArray(rule)) {return { type: "EMPTY_STRING_ARRAY", rule };}+ if (+ rule.type === SQLReviewRule_Type.BUILTIN_STATEMENT_MAXIMUM_SQL_SIZE &&+ hasInvalidNumber(rule)+ ) {+ return { type: "INVALID_NUMBER", rule };+ }}}@@ -813,6 +820,18 @@ const hasEmptyRequiredStringArray = (rule: RuleTemplateV2): boolean => {);};+const hasInvalidNumber = (rule: RuleTemplateV2): boolean => {+ const numberPayload = rule.componentList.find(+ (c) => c.payload.type === "NUMBER"+ )?.payload as NumberPayload | undefined;+ if (!numberPayload) {+ return false;+ }++ const value = numberPayloadToStorageValue(numberPayload);+ return !Number.isFinite(value) || value <= 0;+};+// The convertRuleTemplateToPolicyRule will convert rule template to review policy rule for backend useage.// Will throw exception if we don't implement the payload handler for specific type of rule.const convertRuleTemplateToPolicyRule = (