mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-21 09:35:38 -05:00
Fix Data Explorer context menu items visibility (#4996)
* Fix Data Explorer context menu items visibility The when clause was making the menu items show up for all nodes in the Data Explorer - even ones that didn't make sense such as the Databases folders. This change makes it only appear for the Database and Server nodes (which is how the OE tree is set up)
This commit is contained in:
@@ -3,10 +3,11 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/common/nodeContext';
|
||||
import { localize } from 'vs/nls';
|
||||
import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { DISCONNECT_COMMAND_ID, MANAGE_COMMAND_ID, NEW_QUERY_COMMAND_ID, REFRESH_COMMAND_ID } from './nodeCommands';
|
||||
import { ContextKeyExpr, ContextKeyRegexExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/common/nodeContext';
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
group: 'connection',
|
||||
@@ -18,6 +19,10 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
when: NodeContextKey.IsConnected
|
||||
});
|
||||
|
||||
// The weird regex is because we want this to generically apply to Database and Server nodes but right now
|
||||
// there isn't a consistent standard for the values there. We can't just search for database or server being
|
||||
// in the string at all because there's lots of node types which have those values (such as ServerLevelLogin)
|
||||
// that we don't want these menu items showing up on.
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
group: 'connection',
|
||||
order: 2,
|
||||
@@ -25,9 +30,13 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
id: NEW_QUERY_COMMAND_ID,
|
||||
title: localize('newQuery', 'New Query')
|
||||
},
|
||||
when: NodeContextKey.IsConnectable
|
||||
when: ContextKeyExpr.and(
|
||||
NodeContextKey.IsConnectable,
|
||||
new ContextKeyRegexExpr('viewItem', /.+itemType\.database.*|^database$/i))
|
||||
});
|
||||
|
||||
// Note that we don't show this for Databases under Server nodes (viewItem == Database) because
|
||||
// of an issue there where the connection always being master instead of the actual DB
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
group: 'connection',
|
||||
order: 1,
|
||||
@@ -35,7 +44,9 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
id: MANAGE_COMMAND_ID,
|
||||
title: localize('manage', 'Manage')
|
||||
},
|
||||
when: NodeContextKey.IsConnectable
|
||||
when: ContextKeyExpr.and(
|
||||
NodeContextKey.IsConnectable,
|
||||
new ContextKeyRegexExpr('viewItem', /.+itemType\.database.*/i))
|
||||
});
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
|
||||
|
||||
Reference in New Issue
Block a user