Skip to content

Commit 86a9b31

Browse files
committed
feat(toolbar): enhance toolbar actions with metadata and ROI grouping
1 parent caeb097 commit 86a9b31

3 files changed

Lines changed: 65 additions & 2 deletions

File tree

‎src/actions/registry.ts‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ export function buildStaticActions(
288288
menuPath: "Edit/Metadata/Add metadata…",
289289
iconUrl: getEditIconUrl("metadata_add.svg"),
290290
beginGroup: true,
291+
toolbar: true,
292+
toolbarGroup: "metadata-edit",
293+
toolbarOrder: 0,
291294
enabled: (s) => ready(s) && s.selectedIds.length > 0,
292295
run: cb.onAddMetadata,
293296
},
@@ -296,6 +299,9 @@ export function buildStaticActions(
296299
label: t("Import metadata…"),
297300
menuPath: "Edit/Metadata/Import metadata…",
298301
iconUrl: getEditIconUrl("metadata_import.svg"),
302+
toolbar: true,
303+
toolbarGroup: "metadata-edit",
304+
toolbarOrder: 1,
299305
enabled: (s) => ready(s) && s.selectedIds.length === 1,
300306
run: cb.onImportMetadata,
301307
},
@@ -304,6 +310,9 @@ export function buildStaticActions(
304310
label: t("Export metadata…"),
305311
menuPath: "Edit/Metadata/Export metadata…",
306312
iconUrl: getEditIconUrl("metadata_export.svg"),
313+
toolbar: true,
314+
toolbarGroup: "metadata-edit",
315+
toolbarOrder: 2,
307316
enabled: (s) => ready(s) && s.selectedIds.length === 1,
308317
run: cb.onExportMetadata,
309318
},
@@ -313,6 +322,9 @@ export function buildStaticActions(
313322
menuPath: "Edit/Metadata/Delete object metadata",
314323
iconUrl: getEditIconUrl("metadata_delete.svg"),
315324
beginGroup: true,
325+
toolbar: true,
326+
toolbarGroup: "metadata-del",
327+
toolbarOrder: 0,
316328
enabled: (s) => ready(s) && s.selectedIds.length > 0,
317329
run: cb.onDeleteMetadata,
318330
},
@@ -777,6 +789,9 @@ export function buildRoiActions(
777789
menuPath: "ROI/Copy ROI",
778790
iconUrl: getRoiIconUrl("roi_copy"),
779791
beginGroup: true,
792+
toolbar: true,
793+
toolbarGroup: "roi",
794+
toolbarOrder: 0,
780795
enabled: readyWithRoi,
781796
run: cb.onCopy,
782797
},
@@ -785,6 +800,9 @@ export function buildRoiActions(
785800
label: t("Paste ROI"),
786801
menuPath: "ROI/Paste ROI",
787802
iconUrl: getRoiIconUrl("roi_paste"),
803+
toolbar: true,
804+
toolbarGroup: "roi",
805+
toolbarOrder: 1,
788806
enabled: readyWithClipboard,
789807
run: cb.onPaste,
790808
},
@@ -793,6 +811,9 @@ export function buildRoiActions(
793811
label: t("Import ROI…"),
794812
menuPath: "ROI/Import ROI…",
795813
iconUrl: getRoiIconUrl("roi_import"),
814+
toolbar: true,
815+
toolbarGroup: "roi",
816+
toolbarOrder: 2,
796817
enabled: ready,
797818
run: cb.onImport,
798819
},
@@ -801,6 +822,9 @@ export function buildRoiActions(
801822
label: t("Export ROI…"),
802823
menuPath: "ROI/Export ROI…",
803824
iconUrl: getRoiIconUrl("roi_export"),
825+
toolbar: true,
826+
toolbarGroup: "roi",
827+
toolbarOrder: 3,
804828
enabled: readyWithRoi,
805829
run: cb.onExport,
806830
},
@@ -945,6 +969,9 @@ export function buildImageRoiActions(
945969
menuPath: "ROI/Copy ROI",
946970
iconUrl: getRoiIconUrl("roi_copy"),
947971
beginGroup: true,
972+
toolbar: true,
973+
toolbarGroup: "roi",
974+
toolbarOrder: 0,
948975
enabled: readyWithRoi,
949976
run: cb.onCopy,
950977
},
@@ -953,6 +980,9 @@ export function buildImageRoiActions(
953980
label: t("Paste ROI"),
954981
menuPath: "ROI/Paste ROI",
955982
iconUrl: getRoiIconUrl("roi_paste"),
983+
toolbar: true,
984+
toolbarGroup: "roi",
985+
toolbarOrder: 1,
956986
enabled: readyWithClipboard,
957987
run: cb.onPaste,
958988
},
@@ -961,6 +991,9 @@ export function buildImageRoiActions(
961991
label: t("Import ROI…"),
962992
menuPath: "ROI/Import ROI…",
963993
iconUrl: getRoiIconUrl("roi_import"),
994+
toolbar: true,
995+
toolbarGroup: "roi",
996+
toolbarOrder: 2,
964997
enabled: ready,
965998
run: cb.onImport,
966999
},
@@ -969,6 +1002,9 @@ export function buildImageRoiActions(
9691002
label: t("Export ROI…"),
9701003
menuPath: "ROI/Export ROI…",
9711004
iconUrl: getRoiIconUrl("roi_export"),
1005+
toolbar: true,
1006+
toolbarGroup: "roi",
1007+
toolbarOrder: 3,
9721008
enabled: readyWithRoi,
9731009
run: cb.onExport,
9741010
},

‎src/actions/types.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,18 @@ export type ToolbarItem =
6060

6161
/** Toolbar group ordering, mirroring DataLab desktop's toolbar layout:
6262
* the HDF5 workspace actions (main toolbar) come first, then the
63-
* per-object file / edit / metadata actions (panel toolbar). */
64-
export const TOOLBAR_GROUP_ORDER = ["file-h5", "file", "edit", "metadata"];
63+
* per-object file / edit / metadata / ROI actions (panel toolbar). The
64+
* metadata block is split into three sub-groups to reproduce desktop's
65+
* internal separators (copy/paste | add/import/export | delete). */
66+
export const TOOLBAR_GROUP_ORDER = [
67+
"file-h5",
68+
"file",
69+
"edit",
70+
"metadata",
71+
"metadata-edit",
72+
"metadata-del",
73+
"roi",
74+
];
6575

6676
export interface MenuNode {
6777
/** Canonical English structural label (menu-path segment). Used as a

‎tests/ts/actions/buildToolbar.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@ describe("buildToolbarItems", () => {
5757
expect(ids(items)).toBe("f,|,e,|,m");
5858
});
5959

60+
it("reproduces the full desktop PANEL_TOOLBAR layout", () => {
61+
// One representative action per group, shuffled; the helper must
62+
// restore the desktop order with a separator between each group,
63+
// including the metadata sub-groups (copy/paste | add/import/export |
64+
// delete) and the trailing ROI group.
65+
const items = buildToolbarItems([
66+
action("roi", { toolbar: true, toolbarGroup: "roi" }),
67+
action("del", { toolbar: true, toolbarGroup: "metadata-del" }),
68+
action("h5", { toolbar: true, toolbarGroup: "file-h5" }),
69+
action("meta", { toolbar: true, toolbarGroup: "metadata" }),
70+
action("edit", { toolbar: true, toolbarGroup: "edit" }),
71+
action("metaedit", { toolbar: true, toolbarGroup: "metadata-edit" }),
72+
action("file", { toolbar: true, toolbarGroup: "file" }),
73+
]);
74+
expect(ids(items)).toBe("h5,|,file,|,edit,|,meta,|,metaedit,|,del,|,roi");
75+
});
76+
6077
it("inserts a separator only between groups (never leading/trailing)", () => {
6178
const items = buildToolbarItems([
6279
action("f1", { toolbar: true, toolbarGroup: "file", toolbarOrder: 0 }),

0 commit comments

Comments
 (0)