Log 'delete function' in output channel (#114)
This commit is contained in:
Родитель
f33d7c42b4
Коммит
4e81f14557
|
@ -31,7 +31,7 @@ export class FunctionAppTreeItem implements IAzureParentTreeItem {
|
|||
}
|
||||
this._state = site.state;
|
||||
this._outputChannel = outputChannel;
|
||||
this._functionsTreeItem = new FunctionsTreeItem(this.siteWrapper);
|
||||
this._functionsTreeItem = new FunctionsTreeItem(this.siteWrapper, this._outputChannel);
|
||||
this._appSettingsTreeItem = new AppSettingsTreeItem(this.siteWrapper);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { OutputChannel } from 'vscode';
|
||||
import { SiteWrapper } from 'vscode-azureappservice';
|
||||
import { IAzureNode, IAzureTreeItem, UserCancelledError } from 'vscode-azureextensionui';
|
||||
import KuduClient from 'vscode-azurekudu';
|
||||
|
@ -22,8 +23,9 @@ export class FunctionTreeItem implements IAzureTreeItem {
|
|||
private readonly _name: string;
|
||||
private readonly _disabled: boolean = false;
|
||||
private readonly _parentId: string;
|
||||
private readonly _outputChannel: OutputChannel;
|
||||
|
||||
public constructor(siteWrapper: SiteWrapper, func: FunctionEnvelope, parentId: string) {
|
||||
public constructor(siteWrapper: SiteWrapper, func: FunctionEnvelope, parentId: string, outputChannel: OutputChannel) {
|
||||
if (!func.name) {
|
||||
throw new ArgumentError(func);
|
||||
}
|
||||
|
@ -32,6 +34,7 @@ export class FunctionTreeItem implements IAzureTreeItem {
|
|||
this._name = func.name;
|
||||
this._disabled = (<ITemplateFunction>func.config).disabled;
|
||||
this._parentId = parentId;
|
||||
this._outputChannel = outputChannel;
|
||||
}
|
||||
|
||||
public get id(): string {
|
||||
|
@ -47,10 +50,13 @@ export class FunctionTreeItem implements IAzureTreeItem {
|
|||
}
|
||||
|
||||
public async deleteTreeItem(node: IAzureNode<FunctionTreeItem>): Promise<void> {
|
||||
const message: string = localize('azFunc.ConfirmDelete', 'Are you sure you want to delete "{0}"?', this._name);
|
||||
const message: string = localize('ConfirmDeleteFunction', 'Are you sure you want to delete function "{0}"?', this._name);
|
||||
if (await vscode.window.showWarningMessage(message, DialogResponses.yes, DialogResponses.cancel) === DialogResponses.yes) {
|
||||
this._outputChannel.show(true);
|
||||
this._outputChannel.appendLine(localize('DeletingFunction', 'Deleting function "{0}"...', this._name));
|
||||
const client: KuduClient = await nodeUtils.getKuduClient(node, this._siteWrapper);
|
||||
await client.functionModel.deleteMethod(this._name);
|
||||
this._outputChannel.appendLine(localize('DeleteFunctionSucceeded', 'Successfully deleted function "{0}".', this._name));
|
||||
} else {
|
||||
throw new UserCancelledError();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { OutputChannel } from 'vscode';
|
||||
import { SiteWrapper } from 'vscode-azureappservice';
|
||||
import { IAzureNode, IAzureParentTreeItem, IAzureTreeItem } from 'vscode-azureextensionui';
|
||||
import KuduClient from 'vscode-azurekudu';
|
||||
|
@ -18,9 +19,11 @@ export class FunctionsTreeItem implements IAzureParentTreeItem {
|
|||
public readonly childTypeLabel: string = localize('azFunc.Function', 'Function');
|
||||
|
||||
private readonly _siteWrapper: SiteWrapper;
|
||||
private readonly _outputChannel: OutputChannel;
|
||||
|
||||
public constructor(siteWrapper: SiteWrapper) {
|
||||
public constructor(siteWrapper: SiteWrapper, outputChannel: OutputChannel) {
|
||||
this._siteWrapper = siteWrapper;
|
||||
this._outputChannel = outputChannel;
|
||||
}
|
||||
|
||||
public get id(): string {
|
||||
|
@ -38,6 +41,6 @@ export class FunctionsTreeItem implements IAzureParentTreeItem {
|
|||
public async loadMoreChildren(node: IAzureNode<IAzureTreeItem>, _clearCache: boolean | undefined): Promise<IAzureTreeItem[]> {
|
||||
const client: KuduClient = await nodeUtils.getKuduClient(node, this._siteWrapper);
|
||||
const funcs: FunctionEnvelope[] = await client.functionModel.list();
|
||||
return funcs.map((fe: FunctionEnvelope) => new FunctionTreeItem(this._siteWrapper, fe, this.id));
|
||||
return funcs.map((fe: FunctionEnvelope) => new FunctionTreeItem(this._siteWrapper, fe, this.id, this._outputChannel));
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче