From fe1223395403940773f2a798d5adecfd2f62cdea Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Thu, 11 Apr 2019 09:44:43 -0700 Subject: [PATCH] Azure extension changes (#4987) * removed search box * removed commented code --- extensions/mssql/package.json | 8 ++++++ extensions/mssql/package.nls.json | 5 +++- extensions/mssql/src/main.ts | 2 ++ .../src/objectExplorerNodeProvider/command.ts | 15 +++++++++++ .../objectExplorer/viewlet/serverTreeView.ts | 23 +++++++++++++++- .../electron-browser/connectionViewlet.ts | 26 ------------------ .../browser/connectionViewletPanel.ts | 27 +------------------ .../nodeActions.contribution.ts | 5 ++-- 8 files changed, 55 insertions(+), 56 deletions(-) diff --git a/extensions/mssql/package.json b/extensions/mssql/package.json index fbc91709e2..00bd1a84cd 100644 --- a/extensions/mssql/package.json +++ b/extensions/mssql/package.json @@ -110,6 +110,14 @@ { "command": "mssqlCluster.livy.cmd.submitFileToSparkJob", "title": "%title.submitSparkJob%" + }, + { + "command": "mssql.searchServers", + "title": "%title.searchServers%" + }, + { + "command": "mssql.clearSearchServerResult", + "title": "%title.clearSearchServerResult%" } ], "outputChannels": [ diff --git a/extensions/mssql/package.nls.json b/extensions/mssql/package.nls.json index b7e77c4cb1..b2286155b8 100644 --- a/extensions/mssql/package.nls.json +++ b/extensions/mssql/package.nls.json @@ -24,5 +24,8 @@ "title.openYarnHistory": "View Yarn History", "title.tasks": "Tasks", "title.installPackages": "Install Packages", - "title.configurePython": "Configure Python for Notebooks" + "title.configurePython": "Configure Python for Notebooks", + + "title.searchServers": "Search: Servers", + "title.clearSearchServerResult": "Search: Clear Search Server Results" } \ No newline at end of file diff --git a/extensions/mssql/src/main.ts b/extensions/mssql/src/main.ts index f6bd482b0f..3db280c18a 100644 --- a/extensions/mssql/src/main.ts +++ b/extensions/mssql/src/main.ts @@ -32,6 +32,7 @@ import { OpenSparkJobSubmissionDialogCommand, OpenSparkJobSubmissionDialogFromFi import { OpenSparkYarnHistoryTask } from './sparkFeature/historyTask'; import { MssqlObjectExplorerNodeProvider, mssqlOutputChannel } from './objectExplorerNodeProvider/objectExplorerNodeProvider'; import { CmsService } from './cms/cmsService'; +import { registerSearchServerCommand } from './objectExplorerNodeProvider/command'; const baseConfig = require('./config.json'); const outputChannel = vscode.window.createOutputChannel(Constants.serviceName); @@ -120,6 +121,7 @@ export async function activate(context: vscode.ExtensionContext): Promise { + vscode.window.showInputBox({ + placeHolder: localize('mssql.searchServers', 'Search Server Names') + }).then((stringSearch) => { + if (stringSearch) { + vscode.commands.executeCommand('registeredServers.searchServer', (stringSearch)); + } + }); + }); + appContext.apiWrapper.registerCommand('mssql.clearSearchServerResult', () => { + vscode.commands.executeCommand('registeredServers.clearSearchServerResult'); + }); +} \ No newline at end of file diff --git a/src/sql/parts/objectExplorer/viewlet/serverTreeView.ts b/src/sql/parts/objectExplorer/viewlet/serverTreeView.ts index e8166dce52..994eb36ab2 100644 --- a/src/sql/parts/objectExplorer/viewlet/serverTreeView.ts +++ b/src/sql/parts/objectExplorer/viewlet/serverTreeView.ts @@ -5,7 +5,7 @@ import 'vs/css!./media/serverTreeActions'; import * as errors from 'vs/base/common/errors'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import Severity from 'vs/base/common/severity'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { attachListStyler } from 'vs/platform/theme/common/styler'; @@ -34,6 +34,7 @@ import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMess import { ServerTreeActionProvider } from 'sql/parts/objectExplorer/viewlet/serverTreeActionProvider'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import { isHidden } from 'sql/base/browser/dom'; +import { CommandsRegistry } from 'vs/platform/commands/common/commands'; /** * ServerTreeview implements the dynamic tree view. @@ -72,6 +73,7 @@ export class ServerTreeView { this._treeSelectionHandler.onTreeActionStateChange(false); } }); + this.registerCommands(); } /** @@ -96,6 +98,25 @@ export class ServerTreeView { return this._tree; } + /** + * + * Register search related commands + */ + public registerCommands(): void { + CommandsRegistry.registerCommand({ + id: 'registeredServers.searchServer', + handler: (accessor: ServicesAccessor, ...args: any[]) => { + this.searchTree(args[0]); + } + }); + CommandsRegistry.registerCommand({ + id: 'registeredServers.clearSearchServerResult', + handler: (accessor: ServicesAccessor, ...args: any[]) => { + this.refreshTree(); + } + }); + } + /** * Render the view body */ diff --git a/src/sql/workbench/parts/connection/electron-browser/connectionViewlet.ts b/src/sql/workbench/parts/connection/electron-browser/connectionViewlet.ts index 33e87bf3ef..045a0f3923 100644 --- a/src/sql/workbench/parts/connection/electron-browser/connectionViewlet.ts +++ b/src/sql/workbench/parts/connection/electron-browser/connectionViewlet.ts @@ -32,10 +32,8 @@ import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/la export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet { private _root: HTMLElement; - private _searchBox: InputBox; private _toDisposeViewlet: IDisposable[] = []; private _serverTreeView: ServerTreeView; - private _clearSearchAction: ClearSearchAction; private _addServerAction: IAction; private _addServerGroupAction: IAction; private _activeConnectionsFilterAction: ActiveConnectionsFilterAction; @@ -53,7 +51,6 @@ export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet { super(VIEWLET_ID, configurationService, layoutService, telemetryService, _themeService, storageService); - this._clearSearchAction = this._instantiationService.createInstance(ClearSearchAction, ClearSearchAction.ID, ClearSearchAction.LABEL, this); this._addServerAction = this._instantiationService.createInstance(AddServerAction, AddServerAction.ID, AddServerAction.LABEL); @@ -79,24 +76,6 @@ export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet { super.create(parent); this._root = parent; const viewletContainer = DOM.append(parent, DOM.$('div.server-explorer-viewlet')); - const searchBoxContainer = DOM.append(viewletContainer, DOM.$('div.search-box')); - this._searchBox = new InputBox( - searchBoxContainer, - null, - { - placeholder: localize('Search server names', 'Search server names'), - actions: [this._clearSearchAction], - ariaLabel: localize('Search server names', 'Search server names') - } - ); - - this._searchBox.onDidChange(() => { - this.search(this._searchBox.value); - }); - - // Theme styler - this._toDisposeViewlet.push(attachInputBoxStyler(this._searchBox, this._themeService)); - const viewContainer = DOM.append(viewletContainer, DOM.$('div.object-explorer-view')); this._serverTreeView.renderBody(viewContainer).then(undefined, error => { warn('render registered servers: ' + error); @@ -105,7 +84,6 @@ export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet { public search(value: string): void { if (value) { - this._clearSearchAction.enabled = true; this._serverTreeView.searchTree(value); } else { this.clearSearch(); @@ -129,7 +107,6 @@ export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet { } public layout({ height, width }: DOM.Dimension): void { - this._searchBox.layout(); this._serverTreeView.layout(height - 36); // account for search box DOM.toggleClass(this._root, 'narrow', width <= 350); } @@ -140,9 +117,6 @@ export class ConnectionViewlet extends Viewlet implements IConnectionsViewlet { public clearSearch() { this._serverTreeView.refreshTree(); - this._searchBox.value = ''; - this._clearSearchAction.enabled = false; - this._searchBox.focus(); } public dispose(): void { diff --git a/src/sql/workbench/parts/dataExplorer/browser/connectionViewletPanel.ts b/src/sql/workbench/parts/dataExplorer/browser/connectionViewletPanel.ts index 60ecf1451d..97b2430927 100644 --- a/src/sql/workbench/parts/dataExplorer/browser/connectionViewletPanel.ts +++ b/src/sql/workbench/parts/dataExplorer/browser/connectionViewletPanel.ts @@ -31,10 +31,8 @@ import { IExtensionsWorkbenchService } from 'vs/workbench/contrib/extensions/com export class ConnectionViewletPanel extends ViewletPanel { private _root: HTMLElement; - private _searchBox: InputBox; private _toDisposeViewlet: IDisposable[] = []; private _serverTreeView: ServerTreeView; - private _clearSearchAction: ClearSearchAction; private _addServerAction: IAction; private _addServerGroupAction: IAction; private _activeConnectionsFilterAction: ActiveConnectionsFilterAction; @@ -54,7 +52,7 @@ export class ConnectionViewletPanel extends ViewletPanel { @IObjectExplorerService private objectExplorerService: IObjectExplorerService ) { super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: options.title }, keybindingService, contextMenuService, configurationService); - this._clearSearchAction = this.instantiationService.createInstance(ClearSearchAction, ClearSearchAction.ID, ClearSearchAction.LABEL, this); + //this._clearSearchAction = this.instantiationService.createInstance(ClearSearchAction, ClearSearchAction.ID, ClearSearchAction.LABEL, this); this._addServerAction = this.instantiationService.createInstance(AddServerAction, AddServerAction.ID, AddServerAction.LABEL); @@ -77,24 +75,6 @@ export class ConnectionViewletPanel extends ViewletPanel { renderBody(container: HTMLElement): void { const viewletContainer = DOM.append(container, DOM.$('div.server-explorer-viewlet')); - const searchBoxContainer = DOM.append(viewletContainer, DOM.$('div.search-box')); - this._searchBox = new InputBox( - searchBoxContainer, - null, - { - placeholder: localize('Search server names', 'Search server names'), - actions: [this._clearSearchAction], - ariaLabel: localize('Search server names', 'Search server names') - } - ); - - this._searchBox.onDidChange(() => { - this.search(this._searchBox.value); - }); - - // Theme styler - this._toDisposeViewlet.push(attachInputBoxStyler(this._searchBox, this.themeService)); - const viewContainer = DOM.append(viewletContainer, DOM.$('div.object-explorer-view')); this._serverTreeView.renderBody(viewContainer).then(undefined, error => { console.warn('render registered servers: ' + error); @@ -103,7 +83,6 @@ export class ConnectionViewletPanel extends ViewletPanel { } layoutBody(size: number): void { - this._searchBox.layout(); this._serverTreeView.layout(size - 46); // account for search box and horizontal scroll bar DOM.toggleClass(this._root, 'narrow', this._root.clientWidth < 300); } @@ -140,14 +119,10 @@ export class ConnectionViewletPanel extends ViewletPanel { public clearSearch() { this._serverTreeView.refreshTree(); - this._searchBox.value = ''; - this._clearSearchAction.enabled = false; - this._searchBox.focus(); } public search(value: string): void { if (value) { - this._clearSearchAction.enabled = true; this._serverTreeView.searchTree(value); } else { this.clearSearch(); diff --git a/src/sql/workbench/parts/dataExplorer/electron-browser/nodeActions.contribution.ts b/src/sql/workbench/parts/dataExplorer/electron-browser/nodeActions.contribution.ts index fa04a7a567..e91fde0a8c 100644 --- a/src/sql/workbench/parts/dataExplorer/electron-browser/nodeActions.contribution.ts +++ b/src/sql/workbench/parts/dataExplorer/electron-browser/nodeActions.contribution.ts @@ -10,7 +10,7 @@ import { DISCONNECT_COMMAND_ID, MANAGE_COMMAND_ID, NEW_QUERY_COMMAND_ID, REFRESH MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, { group: 'connection', - order: 4, + order: 3, command: { id: DISCONNECT_COMMAND_ID, title: localize('disconnect', 'Disconnect') @@ -20,6 +20,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, { MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, { group: 'connection', + order: 2, command: { id: NEW_QUERY_COMMAND_ID, title: localize('newQuery', 'New Query') @@ -29,7 +30,7 @@ MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, { MenuRegistry.appendMenuItem(MenuId.DataExplorerContext, { group: 'connection', - order: 4, + order: 1, command: { id: MANAGE_COMMAND_ID, title: localize('manage', 'Manage')