mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
add to favorites moved from toolbar into tab context menu
This commit is contained in:
parent
38aae142ea
commit
7b6ca27b66
@ -87,9 +87,9 @@
|
|||||||
registerCommand({
|
registerCommand({
|
||||||
id: 'tabs.addToFavorites',
|
id: 'tabs.addToFavorites',
|
||||||
category: 'Tabs',
|
category: 'Tabs',
|
||||||
name: 'Favorites',
|
name: 'Add current tab to favorites',
|
||||||
icon: 'icon favorite',
|
// icon: 'icon favorite',
|
||||||
toolbar: true,
|
// toolbar: true,
|
||||||
testEnabled: () =>
|
testEnabled: () =>
|
||||||
getActiveTab()?.tabComponent &&
|
getActiveTab()?.tabComponent &&
|
||||||
tabs[getActiveTab()?.tabComponent] &&
|
tabs[getActiveTab()?.tabComponent] &&
|
||||||
@ -146,9 +146,10 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getContextMenu = (tabid, props) => () => {
|
const getContextMenu = tab => () => {
|
||||||
|
const { tabid, props, tabComponent } = tab;
|
||||||
const { conid, database } = props || {};
|
const { conid, database } = props || {};
|
||||||
const res = [
|
return [
|
||||||
{
|
{
|
||||||
text: 'Close',
|
text: 'Close',
|
||||||
onClick: () => closeTab(tabid),
|
onClick: () => closeTab(tabid),
|
||||||
@ -161,9 +162,19 @@
|
|||||||
text: 'Close others',
|
text: 'Close others',
|
||||||
onClick: () => closeOthers(tabid),
|
onClick: () => closeOthers(tabid),
|
||||||
},
|
},
|
||||||
];
|
tabComponent &&
|
||||||
if (conid && database) {
|
tabs[tabComponent] &&
|
||||||
res.push(
|
tabs[tabComponent].allowAddToFavorites &&
|
||||||
|
tabs[tabComponent].allowAddToFavorites(props) && [
|
||||||
|
{ divider: true },
|
||||||
|
{
|
||||||
|
text: 'Add to favorites',
|
||||||
|
onClick: () => showModal(FavoriteModal, { savingTab: tab }),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
conid &&
|
||||||
|
database && [
|
||||||
|
{ divider: true },
|
||||||
{
|
{
|
||||||
text: `Close with same DB - ${database}`,
|
text: `Close with same DB - ${database}`,
|
||||||
onClick: () => closeWithSameDb(tabid),
|
onClick: () => closeWithSameDb(tabid),
|
||||||
@ -171,10 +182,9 @@
|
|||||||
{
|
{
|
||||||
text: `Close with other DB than ${database}`,
|
text: `Close with other DB than ${database}`,
|
||||||
onClick: () => closeWithOtherDb(tabid),
|
onClick: () => closeWithOtherDb(tabid),
|
||||||
}
|
},
|
||||||
);
|
],
|
||||||
}
|
];
|
||||||
return res;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSetDb = async props => {
|
const handleSetDb = async props => {
|
||||||
@ -216,7 +226,7 @@
|
|||||||
class:selected={tab.selected}
|
class:selected={tab.selected}
|
||||||
on:click={e => handleTabClick(e, tab.tabid)}
|
on:click={e => handleTabClick(e, tab.tabid)}
|
||||||
on:mouseup={e => handleMouseUp(e, tab.tabid)}
|
on:mouseup={e => handleMouseUp(e, tab.tabid)}
|
||||||
use:contextMenu={getContextMenu(tab.tabid, tab.props)}
|
use:contextMenu={getContextMenu(tab)}
|
||||||
>
|
>
|
||||||
<FontIcon icon={tab.busy ? 'icon loading' : tab.icon} />
|
<FontIcon icon={tab.busy ? 'icon loading' : tab.icon} />
|
||||||
<span class="file-name">
|
<span class="file-name">
|
||||||
|
Loading…
Reference in New Issue
Block a user