Success and progress notifications/log messages for PostgreSQL (#1560)

* progress and success notifications and log messages
This commit is contained in:
Neelima Potharaj 2020-06-22 15:27:07 -07:00 коммит произвёл GitHub
Родитель 140c026ea0
Коммит 6bafded0c3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 32 добавлений и 6 удалений

Просмотреть файл

@ -41,15 +41,18 @@ export async function setFirewallRule(treeItem: PostgresServerTreeItem, ip: stri
endIpAddress: ip
};
const progressMessage: string = localize('configuringFirewallRule', 'Adding firewall rule for IP "{0}" to server "{1}"...', ip, serverName);
const options: vscode.ProgressOptions = {
location: vscode.ProgressLocation.Notification,
title: localize('configuringFirewall', 'Adding firewall rule for IP "{0}" to server "{1}"...', ip, serverName)
title: progressMessage
};
await vscode.window.withProgress(options, async () => {
await client.firewallRules.createOrUpdate(resourceGroup, serverName, firewallRuleName, newFirewallRule);
});
const completedMessage: string = localize('addedFirewallRule', 'Successfully added firewall rule for IP "{0}" to server "{1}".', ip, serverName);
vscode.window.showInformationMessage(completedMessage);
ext.outputChannel.appendLog(completedMessage);
await treeItem.refresh();
}

Просмотреть файл

@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Server } from 'azure-arm-postgresql/lib/models';
import * as vscode from 'vscode';
import { Progress } from 'vscode';
import { AzureWizardExecuteStep } from 'vscode-azureextensionui';
import { ext } from '../../../../extensionVariables';
@ -30,6 +31,9 @@ export class PostgresServerSetCredentialsStep extends AzureWizardExecuteStep<IPo
const server: Server = nonNullProp(wizardContext, 'server');
await setPostgresCredentials(user, password, nonNullProp(server, 'id'));
const completedMessage: string = localize('addedCredentialsMessage', 'Successfully setup credentials for server "{0}".', newServerName);
vscode.window.showInformationMessage(completedMessage);
ext.outputChannel.appendLog(completedMessage);
}
public shouldExecute(): boolean {

Просмотреть файл

@ -5,6 +5,7 @@
import PostgreSQLManagementClient from 'azure-arm-postgresql';
import { FirewallRule } from 'azure-arm-postgresql/lib/models';
import * as vscode from 'vscode';
import { Progress } from 'vscode';
import { AzureWizardExecuteStep, createAzureClient } from 'vscode-azureextensionui';
import { ext } from '../../../../extensionVariables';
@ -33,6 +34,9 @@ export class PostgresServerSetFirewallStep extends AzureWizardExecuteStep<IPostg
ext.outputChannel.appendLog(addFirewallMessage);
await client.firewallRules.createOrUpdate(resourceGroup, newServerName, firewallRuleName, newFirewallRule);
const completedMessage: string = localize('addedFirewallRule', 'Successfully added firewall rule for IP "{0}" to server "{1}".', ip, newServerName);
vscode.window.showInformationMessage(completedMessage);
ext.outputChannel.appendLog(completedMessage);
}
public shouldExecute(wizardContext: IPostgresServerWizardContext): boolean {

Просмотреть файл

@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Server } from "azure-arm-postgresql/lib/models";
import * as vscode from 'vscode';
import { IActionContext } from "vscode-azureextensionui";
import { ext } from "../../extensionVariables";
import { localize } from "../../utils/localize";
import { nonNullProp } from "../../utils/nonNull";
import { nonNullProp } from '../../utils/nonNull';
import { PostgresServerTreeItem } from "../tree/PostgresServerTreeItem";
import { setPostgresCredentials } from "./setPostgresCredentials";
@ -32,7 +32,22 @@ export async function enterPostgresCredentials(context: IActionContext, treeItem
validateInput: (value: string) => { return (value && value.length) ? undefined : localize('passwordCannotBeEmpty', 'Password cannot be empty.'); }
});
const server: Server = nonNullProp(treeItem, 'server');
await setPostgresCredentials(username, password, nonNullProp(server, 'id'));
const serverName: string = nonNullProp(treeItem.server, 'name');
const id: string = nonNullProp(treeItem.server, 'id');
const progressMessage: string = localize('setupCredentialsMessage', 'Setting up credentials for server "{0}"...', serverName);
const options: vscode.ProgressOptions = {
location: vscode.ProgressLocation.Notification,
title: progressMessage
};
await vscode.window.withProgress(options, async () => {
await setPostgresCredentials(username, password, id);
});
const completedMessage: string = localize('setupCredentialsMessage', 'Successfully added credentials to server "{0}".', serverName);
vscode.window.showInformationMessage(completedMessage);
ext.outputChannel.appendLog(completedMessage);
await treeItem.refresh();
}