Fix UX for create session issue (#1434)
* fix create session issue * add comment to get PR running * clear password if incorrect password is given when connecting * change createSession signature * review comments
This commit is contained in:
Родитель
094f212124
Коммит
f27b4a29cf
|
@ -232,6 +232,7 @@ export default class MainController implements vscode.Disposable {
|
|||
this._context.subscriptions.push(
|
||||
vscode.commands.registerCommand(
|
||||
Constants.cmdConnectObjectExplorerNode, async (node: ConnectTreeNode) => {
|
||||
self._objectExplorerProvider.currentNode = node.parentNode;
|
||||
await self.createObjectExplorerSession(node.parentNode.connectionCredentials);
|
||||
}));
|
||||
this._context.subscriptions.push(
|
||||
|
@ -321,13 +322,17 @@ export default class MainController implements vscode.Disposable {
|
|||
*/
|
||||
private async createObjectExplorerSession(connectionCredentials?: IConnectionCredentials): Promise<void> {
|
||||
let createSessionPromise = new Deferred<TreeNodeInfo>();
|
||||
await this._objectExplorerProvider.createSession(createSessionPromise, connectionCredentials);
|
||||
const newNode = await createSessionPromise;
|
||||
this._objectExplorerProvider.refresh(undefined);
|
||||
let expandSessionPromise = new Deferred<TreeNodeInfo[]>();
|
||||
await this._objectExplorerProvider.expandNode(newNode, newNode.sessionId, expandSessionPromise);
|
||||
await expandSessionPromise;
|
||||
this._objectExplorerProvider.refresh(undefined);
|
||||
const sessionId = await this._objectExplorerProvider.createSession(createSessionPromise, connectionCredentials);
|
||||
if (sessionId) {
|
||||
const newNode = await createSessionPromise;
|
||||
if (newNode) {
|
||||
this._objectExplorerProvider.refresh(undefined);
|
||||
let expandSessionPromise = new Deferred<TreeNodeInfo[]>();
|
||||
await this._objectExplorerProvider.expandNode(newNode, newNode.sessionId, expandSessionPromise);
|
||||
await expandSessionPromise;
|
||||
this._objectExplorerProvider.refresh(undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ export class ObjectExplorerProvider implements vscode.TreeDataProvider<any> {
|
|||
}
|
||||
}
|
||||
|
||||
async createSession(promise: Deferred<TreeNodeInfo>, connectionCredentials?: IConnectionCredentials): Promise<void> {
|
||||
async createSession(promise: Deferred<TreeNodeInfo>, connectionCredentials?: IConnectionCredentials): Promise<string> {
|
||||
return this._objectExplorerService.createSession(promise, connectionCredentials);
|
||||
}
|
||||
|
||||
|
@ -98,4 +98,8 @@ export class ObjectExplorerProvider implements vscode.TreeDataProvider<any> {
|
|||
public set objectExplorerService(value: ObjectExplorerService) {
|
||||
this._objectExplorerService = value;
|
||||
}
|
||||
|
||||
public set currentNode(node: TreeNodeInfo) {
|
||||
this._objectExplorerService.currentNode = node;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,10 +267,17 @@ export class ObjectExplorerService {
|
|||
} else {
|
||||
// start node session
|
||||
let promise = new Deferred<TreeNodeInfo>();
|
||||
await this.createSession(promise, element.connectionCredentials);
|
||||
let node = await promise;
|
||||
// If node create session failed
|
||||
if (!node) {
|
||||
const sessionId = await this.createSession(promise, element.connectionCredentials);
|
||||
if (sessionId) {
|
||||
let node = await promise;
|
||||
// if password failed
|
||||
if (!node) {
|
||||
const connectNode = new ConnectTreeNode(element);
|
||||
this._treeNodeToChildrenMap.set(element, [connectNode]);
|
||||
return [connectNode];
|
||||
}
|
||||
} else {
|
||||
// If node create session failed
|
||||
const signInNode = new AccountSignInTreeNode(element);
|
||||
this._treeNodeToChildrenMap.set(element, [signInNode]);
|
||||
return [signInNode];
|
||||
|
@ -310,7 +317,7 @@ export class ObjectExplorerService {
|
|||
* OE out of
|
||||
* @param connectionCredentials Connection Credentials for a node
|
||||
*/
|
||||
public async createSession(promise: Deferred<vscode.TreeItem>, connectionCredentials?: IConnectionCredentials): Promise<void> {
|
||||
public async createSession(promise: Deferred<vscode.TreeItem | undefined>, connectionCredentials?: IConnectionCredentials): Promise<string> {
|
||||
if (!connectionCredentials) {
|
||||
const connectionUI = this._connectionManager.connectionUI;
|
||||
connectionCredentials = await connectionUI.showConnections(false);
|
||||
|
@ -325,7 +332,8 @@ export class ObjectExplorerService {
|
|||
// prompt for password
|
||||
password = await this._connectionManager.connectionUI.promptForPassword();
|
||||
if (!password) {
|
||||
return promise.resolve(undefined);
|
||||
promise.resolve(undefined);
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
// look up saved password
|
||||
|
@ -339,8 +347,12 @@ export class ObjectExplorerService {
|
|||
if (response) {
|
||||
this._sessionIdToConnectionCredentialsMap.set(response.sessionId, connectionCredentials);
|
||||
this._sessionIdToPromiseMap.set(response.sessionId, promise);
|
||||
return;
|
||||
return response.sessionId;
|
||||
}
|
||||
} else {
|
||||
// no connection was made
|
||||
promise.resolve(undefined);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,4 +480,11 @@ export class ObjectExplorerService {
|
|||
const connections = this._rootTreeNodeArray.map(node => node.connectionCredentials);
|
||||
return connections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setters
|
||||
*/
|
||||
public set currentNode(node: TreeNodeInfo) {
|
||||
this._currentNode = node;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче