mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-05-16 10:17:27 +01:00
feat: Add "Duplicate Tab" support for Items, Query, and Settings tabs
This commit is contained in:
committed by
BChoudhury-ms
parent
f3ceca4ba5
commit
97134a5e6e
@@ -4,6 +4,7 @@ import { MessageTypes } from "Contracts/MessageTypes";
|
||||
import React from "react";
|
||||
import * as DataModels from "../../../Contracts/DataModels";
|
||||
import type { QueryTabOptions } from "../../../Contracts/ViewModels";
|
||||
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||
import { useTabs } from "../../../hooks/useTabs";
|
||||
import Explorer from "../../Explorer";
|
||||
import { IQueryTabComponentProps, ITabAccessor, QueryTabComponent } from "../../Tabs/QueryTab/QueryTabComponent";
|
||||
@@ -72,6 +73,30 @@ export class NewQueryTab extends TabsBase {
|
||||
});
|
||||
}
|
||||
|
||||
public canDuplicate(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
public duplicateTab(): void {
|
||||
const queryText = this.persistedState?.query?.text ?? "";
|
||||
const id = useTabs.getState().getTabs(ViewModels.CollectionTabKind.Query).length + 1;
|
||||
const newTab = new NewQueryTab(
|
||||
{
|
||||
tabKind: ViewModels.CollectionTabKind.Query,
|
||||
title: `Query ${id}`,
|
||||
tabPath: "",
|
||||
collection: this.collection,
|
||||
node: this.collection,
|
||||
queryText,
|
||||
partitionKey: this.partitionKey,
|
||||
splitterDirection: this.persistedState?.splitterDirection,
|
||||
queryViewSizePercent: this.persistedState?.queryViewSizePercent,
|
||||
},
|
||||
this.props,
|
||||
);
|
||||
useTabs.getState().activateNewTab(newTab);
|
||||
}
|
||||
|
||||
public render(): JSX.Element {
|
||||
return <QueryTabComponent {...this.iQueryTabComponentProps} />;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user