fix: align scope picker with catalog toolbar

This commit is contained in:
yuxuanhui
2026-09-12 13:21:08 +08:00
parent 8981c24fda
commit ed349693db
6 changed files with 78 additions and 17 deletions
@@ -70,6 +70,7 @@ export function CatalogTableToolbar({
label, label,
active = true, active = true,
filterCount = 0, filterCount = 0,
scope,
filters, filters,
onApply, onApply,
onReset, onReset,
@@ -82,6 +83,7 @@ export function CatalogTableToolbar({
label: string; label: string;
active?: boolean; active?: boolean;
filterCount?: number; filterCount?: number;
scope?: ReactNode;
filters: ReactNode; filters: ReactNode;
onApply: () => void; onApply: () => void;
onReset: () => void; onReset: () => void;
@@ -149,6 +151,7 @@ export function CatalogTableToolbar({
role="toolbar" role="toolbar"
aria-label={`${label}表格工具栏`} aria-label={`${label}表格工具栏`}
> >
{scope}
<div className="catalog-toolbar-tools"> <div className="catalog-toolbar-tools">
{popup( {popup(
"filter", "filter",
+9 -6
View File
@@ -310,12 +310,6 @@ export function DatasetPage({
); );
return ( return (
<section className="preparation-page"> <section className="preparation-page">
<ScopeControls
value={scope}
onChange={setScope}
active={active}
revision={version}
/>
{error && <Banner type="danger" description={error} />} {error && <Banner type="danger" description={error} />}
{copied && ( {copied && (
<Banner <Banner
@@ -329,6 +323,15 @@ export function DatasetPage({
/> />
)} )}
<CatalogTableToolbar <CatalogTableToolbar
scope={
<ScopeControls
inline
value={scope}
onChange={setScope}
active={active}
revision={version}
/>
}
label="数据目录" label="数据目录"
active={active && !suspended && !detail} active={active && !suspended && !detail}
filterCount={[q, category, subcategory].filter(Boolean).length} filterCount={[q, category, subcategory].filter(Boolean).length}
+6 -3
View File
@@ -209,16 +209,19 @@ export function FieldBrowser({
setDraft((old) => ({ ...old, [k]: v })); setDraft((old) => ({ ...old, [k]: v }));
return ( return (
<div className="preparation-fields"> <div className="preparation-fields">
{!fixedScope && ( <CatalogTableToolbar
scope={
!fixedScope ? (
<ScopeControls <ScopeControls
inline
value={scope} value={scope}
onChange={setScope} onChange={setScope}
local={source === "local"} local={source === "local"}
active={active} active={active}
revision={revision} revision={revision}
/> />
)} ) : undefined
<CatalogTableToolbar }
label="字段目录" label="字段目录"
active={active && !adding} active={active && !adding}
columns={columnSettings} columns={columnSettings}
+6 -1
View File
@@ -18,6 +18,7 @@ export function ScopePicker({
value, value,
onChange, onChange,
local = false, local = false,
inline = false,
active = true, active = true,
revision = "", revision = "",
options, options,
@@ -28,6 +29,7 @@ export function ScopePicker({
value: Scope; value: Scope;
onChange: (scope: Scope) => void; onChange: (scope: Scope) => void;
local?: boolean; local?: boolean;
inline?: boolean;
active?: boolean; active?: boolean;
revision?: string; revision?: string;
options?: ScopeOption[]; options?: ScopeOption[];
@@ -86,7 +88,10 @@ export function ScopePicker({
value.universe && value.universe &&
Number.isFinite(value.delay); Number.isFinite(value.delay);
return ( return (
<section className="scope-picker" aria-label="组合选择"> <section
className={`scope-picker${inline ? " scope-picker-inline" : ""}`}
aria-label="组合选择"
>
<div className="scope-picker-summary"> <div className="scope-picker-summary">
<div> <div>
<span className="settings-label">组合</span> <span className="settings-label">组合</span>
+28 -1
View File
@@ -5,7 +5,7 @@
.scope-picker-summary { .scope-picker-summary {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: flex-start;
gap: 16px; gap: 16px;
padding: 12px; padding: 12px;
border: 1px solid var(--semi-color-border); border: 1px solid var(--semi-color-border);
@@ -83,3 +83,30 @@
grid-template-columns: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
} }
} }
/* The toolbar variant keeps the summary compact; editing does not move the table. */
.scope-picker-inline {
position: relative;
margin: 0;
max-width: 100%;
}
.scope-picker-inline .scope-picker-summary {
padding: 0;
border: 0;
gap: 8px;
flex-wrap: wrap;
}
.scope-picker-inline .scope-picker-panel {
position: absolute;
top: calc(100% + 8px);
left: 0;
z-index: 10;
box-sizing: border-box;
width: min(560px, calc(100vw - 48px));
max-height: min(600px, 65dvh);
overflow-y: auto;
background: var(--semi-color-bg-2);
border: 1px solid var(--semi-color-border);
border-radius: 6px;
box-shadow: var(--semi-shadow-elevated);
}
+20
View File
@@ -219,6 +219,26 @@ test("目录表格保持紧凑行高、截断和固定分页", async ({ page })
await expect( await expect(
table.locator(".semi-tag").filter({ hasText: "已同步字段" }), table.locator(".semi-tag").filter({ hasText: "已同步字段" }),
).toBeVisible(); ).toBeVisible();
const summary = page
.getByRole("toolbar", { name: "数据目录表格工具栏" })
.locator(".scope-picker-summary");
const summaryBox = await summary.boundingBox();
const filterBox = await page
.getByRole("button", { name: "筛选数据目录", exact: true })
.boundingBox();
expect(
Math.abs(
summaryBox!.y +
summaryBox!.height / 2 -
filterBox!.y -
filterBox!.height / 2,
),
).toBeLessThan(3);
const textBox = await summary.locator(":scope > div").boundingBox();
const changeBox = await summary
.getByRole("button", { name: "更改组合" })
.boundingBox();
expect(changeBox!.x - textBox!.x - textBox!.width).toBeLessThanOrEqual(16);
await page.screenshot({ path: "test-results/catalog-table-layout.png" }); await page.screenshot({ path: "test-results/catalog-table-layout.png" });
await page await page
.getByRole("navigation", { name: "主导航" }) .getByRole("navigation", { name: "主导航" })