Make sure new queries are connected for unsaved password (#2633)

This commit is contained in:
Matt Irvine
2018-09-26 16:21:07 -04:00
committed by GitHub
parent 79c69d03fa
commit 810073a79b
6 changed files with 14 additions and 31 deletions

View File

@@ -33,7 +33,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
public constructor( public constructor(
capabilitiesService: ICapabilitiesService, capabilitiesService: ICapabilitiesService,
model: string | interfaces.IConnectionProfile model: string | sqlops.IConnectionProfile
) { ) {
super(capabilitiesService, model); super(capabilitiesService, model);
if (model && !isString(model)) { if (model && !isString(model)) {
@@ -171,7 +171,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
}; };
} }
public static fromIConnectionProfile(capabilitiesService: ICapabilitiesService, profile: interfaces.IConnectionProfile) { public static fromIConnectionProfile(capabilitiesService: ICapabilitiesService, profile: sqlops.IConnectionProfile) {
if (profile) { if (profile) {
if (profile instanceof ConnectionProfile) { if (profile instanceof ConnectionProfile) {
return profile; return profile;

View File

@@ -26,7 +26,7 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
public constructor( public constructor(
protected capabilitiesService: ICapabilitiesService, protected capabilitiesService: ICapabilitiesService,
model: string | interfaces.IConnectionProfile model: string | sqlops.IConnectionProfile
) { ) {
super(); super();
// we can't really do a whole lot if we don't have a provider // we can't really do a whole lot if we don't have a provider
@@ -195,8 +195,8 @@ export class ProviderConnectionInfo extends Disposable implements sqlops.Connect
if (this._serverCapabilities) { if (this._serverCapabilities) {
idNames = this._serverCapabilities.connectionOptions.map(o => { idNames = this._serverCapabilities.connectionOptions.map(o => {
if ((o.specialValueType || o.isIdentity) if ((o.specialValueType || o.isIdentity)
&& o.specialValueType !== ConnectionOptionSpecialType.password && o.specialValueType !== ConnectionOptionSpecialType.password
&& o.specialValueType !== ConnectionOptionSpecialType.connectionName) { && o.specialValueType !== ConnectionOptionSpecialType.connectionName) {
return o.name; return o.name;
} else { } else {
return undefined; return undefined;

View File

@@ -6,9 +6,9 @@
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile'; import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile';
import { IConnectionManagementService, IErrorMessageService } from 'sql/parts/connection/common/connectionManagement'; import { IConnectionManagementService, IErrorMessageService } from 'sql/parts/connection/common/connectionManagement';
import { ICapabilitiesService } from 'sql/services/capabilities/capabilitiesService';
import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService'; import { IQueryEditorService } from 'sql/parts/query/common/queryEditorService';
import { ServerTreeView } from 'sql/parts/objectExplorer/viewlet/serverTreeView'; import { ServerTreeView } from 'sql/parts/objectExplorer/viewlet/serverTreeView';
import { ConnectionViewlet } from 'sql/parts/objectExplorer/viewlet/connectionViewlet'; import { ConnectionViewlet } from 'sql/parts/objectExplorer/viewlet/connectionViewlet';
@@ -20,7 +20,7 @@ import * as Constants from 'sql/parts/connection/common/constants';
import { IObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService'; import { IObjectExplorerService } from 'sql/parts/objectExplorer/common/objectExplorerService';
import { TreeNode } from 'sql/parts/objectExplorer/common/treeNode'; import { TreeNode } from 'sql/parts/objectExplorer/common/treeNode';
import Severity from 'vs/base/common/severity'; import Severity from 'vs/base/common/severity';
import { ObjectExplorerActionsContext, ObjectExplorerActionUtilities } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions'; import { ObjectExplorerActionsContext } from 'sql/parts/objectExplorer/viewlet/objectExplorerActions';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
export class RefreshAction extends Action { export class RefreshAction extends Action {
@@ -323,7 +323,8 @@ export class NewQueryAction extends Action {
@IQueryEditorService private queryEditorService: IQueryEditorService, @IQueryEditorService private queryEditorService: IQueryEditorService,
@IConnectionManagementService private connectionManagementService: IConnectionManagementService, @IConnectionManagementService private connectionManagementService: IConnectionManagementService,
@IObjectExplorerService protected _objectExplorerService: IObjectExplorerService, @IObjectExplorerService protected _objectExplorerService: IObjectExplorerService,
@IEditorService protected _workbenchEditorService: IEditorService @IEditorService protected _workbenchEditorService: IEditorService,
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService
) { ) {
super(id, label); super(id, label);
this.class = 'extension-action update'; this.class = 'extension-action update';
@@ -331,7 +332,7 @@ export class NewQueryAction extends Action {
public run(actionContext: ObjectExplorerActionsContext): TPromise<boolean> { public run(actionContext: ObjectExplorerActionsContext): TPromise<boolean> {
if (actionContext instanceof ObjectExplorerActionsContext) { if (actionContext instanceof ObjectExplorerActionsContext) {
this._connectionProfile = actionContext.connectionProfile; this._connectionProfile = new ConnectionProfile(this._capabilitiesService, actionContext.connectionProfile);
} }
TaskUtilities.newQuery(this._connectionProfile, this.connectionManagementService, this.queryEditorService, this._objectExplorerService, this._workbenchEditorService); TaskUtilities.newQuery(this._connectionProfile, this.connectionManagementService, this.queryEditorService, this._objectExplorerService, this._workbenchEditorService);

View File

@@ -32,7 +32,7 @@ import { ConnectionProfile } from 'sql/parts/connection/common/connectionProfile
export class ObjectExplorerActionsContext implements sqlops.ObjectExplorerContext { export class ObjectExplorerActionsContext implements sqlops.ObjectExplorerContext {
public connectionProfile: IConnectionProfile; public connectionProfile: sqlops.IConnectionProfile;
public nodeInfo: sqlops.NodeInfo; public nodeInfo: sqlops.NodeInfo;
public isConnectionNode: boolean = false; public isConnectionNode: boolean = false;
} }
@@ -52,8 +52,8 @@ export class OEAction extends ExecuteCommandAction {
id: string, label: string, id: string, label: string,
@IInstantiationService private _instantiationService: IInstantiationService, @IInstantiationService private _instantiationService: IInstantiationService,
@ICommandService commandService: ICommandService, @ICommandService commandService: ICommandService,
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IObjectExplorerService private _objectExplorerService: IObjectExplorerService,
@IObjectExplorerService private _objectExplorerService: IObjectExplorerService @ICapabilitiesService private _capabilitiesService: ICapabilitiesService
) { ) {
super(id, label, commandService); super(id, label, commandService);
} }
@@ -65,7 +65,7 @@ export class OEAction extends ExecuteCommandAction {
let profile: IConnectionProfile; let profile: IConnectionProfile;
if (actionContext instanceof ObjectExplorerActionsContext) { if (actionContext instanceof ObjectExplorerActionsContext) {
if (actionContext.isConnectionNode) { if (actionContext.isConnectionNode) {
profile = actionContext.connectionProfile; profile = new ConnectionProfile(this._capabilitiesService, actionContext.connectionProfile);
} else { } else {
// Get the "correct" version from the tree // Get the "correct" version from the tree
let treeNode = await getTreeNode(actionContext, this._objectExplorerService); let treeNode = await getTreeNode(actionContext, this._objectExplorerService);

View File

@@ -94,8 +94,6 @@ suite('SQL Connection Tree Action tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,
@@ -132,8 +130,6 @@ suite('SQL Connection Tree Action tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,
@@ -173,8 +169,6 @@ suite('SQL Connection Tree Action tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,
@@ -286,8 +280,6 @@ suite('SQL Connection Tree Action tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,
@@ -333,8 +325,6 @@ suite('SQL Connection Tree Action tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,
@@ -370,8 +360,6 @@ suite('SQL Connection Tree Action tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,
@@ -459,8 +447,6 @@ suite('SQL Connection Tree Action tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,

View File

@@ -231,8 +231,6 @@ suite('SQL Object Explorer Service tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,
@@ -250,8 +248,6 @@ suite('SQL Object Explorer Service tests', () => {
password: 'test', password: 'test',
userName: 'testUsername', userName: 'testUsername',
groupId: undefined, groupId: undefined,
getOptionsKey: undefined,
matches: undefined,
providerName: 'MSSQL', providerName: 'MSSQL',
options: {}, options: {},
saveProfile: true, saveProfile: true,