From 7b2a07befd9fd94f3e5c397595d3d1a84bf7960c Mon Sep 17 00:00:00 2001 From: Cheena Malhotra <13396919+cheenamalhotra@users.noreply.github.com> Date: Mon, 1 May 2023 11:55:38 -0700 Subject: [PATCH] Respect 'showDashboard' disabled by default (#22907) --- .../api/browser/mainThreadConnectionManagement.ts | 2 -- src/sql/workbench/browser/actions.ts | 2 +- .../commandLine/electron-browser/commandLine.ts | 14 ++++++++++++-- .../test/electron-browser/commandLine.test.ts | 2 +- .../connection/browser/connection.contribution.ts | 8 ++++++-- .../contrib/dashboard/browser/dashboardActions.ts | 2 -- .../objectExplorer/browser/serverTreeView.ts | 8 ++++++-- .../test/browser/connectionTreeActions.test.ts | 10 +++++----- .../contrib/profiler/browser/profilerActions.ts | 1 - .../connection/browser/connectionDialogService.ts | 2 +- .../browser/connectionManagementService.ts | 3 --- .../objectExplorer/browser/connectionTreeAction.ts | 7 ++++++- .../browser/objectExplorerViewTreeShim.ts | 2 +- .../objectExplorer/browser/treeSelectionHandler.ts | 1 - .../objectExplorer/browser/treeUpdateUtils.ts | 1 - 15 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/sql/workbench/api/browser/mainThreadConnectionManagement.ts b/src/sql/workbench/api/browser/mainThreadConnectionManagement.ts index 6555f2772e..6902686066 100644 --- a/src/sql/workbench/api/browser/mainThreadConnectionManagement.ts +++ b/src/sql/workbench/api/browser/mainThreadConnectionManagement.ts @@ -172,7 +172,6 @@ export class MainThreadConnectionManagement extends Disposable implements MainTh await this._connectionManagementService.connectAndSaveProfile(connectionProfile, undefined, { saveTheConnection: isUndefinedOrNull(connectionCompletionOptions.saveConnection) ? true : connectionCompletionOptions.saveConnection, showDashboard: isUndefinedOrNull(connectionCompletionOptions.showDashboard) ? false : connectionCompletionOptions.showDashboard, - params: undefined, showConnectionDialogOnError: isUndefinedOrNull(connectionCompletionOptions.showConnectionDialogOnError) ? true : connectionCompletionOptions.showConnectionDialogOnError, showFirewallRuleOnError: isUndefinedOrNull(connectionCompletionOptions.showFirewallRuleOnError) ? true : connectionCompletionOptions.showFirewallRuleOnError }); @@ -248,7 +247,6 @@ export class MainThreadConnectionManagement extends Disposable implements MainTh return this._connectionManagementService.connectAndSaveProfile(profile, undefined, { saveTheConnection: saveConnection, showDashboard: showDashboard, - params: undefined, showConnectionDialogOnError: true, showFirewallRuleOnError: true }).then((result) => { diff --git a/src/sql/workbench/browser/actions.ts b/src/sql/workbench/browser/actions.ts index b9df2307d5..1e7cb6bc48 100644 --- a/src/sql/workbench/browser/actions.ts +++ b/src/sql/workbench/browser/actions.ts @@ -47,7 +47,7 @@ export class ManageAction extends Action { override async run(actionContext: ManageActionContext): Promise { if (actionContext.profile) { - await this._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }); + await this._connectionManagementService.connect(actionContext.profile, actionContext.uri, { showDashboard: true, saveTheConnection: false, showConnectionDialogOnError: false, showFirewallRuleOnError: true }); this._angularEventingService.sendAngularEvent(actionContext.uri, AngularEventType.NAV_DATABASE); } } diff --git a/src/sql/workbench/contrib/commandLine/electron-browser/commandLine.ts b/src/sql/workbench/contrib/commandLine/electron-browser/commandLine.ts index 1d2c06c7a5..90c7d5a171 100644 --- a/src/sql/workbench/contrib/commandLine/electron-browser/commandLine.ts +++ b/src/sql/workbench/contrib/commandLine/electron-browser/commandLine.ts @@ -124,7 +124,12 @@ export class CommandLineWorkbenchContribution implements IWorkbenchContribution, let showConnectDialogOnStartup: boolean = this._configurationService.getValue('workbench.showConnectDialogOnStartup'); if (showConnectDialogOnStartup && !commandName && !profile && !this._connectionManagementService.hasRegisteredServers()) { // prompt the user for a new connection on startup if no profiles are registered - await this._connectionManagementService.showConnectionDialog(); + await this._connectionManagementService.showConnectionDialog(undefined, { + showDashboard: true, + saveTheConnection: true, + showConnectionDialogOnError: true, + showFirewallRuleOnError: true + }); return; } let connectedContext: azdata.ConnectedContext = undefined; @@ -235,7 +240,12 @@ export class CommandLineWorkbenchContribution implements IWorkbenchContribution, } const connectionProfile = this.readProfileFromArgs(args); - await this._connectionManagementService.showConnectionDialog(undefined, undefined, connectionProfile); + await this._connectionManagementService.showConnectionDialog(undefined, { + saveTheConnection: true, + showDashboard: true, + showConnectionDialogOnError: true, + showFirewallRuleOnError: true + }, connectionProfile); } catch (err) { this._notificationService.error(localize('errConnectUrl', "Could not open URL due to error {0}", getErrorMessage(err))); } diff --git a/src/sql/workbench/contrib/commandLine/test/electron-browser/commandLine.test.ts b/src/sql/workbench/contrib/commandLine/test/electron-browser/commandLine.test.ts index f548e4143e..046629c6e7 100644 --- a/src/sql/workbench/contrib/commandLine/test/electron-browser/commandLine.test.ts +++ b/src/sql/workbench/contrib/commandLine/test/electron-browser/commandLine.test.ts @@ -140,7 +140,7 @@ suite('commandLineService tests', () => { const connectionManagementService: TypeMoq.Mock = TypeMoq.Mock.ofType(TestConnectionManagementService, TypeMoq.MockBehavior.Strict); - connectionManagementService.setup((c) => c.showConnectionDialog()) + connectionManagementService.setup((c) => c.showConnectionDialog(undefined, TypeMoq.It.isAny())) .returns(() => new Promise((resolve, reject) => { resolve(); })) .verifiable(); connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => false); diff --git a/src/sql/workbench/contrib/connection/browser/connection.contribution.ts b/src/sql/workbench/contrib/connection/browser/connection.contribution.ts index d64a7586f9..7b2d14191f 100644 --- a/src/sql/workbench/contrib/connection/browser/connection.contribution.ts +++ b/src/sql/workbench/contrib/connection/browser/connection.contribution.ts @@ -147,12 +147,16 @@ CommandsRegistry.registerCommand('azdata.connect', connectionManagementService.connect(connectionProfile, undefined, { saveTheConnection: true, showDashboard: true, - params: undefined, showConnectionDialogOnError: true, showFirewallRuleOnError: true }); } else { - connectionManagementService.showConnectionDialog(); + connectionManagementService.showConnectionDialog(undefined, { + saveTheConnection: true, + showDashboard: true, + showConnectionDialogOnError: true, + showFirewallRuleOnError: true + }); } }); diff --git a/src/sql/workbench/contrib/dashboard/browser/dashboardActions.ts b/src/sql/workbench/contrib/dashboard/browser/dashboardActions.ts index 1344547e65..483d97381d 100644 --- a/src/sql/workbench/contrib/dashboard/browser/dashboardActions.ts +++ b/src/sql/workbench/contrib/dashboard/browser/dashboardActions.ts @@ -38,7 +38,6 @@ CommandsRegistry.registerCommand({ let options = { showDashboard: true, saveTheConnection: false, - params: undefined, showConnectionDialogOnError: true, showFirewallRuleOnError: true }; @@ -122,7 +121,6 @@ export class OEManageConnectionAction extends Action { } let options: IConnectionCompletionOptions = { - params: undefined, saveTheConnection: false, showConnectionDialogOnError: true, showDashboard: true, diff --git a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts index 066c209dd4..a56e586fdd 100644 --- a/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts +++ b/src/sql/workbench/contrib/objectExplorer/browser/serverTreeView.ts @@ -186,7 +186,12 @@ export class ServerTreeView extends Disposable implements IServerTreeView { connectButton.label = localize('serverTree.newConnection', "New Connection"); this._register(attachButtonStyler(connectButton, this._themeService)); this._register(connectButton.onDidClick(() => { - this._connectionManagementService.showConnectionDialog(); + this._connectionManagementService.showConnectionDialog(undefined, { + showDashboard: true, + saveTheConnection: true, + showConnectionDialogOnError: true, + showFirewallRuleOnError: true + }); })); } @@ -872,7 +877,6 @@ export class ServerTreeView extends Disposable implements IServerTreeView { if (node instanceof ConnectionProfile) { connectionProfile = node; await TreeUpdateUtils.connectAndCreateOeSession(connectionProfile, { - params: undefined, saveTheConnection: true, showConnectionDialogOnError: true, showFirewallRuleOnError: true, diff --git a/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts b/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts index 78749649af..62031a1c00 100644 --- a/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts +++ b/src/sql/workbench/contrib/objectExplorer/test/browser/connectionTreeActions.test.ts @@ -283,14 +283,14 @@ suite('SQL Connection Tree Action tests', () => { }); }); - test('AddServerAction - test if show connection dialog is called', () => { + test('AddServerAction - test if show connection dialog is called', async () => { let connectionManagementService = createConnectionManagementService(true, undefined); - + connectionManagementService.setup(x => x.showConnectionDialog(undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns( + () => new Promise((resolve, reject) => resolve())); let connectionTreeAction: AddServerAction = new AddServerAction(AddServerAction.ID, AddServerAction.LABEL, connectionManagementService.object); let conProfGroup = new ConnectionProfileGroup('testGroup', undefined, 'testGroup', undefined, undefined); - return connectionTreeAction.run(conProfGroup).then((value) => { - connectionManagementService.verify(x => x.showConnectionDialog(undefined, undefined, TypeMoq.It.isAny()), TypeMoq.Times.once()); - }); + await connectionTreeAction.run(conProfGroup); + connectionManagementService.verify(x => x.showConnectionDialog(undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.once()); }); test('ActiveConnectionsFilterAction - test if view is called to display filtered results', () => { diff --git a/src/sql/workbench/contrib/profiler/browser/profilerActions.ts b/src/sql/workbench/contrib/profiler/browser/profilerActions.ts index 3ea98e5aeb..ce165b9f4b 100644 --- a/src/sql/workbench/contrib/profiler/browser/profilerActions.ts +++ b/src/sql/workbench/contrib/profiler/browser/profilerActions.ts @@ -278,7 +278,6 @@ export class NewProfilerAction extends Task { let profilerInput = accessor.get(IInstantiationService).createInstance(ProfilerInput, profile); await accessor.get(IEditorService).openEditor(profilerInput, { pinned: true }, ACTIVE_GROUP); let options: IConnectionCompletionOptions = { - params: undefined, saveTheConnection: false, showConnectionDialogOnError: true, showDashboard: false, diff --git a/src/sql/workbench/services/connection/browser/connectionDialogService.ts b/src/sql/workbench/services/connection/browser/connectionDialogService.ts index 76d7377bf8..341f347d72 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogService.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogService.ts @@ -265,7 +265,7 @@ export class ConnectionDialogService implements IConnectionDialogService { let options: IConnectionCompletionOptions = this._options || { params: params, saveTheConnection: !isTemporaryConnection, - showDashboard: params && params.showDashboard !== undefined ? params.showDashboard : !fromEditor && !isTemporaryConnection, + showDashboard: params?.showDashboard ?? false, showConnectionDialogOnError: false, showFirewallRuleOnError: true }; diff --git a/src/sql/workbench/services/connection/browser/connectionManagementService.ts b/src/sql/workbench/services/connection/browser/connectionManagementService.ts index d1c5f2e5fc..70d1c6c5b4 100644 --- a/src/sql/workbench/services/connection/browser/connectionManagementService.ts +++ b/src/sql/workbench/services/connection/browser/connectionManagementService.ts @@ -492,7 +492,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti saveTheConnection: saveConnection, showConnectionDialogOnError: true, showDashboard: purpose === 'dashboard', - params: undefined, showFirewallRuleOnError: true, }; return this.connect(connection, ownerUri, options).then(connectionResult => { @@ -524,7 +523,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti options = { saveTheConnection: true, showDashboard: false, - params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }; @@ -574,7 +572,6 @@ export class ConnectionManagementService extends Disposable implements IConnecti options = { saveTheConnection: false, showDashboard: false, - params: undefined, showConnectionDialogOnError: false, showFirewallRuleOnError: true }; diff --git a/src/sql/workbench/services/objectExplorer/browser/connectionTreeAction.ts b/src/sql/workbench/services/objectExplorer/browser/connectionTreeAction.ts index b9ca5d1e8c..b957017840 100644 --- a/src/sql/workbench/services/objectExplorer/browser/connectionTreeAction.ts +++ b/src/sql/workbench/services/objectExplorer/browser/connectionTreeAction.ts @@ -179,7 +179,12 @@ export class AddServerAction extends Action { saveProfile: true, id: element.id! } as Partial; - await this._connectionManagementService.showConnectionDialog(undefined, undefined, connection); + await this._connectionManagementService.showConnectionDialog(undefined, { + showDashboard: true, + saveTheConnection: true, + showConnectionDialogOnError: true, + showFirewallRuleOnError: true + }, connection); } } diff --git a/src/sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim.ts b/src/sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim.ts index 139422c669..6dcb24a80f 100644 --- a/src/sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim.ts +++ b/src/sql/workbench/services/objectExplorer/browser/objectExplorerViewTreeShim.ts @@ -87,7 +87,7 @@ export class OEShimService extends Disposable implements IOEShimService { private async connectOrPrompt(connProfile: ConnectionProfile): Promise { connProfile = await new Promise(async (resolve, reject) => { - let result = await this.cm.connect(connProfile, undefined, { showConnectionDialogOnError: true, showFirewallRuleOnError: true, saveTheConnection: false, showDashboard: false, params: undefined }, { + let result = await this.cm.connect(connProfile, undefined, { showConnectionDialogOnError: true, showFirewallRuleOnError: true, saveTheConnection: false, showDashboard: false }, { onConnectSuccess: async (e, profile) => { let existingConnection = this.cm.findExistingConnection(profile); connProfile = new ConnectionProfile(this.capabilities, existingConnection); diff --git a/src/sql/workbench/services/objectExplorer/browser/treeSelectionHandler.ts b/src/sql/workbench/services/objectExplorer/browser/treeSelectionHandler.ts index ab674ded3d..079edde2b9 100644 --- a/src/sql/workbench/services/objectExplorer/browser/treeSelectionHandler.ts +++ b/src/sql/workbench/services/objectExplorer/browser/treeSelectionHandler.ts @@ -142,7 +142,6 @@ export class TreeSelectionHandler { doubleClickHandler(selectedNode); } else if (selectedNode instanceof ConnectionProfile) { let options: IConnectionCompletionOptions = { - params: undefined, saveTheConnection: true, showConnectionDialogOnError: true, showFirewallRuleOnError: true, diff --git a/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts b/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts index 5f893fa05a..e8f4d24228 100644 --- a/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts +++ b/src/sql/workbench/services/objectExplorer/browser/treeUpdateUtils.ts @@ -305,7 +305,6 @@ export class TreeUpdateUtils { return rootNode.children ?? []; } else { const options: IConnectionCompletionOptions = { - params: undefined, saveTheConnection: true, showConnectionDialogOnError: true, showFirewallRuleOnError: true,