-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathBindingSettingStepBase.ts
More file actions
32 lines (26 loc) · 1.64 KB
/
BindingSettingStepBase.ts
File metadata and controls
32 lines (26 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { AzureWizardPromptStep } from "@microsoft/vscode-azext-utils";
import { type BindingSettingValue } from "../../../funcConfig/function";
import { type IBindingSetting } from "../../../templates/IBindingTemplate";
import { type ParsedInput } from "../../../templates/script/parseScriptTemplatesV2";
import { getBindingSetting, setBindingSetting, type IFunctionWizardContext } from "../../createFunction/IFunctionWizardContext";
export abstract class BindingSettingStepBase extends AzureWizardPromptStep<IFunctionWizardContext> {
protected readonly _setting: IBindingSetting | ParsedInput;
protected readonly _resourceType: string;
constructor(setting: IBindingSetting | ParsedInput) {
super();
this._setting = setting;
this.id = setting.name;
this._resourceType = (setting as IBindingSetting).resourceType ?? (setting as ParsedInput).resource ?? '';
}
public abstract promptCore(context: IFunctionWizardContext): Promise<BindingSettingValue>;
public async prompt(context: IFunctionWizardContext): Promise<void> {
setBindingSetting(context, this._setting as IBindingSetting, await this.promptCore(context));
}
public shouldPrompt(context: IFunctionWizardContext): boolean {
return !getBindingSetting(context, this._setting);
}
}