mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 06:06:01 +00:00
feat: add reopen closed tab command
This commit is contained in:
@@ -155,6 +155,19 @@
|
||||
);
|
||||
const closeOthersInMultiTab = multiTabIndex =>
|
||||
closeTabFunc((x, active) => x.tabid != active.tabid && (x.multiTabIndex || 0) == multiTabIndex);
|
||||
const reopenClosedTab = () => {
|
||||
const lastClosedTabId = getOpenedTabs()
|
||||
.filter(x => x.closedTime)
|
||||
.sort((a, b) => b.closedTime - a.closedTime)[0]?.tabid;
|
||||
|
||||
if (!lastClosedTabId) return;
|
||||
|
||||
openedTabs.update(x =>
|
||||
x.map(tab =>
|
||||
tab.tabid === lastClosedTabId ? { ...tab, selected: true, closedTime: null } : { ...tab, selected: false }
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
function getTabDbName(tab, connectionList) {
|
||||
if (tab.tabComponent == 'ConnectionTab') return 'Connections';
|
||||
@@ -244,6 +257,15 @@
|
||||
onClick: closeTabsButCurrentDb,
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'tabs.reopenClosedTab',
|
||||
category: 'Tabs',
|
||||
name: 'Reopen closed tab',
|
||||
keyText: 'CtrlOrCommand+Shift+T',
|
||||
testEnabled: () => getOpenedTabs().filter(x => x.closedTime).length >= 1,
|
||||
onClick: reopenClosedTab,
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'tabs.addToFavorites',
|
||||
category: 'Tabs',
|
||||
|
||||
Reference in New Issue
Block a user