fix(tabs): allow duplicating data tabs with fresh results
This commit is contained in:
1 parent
5017aa7bb9
commit
5433f067d7
5 files changed
+91
-9
No files matched your search
+19
-1
@@ -4,7 +4,7 @@ import { createCloseAllTabMenuItem, createCloseLeftTabMenuItem, createCloseOther
|
||||
const t = (key: string) => key;
|
||||
|
||||
describe("shared tab menu helpers", () => {
|
||||
it("builds rename and duplicate items only when renaming is allowed", () => {
|
||||
it("builds rename and duplicate items for query tabs", () => {
|
||||
const items = createRenameDuplicateTabItems({
|
||||
tab: { id: "t1" } as never,
|
||||
t,
|
||||
@@ -29,6 +29,24 @@ describe("shared tab menu helpers", () => {
|
||||
expect(queryOnly[0]?.visible).toBe(false);
|
||||
});
|
||||
|
||||
it("allows duplicating data tabs without allowing rename", () => {
|
||||
let duplicated = false;
|
||||
const items = createRenameDuplicateTabItems({
|
||||
tab: { id: "data", mode: "data" } as never,
|
||||
t,
|
||||
canRename: false,
|
||||
onRename: () => undefined,
|
||||
onDuplicate: () => {
|
||||
duplicated = true;
|
||||
},
|
||||
});
|
||||
expect(items).toHaveLength(1);
|
||||
expect(items[0]?.label).toBe("contextMenu.duplicateTab");
|
||||
expect(items[0]?.visible).toBe(true);
|
||||
items[0]?.action?.();
|
||||
expect(duplicated).toBe(true);
|
||||
});
|
||||
|
||||
it("builds locate and pin menu items with the expected actions", () => {
|
||||
let located = false;
|
||||
let toggled = false;
|
||||
|
||||
@@ -17,7 +17,7 @@ export function createRenameDuplicateTabItems(options: { tab: QueryTab; t: (key:
|
||||
label: options.t("contextMenu.duplicateTab"),
|
||||
action: options.onDuplicate,
|
||||
icon: Copy,
|
||||
visible: options.canRename,
|
||||
visible: options.canRename || options.tab.mode === "data",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user