Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions canvas/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ function Canvas() {
onToggleDrawer={() => setDrawerOpen((v) => !v)}
drawerOpen={drawerOpen}
filterCount={activeAreas.size}
// Scoped erwin export: when EXACTLY one subject area is filtered, the erwin export is
// scoped to it (passes ?subject_area=). Zero or several selected -> whole model.
scopeSubjectArea={activeAreas.size === 1 ? [...activeAreas][0] : null}
/>
)}
<div className="canvas-wrap">
Expand Down
3 changes: 3 additions & 0 deletions canvas/src/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function TopBar({
onToggleDrawer,
drawerOpen,
filterCount,
scopeSubjectArea,
}: {
doc: ModelDoc;
diagnostics: DiagnosticsDoc | null;
Expand Down Expand Up @@ -83,6 +84,7 @@ export function TopBar({
drawerOpen: boolean;
/** number of subject areas currently filtered to (0 = showing all) — badges the hamburger */
filterCount: number;
scopeSubjectArea: string | null;
}) {
const errors = diagnostics?.items.filter((d) => d.severity === "error").length ?? 0;
const warnings = diagnostics?.items.filter((d) => d.severity === "warning").length ?? 0;
Expand Down Expand Up @@ -251,6 +253,7 @@ export function TopBar({
buttonClass="grp-btn"
applyBatch={onImportBatch}
openImport={openImport}
scopeSubjectArea={scopeSubjectArea}
/>
</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions canvas/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,12 @@ export const fetchExportFormats = () =>

/** A same-origin URL the browser can open to download an export (the endpoint sets
* Content-Disposition: attachment). Respects the /view/<slug> catalog prefix. */
export const exportUrl = (fmt: string, dialect?: string): string => {
const q = dialect ? `?dialect=${encodeURIComponent(dialect)}` : "";
return `${API_BASE}/api/export/${encodeURIComponent(fmt)}${q}`;
export const exportUrl = (fmt: string, dialect?: string, subjectArea?: string | null): string => {
const params = new URLSearchParams();
if (dialect) params.set("dialect", dialect);
if (subjectArea) params.set("subject_area", subjectArea);
const q = params.toString();
return `${API_BASE}/api/export/${encodeURIComponent(fmt)}${q ? `?${q}` : ""}`;
};

export interface ImportResult {
Expand Down
5 changes: 5 additions & 0 deletions canvas/src/sme/ImportExportMenu.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
color: var(--text-dim);
margin: 0;
}
/* the "· filtered area only" note on the erwin export item when a single SA is filtered */
.ie-scope {
font-size: 11px;
color: var(--text-dim);
}
.ie-textarea {
width: 100%;
font-family: var(--mono);
Expand Down
36 changes: 23 additions & 13 deletions canvas/src/sme/ImportExportMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function ImportExportMenu({
openImport = false,
prefillImport = "",
onPreview,
scopeSubjectArea = null,
}: {
exec: Exec;
canEdit: boolean;
Expand All @@ -49,6 +50,9 @@ export function ImportExportMenu({
* reveals the canvas with `?import=1`, so the same wizard the toolbar button
* opens is already up when the panel appears. */
openImport?: boolean;
/** when a single subject area is filtered on the canvas, the erwin export is scoped to it
* (its id); null = export the whole model. Other formats ignore it. */
scopeSubjectArea?: string | null;
}) {
const [open, setOpen] = useState<"export" | "import" | null>(
openImport && canEdit ? "import" : null,
Expand Down Expand Up @@ -112,19 +116,25 @@ export function ImportExportMenu({
</select>
</label>
)}
{formats.map((f) => (
<a
key={f.id}
className="ie-item"
href={exportUrl(f.id, f.id === "sql" ? dialect : undefined)}
// download attribute lets the browser save rather than navigate; the
// server also sets Content-Disposition: attachment as a belt-and-braces.
download
onClick={() => setOpen(null)}
>
{f.label}
</a>
))}
{formats.map((f) => {
// erwin export honours a single active subject-area filter (exports just that
// slice); every other format always exports the whole model.
const scoped = f.id === "erwin" ? scopeSubjectArea : null;
return (
<a
key={f.id}
className="ie-item"
href={exportUrl(f.id, f.id === "sql" ? dialect : undefined, scoped)}
// download attribute lets the browser save rather than navigate; the
// server also sets Content-Disposition: attachment as a belt-and-braces.
download
onClick={() => setOpen(null)}
>
{f.label}
{scoped && <span className="ie-scope"> · filtered area only</span>}
</a>
);
})}
</div>
)}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading