mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
close tabs by DB #194
This commit is contained in:
parent
94b6ec3a56
commit
37f0dc8b32
@ -181,7 +181,7 @@
|
|||||||
|
|
||||||
const getContextMenu = tab => () => {
|
const getContextMenu = tab => () => {
|
||||||
const { tabid, props, tabComponent } = tab;
|
const { tabid, props, tabComponent } = tab;
|
||||||
const { conid, database } = props || {};
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
text: 'Close',
|
text: 'Close',
|
||||||
@ -209,20 +209,27 @@
|
|||||||
onClick: () => showModal(FavoriteModal, { savingTab: tab }),
|
onClick: () => showModal(FavoriteModal, { savingTab: tab }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
function getDatabaseContextMenu(tabs) {
|
||||||
|
const { tabid, props } = tabs[0];
|
||||||
|
const { conid, database } = props;
|
||||||
|
|
||||||
|
return [
|
||||||
conid &&
|
conid &&
|
||||||
database && [
|
database && [
|
||||||
{ divider: true },
|
|
||||||
{
|
{
|
||||||
text: `Close with same DB - ${database}`,
|
text: `Close tabs with DB ${database}`,
|
||||||
onClick: () => closeWithSameDb(tabid),
|
onClick: () => closeWithSameDb(tabid),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: `Close with other DB than ${database}`,
|
text: `Close tabs with other DB than ${database}`,
|
||||||
onClick: () => closeWithOtherDb(tabid),
|
onClick: () => closeWithOtherDb(tabid),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
};
|
}
|
||||||
|
|
||||||
const handleSetDb = async props => {
|
const handleSetDb = async props => {
|
||||||
const { conid, database } = props || {};
|
const { conid, database } = props || {};
|
||||||
@ -251,9 +258,14 @@
|
|||||||
class="db-name"
|
class="db-name"
|
||||||
class:selected={tabsByDb[dbKey][0].tabDbKey == currentDbKey}
|
class:selected={tabsByDb[dbKey][0].tabDbKey == currentDbKey}
|
||||||
on:click={() => handleSetDb(tabsByDb[dbKey][0].props)}
|
on:click={() => handleSetDb(tabsByDb[dbKey][0].props)}
|
||||||
|
use:contextMenu={getDatabaseContextMenu(tabsByDb[dbKey])}
|
||||||
>
|
>
|
||||||
<FontIcon icon={getDbIcon(dbKey)} />
|
<FontIcon icon={getDbIcon(dbKey)} />
|
||||||
{tabsByDb[dbKey][0].tabDbName}
|
{tabsByDb[dbKey][0].tabDbName}
|
||||||
|
|
||||||
|
<span class="close-button-right tabCloseButton" on:click={e => closeWithSameDb(tabsByDb[dbKey][0].tabid)}>
|
||||||
|
<FontIcon icon="icon close" />
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="db-group">
|
<div class="db-group">
|
||||||
{#each _.sortBy(tabsByDb[dbKey], ['title', 'tabid']) as tab}
|
{#each _.sortBy(tabsByDb[dbKey], ['title', 'tabid']) as tab}
|
||||||
@ -332,7 +344,17 @@
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
color: var(--theme-font-3);
|
color: var(--theme-font-3);
|
||||||
}
|
}
|
||||||
|
.close-button-right {
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-right: 5px;
|
||||||
|
color: var(--theme-font-3);
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
.close-button:hover {
|
.close-button:hover {
|
||||||
color: var(--theme-font-1);
|
color: var(--theme-font-1);
|
||||||
}
|
}
|
||||||
|
.close-button-right:hover {
|
||||||
|
color: var(--theme-font-1);
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user