only show new query when query is supported (#17346)

* only show new query when query is supported

* test case fix and pr comments

* rename context key
This commit is contained in:
Alan Ren
2021-10-13 13:01:31 -07:00
committed by GitHub
parent 547ceba501
commit 156f8f1d5f
13 changed files with 66 additions and 20 deletions

View File

@@ -30,6 +30,10 @@ const ConnectionProviderContrib: IJSONSchema = {
type: 'string',
description: localize('schema.notebookKernelAlias', "Notebook Kernel Alias for the provider")
},
isQueryProvider: {
type: 'boolean',
description: localize('schema.isQueryProvider', "Whether the provider is also a query provider. The default value is true.")
},
iconPath: {
description: localize('schema.iconPath', "Icon path for the server type"),
oneOf: [

View File

@@ -134,7 +134,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
id: OE_NEW_NOTEBOOK_COMMAND_ID,
title: localize('newQuery', "New Notebook")
},
when: ContextKeyExpr.or(ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.NodeType.isEqualTo('Server')), ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.NodeType.isEqualTo('Database')))
when: ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.IsQueryProvider.isEqualTo(true), ContextKeyExpr.or(TreeNodeContextKey.NodeType.isEqualTo('Server'), TreeNodeContextKey.NodeType.isEqualTo('Database')))
});
const ExplorerNotebookActionID = 'explorer.notebook';

View File

@@ -78,7 +78,7 @@ MenuRegistry.appendMenuItem(MenuId.ObjectExplorerItemContext, {
id: OE_NEW_QUERY_ACTION_ID,
title: localize('newQuery', "New Query")
},
when: ContextKeyExpr.or(ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.NodeType.isEqualTo('Server')), ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.NodeType.isEqualTo('Database')))
when: ContextKeyExpr.and(TreeNodeContextKey.Status.notEqualsTo('Unavailable'), TreeNodeContextKey.IsQueryProvider.isEqualTo(true), ContextKeyExpr.or(TreeNodeContextKey.NodeType.isEqualTo('Server'), TreeNodeContextKey.NodeType.isEqualTo('Database')))
});
// New Query
@@ -89,7 +89,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, {
id: DE_NEW_QUERY_COMMAND_ID,
title: localize('newQuery', "New Query")
},
when: MssqlNodeContext.IsDatabaseOrServer
when: ContextKeyExpr.and(MssqlNodeContext.IsDatabaseOrServer, MssqlNodeContext.IsQueryProvider)
});
const ExplorerNewQueryActionID = 'explorer.query';