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(frontend): ui guideline for instance form (#21473)
ecmadao393de434cd26
diff --git a/docs/agents/frontend-ux.md b/docs/agents/frontend-ux.mdindex e92d4d9d9f..8710ac199e 100644--- a/docs/agents/frontend-ux.md+++ b/docs/agents/frontend-ux.md@@ -194,6 +194,20 @@ behavior:- Required fields, disabled state, pending state, and server errors MUST remainunderstandable without color alone.+### Choice Controls++- Use the shared `Switch` only for an independent binary behavior: its label+ names the behavior being enabled, such as "Use SSH tunnel" or "Sync all+ databases". The off state MUST have a clear, meaningful result.+- Use `RadioGroup` for two peer values where neither value is an enabled or+ disabled version of the other, such as `TCP` versus `UDP`. Keep both values+ visible when users need to compare them or their descriptions.+- Use the shared `Select` dropdown for more than two mutually exclusive+ options. It MAY also be used for two peer values when space is constrained+ and comparison is unnecessary.+- Do not use `SegmentedControl` for ordinary form values. Reserve it for+ compact view or mode controls outside forms.+### Dense Horizontal FormsMulti-option connection forms MAY use horizontal fields through shared form@@ -208,19 +222,19 @@ third column for section titles.- Keep concise descriptions and validation beside the control they explain.Long secondary guidance that would make a dense form harder to scan MAY usea focusable info tooltip beside the field title; validation and essential- status remain visible beside the control. Associate labels and radio groups+ status remain visible beside the control. Associate labels and choice controlswith accessible names in both layouts.- Put choices that determine subsequent fields first. Use one `Select` dropdowncombining authentication methods and password sources. Do not add a separate- password-source selector. Keep synchronization choices visible in a- `SegmentedControl`.+ password-source selector. Use a `Switch` for binary choices such as syncing+ all databases; reveal the selected-database controls only when it is off.- Reveal the selected authentication method's fields below the selector.External sources reveal their configuration there. Preserve separate draftswhile switching sources, and submit only the active source. Reveal dependentTLS, SSH, IAM, and external-source configuration below its controllingchoice, using nested flow rather than a framed surface inside another frame.- Keep security modes visible; reveal their dependent fields when selected.- Switches, segmented controls, and radio groups align to the start of their+ Switches, select triggers, and radio groups align to the start of theircontrol column. Keep ordinary connection rows on the 16px rhythm using`FormFieldGroup density="compact"`, including across engine-specific fieldgroups. Empty conditional groups MUST NOT reserve space. Larger gaps need adiff --git a/frontend/src/components/AdvancedSearch.tsx b/frontend/src/components/AdvancedSearch.tsxindex 8ee7d9bc84..1bce5433e5 100644--- a/frontend/src/components/AdvancedSearch.tsx+++ b/frontend/src/components/AdvancedSearch.tsx@@ -764,6 +764,7 @@ export function AdvancedSearch({"flex-1 bg-transparent border-none px-2 text-sm text-main placeholder:text-control-placeholder focus:outline-none focus:border-none focus:ring-0 focus:shadow-none",visibleTags.length > 0 ? "min-w-[40px]" : "min-w-[120px]")}+ autoComplete="off"value={inputText}placeholder={visibleTags.length > 0 ? "" : (placeholder ?? t("common.filter"))diff --git a/frontend/src/components/TableSchemaViewer.tsx b/frontend/src/components/TableSchemaViewer.tsxindex 38799b80d2..7b1e8ab946 100644--- a/frontend/src/components/TableSchemaViewer.tsx+++ b/frontend/src/components/TableSchemaViewer.tsx@@ -1,12 +1,8 @@import { create } from "@bufbuild/protobuf";-import { Copy } from "lucide-react";import { useEffect, useState } from "react";-import { useTranslation } from "react-i18next";import { databaseServiceClientConnect } from "@/api";import { ReadonlyMonaco } from "@/components/monaco/ReadonlyMonaco";-import { Button } from "@/components/ui/button";-import { Tooltip } from "@/components/ui/tooltip";-import { writeTextToClipboard } from "@/lib/clipboard";+import { CopyButton } from "@/components/ui/copy-button";import {type Database,type GetSchemaStringRequest_ObjectType,@@ -35,7 +31,6 @@ export function TableSchemaViewer({type,className,}: Props) {- const { t } = useTranslation();const [schemaString, setSchemaString] = useState<string>("");const engine = getInstanceResource(database).engine;@@ -64,10 +59,6 @@ export function TableSchemaViewer({};}, [database.name, schema, object, type]);- const handleCopy = async () => {- await writeTextToClipboard(schemaString);- };-return (<divclassName={`w-full h-auto flex flex-col justify-start items-center ${className ?? ""}`}@@ -76,17 +67,7 @@ export function TableSchemaViewer({<div className="text-sm text-control flex-1 truncate">{resourceName}</div>- <Tooltip content={t("common.copy")}>- <Button- type="button"- appearance="secondary"- size="sm"- disabled={!schemaString}- onClick={handleCopy}- >- <Copy className="size-4" />- </Button>- </Tooltip>+ <CopyButton content={schemaString} disabled={!schemaString} size="sm" /></div><ReadonlyMonacocontent={schemaString}diff --git a/frontend/src/components/instance/CreateDataSourceExample.test.tsx b/frontend/src/components/instance/CreateDataSourceExample.test.tsxindex 0bf5eee009..502f96f9c2 100644--- a/frontend/src/components/instance/CreateDataSourceExample.test.tsx+++ b/frontend/src/components/instance/CreateDataSourceExample.test.tsx@@ -6,6 +6,7 @@ import { DataSource_AuthenticationType, DataSourceType } from "@/types/proto-es/import { CreateDataSourceExample } from "./CreateDataSourceExample";vi.mock("react-i18next", () => ({+ initReactI18next: { type: "3rdParty", init: () => {} },useTranslation: () => ({ t: (key: string) => key.split(".").reduce<unknown>((value, part) => (value as Record<string, unknown>)[part], enUS) }),}));vi.mock("@/types", () => ({@@ -14,6 +15,7 @@ vi.mock("@/types", () => ({languageOfEngineV1: () => "sql",}));vi.mock("@/lib/clipboard", () => ({ writeTextToClipboard: vi.fn() }));+vi.mock("@/components/ui/copy-button", () => ({ CopyButton: () => null }));afterEach(cleanup);test.each([diff --git a/frontend/src/components/instance/CreateDataSourceExample.tsx b/frontend/src/components/instance/CreateDataSourceExample.tsxindex 8e35f576cf..e9a96b94af 100644--- a/frontend/src/components/instance/CreateDataSourceExample.tsx+++ b/frontend/src/components/instance/CreateDataSourceExample.tsx@@ -1,8 +1,7 @@import { useCallback, useMemo, useState } from "react";import { useTranslation } from "react-i18next";import { Alert } from "@/components/ui/alert";-import { Button } from "@/components/ui/button";-import { writeTextToClipboard } from "@/lib/clipboard";+import { CopyButton } from "@/components/ui/copy-button";import {DATASOURCE_ADMIN_USER_NAME,DATASOURCE_READONLY_USER_NAME,@@ -469,10 +468,6 @@ export function CreateDataSourceExample({[engine, dataSourceType, authenticationType]);- const handleCopy = useCallback(() => {- void writeTextToClipboard(grantStatement);- }, [grantStatement]);-const toggleExample = useCallback(() => {setShowExample((prev) => !prev);}, []);@@ -509,24 +504,10 @@ export function CreateDataSourceExample({<pre className="flex-1 min-w-0 w-full inline-flex items-center px-3 py-2 border border-r border-control-border bg-control-bg/50 text-sm whitespace-pre-line rounded-l-xs font-mono overflow-auto">{grantStatement}</pre>- <Button- type="button"- appearance="secondary"- size="xs"+ <CopyButton+ content={grantStatement}className="-ml-px h-auto rounded-r-xs border border-control-border bg-control-bg/50 px-2 py-2 text-sm text-control-light hover:bg-control-bg focus:ring-control"- onClick={handleCopy}- title="Copy"- >- <svg- className="w-4 h-4"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- >- <rect x="9" y="9" width="13" height="13" rx="2" ry="2" />- <path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />- </svg>- </Button>+ /></div></div>)}diff --git a/frontend/src/components/instance/CredentialSourceForm.test.tsx b/frontend/src/components/instance/CredentialSourceForm.test.tsxindex a7dbc2d81e..553c95f774 100644--- a/frontend/src/components/instance/CredentialSourceForm.test.tsx+++ b/frontend/src/components/instance/CredentialSourceForm.test.tsx@@ -183,8 +183,9 @@ describe("CredentialSourceForm", () => {const { container, unmount } = render(<StatefulCredentialSourceForm />);- const radios = container.querySelectorAll('[role="radio"]');- const specificCredential = radios[1] as HTMLElement;+ const specificCredential = container.querySelector(+ '[role="switch"]'+ ) as HTMLElement;act(() => {specificCredential.click();});@@ -218,12 +219,12 @@ describe("CredentialSourceForm", () => {const { container, unmount } = render(<StatefulCredentialSourceForm />);- const radios = container.querySelectorAll('[role="radio"]');- const defaultCredential = radios[0] as HTMLElement;- const specificCredential = radios[1] as HTMLElement;+ const specificCredential = container.querySelector(+ '[role="switch"]'+ ) as HTMLElement;- expect(defaultCredential.getAttribute("aria-checked")).toBe("false");expect(specificCredential.getAttribute("aria-checked")).toBe("true");+ expect(specificCredential).toHaveAttribute("aria-disabled", "true");expect(container.querySelector("textarea")?.getAttribute("placeholder")).toBe("instance.type-or-paste-credentials-write-only");@@ -252,11 +253,9 @@ describe("CredentialSourceForm", () => {/>);- const radios = container.querySelectorAll('[role="radio"]');- const specificCredential = radios[1] as HTMLElement;- act(() => {- specificCredential.click();- });+ const specificCredential = container.querySelector(+ '[role="switch"]'+ ) as HTMLElement;expect(specificCredential.getAttribute("aria-checked")).toBe("true");expect(onDataSourceChange).not.toHaveBeenCalled();diff --git a/frontend/src/components/instance/CredentialSourceForm.tsx b/frontend/src/components/instance/CredentialSourceForm.tsxindex 9e8ca6095f..b3aba4647d 100644--- a/frontend/src/components/instance/CredentialSourceForm.tsx+++ b/frontend/src/components/instance/CredentialSourceForm.tsx@@ -7,7 +7,15 @@ import {useState,} from "react";import { Trans, useTranslation } from "react-i18next";-import { SegmentedControl } from "@/components/ui/segmented-control";+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { Switch } from "@/components/ui/switch";import { useServerState } from "@/hooks/useAppState";import { Engine } from "@/types/proto-es/v1/common_pb";import {@@ -147,21 +155,6 @@ function CredentialSourceForm({isDefaultCredentialDisabled,]);- const options = useMemo(- () => [- {- label: t("common.default"),- value: "default" as CredentialSource,- disabled: isDefaultCredentialDisabled,- },- {- label: t("instance.iam-extension.specific-credential"),- value: "specific-credential" as CredentialSource,- },- ],- [t, isDefaultCredentialDisabled]- );-const handleCredentialSourceChange = (value: CredentialSource) => {if (!allowEdit) return;if (value === "default") {@@ -225,21 +218,29 @@ function CredentialSourceForm({validationField="iamExtension"title={t("instance.iam-extension.credential-source")}>- <SegmentedControl- value={credentialSource}- onValueChange={(value) =>- handleCredentialSourceChange(value as CredentialSource)- }- ariaLabel={t("instance.iam-extension.credential-source")}- options={options.map((option) => ({- ...option,- tooltip: option.disabled- ? t("instance.iam-extension.saas-default-credential-restriction")- : undefined,- }))}- disabled={!allowEdit}- size="sm"- />+ <div className="flex flex-col gap-y-1">+ <div className="flex items-center gap-x-3">+ <Switch+ id="specificCredential"+ checked={credentialSource === "specific-credential"}+ disabled={!allowEdit || isDefaultCredentialDisabled}+ aria-label={t("instance.iam-extension.credential-source")}+ onCheckedChange={(checked) =>+ handleCredentialSourceChange(+ checked ? "specific-credential" : "default"+ )+ }+ />+ <label htmlFor="specificCredential" className="text-sm">+ {t("instance.iam-extension.specific-credential")}+ </label>+ </div>+ {isDefaultCredentialDisabled && (+ <p className="text-sm text-control-light">+ {t("instance.iam-extension.saas-default-credential-restriction")}+ </p>+ )}+ </div>{credentialSource === "default" && (<DefaultCredentialInfo@@ -353,17 +354,48 @@ function CloudSQLIPTypeField({return (<FormField title={t("instance.cloud-sql-ip-type.label")}>- <SegmentedControl- value={String(current)}- onValueChange={(next) => onChange(Number(next))}- ariaLabel={t("instance.cloud-sql-ip-type.label")}- options={options.map((option) => ({- value: String(option.value),- label: option.label,- }))}- disabled={!allowEdit}- size="sm"- />+ {options.length === 2 ? (+ <RadioGroup+ className="gap-x-4"+ value={String(current)}+ onValueChange={(next) =>+ onChange(Number(next) as DataSource_CloudSQLIPType)+ }+ aria-label={t("instance.cloud-sql-ip-type.label")}+ >+ {options.map((option) => (+ <RadioGroupItem+ key={option.value}+ value={String(option.value)}+ disabled={!allowEdit}+ >+ {option.label}+ </RadioGroupItem>+ ))}+ </RadioGroup>+ ) : (+ <Select+ value={String(current)}+ onValueChange={(next) => {+ if (next) onChange(Number(next) as DataSource_CloudSQLIPType);+ }}+ disabled={!allowEdit}+ >+ <SelectTrigger+ aria-label={t("instance.cloud-sql-ip-type.label")}+ className="w-full sm:w-80"+ >+ <SelectValue>{label(current)}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ {options.map((option) => (+ <SelectItem key={option.value} value={String(option.value)}>+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ )}<p className="text-sm text-control-light">{t("instance.cloud-sql-ip-type.description")}</p>diff --git a/frontend/src/components/instance/DataSourceForm.tsx b/frontend/src/components/instance/DataSourceForm.tsxindex 88bf987808..035784c031 100644--- a/frontend/src/components/instance/DataSourceForm.tsx+++ b/frontend/src/components/instance/DataSourceForm.tsx@@ -20,6 +20,7 @@ import {SelectTrigger,SelectValue,} from "@/components/ui/select";+import { Switch } from "@/components/ui/switch";import { cn } from "@/lib/utils";import { useAppStore } from "@/stores/app";import { Engine } from "@/types/proto-es/v1/common_pb";@@ -906,27 +907,28 @@ export function DataSourceForm({className="w-fit textlabel gap-x-3"value={dataSource.saslConfig?.mechanism?.value- ?.kdcTransportProtocol ?? ""+ ?.kdcTransportProtocol ?? "tcp"}- onValueChange={(proto) => {+ onValueChange={(protocol) => {const updated = { ...dataSource };if (updated.saslConfig?.mechanism?.case ==="krbConfig") {updated.saslConfig.mechanism.value.kdcTransportProtocol =- String(proto);+ protocol as string;}onDataSourceChange(updated);}}+ aria-label={t("instance.kerberos-kdc")}>- {["tcp", "udp"].map((proto) => (+ {["tcp", "udp"].map((protocol) => (<RadioGroupItem- key={proto}- value={proto}+ key={protocol}+ value={protocol}disabled={!allowEdit}>- {proto.toUpperCase()}+ {protocol.toUpperCase()}</RadioGroupItem>))}</RadioGroup>@@ -1254,11 +1256,15 @@ export function DataSourceForm({) as DataSourceExternalSecret_AuthType)}+ aria-label={t(+ "instance.external-secret-vault.vault-auth-type.self"+ )}><RadioGroupItemvalue={String(DataSourceExternalSecret_AuthType.TOKEN)}+ disabled={!allowEdit}>{t("instance.external-secret-vault.vault-auth-type.token.self"@@ -1268,6 +1274,7 @@ export function DataSourceForm({value={String(DataSourceExternalSecret_AuthType.VAULT_APP_ROLE)}+ disabled={!allowEdit}>{t("instance.external-secret-vault.vault-auth-type.approle.self"@@ -1335,48 +1342,68 @@ export function DataSourceForm({which is disallowed in SaaS mode; onlyplain is offered there. */}{!isSaaSMode && (- <RadioGroup- className="textlabel my-1 gap-x-4"+ <Selectvalue={String(tokenType)}- onValueChange={(value) =>- changeTokenType(- Number(- value- ) as DataSourceExternalSecret_TokenType- )- }+ onValueChange={(+ value+ ) => {+ if (value) {+ changeTokenType(+ Number(+ value+ ) as DataSourceExternalSecret_TokenType+ );+ }+ }}+ disabled={!allowEdit}>- <RadioGroupItem- value={String(- DataSourceExternalSecret_TokenType.PLAIN- )}- disabled={!allowEdit}- >- {t(- "instance.external-secret-vault.vault-auth-type.token.type-plain"- )}- </RadioGroupItem>- <RadioGroupItem- value={String(+ <SelectTrigger className="my-1 w-full sm:w-80">+ <SelectValue>+ {tokenType ===DataSourceExternalSecret_TokenType.ENVIRONMENT- )}- disabled={!allowEdit}- >- {t(- "instance.external-secret-vault.vault-auth-type.token.type-environment"- )}- </RadioGroupItem>- <RadioGroupItem- value={String(- DataSourceExternalSecret_TokenType.FILE- )}- disabled={!allowEdit}- >- {t(- "instance.external-secret-vault.vault-auth-type.token.type-file"- )}- </RadioGroupItem>- </RadioGroup>+ ? t(+ "instance.external-secret-vault.vault-auth-type.token.type-environment"+ )+ : tokenType ===+ DataSourceExternalSecret_TokenType.FILE+ ? t(+ "instance.external-secret-vault.vault-auth-type.token.type-file"+ )+ : t(+ "instance.external-secret-vault.vault-auth-type.token.type-plain"+ )}+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ <SelectItem+ value={String(+ DataSourceExternalSecret_TokenType.PLAIN+ )}+ >+ {t(+ "instance.external-secret-vault.vault-auth-type.token.type-plain"+ )}+ </SelectItem>+ <SelectItem+ value={String(+ DataSourceExternalSecret_TokenType.ENVIRONMENT+ )}+ >+ {t(+ "instance.external-secret-vault.vault-auth-type.token.type-environment"+ )}+ </SelectItem>+ <SelectItem+ value={String(+ DataSourceExternalSecret_TokenType.FILE+ )}+ >+ {t(+ "instance.external-secret-vault.vault-auth-type.token.type-file"+ )}+ </SelectItem>+ </SelectContent>+ </Select>)}<Inputvalue={@@ -1481,62 +1508,58 @@ export function DataSourceForm({which is disallowed in SaaS mode; only plainis offered there. */}{!isSaaSMode && (- <RadioGroup- className="textlabel my-1 gap-x-4"- value={String(- dataSource.externalSecret- .authOption.value.type- )}- onValueChange={(value) => {- const ds = {- ...dataSource,- };- if (- ds.externalSecret- ?.authOption?.case ===- "appRole"- ) {- ds.externalSecret = {- ...ds.externalSecret,- authOption: {- ...ds.externalSecret- .authOption,- value: {+ <FormControlRow className="my-1 w-fit">+ <Switch+ id="appRoleSecretType"+ checked={+ dataSource+ .externalSecret+ .authOption.value+ .type ===+ DataSourceExternalSecret_AppRoleAuthOption_SecretType.ENVIRONMENT+ }+ disabled={!allowEdit}+ onCheckedChange={(+ checked+ ) => {+ const ds = {+ ...dataSource,+ };+ if (+ ds.externalSecret+ ?.authOption+ ?.case === "appRole"+ ) {+ ds.externalSecret = {+ ...ds.externalSecret,+ authOption: {...ds.externalSecret- .authOption- .value,- type: Number(- value- ) as DataSourceExternalSecret_AppRoleAuthOption_SecretType,+ .authOption,+ value: {+ ...ds+ .externalSecret+ .authOption+ .value,+ type: checked+ ? DataSourceExternalSecret_AppRoleAuthOption_SecretType.ENVIRONMENT+ : DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN,+ },},- },- };- }- onDataSourceChange(ds);- }}- >- <RadioGroupItem- value={String(- DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN- )}- disabled={!allowEdit}- >- {t(- "instance.external-secret-vault.vault-auth-type.approle.secret-plain-text"- )}- </RadioGroupItem>- <RadioGroupItem- value={String(- DataSourceExternalSecret_AppRoleAuthOption_SecretType.ENVIRONMENT- )}- disabled={!allowEdit}+ };+ }+ onDataSourceChange(ds);+ }}+ />+ <label+ htmlFor="appRoleSecretType"+ className="text-sm">{t("instance.external-secret-vault.vault-auth-type.approle.secret-env-name")}- </RadioGroupItem>- </RadioGroup>+ </label>+ </FormControlRow>)}<Inputvalue={diff --git a/frontend/src/components/instance/InstanceFormBody.test.tsx b/frontend/src/components/instance/InstanceFormBody.test.tsxindex 0c49d2bf4f..2ffa202fc0 100644--- a/frontend/src/components/instance/InstanceFormBody.test.tsx+++ b/frontend/src/components/instance/InstanceFormBody.test.tsx@@ -265,7 +265,7 @@ afterEach(cleanup);const input = (container: HTMLElement, id: string) =>container.querySelector<HTMLInputElement>(`#${id}`)!;-test("uses a compact segmented synchronization selector", () => {+test("uses a switch for synchronization scope", () => {const { container } = render(<InstanceFormProvider><SyncDatabases@@ -277,11 +277,10 @@ test("uses a compact segmented synchronization selector", () => {</InstanceFormProvider>);- const group = container.querySelector('[role="radiogroup"]');- expect(group?.classList.contains("inline-flex")).toBe(true);- expect(group?.classList.contains("rounded-xs")).toBe(true);- expect(group?.classList.contains("flex-col")).toBe(false);- expect(group?.querySelectorAll('[role="radio"]')).toHaveLength(2);+ expect(container.querySelector('[role="switch"]')).toHaveAttribute(+ "aria-checked",+ "true"+ );});test("keeps newly loaded selections in the database preview", async () => {@@ -623,10 +622,15 @@ test("MongoDB SRV mode only clears the selected connection's address fields", ()expect(context.adminDataSource.additionalAddresses).toHaveLength(1);});-test("Redis connection mode belongs to the selected data source", () => {+test("Redis connection mode belongs to the selected data source", async () => {mount(Engine.REDIS);fireEvent.click(screen.getByRole("button", { name: "common.read-only" }));- fireEvent.click(screen.getByRole("radio", { name: "Cluster" }));+ fireEvent.click(+ screen.getByRole("combobox", { name: "data-source.connection-type" })+ );+ const cluster = await screen.findByRole("option", { name: "Cluster" });+ fireEvent.pointerDown(cluster, { pointerType: "mouse" });+ fireEvent.click(cluster);expect(context.readonlyDataSourceList[0].redisType).toBe(DataSource_RedisType.CLUSTER);diff --git a/frontend/src/components/instance/InstanceFormBody.tsx b/frontend/src/components/instance/InstanceFormBody.tsxindex d07cf16a43..6ad0544fe4 100644--- a/frontend/src/components/instance/InstanceFormBody.tsx+++ b/frontend/src/components/instance/InstanceFormBody.tsx@@ -37,7 +37,13 @@ import {ResponsiveFormLayout,} from "@/components/ui/form";import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";-import { SegmentedControl } from "@/components/ui/segmented-control";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";import { Switch } from "@/components/ui/switch";import { Tooltip } from "@/components/ui/tooltip";import { cn } from "@/lib/utils";@@ -472,39 +478,40 @@ function ScanIntervalInput({</span>}>- <RadioGroup- className="gap-x-6"- value={mode}- onValueChange={(value) => handleModeChange(value as typeof mode)}- >- <RadioGroupItem value="DEFAULT" disabled={!allowEdit}>- {t("instance.scan-interval.default-never")}- </RadioGroupItem>- <RadioGroupItem- value="CUSTOM"+ <div className="flex items-center gap-x-3">+ <Switch+ id="customScanInterval"+ checked={mode === "CUSTOM"}disabled={!allowEdit}- contentClassName="flex items-center gap-x-2"- >- <span>{t("common.custom")}</span>- <Input- type="number"- value={minutes ?? ""}- className={`w-16 ${!isValid ? "border-error" : ""}`}- placeholder={`>= ${MIN_SCAN_MINUTES}`}- disabled={mode !== "CUSTOM"}- onChange={(e) => handleMinuteChange(e.target.value)}- />- {!isValid ? (- <span className="text-error text-sm">- {t("instance.scan-interval.min-value", {- value: MIN_SCAN_MINUTES,- })}- </span>- ) : (- <span className="text-sm">{t("common.minutes")}</span>- )}- </RadioGroupItem>- </RadioGroup>+ onCheckedChange={(checked) =>+ handleModeChange(checked ? "CUSTOM" : "DEFAULT")+ }+ />+ <FormLabel htmlFor="customScanInterval" className="font-normal!">+ {t("common.custom")}+ </FormLabel>+ {mode === "CUSTOM" && (+ <>+ <Input+ type="number"+ value={minutes ?? ""}+ className={`w-16 ${!isValid ? "border-error" : ""}`}+ placeholder={`>= ${MIN_SCAN_MINUTES}`}+ disabled={!allowEdit}+ onChange={(e) => handleMinuteChange(e.target.value)}+ />+ {!isValid ? (+ <span className="text-error text-sm">+ {t("instance.scan-interval.min-value", {+ value: MIN_SCAN_MINUTES,+ })}+ </span>+ ) : (+ <span className="text-sm">{t("common.minutes")}</span>+ )}+ </>+ )}+ </div></FormField>);}@@ -724,25 +731,26 @@ export function SyncDatabases({}><div className="flex flex-col gap-y-2">- <SegmentedControl- value={syncAll ? "all" : "selected"}- onValueChange={(value) => setSyncAll(value === "all")}- options={[- { value: "all", label: t("instance.sync-databases.all-databases") },- {- value: "selected",- label: t("instance.sync-databases.selected-databases"),- },- ]}- disabled={!allowEdit}- ariaLabel={- hasProjectContext- ? t("instance.sync-databases.project-sync-all")- : t("instance.sync-databases.self")- }- aria-describedby={disabledReason ? disabledReasonId : undefined}- size="sm"- />+ <FormControlRow className="w-fit">+ <Switch+ checked={syncAll}+ onCheckedChange={setSyncAll}+ disabled={!allowEdit || !!disabledReason}+ aria-label={+ hasProjectContext+ ? t("instance.sync-databases.project-sync-all")+ : t("instance.sync-databases.self")+ }+ aria-describedby={disabledReason ? disabledReasonId : undefined}+ />+ <span+ className={cn("text-sm", disabledReason && "text-control-light")}+ >+ {syncAll+ ? t("instance.sync-databases.all-databases")+ : t("instance.sync-databases.selected-databases")}+ </span>+ </FormControlRow>{disabledReason && (<pid={disabledReasonId}@@ -758,7 +766,7 @@ export function SyncDatabases({{t("common.loading")}...</div>) : (- <div className="pl-4 flex flex-col gap-y-2">+ <div className="flex flex-col gap-y-2"><Inputvalue={searchText}className="w-full"@@ -1676,9 +1684,14 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {value as string)}+ aria-label={t("data-source.connection-string-schema")}>{MongoDBConnectionStringSchemaList.map((type) => (- <RadioGroupItem key={type} value={type}>+ <RadioGroupItem+ key={type}+ value={type}+ disabled={!allowEdit}+ >{type}</RadioGroupItem>))}@@ -1730,7 +1743,7 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {connectionDataSource.additionalAddresses.length ===0 && (<FormControlRow className="w-fit">- <Checkbox+ <Switchid="directConnection"checked={connectionDataSource.directConnection@@ -1762,19 +1775,27 @@ export function InstanceFormBody({ onOpenInfoPanel }: InstanceFormBodyProps) {<FormLabel htmlFor="connectionStringSchema">{t("data-source.connection-type")}</FormLabel>- <RadioGroup- className="gap-x-4"+ <Selectvalue={currentRedisConnectionType}- onValueChange={(value) =>- handleRedisConnectionTypeChange(value as string)- }+ onValueChange={(value) => {+ if (value) handleRedisConnectionTypeChange(value);+ }}+ disabled={!allowEdit}>- {RedisConnectionType.map((type) => (- <RadioGroupItem key={type} value={type}>- {type}- </RadioGroupItem>- ))}- </RadioGroup>+ <SelectTrigger+ aria-label={t("data-source.connection-type")}+ className="w-full sm:w-80"+ >+ <SelectValue>{currentRedisConnectionType}</SelectValue>+ </SelectTrigger>+ <SelectContent>+ {RedisConnectionType.map((type) => (+ <SelectItem key={type} value={type}>+ {type}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>{showAdditionalAddresses && (<ResponsiveFormLayout className="mt-2"><fieldsetdiff --git a/frontend/src/components/instance/InstanceFormContext.test.tsx b/frontend/src/components/instance/InstanceFormContext.test.tsxindex 05e9e02239..54a21c3eb1 100644--- a/frontend/src/components/instance/InstanceFormContext.test.tsx+++ b/frontend/src/components/instance/InstanceFormContext.test.tsx@@ -399,9 +399,10 @@ describe("InstanceFormProvider", () => {</InstanceFormProvider>);- expect(- harness.container.querySelector('input[type="radio"][value="selected"]')- ).toBeChecked();+ expect(harness.container.querySelector('[role="switch"]')).toHaveAttribute(+ "aria-checked",+ "false"+ );} finally {harness.unmount();}@@ -535,23 +536,25 @@ describe("InstanceFormProvider", () => {</InstanceFormProvider>);await act(async () => {- harness.container- .querySelector<HTMLElement>('[role="radio"][value="selected"]')- ?.click();+ const syncScope = harness.container.querySelector<HTMLElement>(+ '[role="switch"]'+ );+ expect(syncScope).not.toBeNull();+ syncScope!.click();await vi.advanceTimersByTimeAsync(600);});const checkbox = harness.container.querySelector<HTMLElement>('[role="checkbox"]');- expect(checkbox).toBeDefined();+ expect(checkbox).not.toBeNull();mocks.listInstanceDatabases.mockClear();mocks.listInstanceDatabases.mockImplementation(() => new Promise(() => {}));await act(async () => {- checkbox?.click();+ checkbox!.click();await vi.advanceTimersByTimeAsync(300);});diff --git a/frontend/src/components/instance/SshConnectionForm.test.tsx b/frontend/src/components/instance/SshConnectionForm.test.tsxindex 96b4ded593..42922affef 100644--- a/frontend/src/components/instance/SshConnectionForm.test.tsx+++ b/frontend/src/components/instance/SshConnectionForm.test.tsx@@ -63,18 +63,12 @@ describe("SshConnectionForm", () => {document.body.innerHTML = "";});- test("renders a compact segmented SSH selector", () => {+ test("renders an SSH tunnel switch", () => {const { container, root } = mount(<ControlledSshConnectionForm />);- expect(- container- .querySelector('[role="radiogroup"]')- ?.classList.contains("inline-flex")- ).toBe(true);- expect(- container- .querySelector('[role="radiogroup"]')- ?.classList.contains("rounded-xs")- ).toBe(true);+ expect(container.querySelector('[role="switch"]')).toHaveAttribute(+ "aria-checked",+ "false"+ );act(() => {root.unmount();@@ -83,13 +77,13 @@ describe("SshConnectionForm", () => {test("keeps tunnel selected after editing SSH fields before port is entered", () => {const { container, root } = mount(<ControlledSshConnectionForm />);- const tunnelRadio = container.querySelector(- 'input[value="TUNNEL+PK"]'- ) as HTMLInputElement | null;- expect(tunnelRadio).not.toBeNull();+ const tunnelSwitch = container.querySelector(+ '[role="switch"]'+ ) as HTMLElement | null;+ expect(tunnelSwitch).not.toBeNull();act(() => {- tunnelRadio?.click();+ tunnelSwitch?.click();});let userInput = container.querySelector(@@ -103,10 +97,10 @@ describe("SshConnectionForm", () => {userInput = container.querySelector("#sshUser");expect(userInput).not.toBeNull();- expect(- (container.querySelector('input[value="TUNNEL+PK"]') as HTMLInputElement)- .checked- ).toBe(true);+ expect(container.querySelector('[role="switch"]')).toHaveAttribute(+ "aria-checked",+ "true"+ );act(() => {root.unmount();diff --git a/frontend/src/components/instance/SshConnectionForm.tsx b/frontend/src/components/instance/SshConnectionForm.tsxindex f1d1fa289a..0102bd6878 100644--- a/frontend/src/components/instance/SshConnectionForm.tsx+++ b/frontend/src/components/instance/SshConnectionForm.tsx@@ -2,12 +2,13 @@ import { type ReactNode, useCallback, useEffect, useState } from "react";import { useTranslation } from "react-i18next";import { SecretInput } from "@/components/SecretInput";import {+ FormControlRow,FormField,FormLabel,ResponsiveFormLayout,} from "@/components/ui/form";import { Input } from "@/components/ui/input";-import { SegmentedControl } from "@/components/ui/segmented-control";+import { Switch } from "@/components/ui/switch";import type { Instance } from "@/types/proto-es/v1/instance_service_pb";const SSH_TYPES = ["NONE", "TUNNEL+PK"] as const;@@ -77,28 +78,21 @@ export function SshConnectionForm({[onChange]);- const getSshTypeLabel = (type: SshType): string => {- if (type === "TUNNEL+PK") {- return t("data-source.ssh-type.tunnel-and-private-key");- }- return t("data-source.ssh-type.none");- };-return (<div className="flex flex-col gap-4"><FormField title={title ?? t("data-source.ssh-connection")}><div className="flex flex-col gap-4">- <SegmentedControl- value={sshType}- onValueChange={(value) => handleSelectType(value as SshType)}- ariaLabel={t("data-source.ssh-connection")}- options={SSH_TYPES.map((type) => ({- value: type,- label: getSshTypeLabel(type),- }))}- size="sm"- disabled={disabled}- />+ <FormControlRow className="w-fit">+ <Switch+ checked={sshType === "TUNNEL+PK"}+ onCheckedChange={(checked) =>+ handleSelectType(checked ? "TUNNEL+PK" : "NONE")+ }+ aria-label={t("data-source.ssh-connection")}+ disabled={disabled}+ />+ <span className="text-sm">{t("data-source.ssh-connection")}</span>+ </FormControlRow>{sshType !== "NONE" && (<ResponsiveFormLayout><fieldset className="flex flex-col gap-4 rounded-xs border border-control-border px-3 py-2">diff --git a/frontend/src/components/instance/SslCertificateForm.test.tsx b/frontend/src/components/instance/SslCertificateForm.test.tsxindex d79f856fd6..800c5c6603 100644--- a/frontend/src/components/instance/SslCertificateForm.test.tsx+++ b/frontend/src/components/instance/SslCertificateForm.test.tsx@@ -1,9 +1,8 @@-import * as stylex from "@stylexjs/stylex";import type { ReactNode } from "react";import { act } from "react";import { createRoot } from "react-dom/client";+import { fireEvent, screen } from "@testing-library/react";import { afterEach, describe, expect, test, vi } from "vitest";-import { controlMinHeightStyle } from "@/components/ui/styles.stylex";import { Engine } from "@/types/proto-es/v1/common_pb";import { SslCertificateForm } from "./SslCertificateForm";@@ -62,7 +61,7 @@ describe("SslCertificateForm", () => {});});- test("renders posture-first connection security controls", () => {+ test("renders posture-first connection security controls", async () => {const container = document.createElement("div");document.body.appendChild(container);const root = createRoot(container);@@ -87,38 +86,25 @@ describe("SslCertificateForm", () => {expect(container.textContent).not.toContain("data-source.ssl.connection-security");- expect(container.textContent).toContain("data-source.ssl.posture.disabled");expect(container.textContent).toContain("data-source.ssl.posture.tls");- expect(container.textContent).toContain(- "data-source.ssl.posture.mutual-tls"- );expect(container.textContent).not.toContain("data-source.ssl.posture.self");+ const posture = screen.getByRole("combobox", {+ name: "data-source.ssl.posture.self",+ });+ fireEvent.click(posture);expect(- container.querySelector('[aria-label="data-source.ssl.posture.self"]')- ).not.toBeNull();- expect(- container- .querySelector('[aria-label="data-source.ssl.posture.self"]')- ?.classList.contains("self-start")- ).toBe(true);- const selectedPostureInput = container.querySelector(- '[aria-label="data-source.ssl.posture.self"] [aria-checked="true"]'- );- const selectedPostureLabel = selectedPostureInput?.closest("label");- expect(- Array.from(selectedPostureLabel?.classList ?? []).some((className) =>- /^z-\d+$/.test(className)- )- ).toBe(false);- expect(selectedPostureLabel?.className).toContain(- stylex.props(controlMinHeightStyle("sm")).className- );+ await screen.findByRole("option", {+ name: "data-source.ssl.posture.disabled",+ })+ ).toBeTruthy();expect(- selectedPostureLabel?.classList.contains("focus-within:ring-inset")- ).toBe(true);+ screen.getByRole("option", { name: "data-source.ssl.posture.tls" })+ ).toBeTruthy();expect(- selectedPostureLabel?.nextElementSibling?.classList.contains("border-l")- ).toBe(false);+ screen.getByRole("option", {+ name: "data-source.ssl.posture.mutual-tls",+ })+ ).toBeTruthy();expect(container.textContent).toContain("data-source.ssl.server-identity");expect(container.textContent).not.toContain("data-source.ssl.ca-empty-uses-system-trust"@@ -132,7 +118,7 @@ describe("SslCertificateForm", () => {});});- test("renders client identity for mutual TLS without a None source option", () => {+ test("renders client identity for mutual TLS without a None source option", async () => {const container = document.createElement("div");document.body.appendChild(container);const root = createRoot(container);@@ -159,9 +145,6 @@ describe("SslCertificateForm", () => {expect(container.textContent).toContain("data-source.ssl.client-cert-source.inline-pem");- expect(container.textContent).toContain(- "data-source.ssl.client-cert-source.file-path"- );expect(container.textContent).not.toContain("data-source.ssl.client-cert-source.none");@@ -173,18 +156,12 @@ describe("SslCertificateForm", () => {"data-source.ssl.client-cert-placeholder","data-source.ssl.client-key-placeholder",]);- const segmentSizeClassName =- stylex.props(controlMinHeightStyle("sm")).className ?? "";- for (const ariaLabel of [- "data-source.ssl.posture.self",- "data-source.ssl.ca-source.self",- "data-source.ssl.client-cert-source.self",- ]) {- const firstSegment = container- .querySelector(`[aria-label="${ariaLabel}"] [aria-checked]`)- ?.closest("label");- expect(firstSegment?.className).toContain(segmentSizeClassName);- }+ const clientCertSource = screen.getByRole("radio", {+ name: "data-source.ssl.client-cert-source.inline-pem",+ });+ expect(+ clientCertSource+ ).toHaveAttribute("aria-checked", "true");act(() => {root.unmount();@@ -292,7 +269,7 @@ describe("SslCertificateForm", () => {});});- test("disables file path source options in SaaS mode", () => {+ test("disables file path source options in SaaS mode", async () => {const container = document.createElement("div");document.body.appendChild(container);const root = createRoot(container);@@ -316,16 +293,16 @@ describe("SslCertificateForm", () => {);});+ fireEvent.click(+ screen.getByRole("combobox", {+ name: "data-source.ssl.ca-source.self",+ })+ );expect(- container.querySelector(- '[aria-label="data-source.ssl.ca-source.self"] [aria-disabled="true"][aria-checked="true"]'- )- ).not.toBeNull();- expect(- container.querySelector(- '[aria-label="data-source.ssl.client-cert-source.self"] [aria-disabled="true"][aria-checked="true"]'- )- ).not.toBeNull();+ await screen.findByRole("option", {+ name: "data-source.ssl.ca-source.file-path",+ })+ ).toHaveAttribute("aria-disabled", "true");expect(container.querySelector<HTMLInputElement>('[data-testid="tls-ca-path-input"]'@@ -341,16 +318,12 @@ describe("SslCertificateForm", () => {'[data-testid="tls-key-path-input"]')?.disabled).toBe(true);- expect(container.textContent).toContain(- "data-source.ssl.ca-source.file-path-unavailable-saas"- );-act(() => {root.unmount();});});- test("shows disabled mutual TLS for unsupported engines", () => {+ test("shows disabled mutual TLS for unsupported engines", async () => {const container = document.createElement("div");document.body.appendChild(container);const root = createRoot(container);@@ -372,17 +345,23 @@ describe("SslCertificateForm", () => {);});- expect(container.textContent).toContain(- "data-source.ssl.mutual-tls-unavailable-engine"+ fireEvent.click(+ screen.getByRole("combobox", {+ name: "data-source.ssl.posture.self",+ }));- expect(container.querySelector('[aria-disabled="true"]')).not.toBeNull();+ expect(+ await screen.findByRole("option", {+ name: "data-source.ssl.posture.mutual-tls",+ })+ ).toHaveAttribute("aria-disabled", "true");act(() => {root.unmount();});});- test("falls back from mutual TLS for unsupported engines without saved client identity", () => {+ test("falls back from mutual TLS for unsupported engines without saved client identity", async () => {const container = document.createElement("div");document.body.appendChild(container);const root = createRoot(container);@@ -404,15 +383,11 @@ describe("SslCertificateForm", () => {);});- expect(container.textContent).toContain(- "data-source.ssl.mutual-tls-unavailable-engine"- );- expect(container.querySelector('[aria-disabled="true"]')).not.toBeNull();expect(- container.querySelector(- '[aria-label="data-source.ssl.posture.self"] [aria-disabled="true"][aria-checked="true"]'- )- ).toBeNull();+ screen.getByRole("combobox", {+ name: "data-source.ssl.posture.self",+ })+ ).toHaveTextContent("data-source.ssl.posture.tls");expect(container.textContent).not.toContain("data-source.ssl.client-identity");@@ -422,7 +397,7 @@ describe("SslCertificateForm", () => {});});- test("does not treat non-none source as saved client identity for unsupported engines", () => {+ test("does not treat non-none source as saved client identity for unsupported engines", async () => {const container = document.createElement("div");document.body.appendChild(container);const root = createRoot(container);@@ -444,14 +419,11 @@ describe("SslCertificateForm", () => {);});- expect(container.textContent).toContain(- "data-source.ssl.mutual-tls-unavailable-engine"- );expect(- container.querySelector(- '[aria-label="data-source.ssl.posture.self"] [aria-disabled="true"][aria-checked="true"]'- )- ).toBeNull();+ screen.getByRole("combobox", {+ name: "data-source.ssl.posture.self",+ })+ ).toHaveTextContent("data-source.ssl.posture.tls");expect(container.textContent).not.toContain("data-source.ssl.client-identity");@@ -489,10 +461,10 @@ describe("SslCertificateForm", () => {expect(container.textContent).toContain("data-source.ssl.client-cert");expect(container.textContent).toContain("data-source.ssl.client-key");expect(- container.querySelector(- '[aria-label="data-source.ssl.posture.self"] [aria-checked="true"][aria-disabled="true"]'- )- ).not.toBeNull();+ screen.getByRole("combobox", {+ name: "data-source.ssl.posture.self",+ })+ ).toHaveTextContent("data-source.ssl.posture.mutual-tls");act(() => {root.unmount();diff --git a/frontend/src/components/instance/SslCertificateForm.tsx b/frontend/src/components/instance/SslCertificateForm.tsxindex 19da89963d..5190ae211e 100644--- a/frontend/src/components/instance/SslCertificateForm.tsx+++ b/frontend/src/components/instance/SslCertificateForm.tsx@@ -2,10 +2,14 @@ import { type DragEvent, useCallback } from "react";import { useTranslation } from "react-i18next";import { Badge } from "@/components/ui/badge";import { ResponsiveFormLayout } from "@/components/ui/form";+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";import {- SegmentedControl,- type SegmentedControlOption,-} from "@/components/ui/segmented-control";+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";import { Switch } from "@/components/ui/switch";import { Tabs, TabsList, TabsPanel, TabsTrigger } from "@/components/ui/tabs";import { Engine } from "@/types/proto-es/v1/common_pb";@@ -131,7 +135,7 @@ function CaSourceSelector({isSaaSMode?: boolean;}) {const { t } = useTranslation();- const options: SegmentedControlOption<LocalTlsCaSource>[] = [+ const options = [{value: LOCAL_TLS_CA_SOURCE_SYSTEM_TRUST,label: t("data-source.ssl.ca-source.system-trust"),@@ -151,14 +155,34 @@ function CaSourceSelector({];return (- <SegmentedControl+ <Selectvalue={value}- onValueChange={onChange}- ariaLabel={t("data-source.ssl.ca-source.self")}- options={options}+ onValueChange={(next) => {+ if (next) onChange(next);+ }}disabled={disabled}- size="sm"- />+ >+ <SelectTrigger+ aria-label={t("data-source.ssl.ca-source.self")}+ className="w-full sm:w-80"+ >+ <SelectValue>+ {options.find((option) => option.value === value)?.label}+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {options.map((option) => (+ <SelectItem+ key={option.value}+ value={option.value}+ disabled={option.disabled}+ title={option.tooltip}+ >+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>);}@@ -176,7 +200,7 @@ function ClientCertSourceSelector({allowNone?: boolean;}) {const { t } = useTranslation();- const options: SegmentedControlOption<LocalTlsClientCertSource>[] = [+ const options = [...(allowNone? [{@@ -199,15 +223,57 @@ function ClientCertSourceSelector({},];+ if (!allowNone) {+ return (+ <RadioGroup+ className="gap-x-4"+ value={value}+ onValueChange={(next) => onChange(next as LocalTlsClientCertSource)}+ aria-label={t("data-source.ssl.client-cert-source.self")}+ >+ {options.map((option) => (+ <RadioGroupItem+ key={option.value}+ value={option.value}+ disabled={disabled || option.disabled}+ title={option.tooltip}+ >+ {option.label}+ </RadioGroupItem>+ ))}+ </RadioGroup>+ );+ }+return (- <SegmentedControl+ <Selectvalue={value}- onValueChange={(next) => onChange(next)}- ariaLabel={t("data-source.ssl.client-cert-source.self")}- options={options}+ onValueChange={(next) => {+ if (next) onChange(next);+ }}disabled={disabled}- size="sm"- />+ >+ <SelectTrigger+ aria-label={t("data-source.ssl.client-cert-source.self")}+ className="w-full sm:w-80"+ >+ <SelectValue>+ {options.find((option) => option.value === value)?.label}+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {options.map((option) => (+ <SelectItem+ key={option.value}+ value={option.value}+ disabled={option.disabled}+ title={option.tooltip}+ >+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>);}@@ -369,7 +435,7 @@ export function SslCertificateForm({</div>);const renderPostureControl = () => {- const options: SegmentedControlOption<LocalTlsPosture>[] = [+ const options = [{value: LOCAL_TLS_POSTURE_DISABLED,label: t("data-source.ssl.posture.disabled"),@@ -390,14 +456,37 @@ export function SslCertificateForm({return (<div className="flex flex-col gap-y-1">- <SegmentedControl+ <Selectvalue={resolvedPosture}- onValueChange={(next) => onPostureChange?.(next)}- ariaLabel={t("data-source.ssl.posture.self")}- options={options}+ onValueChange={(next) => {+ if (next) onPostureChange?.(next);+ }}disabled={disabled}- size="sm"- />+ >+ <SelectTrigger+ aria-label={t("data-source.ssl.posture.self")}+ className="w-full sm:w-80"+ >+ <SelectValue>+ {+ options.find((option) => option.value === resolvedPosture)+ ?.label+ }+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {options.map((option) => (+ <SelectItem+ key={option.value}+ value={option.value}+ disabled={option.disabled}+ title={option.tooltip}+ >+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select></div>);};diff --git a/frontend/src/components/ui/switch.test.tsx b/frontend/src/components/ui/switch.test.tsxnew file mode 100644index 0000000000..2d86aa5572--- /dev/null+++ b/frontend/src/components/ui/switch.test.tsx@@ -0,0 +1,19 @@+import { render, screen } from "@testing-library/react";+import { expect, test } from "vitest";+import { Switch } from "./switch";++test("uses disabled state selectors for a locked checked switch", () => {+ render(+ <Switch+ checked+ disabled+ aria-label="Sync all databases"+ onCheckedChange={() => undefined}+ />+ );++ const control = screen.getByRole("switch", { name: "Sync all databases" });+ expect(control).toHaveAttribute("data-disabled");+ expect(control).toHaveClass("data-disabled:cursor-not-allowed");+ expect(control).toHaveClass("data-disabled:data-[checked]:bg-accent/50");+});diff --git a/frontend/src/components/ui/switch.tsx b/frontend/src/components/ui/switch.tsxindex ac07e97b24..27d243a072 100644--- a/frontend/src/components/ui/switch.tsx+++ b/frontend/src/components/ui/switch.tsx@@ -73,7 +73,11 @@ function Switch({// the off state into a colored fill. Checked uses the accent."bg-control/30 data-[checked]:bg-accent","focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",- "disabled:cursor-not-allowed disabled:opacity-50",+ // Base UI renders the root as a span and exposes disabled state through+ // `data-disabled`, so native `:disabled` selectors do not apply here.+ // Preserve the checked state with a muted accent while making the+ // locked control visually subordinate.+ "data-disabled:cursor-not-allowed data-disabled:data-[checked]:bg-accent/50 data-disabled:not-data-[checked]:opacity-50 data-disabled:[&>span]:bg-control-bg",className)}>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 7c3cccae27..f0ec98b25d 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -645,10 +645,6 @@"user": "User"},"ssh-connection": "SSH tunnel",- "ssh-type": {- "none": "None",- "tunnel-and-private-key": "Tunnel + Private Key"- },"ssl": {"ca-cert": "CA Certificate","ca-path": "CA Certificate Path",@@ -1099,7 +1095,6 @@"role-id": "Auth role id","secret-env-name": "Environment name","secret-id": "Auth secret id",- "secret-plain-text": "Plain text","self": "AppRole"},"self": "Auth type",@@ -1262,7 +1257,6 @@"sample-project-instance-description-self-host": "Use a Sample Project Instance to explore Bytebase with a ready-to-use database.","sample-project-instance-title": "Try a Sample Project Instance","scan-interval": {- "default-never": "Default (never)","description": "Bytebase periodically syncs instance schema and detects anomalies.","min-value": "Min value {{value}} minutes","self": "Scan Interval"diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex a59995e85d..ce4be4014f 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -645,10 +645,6 @@"user": "Nombre de usuario"},"ssh-connection": "Túnel SSH",- "ssh-type": {- "none": "Ninguno",- "tunnel-and-private-key": "Túnel + Clave Privada"- },"ssl": {"ca-cert": "Certificado de CA","ca-path": "Ruta del certificado de CA",@@ -1099,7 +1095,6 @@"role-id": "ID de rol de autenticación","secret-env-name": "Nombre del entorno","secret-id": "ID de secreto de autenticación",- "secret-plain-text": "Texto sin formato","self": "AppRole"},"self": "Tipo de autenticación",@@ -1262,7 +1257,6 @@"sample-project-instance-description-self-host": "Use una instancia de proyecto de muestra para explorar Bytebase con una base de datos lista para usar.","sample-project-instance-title": "Pruebe una instancia de proyecto de muestra","scan-interval": {- "default-never": "Predeterminado (nunca)","description": "Bytebase sincroniza periódicamente el esquema de instancia y detecta anomalías.","min-value": "Valor mínimo {{value}} minutos","self": "Intervalo de escaneo"diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex dcab92736e..ac32313ec7 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -645,10 +645,6 @@"user": "ユーザー名"},"ssh-connection": "SSH トンネル",- "ssh-type": {- "none": "なし",- "tunnel-and-private-key": "トンネル + 秘密鍵"- },"ssl": {"ca-cert": "CA証明書","ca-path": "CA証明書のパス",@@ -1099,7 +1095,6 @@"role-id": "認証ロールID","secret-env-name": "環境変数名","secret-id": "認証シークレットID",- "secret-plain-text": "プレーンテキスト","self": "AppRole"},"self": "認証タイプ",@@ -1262,7 +1257,6 @@"sample-project-instance-description-self-host": "すぐに使えるデータベースを備えたサンプルプロジェクトインスタンスを使用して、Bytebase を試すことができます。","sample-project-instance-title": "サンプルプロジェクトインスタンスを試す","scan-interval": {- "default-never": "デフォルト (なし)","description": "Bytebase は定期的にインスタンスのスキーマを同期し、異常検出を実行します。","min-value": "最短 {{value}} 分","self": "スキャン間隔"diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 554ceed4fe..d789a08d94 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -645,10 +645,6 @@"user": "Người dùng"},"ssh-connection": "Đường hầm SSH",- "ssh-type": {- "none": "Không có",- "tunnel-and-private-key": "Đường hầm + Khóa riêng"- },"ssl": {"ca-cert": "Chứng chỉ CA","ca-path": "Đường dẫn chứng chỉ CA",@@ -1099,7 +1095,6 @@"role-id": "ID vai trò xác thực","secret-env-name": "Tên môi trường","secret-id": "ID bí mật xác thực",- "secret-plain-text": "Văn bản thuần","self": "AppRole"},"self": "Loại xác thực",@@ -1262,7 +1257,6 @@"sample-project-instance-description-self-host": "Sử dụng Phiên bản dự án mẫu để khám phá Bytebase với cơ sở dữ liệu sẵn sàng sử dụng.","sample-project-instance-title": "Dùng thử Phiên bản dự án mẫu","scan-interval": {- "default-never": "Mặc định (không bao giờ)","description": "Bytebase định kỳ đồng bộ lược đồ phiên bản và phát hiện bất thường.","min-value": "Giá trị nhỏ nhất {{value}} phút","self": "Khoảng thời gian quét"diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 545923c7b0..d32e948dde 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -645,10 +645,6 @@"user": "用户名"},"ssh-connection": "SSH 隧道",- "ssh-type": {- "none": "不使用",- "tunnel-and-private-key": "隧道 + 私钥"- },"ssl": {"ca-cert": "CA 证书","ca-path": "CA 证书路径",@@ -1099,7 +1095,6 @@"role-id": "Auth role id","secret-env-name": "环境变量名","secret-id": "Auth secret id",- "secret-plain-text": "明文","self": "AppRole"},"self": "认证方式",@@ -1262,7 +1257,6 @@"sample-project-instance-description-self-host": "使用带有预配置数据库的示例项目实例探索 Bytebase。","sample-project-instance-title": "试用示例项目实例","scan-interval": {- "default-never": "默认(永不)","description": "Bytebase 会定期同步实例的 schema 以及进行异常检测。","min-value": "最小值 {{value}} 分钟","self": "扫描间隔"diff --git a/frontend/src/routes/project/database-detail/DatabaseDetailHeader.tsx b/frontend/src/routes/project/database-detail/DatabaseDetailHeader.tsxindex 4386be3d08..a16d3f1b0d 100644--- a/frontend/src/routes/project/database-detail/DatabaseDetailHeader.tsx+++ b/frontend/src/routes/project/database-detail/DatabaseDetailHeader.tsx@@ -1,11 +1,10 @@-import { Check, Copy, ShieldAlert } from "lucide-react";-import { useCallback, useMemo, useState } from "react";+import { ShieldAlert } from "lucide-react";+import { useMemo } from "react";import { useTranslation } from "react-i18next";import { InstanceLabel } from "@/components/InstanceLabel";import { RouterLink } from "@/components/RouterLink";-import { Button } from "@/components/ui/button";+import { CopyButton } from "@/components/ui/copy-button";import { useEnvironment, usePlanFeature } from "@/hooks/useAppState";-import { writeTextToClipboard } from "@/lib/clipboard";import type { Database } from "@/types/proto-es/v1/database_service_pb";import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";import {@@ -33,7 +32,6 @@ const extractDatabaseParts = (resource: string) => {export function DatabaseDetailHeader({ database }: { database: Database }) {const { t } = useTranslation();- const [copied, setCopied] = useState(false);const { databaseName } = useMemo(() => extractDatabaseParts(database.name),[database.name]@@ -83,14 +81,6 @@ export function DatabaseDetailHeader({ database }: { database: Database }) {};}, [environmentColorRgb]);- const handleCopy = useCallback(async () => {- const success = await writeTextToClipboard(database.name);- setCopied(success);- if (success) {- window.setTimeout(() => setCopied(false), 1200);- }- }, [database.name]);-return (<div className="flex min-w-0 flex-1 shrink-0 flex-col gap-y-2"><div className="flex w-full min-w-0 flex-col">@@ -103,19 +93,10 @@ export function DatabaseDetailHeader({ database }: { database: Database }) {<span className="min-w-0 truncate" title={database.name}>{database.name}</span>- <Button- appearance="secondary"- size="xs"- type="button"- className="inline-flex shrink-0 items-center p-0.5 text-control-light hover:text-main"- onClick={() => void handleCopy()}- >- {copied ? (- <Check className="h-3.5 w-3.5" />- ) : (- <Copy className="h-3.5 w-3.5" />- )}- </Button>+ <CopyButton+ content={database.name}+ className="shrink-0 p-0.5 text-control-light hover:text-main"+ /></div></div>diff --git a/frontend/src/routes/workspace/IDPsPage.tsx b/frontend/src/routes/workspace/IDPsPage.tsxindex fda506bab9..25ec193ebf 100644--- a/frontend/src/routes/workspace/IDPsPage.tsx+++ b/frontend/src/routes/workspace/IDPsPage.tsx@@ -27,6 +27,7 @@ import {} from "@/components/ResourceIdField";import { Button } from "@/components/ui/button";import { Checkbox } from "@/components/ui/checkbox";+import { CopyButton } from "@/components/ui/copy-button";import { FormField, FormFieldGroup, FormTitle } from "@/components/ui/form";import { Input } from "@/components/ui/input";import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";@@ -53,7 +54,6 @@ import {WorkspacePageToolbar,} from "@/components/WorkspacePageLayout";import { useIdentityProviderList } from "@/hooks/useAppState";-import { writeTextToClipboard } from "@/lib/clipboard";import { pushNotification } from "@/stores";import { useAppStore } from "@/stores/app";import {@@ -166,16 +166,6 @@ function ExternalURLInfo({ type }: { type: IdentityProviderType }) {if (!redirectUrl) return null;- const handleCopy = async () => {- if (await writeTextToClipboard(redirectUrl)) {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.copied"),- });- }- };-return (<div className="rounded-sm border border-block-border bg-control-bg p-4"><div className="flex items-start gap-x-3">@@ -197,9 +187,11 @@ function ExternalURLInfo({ type }: { type: IdentityProviderType }) {readOnlyclassName="flex-1 font-mono"/>- <Button appearance="outline" size="sm" onClick={handleCopy}>- {t("common.copy")}- </Button>+ <CopyButton+ content={redirectUrl}+ appearance="outline"+ size="sm"+ /></div></div></div>diff --git a/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx b/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsxindex d74c9acc30..1c740719a5 100644--- a/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx+++ b/frontend/src/routes/workspace/shared/AADSyncSheet.test.tsx@@ -34,6 +34,7 @@ vi.mock("@/stores/app", () => ({{getState: () => ({loadWorkspaceProfile: mocks.loadWorkspaceProfile,+ notify: vi.fn(),}),}),diff --git a/frontend/src/routes/workspace/shared/AADSyncSheet.tsx b/frontend/src/routes/workspace/shared/AADSyncSheet.tsxindex ac851fe404..4fd640b359 100644--- a/frontend/src/routes/workspace/shared/AADSyncSheet.tsx+++ b/frontend/src/routes/workspace/shared/AADSyncSheet.tsx@@ -1,5 +1,4 @@import { create } from "@bufbuild/protobuf";-import { Copy } from "lucide-react";import { useState } from "react";import { useTranslation } from "react-i18next";import { workspaceServiceClientConnect } from "@/api";@@ -7,6 +6,7 @@ import { ExternalUrlAlert } from "@/components/ExternalUrlAlert";import { LearnMoreLink } from "@/components/LearnMoreLink";import { Alert } from "@/components/ui/alert";import { Button } from "@/components/ui/button";+import { CopyButton } from "@/components/ui/copy-button";import { Input } from "@/components/ui/input";import {Sheet,@@ -16,7 +16,6 @@ import {SheetHeader,SheetTitle,} from "@/components/ui/sheet";-import { writeTextToClipboard } from "@/lib/clipboard";import { pushNotification } from "@/stores";import { useAppStore } from "@/stores/app";import { RotateDirectorySyncTokenRequestSchema } from "@/types/proto-es/v1/workspace_service_pb";@@ -46,22 +45,6 @@ export function AADSyncSheet({? `${externalUrl}/hook/scim/${workspaceResourceName}`: "";- const copyToClipboard = async (value: string) => {- if (await writeTextToClipboard(value)) {- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("common.copied"),- });- } else {- pushNotification({- module: "bytebase",- style: "WARN",- title: t("common.copy-failed"),- });- }- };-// The plaintext token is returned exactly once by the rotate RPC, so it lives// in local state only. The sheet stays mounted when closed, so this must be// cleared explicitly — otherwise reopening would redisplay a token that is@@ -149,14 +132,12 @@ export function AADSyncSheet({</span><div className="flex items-center gap-x-2"><Input readOnly value={scimUrl} className="flex-1 text-sm" />- <Button+ <CopyButton+ content={scimUrl}appearance="outline"size="sm"disabled={!scimUrl}- onClick={() => copyToClipboard(scimUrl)}- >- <Copy className="h-4 w-4" />- </Button>+ /></div></div>@@ -176,13 +157,11 @@ export function AADSyncSheet({value={mintedToken}className="flex-1 text-sm font-mono"/>- <Button+ <CopyButton+ content={mintedToken}appearance="outline"size="sm"- onClick={() => copyToClipboard(mintedToken)}- >- <Copy className="size-4" />- </Button>+ /></div><Alertvariant="warning"diff --git a/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.test.tsx b/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.test.tsxindex 33ef5f5e23..aab6eee9a6 100644--- a/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.test.tsx+++ b/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.test.tsx@@ -170,6 +170,20 @@ beforeEach(async () => {});describe("TwoFactorSetupPage", () => {+ test("does not announce the changing countdown as an alert", async () => {+ const { container, render, unmount } = renderIntoContainer(+ <TwoFactorSetupPage />+ );++ try {+ await render();++ expect(container.querySelector('[role="alert"]')).toBeNull();+ } finally {+ unmount();+ }+ });+test("renders the secret from the enrollment response, not from the user", async () => {const { container, render, unmount } = renderIntoContainer(<TwoFactorSetupPage />diff --git a/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.tsx b/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.tsxindex ca97cff67b..ea1f013f21 100644--- a/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.tsx+++ b/frontend/src/routes/workspace/two-factor/TwoFactorSetupPage.tsx@@ -334,6 +334,7 @@ export function TwoFactorSetupPage({ cancelAction }: TwoFactorSetupPageProps) {<Alertvariant={isExpired || isExpiringSoon ? "error" : "warning"}showIcon={false}+ role="none"className="w-full p-3"><div className="flex items-center justify-between">diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.jsindex 13ed24c75e..cea85a9a34 100644--- a/frontend/tailwind.config.js+++ b/frontend/tailwind.config.js@@ -69,6 +69,17 @@ module.exports = {success: "rgb(var(--color-success) / <alpha-value>)","success-hover": "rgb(var(--color-success-hover) / <alpha-value>)",+ "classification-level-1":+ "rgb(var(--color-classification-level-1) / <alpha-value>)",+ "classification-level-2":+ "rgb(var(--color-classification-level-2) / <alpha-value>)",+ "classification-level-3":+ "rgb(var(--color-classification-level-3) / <alpha-value>)",+ "classification-level-4":+ "rgb(var(--color-classification-level-4) / <alpha-value>)",+ "classification-level-5":+ "rgb(var(--color-classification-level-5) / <alpha-value>)",+"link-hover": "rgb(var(--color-link-hover) / <alpha-value>)","block-border": "rgb(var(--color-block-border) / <alpha-value>)",