user management fixes (#22282)

* fix a few user management bugs

* revert user dialog change
This commit is contained in:
Alan Ren
2023-03-09 14:11:04 -08:00
committed by GitHub
parent 39f90afe6c
commit 6ace579986
5 changed files with 30 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
"version": "4.6.0.4",
"version": "4.6.0.5",
"downloadFileNames": {
"Windows_86": "win-x86-net7.0.zip",
"Windows_64": "win-x64-net7.0.zip",

View File

@@ -43,8 +43,12 @@ function getObjectManagementService(appContext: AppContext, useTestService: bool
}
async function handleNewLoginDialogCommand(context: azdata.ObjectExplorerContext, service: IObjectManagementService): Promise<void> {
const connectionUri = await getConnectionUri(context);
if (!connectionUri) {
return;
}
try {
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile.id);
const dialog = new LoginDialog(service, connectionUri, true, undefined, context);
await dialog.open();
}
@@ -57,8 +61,11 @@ async function handleNewLoginDialogCommand(context: azdata.ObjectExplorerContext
}
async function handleNewUserDialogCommand(context: azdata.ObjectExplorerContext, service: IObjectManagementService): Promise<void> {
const connectionUri = await getConnectionUri(context);
if (!connectionUri) {
return;
}
try {
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile.id);
const dialog = new UserDialog(service, connectionUri, context.connectionProfile.databaseName, true, undefined, context);
await dialog.open();
}
@@ -71,9 +78,12 @@ async function handleNewUserDialogCommand(context: azdata.ObjectExplorerContext,
}
async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplorerContext, service: IObjectManagementService): Promise<void> {
const connectionUri = await getConnectionUri(context);
if (!connectionUri) {
return;
}
const nodeTypeDisplayName = getNodeTypeDisplayName(context.nodeInfo.nodeType);
try {
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile.id);
let dialog;
switch (context.nodeInfo.nodeType) {
case NodeType.Login:
@@ -98,6 +108,10 @@ async function handleObjectPropertiesDialogCommand(context: azdata.ObjectExplore
}
async function handleDeleteObjectCommand(context: azdata.ObjectExplorerContext, service: IObjectManagementService): Promise<void> {
const connectionUri = await getConnectionUri(context);
if (!connectionUri) {
return;
}
let additionalConfirmationMessage: string;
switch (context.nodeInfo.nodeType) {
case NodeType.Login:
@@ -122,7 +136,6 @@ async function handleDeleteObjectCommand(context: azdata.ObjectExplorerContext,
operation: async (operation) => {
try {
const startTime = Date.now();
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile.id);
switch (context.nodeInfo.nodeType) {
case NodeType.Login:
await service.deleteLogin(connectionUri, context.nodeInfo.label);
@@ -151,3 +164,11 @@ async function handleDeleteObjectCommand(context: azdata.ObjectExplorerContext,
}
});
}
async function getConnectionUri(context: azdata.ObjectExplorerContext): Promise<string> {
const connectionUri = await azdata.connection.getUriForConnection(context.connectionProfile.id);
if (!connectionUri) {
await vscode.window.showErrorMessage(localizedConstants.FailedToRetrieveConnectionInfoErrorMessage, { modal: true });
}
return connectionUri;
}

View File

@@ -16,7 +16,8 @@ export const UserTypeDisplayNameInTitle: string = localize('objectManagement.Use
export const HelpText: string = localize('objectManagement.helpText', "Help");
export const YesText: string = localize('objectManagement.yesText', "Yes");
export const OkText: string = localize('objectManagement.OkText', "OK");
export const LoadingDialogText: string = localize('objectManagement.loadingDialog', "Loading dialog...")
export const LoadingDialogText: string = localize('objectManagement.loadingDialog', "Loading dialog...");
export const FailedToRetrieveConnectionInfoErrorMessage: string = localize('objectManagement.noConnectionUriError', "Failed to retrieve the connection information, please reconnect and try again.")
export function RefreshObjectExplorerError(error: string): string {
return localize({

View File

@@ -111,7 +111,7 @@ export class ObjectManagementService implements IObjectManagementService {
return this.client.sendRequest(contracts.UpdateUserRequest.type, params).then(
r => { },
e => {
this.client.logFailedRequest(contracts.UpdateLoginRequest.type, e);
this.client.logFailedRequest(contracts.UpdateUserRequest.type, e);
return Promise.reject(new Error(e.message));
}
);

View File

@@ -184,6 +184,7 @@ export abstract class ObjectManagementDialogBase<ObjectInfoType extends ObjectMa
objectType: this.objectType
}).send();
void vscode.window.showErrorMessage(getErrorMessage(err));
azdata.window.closeDialog(this.dialogObject);
}
}