Azure pane in connection dialog (#11736)

* azure pane in connection dialog

* fix layering

* fix issues

* fix test

* more test fixes

* add back double click to connect for non-contributed views
This commit is contained in:
Anthony Dresser
2020-08-13 17:02:42 -07:00
committed by GitHub
parent a69b4bf662
commit 8cf82c1f8b
19 changed files with 272 additions and 167 deletions

View File

@@ -14,10 +14,12 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { coalesce } from 'vs/base/common/arrays';
import { CustomTreeView, TreeViewPane } from 'sql/workbench/browser/parts/views/treeView';
import { VIEWLET_ID } from 'sql/workbench/contrib/dataExplorer/browser/dataExplorerViewlet';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ICustomViewDescriptor } from 'vs/workbench/api/browser/viewsExtensionPoint';
import { CustomTreeView as VSCustomTreeView } from 'vs/workbench/contrib/views/browser/treeView';
import { TreeViewPane } from 'vs/workbench/browser/parts/views/treeView';
import { CustomTreeView } from 'sql/workbench/contrib/views/browser/treeView';
interface IUserFriendlyViewDescriptor {
id: string;
@@ -39,7 +41,7 @@ const viewDescriptor: IJSONSchema = {
when: {
description: localize('vscode.extension.contributes.view.when', "Condition which must be true to show this view"),
type: 'string'
},
}
}
};
@@ -62,7 +64,6 @@ const dataExplorerContribution: IJSONSchema = {
}
};
const dataExplorerExtensionPoint: IExtensionPoint<{ [loc: string]: IUserFriendlyViewDescriptor[] }> = ExtensionsRegistry.registerExtensionPoint<{ [loc: string]: IUserFriendlyViewDescriptor[] }>({ extensionPoint: 'dataExplorer', jsonSchema: dataExplorerContribution });
export class DataExplorerContainerExtensionHandler implements IWorkbenchContribution {
@@ -86,9 +87,8 @@ export class DataExplorerContainerExtensionHandler implements IWorkbenchContribu
return;
}
let container = this.viewContainersRegistry.get(VIEWLET_ID);
let container = this.viewContainersRegistry.get(entry.key);
if (!container) {
collector.warn(localize('ViewsContainerDoesnotExist', "View container '{0}' does not exist and all views registered to it will be added to 'Data Explorer'.", entry.key));
container = this.viewContainersRegistry.get(VIEWLET_ID);
}
const registeredViews = Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).getViews(container);
@@ -111,7 +111,7 @@ export class DataExplorerContainerExtensionHandler implements IWorkbenchContribu
when: ContextKeyExpr.deserialize(item.when),
canToggleVisibility: true,
canMoveView: true,
treeView: this.instantiationService.createInstance(CustomTreeView, item.id, item.name),
treeView: container.id === VIEWLET_ID ? this.instantiationService.createInstance(CustomTreeView, item.id, item.name) : this.instantiationService.createInstance(VSCustomTreeView, item.id, item.name),
collapsed: this.showCollapsed(container),
extensionId: extension.description.identifier,
originalContainerId: entry.key
@@ -154,4 +154,3 @@ export class DataExplorerContainerExtensionHandler implements IWorkbenchContribu
return true;
}
}

View File

@@ -10,7 +10,7 @@ import {
DISCONNECT_COMMAND_ID, REFRESH_COMMAND_ID
} from './nodeCommands.common';
import { ContextKeyExpr, ContextKeyNotEqualsExpr } from 'vs/platform/contextkey/common/contextkey';
import { NodeContextKey } from 'sql/workbench/browser/parts/views/nodeContext';
import { NodeContextKey } from 'sql/workbench/contrib/views/browser/nodeContext';
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';

View File

@@ -3,7 +3,6 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { INodeContextValue } from 'sql/workbench/browser/parts/views/nodeContext';
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { Disposable } from 'vs/base/common/lifecycle';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
@@ -12,6 +11,7 @@ import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilit
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { NodeType } from 'sql/workbench/services/objectExplorer/common/nodeType';
import { isWindows } from 'vs/base/common/platform';
import { INodeContextValue } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
export class NodeContextUtils extends Disposable {

View File

@@ -28,7 +28,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { URI } from 'vs/base/common/uri';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspaces/common/workspaceEditing';
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { NodeContextKey } from 'sql/workbench/browser/parts/views/nodeContext';
import { NodeContextKey } from 'sql/workbench/contrib/views/browser/nodeContext';
import { MssqlNodeContext } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
import { mssqlProviderName } from 'sql/platform/connection/common/constants';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';

View File

@@ -15,7 +15,7 @@ import { IViewletViewOptions } from 'vs/workbench/browser/parts/views/viewsViewl
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Extensions as ViewContainerExtensions, IViewDescriptor, IViewsRegistry, IViewContainersRegistry, ViewContainerLocation, IViewDescriptorService } from 'vs/workbench/common/views';
import { Extensions as ViewContainerExtensions, IViewDescriptor, IViewsRegistry, IViewContainersRegistry, ViewContainerLocation, IViewDescriptorService, ITreeViewDescriptor } from 'vs/workbench/common/views';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { Registry } from 'vs/platform/registry/common/platform';
@@ -35,7 +35,6 @@ import { MessageType } from 'vs/base/browser/ui/inputbox/inputBox';
import { QueryBuilder, ITextQueryBuilderOptions } from 'vs/workbench/contrib/search/common/queryBuilder';
import { IFileService } from 'vs/platform/files/common/files';
import { getOutOfWorkspaceEditorResources } from 'vs/workbench/contrib/search/common/search';
import { TreeViewPane } from 'sql/workbench/browser/parts/views/treeView';
import { NotebookSearchView } from 'sql/workbench/contrib/notebook/browser/notebookExplorer/notebookSearch';
import * as path from 'vs/base/common/path';
import { URI } from 'vs/base/common/uri';
@@ -265,20 +264,15 @@ export class NotebookExplorerViewPaneContainer extends ViewPaneContainer {
if (this.views.length > 1) {
let filesToIncludeFiltered: string = '';
this.views.forEach(async (v) => {
let booksViewPane = (<TreeViewPane>this.getView(v.id));
if (booksViewPane?.treeView?.root) {
let root = booksViewPane.treeView.root;
if (root.children) {
let items = root.children;
items?.forEach(root => {
this.updateViewletsState();
let folderToSearch: IFolderQuery = { folder: URI.file(path.join(isString(root.tooltip) ? root.tooltip : root.tooltip.value, 'content')) };
query.folderQueries.push(folderToSearch);
filesToIncludeFiltered = filesToIncludeFiltered + path.join(folderToSearch.folder.fsPath, '**', '*.md') + ',' + path.join(folderToSearch.folder.fsPath, '**', '*.ipynb') + ',';
this.searchView.startSearch(query, null, filesToIncludeFiltered, false, this.searchWidget);
});
}
}
const { treeView } = (<ITreeViewDescriptor>Registry.as<IViewsRegistry>(ViewContainerExtensions.ViewsRegistry).getView(v.id));
let items = await treeView?.dataProvider.getChildren();
items?.forEach(root => {
this.updateViewletsState();
let folderToSearch: IFolderQuery = { folder: URI.file(path.join(isString(root.tooltip) ? root.tooltip : root.tooltip.value, 'content')) };
query.folderQueries.push(folderToSearch);
filesToIncludeFiltered = filesToIncludeFiltered + path.join(folderToSearch.folder.fsPath, '**', '*.md') + ',' + path.join(folderToSearch.folder.fsPath, '**', '*.ipynb') + ',';
this.searchView.startSearch(query, null, filesToIncludeFiltered, false, this.searchWidget);
});
});
}

View File

@@ -0,0 +1,83 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ConnectionContextKey } from 'sql/workbench/services/connection/common/connectionContextKey';
import { IOEShimService } from 'sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim';
import { Disposable } from 'vs/base/common/lifecycle';
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IQueryManagementService } from 'sql/workbench/services/query/common/queryManagement';
import { MssqlNodeContext, INodeContextValue } from 'sql/workbench/services/objectExplorer/browser/mssqlNodeContext';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
export class NodeContextKey extends Disposable implements IContextKey<INodeContextValue> {
static IsConnectable = new RawContextKey<boolean>('isConnectable', false);
static IsConnected = new RawContextKey<boolean>('isConnected', false);
static ViewId = new RawContextKey<string>('view', undefined);
static ViewItem = new RawContextKey<string>('viewItem', undefined);
static Node = new RawContextKey<INodeContextValue>('node', undefined);
private readonly _connectionContextKey: ConnectionContextKey;
private readonly _connectableKey: IContextKey<boolean>;
private readonly _connectedKey: IContextKey<boolean>;
private readonly _viewIdKey: IContextKey<string>;
private readonly _viewItemKey: IContextKey<string>;
private readonly _nodeContextKey: IContextKey<INodeContextValue>;
private _nodeContextUtils: MssqlNodeContext;
constructor(
@IContextKeyService private contextKeyService: IContextKeyService,
@IOEShimService private oeService: IOEShimService,
@IQueryManagementService queryManagementService: IQueryManagementService,
@IConnectionManagementService private connectionManagementService: IConnectionManagementService,
@ICapabilitiesService private capabilitiesService: ICapabilitiesService
) {
super();
this._connectableKey = NodeContextKey.IsConnectable.bindTo(contextKeyService);
this._connectedKey = NodeContextKey.IsConnected.bindTo(contextKeyService);
this._viewIdKey = NodeContextKey.ViewId.bindTo(contextKeyService);
this._viewItemKey = NodeContextKey.ViewItem.bindTo(contextKeyService);
this._nodeContextKey = NodeContextKey.Node.bindTo(contextKeyService);
this._connectionContextKey = new ConnectionContextKey(contextKeyService, queryManagementService);
}
set(value: INodeContextValue) {
if (value.node && value.node.payload) {
this._connectableKey.set(true);
this._connectedKey.set(this.oeService.isNodeConnected(value.viewId, value.node));
this._connectionContextKey.set(value.node.payload);
} else {
this._connectableKey.set(false);
this._connectedKey.set(false);
this._connectionContextKey.reset();
}
if (value.node) {
this._viewItemKey.set(value.node.contextValue);
} else {
this._viewItemKey.reset();
}
this._nodeContextKey.set(value);
this._viewIdKey.set(value.viewId);
this._nodeContextUtils = new MssqlNodeContext(this._nodeContextKey.get(), this.contextKeyService,
this.connectionManagementService, this.capabilitiesService);
}
reset(): void {
this._viewIdKey.reset();
this._viewItemKey.reset();
this._connectableKey.reset();
this._connectedKey.reset();
this._connectionContextKey.reset();
this._nodeContextKey.reset();
this._nodeContextUtils.dispose();
}
get(): INodeContextValue | undefined {
return this._nodeContextKey.get();
}
}

File diff suppressed because it is too large Load Diff