Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: ui fix and optimize (#21516)
ecmadao924bf38b2db9
diff --git a/frontend/src/components/DashboardBodyShell.test.tsx b/frontend/src/components/DashboardBodyShell.test.tsxindex 524780e6cb..bc936e2b57 100644--- a/frontend/src/components/DashboardBodyShell.test.tsx+++ b/frontend/src/components/DashboardBodyShell.test.tsx@@ -107,6 +107,7 @@ describe("DashboardBodyShell", () => {expect(targets.quickstart).toBeInstanceOf(HTMLDivElement);expect(targets.mainContainer?.id).toBe("bb-layout-main");expect(targets.mainContainer?.className).toContain("overscroll-y-contain");+ expect(targets.mainContainer?.className).toContain("overflow-x-auto");expect(targets.desktopSidebar?.className).toContain("overscroll-y-contain");expect(targets.mobileSidebar?.className).toContain("overscroll-y-contain");expect(@@ -257,6 +258,7 @@ describe("DashboardBodyShell", () => {expect(container.querySelector('[data-label="bb-main-body-wrapper"]')?.className).toContain("border-x");+ expect(targets.mainContainer?.className).not.toContain("overflow-x-auto");expect(container.querySelector('[data-testid="dashboard-header"][data-show-logo="true"][data-show-mobile-toggle="false"]'diff --git a/frontend/src/components/DashboardBodyShell.tsx b/frontend/src/components/DashboardBodyShell.tsxindex 7887e1cb38..41dabf74ec 100644--- a/frontend/src/components/DashboardBodyShell.tsx+++ b/frontend/src/components/DashboardBodyShell.tsx@@ -155,7 +155,7 @@ export function DashboardBodyShell({ref={mainContainerRef}className={cn("flex-1 overflow-y-auto overscroll-y-contain",- variant === "workspace" ? "md:min-w-0" : "min-w-0"+ variant === "workspace" ? "overflow-x-auto md:min-w-0" : "min-w-0")}><div ref={contentRef} className="h-full" />diff --git a/frontend/src/components/ExprEditor.test.tsx b/frontend/src/components/ExprEditor.test.tsxindex 3358f3536d..c4a028163d 100644--- a/frontend/src/components/ExprEditor.test.tsx+++ b/frontend/src/components/ExprEditor.test.tsx@@ -6,6 +6,7 @@ import type { Factor } from "@/modules/cel/types/factor";import { type ConditionGroupExpr, ExprType } from "@/modules/cel/types/simple";import {CEL_ATTRIBUTE_RESOURCE_DATABASE,+ CEL_ATTRIBUTE_RESOURCE_ENVIRONMENT_ID,CEL_ATTRIBUTE_RESOURCE_TABLE_NAME,CEL_ATTRIBUTE_RISK_LEVEL,CEL_ATTRIBUTE_STATEMENT_SQL_TYPE,@@ -223,6 +224,54 @@ describe("ExprEditor", () => {unmount();});+ test("hides expression editing actions in read-only mode", async () => {+ const initialExpr: ConditionGroupExpr = {+ type: ExprType.ConditionGroup,+ operator: "_&&_",+ args: [+ {+ type: ExprType.ConditionGroup,+ operator: "_&&_",+ args: [+ {+ type: ExprType.Condition,+ operator: "@in",+ args: [CEL_ATTRIBUTE_STATEMENT_SQL_TYPE, ["DDL"]],+ },+ ],+ },+ {+ type: ExprType.Condition,+ operator: "@in",+ args: [CEL_ATTRIBUTE_RISK_LEVEL, ["HIGH"]],+ },+ ],+ };++ const { container, unmount } = renderIntoContainer(+ <ExprEditor+ expr={initialExpr}+ readonly+ factorList={[+ CEL_ATTRIBUTE_STATEMENT_SQL_TYPE,+ CEL_ATTRIBUTE_RISK_LEVEL,+ ]}+ optionConfigMap={optionConfigMap}+ onUpdate={() => {}}+ />+ );+ await flushEffects();++ expect(container.textContent).toContain("Where");+ expect(container.textContent).toContain("DDL");+ expect(container.textContent).not.toContain("cel.condition.add");+ expect(container.textContent).not.toContain(+ "cel.condition.add-raw-expression"+ );++ unmount();+ });+test("static multi-select dropdown constrains overflow", async () => {const initialExpr: ConditionGroupExpr = {type: ExprType.ConditionGroup,@@ -456,6 +505,51 @@ describe("ExprEditor", () => {unmount();});+ test("searchable multi-select dropdown can exceed its trigger width", async () => {+ const initialExpr: ConditionGroupExpr = {+ type: ExprType.ConditionGroup,+ operator: "_&&_",+ args: [+ {+ type: ExprType.Condition,+ operator: "@in",+ args: [CEL_ATTRIBUTE_RESOURCE_DATABASE, []],+ },+ ],+ };++ const { container, unmount } = renderIntoContainer(+ <ExprEditor+ expr={initialExpr}+ factorList={[CEL_ATTRIBUTE_RESOURCE_DATABASE]}+ optionConfigMap={searchableOptionConfigMap}+ onUpdate={() => {}}+ />+ );+ await flushEffects();++ const trigger = Array.from(container.querySelectorAll("div")).find(+ (element) => element.className.includes("cursor-pointer")+ );+ expect(trigger).toBeInstanceOf(HTMLDivElement);++ await act(async () => {+ trigger?.dispatchEvent(new MouseEvent("click", { bubbles: true }));+ await Promise.resolve();+ });++ const filterInput = Array.from(document.body.querySelectorAll("input")).find(+ (input) => input.placeholder === "common.filter-by-name"+ );+ const dropdown = filterInput?.parentElement?.parentElement?.parentElement;++ expect(dropdown).toBeInstanceOf(HTMLDivElement);+ expect(dropdown?.className).toContain("w-80");+ expect(dropdown?.getAttribute("style")).not.toContain("width");++ unmount();+ });+test("collection operator uses tag input when option config disables multi-select", async () => {const initialExpr: ConditionGroupExpr = {type: ExprType.ConditionGroup,@@ -504,6 +598,90 @@ describe("ExprEditor", () => {unmount();});+ test("constrains long selected CEL values to one line", async () => {+ const initialExpr: ConditionGroupExpr = {+ type: ExprType.ConditionGroup,+ operator: "_&&_",+ args: [+ {+ type: ExprType.Condition,+ operator: "@in",+ args: [CEL_ATTRIBUTE_RESOURCE_DATABASE, ["long-value"]],+ },+ ],+ };+ const longLabel = "prod instance (prod-sample-instance)";+ const selectedValueOptions = new Map<Factor, OptionConfig>([+ [+ CEL_ATTRIBUTE_RESOURCE_DATABASE,+ {+ options: [],+ fetch: async () => [{ value: "long-value", label: longLabel }],+ search: async () => ({ options: [], nextPageToken: "" }),+ },+ ],+ ]);++ const { container, unmount } = renderIntoContainer(+ <ExprEditor+ expr={initialExpr}+ factorList={[CEL_ATTRIBUTE_RESOURCE_DATABASE]}+ optionConfigMap={selectedValueOptions}+ onUpdate={() => {}}+ />+ );+ await flushEffects();++ const tag = Array.from(container.querySelectorAll("span")).find(+ (span) =>+ span.textContent === longLabel && span.className.includes("max-w-full")+ );++ expect(tag).toBeInstanceOf(HTMLSpanElement);+ expect(tag?.querySelector("span")?.className).toContain("truncate");++ unmount();+ });++ test("left-aligns selected environment values", async () => {+ const initialExpr: ConditionGroupExpr = {+ type: ExprType.ConditionGroup,+ operator: "_&&_",+ args: [+ {+ type: ExprType.Condition,+ operator: "@in",+ args: [CEL_ATTRIBUTE_RESOURCE_ENVIRONMENT_ID, ["test"]],+ },+ ],+ };+ const environmentOptionConfig = new Map<Factor, OptionConfig>([+ [+ CEL_ATTRIBUTE_RESOURCE_ENVIRONMENT_ID,+ { options: [{ value: "test", label: "Test" }] },+ ],+ ]);++ const { container, unmount } = renderIntoContainer(+ <ExprEditor+ expr={initialExpr}+ factorList={[CEL_ATTRIBUTE_RESOURCE_ENVIRONMENT_ID]}+ optionConfigMap={environmentOptionConfig}+ onUpdate={() => {}}+ />+ );+ await flushEffects();++ const trigger = Array.from(container.querySelectorAll("button")).find(+ (button) => button.textContent?.includes("environments/test")+ );++ expect(trigger).toBeInstanceOf(HTMLButtonElement);+ expect(trigger?.className).toContain("justify-start");++ unmount();+ });+test("searchable value trigger aligns with select trigger sizing", async () => {const initialExpr: ConditionGroupExpr = {type: ExprType.ConditionGroup,diff --git a/frontend/src/components/ExprEditor.tsx b/frontend/src/components/ExprEditor.tsxindex 7b78df6ecc..57500b8532 100644--- a/frontend/src/components/ExprEditor.tsx+++ b/frontend/src/components/ExprEditor.tsx@@ -91,6 +91,8 @@ function getDefaultValue(const VALUE_MULTI_FIELD_CLASS ="min-h-9 px-3 py-1 text-sm leading-5 rounded-xs border border-control-border bg-background";+const VALUE_TAG_CLASS =+ "inline-flex min-w-0 max-w-full items-center gap-1 rounded-xs bg-control-bg px-1.5 py-0.5 text-xs";// Clone root, apply a mutation to the clone, return the clone.function updateExpr(@@ -550,11 +552,8 @@ function MultiSearchableSelect({<span className="text-control-placeholder">{placeholder ?? ""}</span>)}{value.map((v) => (- <span- key={v}- className="inline-flex items-center gap-1 bg-control-bg text-xs px-1.5 py-0.5 rounded-xs"- >- {getLabelForValue(v)}+ <span key={v} className={VALUE_TAG_CLASS}>+ <span className="min-w-0 truncate">{getLabelForValue(v)}</span>{!disabled && (<Buttontype="button"@@ -576,8 +575,7 @@ function MultiSearchableSelect({<PortaledDropdownanchorRef={triggerRef}dropdownRef={dropdownRef}- matchAnchorWidth- className="bg-background border border-control-border rounded-sm shadow-md"+ className="w-80 max-w-[calc(100vw-2rem)] bg-background border border-control-border rounded-sm shadow-md"><div className="p-1 border-b border-control-border"><SearchInput@@ -670,11 +668,8 @@ function TagInput({)}>{value.map((tag) => (- <span- key={tag}- className="inline-flex items-center gap-1 bg-control-bg text-xs px-1.5 py-0.5 rounded-xs"- >- {tag}+ <span key={tag} className={VALUE_TAG_CLASS}>+ <span className="min-w-0 truncate">{tag}</span>{!disabled && (<Buttontype="button"@@ -758,7 +753,7 @@ function MultiCheckSelect({size="xs"className={cn(VALUE_MULTI_FIELD_CLASS,- "h-auto w-full flex-wrap text-left whitespace-normal hover:bg-control-bg disabled:pointer-events-none"+ "h-auto w-full flex-wrap justify-start text-left whitespace-normal hover:bg-control-bg disabled:pointer-events-none")}disabled={disabled}onClick={() => setOpen(!open)}@@ -767,13 +762,12 @@ function MultiCheckSelect({<span className="text-control-placeholder">{placeholder}</span>)}{value.map((v) => (- <span- key={v}- className="inline-flex items-center gap-1 bg-control-bg text-xs px-1.5 py-0.5 rounded-xs"- >- {renderValue- ? renderValue(v, getLabelForValue(v))- : getLabelForValue(v)}+ <span key={v} className={VALUE_TAG_CLASS}>+ <span className="min-w-0 truncate">+ {renderValue+ ? renderValue(v, getLabelForValue(v))+ : getLabelForValue(v)}+ </span>{!disabled && (<spanrole="button"@@ -1503,7 +1497,7 @@ function ConditionGroup({</div>))}- {!root && (+ {!root && !readonly && (<div className="pl-1.5 pb-1 flex gap-x-1"><Buttontype="button"@@ -1530,7 +1524,7 @@ function ConditionGroup({</div>)}- {root && (+ {root && !readonly && (<div className="flex gap-x-1"><Buttontype="button"diff --git a/frontend/src/components/SemanticTypeSelect.test.tsx b/frontend/src/components/SemanticTypeSelect.test.tsxnew file mode 100644index 0000000000..856d7687f2--- /dev/null+++ b/frontend/src/components/SemanticTypeSelect.test.tsx@@ -0,0 +1,87 @@+import { create } from "@bufbuild/protobuf";+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, expect, test, vi } from "vitest";+import {+ AlgorithmSchema,+ SemanticTypeSetting_SemanticTypeSchema,+} from "@/types/proto-es/v1/setting_service_pb";+import { SemanticTypeSelect } from "./SemanticTypeSelect";++const semanticTypes = [+ create(SemanticTypeSetting_SemanticTypeSchema, {+ id: "bb.default",+ title: "Default",+ }),+ create(SemanticTypeSetting_SemanticTypeSchema, {+ id: "bb.default-partial",+ title: "Default Partial",+ }),+ create(SemanticTypeSetting_SemanticTypeSchema, {+ id: "EMAIL",+ title: "Email",+ description: "Email address",+ algorithm: create(AlgorithmSchema, {+ mask: {+ case: "fullMask",+ value: { substitution: "*" },+ },+ }),+ }),+];++vi.mock("react-i18next", () => ({+ initReactI18next: { type: "3rdParty", init: () => {} },+ useTranslation: () => ({+ t: (key: string, options?: { effect?: string }) =>+ options?.effect ? `${key}: ${options.effect}` : key,+ }),+}));++vi.mock("@/hooks/useSemanticTypes", () => ({+ useSemanticTypes: () => ({ configuredSemanticTypes: [], semanticTypes }),+}));++afterEach(cleanup);++test("shows built-in and configured semantic types with their masking descriptions", async () => {+ render(+ <SemanticTypeSelect+ value="bb.default"+ onValueChange={vi.fn()}+ aria-label="Semantic type"+ />+ );++ const select = screen.getByLabelText("Semantic type");+ expect(select.textContent).toContain("Default");+ expect(select.textContent).not.toContain("bb.default");++ fireEvent.click(select);++ expect(await screen.findByRole("listbox")).toHaveClass(+ "w-(--anchor-width)"+ );+ expect(+ await screen.findByText(+ "dynamic.settings.sensitive-data.semantic-types.template.bb-default.algorithm.description"+ )+ ).toBeInTheDocument();+ expect(screen.getByRole("option", { name: /Email/ })).toHaveTextContent(+ "settings.sensitive-data.semantic-types.masking-effect: settings.sensitive-data.algorithms.full-mask.self"+ );+});++test("uses the supplied empty label for a cleared semantic type", () => {+ render(+ <SemanticTypeSelect+ value=""+ emptyLabel="No semantic type"+ onValueChange={vi.fn()}+ aria-label="Semantic type"+ />+ );++ expect(screen.getByLabelText("Semantic type").textContent).toContain(+ "No semantic type"+ );+});diff --git a/frontend/src/components/SemanticTypeSelect.tsx b/frontend/src/components/SemanticTypeSelect.tsxnew file mode 100644index 0000000000..e6f3014109--- /dev/null+++ b/frontend/src/components/SemanticTypeSelect.tsx@@ -0,0 +1,229 @@+import { Pencil } from "lucide-react";+import { useEffect, useMemo, useState } from "react";+import { useTranslation } from "react-i18next";+import { Button } from "@/components/ui/button";+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from "@/components/ui/popover";+import { SearchInput } from "@/components/ui/search-input";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";+import { useSemanticTypes } from "@/hooks/useSemanticTypes";+import { getMaskingType } from "@/lib/sensitive-data/components-utils";+import { cn } from "@/lib/utils";+import type { SemanticTypeSetting_SemanticType } from "@/types/proto-es/v1/setting_service_pb";+import {+ getSemanticTypeListWithBuiltins,+ isBuiltinSemanticTypeId,+} from "@/types/semanticTypes";++const EMPTY_SELECT_VALUE = "__EMPTY__";++function getSemanticTypeDescription(+ semanticType: SemanticTypeSetting_SemanticType,+ t: ReturnType<typeof useTranslation>["t"]+) {+ if (isBuiltinSemanticTypeId(semanticType.id)) {+ return t(+ `dynamic.settings.sensitive-data.semantic-types.template.${semanticType.id.split(".").join("-")}.algorithm.description`+ );+ }++ const maskingType = getMaskingType(semanticType.algorithm);+ if (maskingType) {+ return t("settings.sensitive-data.semantic-types.masking-effect", {+ effect: t(`settings.sensitive-data.algorithms.${maskingType}.self`),+ });+ }++ return semanticType.description;+}++export function SemanticTypeOption({+ className,+ semanticType,+ showId = false,+}: {+ className?: string;+ semanticType: SemanticTypeSetting_SemanticType;+ showId?: boolean;+}) {+ const { t } = useTranslation();+ const description = getSemanticTypeDescription(semanticType, t);++ return (+ <div className={cn("flex min-w-0 flex-col", className)}>+ <span className="truncate">{semanticType.title || semanticType.id}</span>+ {showId && semanticType.title && (+ <span className="text-xs text-control">{semanticType.id}</span>+ )}+ {description && (+ <span className="whitespace-normal text-xs text-control-light">+ {description}+ </span>+ )}+ </div>+ );+}++export function SemanticTypeSelect({+ "aria-label": ariaLabel,+ className,+ disabled = false,+ emptyLabel,+ id,+ onValueChange,+ placeholder,+ semanticTypeList,+ value,+}: {+ "aria-label"?: string;+ className?: string;+ disabled?: boolean;+ emptyLabel?: string;+ id?: string;+ onValueChange: (value: string) => void;+ placeholder?: string;+ semanticTypeList?: SemanticTypeSetting_SemanticType[];+ value: string;+}) {+ const { t } = useTranslation();+ const { semanticTypes: workspaceSemanticTypes } = useSemanticTypes();+ const semanticTypes = semanticTypeList+ ? getSemanticTypeListWithBuiltins(semanticTypeList, t)+ : workspaceSemanticTypes;+ const selectedSemanticType = semanticTypes.find(+ (semanticType) => semanticType.id === value+ );+ const normalizedValue = value || (emptyLabel ? EMPTY_SELECT_VALUE : "");+ const selectPlaceholder =+ placeholder ??+ emptyLabel ??+ t("settings.sensitive-data.semantic-types.select");++ return (+ <Select+ value={normalizedValue}+ disabled={disabled}+ onValueChange={(nextValue) => {+ onValueChange(+ !nextValue || nextValue === EMPTY_SELECT_VALUE ? "" : nextValue+ );+ }}+ >+ <SelectTrigger id={id} aria-label={ariaLabel} className={className}>+ <SelectValue placeholder={selectPlaceholder}>+ {selectedSemanticType?.title || value || selectPlaceholder}+ </SelectValue>+ </SelectTrigger>+ <SelectContent className="w-(--anchor-width)">+ {emptyLabel && (+ <SelectItem value={EMPTY_SELECT_VALUE}>{emptyLabel}</SelectItem>+ )}+ {semanticTypes.map((semanticType) => (+ <SelectItem+ key={semanticType.id}+ value={semanticType.id}+ className="h-auto items-start py-2"+ >+ <SemanticTypeOption semanticType={semanticType} />+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ );+}++export function SemanticTypePicker({+ onSelect,+ testId,+}: {+ onSelect: (semanticTypeId: string) => void;+ testId: string;+}) {+ const { t } = useTranslation();+ const { semanticTypes } = useSemanticTypes();+ const [open, setOpen] = useState(false);+ const [searchText, setSearchText] = useState("");++ useEffect(() => {+ if (open) {+ setSearchText("");+ }+ }, [open]);++ const filteredSemanticTypes = useMemo(() => {+ const normalizedSearch = searchText.trim().toLowerCase();+ if (!normalizedSearch) {+ return semanticTypes;+ }++ return semanticTypes.filter((semanticType) =>+ [semanticType.id, semanticType.title, semanticType.description].some(+ (value) => value?.toLowerCase().includes(normalizedSearch)+ )+ );+ }, [searchText, semanticTypes]);++ return (+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger+ aria-label={t("common.edit")}+ data-testid={testId}+ className="inline-flex size-5 items-center justify-center rounded-xs text-control transition-colors hover:bg-control-bg hover:text-main focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent [&_svg]:pointer-events-none"+ onKeyDown={(event) => {+ if (event.key === "Enter" || event.key === " ") {+ event.stopPropagation();+ }+ }}+ onMouseDown={(event) => event.stopPropagation()}+ onPointerDown={(event) => event.stopPropagation()}+ onClick={(event) => event.stopPropagation()}+ >+ <Pencil className="size-3" />+ </PopoverTrigger>+ <PopoverContent align="start" className="w-96 p-0">+ <div className="flex flex-col gap-y-2 p-3">+ <SearchInput+ placeholder={t("common.filter-by-name")}+ value={searchText}+ onChange={(event) => setSearchText(event.target.value)}+ />+ <div className="max-h-80 overflow-y-auto rounded-sm border border-block-border">+ {filteredSemanticTypes.length === 0 ? (+ <div className="px-4 py-6 text-sm text-control-light">+ {t("common.no-data")}+ </div>+ ) : (+ <div className="divide-y divide-block-border">+ {filteredSemanticTypes.map((semanticType) => (+ <Button+ key={semanticType.id}+ type="button"+ appearance="secondary"+ size="sm"+ data-testid={`semantic-type-option-${semanticType.id.replaceAll(".", "-")}`}+ className="h-auto w-full flex-col items-start rounded-none px-4 py-3 text-left font-normal whitespace-normal"+ onClick={() => {+ onSelect(semanticType.id);+ setOpen(false);+ }}+ >+ <SemanticTypeOption semanticType={semanticType} showId />+ </Button>+ ))}+ </div>+ )}+ </div>+ </div>+ </PopoverContent>+ </Popover>+ );+}diff --git a/frontend/src/components/WorkspacePageLayout.test.tsx b/frontend/src/components/WorkspacePageLayout.test.tsxnew file mode 100644index 0000000000..5ef8727c04--- /dev/null+++ b/frontend/src/components/WorkspacePageLayout.test.tsx@@ -0,0 +1,41 @@+import { act } from "react";+import { createRoot } from "react-dom/client";+import { afterEach, beforeEach, describe, expect, test } from "vitest";+import { WorkspacePageLayout } from "./WorkspacePageLayout";++(+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }+).IS_REACT_ACT_ENVIRONMENT = true;++let container: HTMLDivElement;+let root: ReturnType<typeof createRoot>;++beforeEach(() => {+ container = document.createElement("div");+ document.body.appendChild(container);+ root = createRoot(container);+});++afterEach(() => {+ act(() => {+ root.unmount();+ });+ container.remove();+});++describe("WorkspacePageLayout", () => {+ test("only exposes horizontal overflow when a page opts in", () => {+ act(() => {+ root.render(+ <>+ <WorkspacePageLayout />+ <WorkspacePageLayout allowHorizontalOverflow />+ </>+ );+ });++ const pages = container.querySelectorAll("[data-slot='workspace-page-layout']");+ expect(pages).toHaveLength(2);+ expect(pages[0]?.className).not.toBe(pages[1]?.className);+ });+});diff --git a/frontend/src/components/WorkspacePageLayout.tsx b/frontend/src/components/WorkspacePageLayout.tsxindex 38b525bff1..89379da11a 100644--- a/frontend/src/components/WorkspacePageLayout.tsx+++ b/frontend/src/components/WorkspacePageLayout.tsx@@ -15,6 +15,9 @@ const styles = stylex.create({pagePadding: {paddingInline: 16,},+ horizontalOverflow: {+ overflowX: "visible",+ },content: {minWidth: 0,},@@ -40,11 +43,13 @@ const styles = stylex.create({});type WorkspacePageLayoutProps = ComponentProps<"div"> & {+ allowHorizontalOverflow?: boolean;padding?: "page" | "flush";};function WorkspacePageLayout({className,+ allowHorizontalOverflow = false,padding = "page",ref,style,@@ -52,7 +57,8 @@ function WorkspacePageLayout({}: WorkspacePageLayoutProps) {const stylexProps = stylex.props(styles.root,- padding === "page" && styles.pagePadding+ padding === "page" && styles.pagePadding,+ allowHorizontalOverflow && styles.horizontalOverflow);return (<divdiff --git a/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.test.tsx b/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.test.tsxindex 86ca0be9b0..bbf954d712 100644--- a/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.test.tsx+++ b/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.test.tsx@@ -229,7 +229,7 @@ test("explains the masking effect for built-in semantic types", async () => {const partialDescription = screen.getByText("dynamic.settings.sensitive-data.semantic-types.template.bb-default-partial.algorithm.description");- expect(partialDescription).toHaveClass("max-w-prose", "whitespace-normal");+ expect(partialDescription).toHaveClass("whitespace-normal");expect(partialOption).toContainElement(partialDescription);});diff --git a/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.tsx b/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.tsxindex 7cb1861f08..858e810ece 100644--- a/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.tsx+++ b/frontend/src/routes/project/database-detail/catalog/MarkSensitiveDataSheet.tsx@@ -1,5 +1,6 @@import { useEffect, useState } from "react";import { useTranslation } from "react-i18next";+import { SemanticTypeSelect } from "@/components/SemanticTypeSelect";import { Button } from "@/components/ui/button";import { FormField, FormFieldGroup, FormLabel } from "@/components/ui/form";import {@@ -20,10 +21,8 @@ import {} from "@/components/ui/sheet";import { useAppDatabaseMetadata } from "@/hooks/useAppDatabaseMetadata";import { updateColumnCatalog } from "@/lib/column-data-table/utils";-import { getMaskingType } from "@/lib/sensitive-data/components-utils";import type { Database } from "@/types/proto-es/v1/database_service_pb";import type { SemanticTypeSetting_SemanticType } from "@/types/proto-es/v1/setting_service_pb";-import { isBuiltinSemanticTypeId } from "@/types/semanticTypes";interface MarkSensitiveDataSheetProps {database: Database;@@ -50,9 +49,6 @@ export function MarkSensitiveDataSheet({schemaIndex === "" ? undefined : metadata.schemas[Number(schemaIndex)];const selectedTable =tableIndex === "" ? undefined : selectedSchema?.tables[Number(tableIndex)];- const selectedSemanticType = semanticTypeList.find(- (semanticType) => semanticType.id === semanticTypeId- );const canSave =!!selectedSchema &&!!selectedTable &&@@ -217,53 +213,16 @@ export function MarkSensitiveDataSheet({"settings.sensitive-data.semantic-type-description")}>- <Select+ <SemanticTypeSelectvalue={semanticTypeId}- onValueChange={(value) => setSemanticTypeId(value ?? "")}- >- <SelectTrigger- id="mark-sensitive-data-semantic-type"- className="w-full"- >- <SelectValue>- {selectedSemanticType?.title ||- t("settings.sensitive-data.semantic-types.select")}- </SelectValue>- </SelectTrigger>- <SelectContent>- {semanticTypeList.map((semanticType) => {- const maskingType = getMaskingType(semanticType.algorithm);- const maskingEffect = isBuiltinSemanticTypeId(- semanticType.id- )- ? t(- `dynamic.settings.sensitive-data.semantic-types.template.${semanticType.id.split(".").join("-")}.algorithm.description`- )- : maskingType- ? t(- "settings.sensitive-data.semantic-types.masking-effect",- {- effect: t(- `settings.sensitive-data.algorithms.${maskingType}.self`- ),- }- )- : undefined;- return (- <SelectItem key={semanticType.id} value={semanticType.id}>- <div className="flex min-w-0 flex-col">- <span className="truncate">{semanticType.title}</span>- {maskingEffect && (- <span className="max-w-prose whitespace-normal text-xs leading-5 text-control-light">- {maskingEffect}- </span>- )}- </div>- </SelectItem>- );- })}- </SelectContent>- </Select>+ onValueChange={setSemanticTypeId}+ id="mark-sensitive-data-semantic-type"+ aria-label={t(+ "settings.sensitive-data.semantic-types.table.semantic-type"+ )}+ className="w-full"+ semanticTypeList={semanticTypeList}+ /></FormField></FormFieldGroup></SheetBody>diff --git a/frontend/src/routes/project/database-detail/catalog/SensitiveColumnTable.tsx b/frontend/src/routes/project/database-detail/catalog/SensitiveColumnTable.tsxindex 8781d8517e..d3162f195e 100644--- a/frontend/src/routes/project/database-detail/catalog/SensitiveColumnTable.tsx+++ b/frontend/src/routes/project/database-detail/catalog/SensitiveColumnTable.tsx@@ -2,6 +2,7 @@ import { Trash2 } from "lucide-react";import { useMemo } from "react";import { useTranslation } from "react-i18next";import { RouterLink } from "@/components/RouterLink";+import { SemanticTypeSelect } from "@/components/SemanticTypeSelect";import { Button } from "@/components/ui/button";import { Checkbox } from "@/components/ui/checkbox";import {@@ -88,7 +89,6 @@ export function SensitiveColumnTable({showSelection,canEdit,showOperation,- semanticTypeOptions,classificationOptions,onCheckedColumnListChange,onSemanticTypeChange,@@ -101,7 +101,6 @@ export function SensitiveColumnTable({showSelection: boolean;canEdit: boolean;showOperation: boolean;- semanticTypeOptions: SelectOption[];classificationOptions: SelectOption[];onCheckedColumnListChange: (columnList: MaskData[]) => void;onSemanticTypeChange: (@@ -242,11 +241,11 @@ export function SensitiveColumnTable({{item.column || t("common.empty")}</TableCell><TableCell>- <EditableSelect+ <SemanticTypeSelectvalue={item.semanticTypeId}- options={semanticTypeOptions}disabled={semanticTypeDisabled}- placeholder={t("common.empty")}+ emptyLabel={t("common.empty")}+ className="w-full"onValueChange={(semanticTypeId) =>void onSemanticTypeChange(item, semanticTypeId)}diff --git a/frontend/src/routes/project/database-detail/overview/TableDetailSheet.test.tsx b/frontend/src/routes/project/database-detail/overview/TableDetailSheet.test.tsxindex c78b53362a..3fd81185ee 100644--- a/frontend/src/routes/project/database-detail/overview/TableDetailSheet.test.tsx+++ b/frontend/src/routes/project/database-detail/overview/TableDetailSheet.test.tsx@@ -45,6 +45,7 @@ const mocks = vi.hoisted(() => ({let TableDetailSheet: typeof import("./TableDetailSheet").TableDetailSheet;vi.mock("react-i18next", () => ({+ initReactI18next: { type: "3rdParty", init: () => {} },useTranslation: mocks.useTranslation,}));@@ -171,6 +172,7 @@ vi.mock("@/components/FeatureAttention", () => ({}));vi.mock("@/types/semanticTypes", () => ({+ isBuiltinSemanticTypeId: (id: string) => id.startsWith("bb."),getSemanticTypeListWithBuiltins: (semanticTypeList: Array<{ id: string; title: string }>) => [diff --git a/frontend/src/routes/project/database-detail/overview/TableDetailSheet.tsx b/frontend/src/routes/project/database-detail/overview/TableDetailSheet.tsxindex 7ad80ec6eb..583de72022 100644--- a/frontend/src/routes/project/database-detail/overview/TableDetailSheet.tsx+++ b/frontend/src/routes/project/database-detail/overview/TableDetailSheet.tsx@@ -6,6 +6,7 @@ import { useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { classificationLevelBackgroundClasses } from "@/components/classification-level";import { FeatureAttention } from "@/components/FeatureAttention";+import { SemanticTypePicker } from "@/components/SemanticTypeSelect";import { Button } from "@/components/ui/button";import { Checkbox } from "@/components/ui/checkbox";import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";@@ -616,107 +617,6 @@ function ClassificationPickerPopover({);}-function SemanticTypePickerPopover({- onSelect,- semanticTypeList,- testId,-}: {- onSelect: (semanticTypeId: string) => void;- semanticTypeList: SemanticTypeSetting_SemanticType[];- testId: string;-}) {- const { t } = useTranslation();- const [open, setOpen] = useState(false);- const [searchText, setSearchText] = useState("");-- useEffect(() => {- if (open) {- setSearchText("");- }- }, [open]);-- const filteredSemanticTypeList = useMemo(() => {- const normalizedSearch = searchText.trim().toLowerCase();- if (!normalizedSearch) {- return semanticTypeList;- }-- return semanticTypeList.filter((semanticType) => {- return (- semanticType.id.toLowerCase().includes(normalizedSearch) ||- semanticType.title.toLowerCase().includes(normalizedSearch) ||- (semanticType.description?.toLowerCase().includes(normalizedSearch) ??- false)- );- });- }, [searchText, semanticTypeList]);-- return (- <Popover open={open} onOpenChange={setOpen}>- <PopoverTrigger- aria-label={t("common.edit")}- data-testid={testId}- className="inline-flex size-5 items-center justify-center rounded-xs text-control transition-colors hover:bg-control-bg hover:text-main focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent [&_svg]:pointer-events-none"- onKeyDown={(event) => {- if (event.key === "Enter" || event.key === " ") {- event.stopPropagation();- }- }}- onMouseDown={(event) => event.stopPropagation()}- onPointerDown={(event) => event.stopPropagation()}- onClick={(event) => event.stopPropagation()}- >- <Pencil className="size-3" />- </PopoverTrigger>- <PopoverContent align="start" className="w-96 p-0">- <div className="flex flex-col gap-y-2 p-3">- <SearchInput- placeholder={t("common.filter-by-name")}- value={searchText}- onChange={(event) => setSearchText(event.target.value)}- />- <div className="max-h-80 overflow-y-auto rounded-sm border border-block-border">- {filteredSemanticTypeList.length === 0 ? (- <div className="px-4 py-6 text-sm text-control-light">- {t("common.no-data")}- </div>- ) : (- <div className="divide-y divide-block-border">- {filteredSemanticTypeList.map((semanticType) => (- <Button- key={semanticType.id}- type="button"- appearance="secondary"- size="sm"- data-testid={`semantic-type-option-${toTestId(semanticType.id)}`}- className="h-auto w-full flex-col items-start rounded-none px-4 py-3 text-left font-normal whitespace-normal"- onClick={() => {- onSelect(semanticType.id);- setOpen(false);- }}- >- <span className="text-sm font-medium text-main">- {semanticType.title}- </span>- <span className="text-xs text-control">- {semanticType.id}- </span>- {semanticType.description && (- <span className="text-xs text-control-light">- {semanticType.description}- </span>- )}- </Button>- ))}- </div>- )}- </div>- </div>- </PopoverContent>- </Popover>- );-}-export function EditableClassificationCell({classification,classificationConfig,@@ -834,8 +734,7 @@ function EditableSemanticTypeCell({</MiniActionButton>)}{!readonly && hasSensitiveDataFeature && !instanceMissingLicense && (- <SemanticTypePickerPopover- semanticTypeList={semanticTypeList}+ <SemanticTypePickertestId={`${testIdPrefix}-edit`}onSelect={(nextSemanticTypeId) => {void onApply(nextSemanticTypeId);diff --git a/frontend/src/routes/project/database-detail/panels/DatabaseCatalogPanel.tsx b/frontend/src/routes/project/database-detail/panels/DatabaseCatalogPanel.tsxindex 1139f1fb8c..08d9af662c 100644--- a/frontend/src/routes/project/database-detail/panels/DatabaseCatalogPanel.tsx+++ b/frontend/src/routes/project/database-detail/panels/DatabaseCatalogPanel.tsx@@ -242,14 +242,6 @@ export function DatabaseCatalogPanel({ database }: { database: Database }) {setPendingDeleteItem(null);}, [database.name]);- const semanticTypeOptions = useMemo(- () =>- semanticTypes.map((semanticType) => ({- label: semanticType.title || semanticType.id,- value: semanticType.id,- })),- [semanticTypes]- );const classificationOptions = useMemo(() =>Object.values(classificationConfig?.classification ?? {}).map(@@ -499,7 +491,6 @@ export function DatabaseCatalogPanel({ database }: { database: Database }) {showSelection={!isMaskingForNoSQL}canEdit={hasUpdateCatalogPermission && hasSensitiveDataFeature}showOperation={hasUpdateCatalogPermission && hasSensitiveDataFeature}- semanticTypeOptions={semanticTypeOptions}classificationOptions={classificationOptions}onCheckedColumnListChange={(columnList) =>setCheckedColumnList(columnList)diff --git a/frontend/src/routes/workspace/GlobalMaskingPage.test.tsx b/frontend/src/routes/workspace/GlobalMaskingPage.test.tsxindex 71ab904c21..b1bcb10a4b 100644--- a/frontend/src/routes/workspace/GlobalMaskingPage.test.tsx+++ b/frontend/src/routes/workspace/GlobalMaskingPage.test.tsx@@ -81,6 +81,7 @@ vi.mock("@/components/ui/select", () => ({vi.mock("@/lib/sensitive-data/components-utils", () => ({factorOperatorOverrideMap: {},getClassificationLevelOptions: () => [],+ getMaskingType: () => undefined,}));vi.mock("@/stores/app", () => {@@ -149,6 +150,7 @@ vi.mock("@/types/proto-es/v1/subscription_service_pb", () => ({}));vi.mock("@/types/semanticTypes", () => ({+ isBuiltinSemanticTypeId: (id: string) => id.startsWith("bb."),getSemanticTypeListWithBuiltins: (semanticTypes: Array<{ id: string; title: string }>) => [@@ -236,12 +238,18 @@ describe("GlobalMaskingPage", () => {expect(semanticTypeHeading?.className).toContain("h-9");expect(semanticTypeHeading?.className).toContain("items-center");expect(semanticTypeHeading?.parentElement?.className).toContain("gap-y-2");+ expect(semanticTypeHeading?.parentElement?.className).toContain("w-full");+ expect(semanticTypeHeading?.parentElement?.className).toContain(+ "xl:w-80"+ );expect(container.querySelector("[data-testid='expr-editor']")).not.toBeNull();- expect(- container.querySelector("[data-testid='semantic-type-trigger']")- ).not.toBeNull();+ const semanticTypeTrigger = container.querySelector(+ "[data-testid='semantic-type-trigger']"+ );+ expect(semanticTypeTrigger).not.toBeNull();+ expect(semanticTypeTrigger?.className).toContain("w-full");});it("lists built-in semantic types before configured types", async () => {diff --git a/frontend/src/routes/workspace/GlobalMaskingPage.tsx b/frontend/src/routes/workspace/GlobalMaskingPage.tsxindex 71d0484e3a..3f11047e69 100644--- a/frontend/src/routes/workspace/GlobalMaskingPage.tsx+++ b/frontend/src/routes/workspace/GlobalMaskingPage.tsx@@ -13,21 +13,14 @@ import { v4 as uuidv4 } from "uuid";import { ExprEditor, type OptionConfig } from "@/components/ExprEditor";import { FeatureAttention } from "@/components/FeatureAttention";import { LearnMoreLink } from "@/components/LearnMoreLink";+import { SemanticTypeSelect } from "@/components/SemanticTypeSelect";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";-import {- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from "@/components/ui/select";import {WorkspacePageInfo,WorkspacePageLayout,WorkspacePageToolbar,} from "@/components/WorkspacePageLayout";-import { useSemanticTypes } from "@/hooks/useSemanticTypes";import {factorOperatorOverrideMap,getClassificationLevelOptions,@@ -124,8 +117,6 @@ function MaskingRuleConfig({const [dirty, setDirty] = useState(false);const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);- const { semanticTypes: semanticTypeOptions } = useSemanticTypes();-const resetIdRef = useRef(0);const resetToRule = useCallback(async (rule: MaskingRulePolicy_MaskingRule) => {@@ -200,7 +191,7 @@ function MaskingRuleConfig({return (<div className="flex flex-col gap-y-4 w-full">- <div className="flex flex-col md:flex-row items-start md:items-stretch gap-x-4 gap-y-4">+ <div className="flex flex-col items-start gap-x-4 gap-y-4 xl:flex-row xl:items-stretch"><div className="flex-1 flex flex-col gap-y-2 min-w-0"><div className="flex items-center h-9">{!readonly ? (@@ -230,39 +221,19 @@ function MaskingRuleConfig({onUpdate={handleExprUpdate}/></div>- <div className="flex flex-col gap-y-2">+ <div className="flex w-full flex-col gap-y-2 xl:w-80"><h3 className="flex items-center h-9 font-medium text-sm text-main">{t("settings.sensitive-data.semantic-types.table.semantic-type")}</h3>- <Select+ <SemanticTypeSelectvalue={semanticType ?? ""}disabled={disabled || readonly}- onValueChange={(val) => {- setSemanticType(val || undefined);+ className="w-full"+ onValueChange={(value) => {+ setSemanticType(value || undefined);setDirty(true);}}- >- <SelectTrigger className="min-w-40">- <SelectValue- placeholder={t("settings.sensitive-data.semantic-types.select")}- >- {(value: string | null) => {- if (!value) return null;- const found = semanticTypeOptions.find(- (st) => st.id === value- );- return found?.title ?? value;- }}- </SelectValue>- </SelectTrigger>- <SelectContent>- {semanticTypeOptions.map((st) => (- <SelectItem key={st.id} value={st.id}>- {st.title}- </SelectItem>- ))}- </SelectContent>- </Select>+ /></div></div>@@ -556,7 +527,7 @@ export function GlobalMaskingPage() {};return (- <WorkspacePageLayout className="gap-y-4">+ <WorkspacePageLayout allowHorizontalOverflow className="gap-y-4"><FeatureAttention feature={PlanFeature.FEATURE_DATA_MASKING} /><WorkspacePageInfo