mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 03:53:57 +00:00
#238 menu command - close tabs x current DB
This commit is contained in:
@@ -22,8 +22,10 @@ module.exports = [
|
|||||||
{
|
{
|
||||||
label: 'Window',
|
label: 'Window',
|
||||||
submenu: [
|
submenu: [
|
||||||
{ command: 'tabs.closeTab', hideDisabled: true },
|
{ command: 'tabs.closeTab', hideDisabled: false },
|
||||||
{ command: 'tabs.closeAll', hideDisabled: true },
|
{ command: 'tabs.closeAll', hideDisabled: false },
|
||||||
|
{ command: 'tabs.closeTabsWithCurrentDb', hideDisabled: false },
|
||||||
|
{ command: 'tabs.closeTabsButCurrentDb', hideDisabled: false },
|
||||||
{ divider: true },
|
{ divider: true },
|
||||||
{ command: 'app.zoomIn', hideDisabled: true },
|
{ command: 'app.zoomIn', hideDisabled: true },
|
||||||
{ command: 'app.zoomOut', hideDisabled: true },
|
{ command: 'app.zoomOut', hideDisabled: true },
|
||||||
|
|||||||
@@ -53,6 +53,18 @@
|
|||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const closeTabsWithCurrentDb = () => {
|
||||||
|
const db = getCurrentDatabase();
|
||||||
|
closeMultipleTabs(tab => {
|
||||||
|
return db?.connection?._id == tab?.props?.conid && db?.name == tab?.props?.database;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const closeTabsButCurrentDb = () => {
|
||||||
|
const db = getCurrentDatabase();
|
||||||
|
closeMultipleTabs(tab => {
|
||||||
|
return db?.connection?._id != tab?.props?.conid || db?.name != tab?.props?.database;
|
||||||
|
});
|
||||||
|
};
|
||||||
const closeCurrentTab = () => {
|
const closeCurrentTab = () => {
|
||||||
closeTab(getActiveTabId());
|
closeTab(getActiveTabId());
|
||||||
};
|
};
|
||||||
@@ -117,6 +129,22 @@
|
|||||||
onClick: closeCurrentTab,
|
onClick: closeCurrentTab,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'tabs.closeTabsWithCurrentDb',
|
||||||
|
category: 'Tabs',
|
||||||
|
name: 'Close tabs with current DB',
|
||||||
|
testEnabled: () => getOpenedTabs().filter(x => !x.closedTime).length >= 1 && !!getCurrentDatabase(),
|
||||||
|
onClick: closeTabsWithCurrentDb,
|
||||||
|
});
|
||||||
|
|
||||||
|
registerCommand({
|
||||||
|
id: 'tabs.closeTabsButCurrentDb',
|
||||||
|
category: 'Tabs',
|
||||||
|
name: 'Close tabs but current DB',
|
||||||
|
testEnabled: () => getOpenedTabs().filter(x => !x.closedTime).length >= 1 && !!getCurrentDatabase(),
|
||||||
|
onClick: closeTabsButCurrentDb,
|
||||||
|
});
|
||||||
|
|
||||||
registerCommand({
|
registerCommand({
|
||||||
id: 'tabs.addToFavorites',
|
id: 'tabs.addToFavorites',
|
||||||
category: 'Tabs',
|
category: 'Tabs',
|
||||||
@@ -143,7 +171,15 @@
|
|||||||
import { showModal } from '../modals/modalTools';
|
import { showModal } from '../modals/modalTools';
|
||||||
import newQuery from '../query/newQuery';
|
import newQuery from '../query/newQuery';
|
||||||
|
|
||||||
import { currentDatabase, getActiveTab, getOpenedTabs, openedTabs, activeTabId, getActiveTabId } from '../stores';
|
import {
|
||||||
|
currentDatabase,
|
||||||
|
getActiveTab,
|
||||||
|
getOpenedTabs,
|
||||||
|
openedTabs,
|
||||||
|
activeTabId,
|
||||||
|
getActiveTabId,
|
||||||
|
getCurrentDatabase,
|
||||||
|
} from '../stores';
|
||||||
import tabs from '../tabs';
|
import tabs from '../tabs';
|
||||||
import { setSelectedTab } from '../utility/common';
|
import { setSelectedTab } from '../utility/common';
|
||||||
import contextMenu from '../utility/contextMenu';
|
import contextMenu from '../utility/contextMenu';
|
||||||
|
|||||||
Reference in New Issue
Block a user