Skip to content

Commit

Permalink
Hide app settings value by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nturinski committed Dec 14, 2023
1 parent ab23bf1 commit f25be51
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@
"title": "%azureFunctions.restartFunctionApp%",
"category": "Azure Functions"
},
{
"command": "azureFunctions.setAzureWebJobsStorage",
"title": "%azureFunctions.setAzureWebJobsStorage%",
"category": "Azure Functions"
},
{
"command": "azureFunctions.startFunctionApp",
"title": "%azureFunctions.startFunctionApp%",
Expand Down
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"azureFunctions.requestTimeout": "The timeout (in seconds) to be used when making requests, for example getting the latest templates.",
"azureFunctions.restartFunctionApp": "Restart",
"azureFunctions.scmDoBuildDuringDeployment": "Set to true to build your project on the server. Currently only applicable for Linux Function Apps.",
"azureFunctions.setAzureWebJobsStorage": "Set AzureWebJobsStorage...",
"azureFunctions.show64BitWarning": "Show a warning to install a 64-bit version of the Azure Functions Core Tools when you create a .NET Framework project.",
"azureFunctions.showCoreToolsWarning": "Show a warning if your installed version of Azure Functions Core Tools is out-of-date.",
"azureFunctions.showDeployConfirmation": "Ask for confirmation before deploying to a Function App in Azure (deploying will overwrite any previous deployment and cannot be undone).",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export abstract class AzureConnectionCreateStepBase<T extends IBindingWizardCont
progress.report({ message: localize('retrieving', 'Retrieving connection string...') });

const result: IConnection = await this.getConnection(context);
let appSettingKey: string = context.useStorageEmulator ?
// if using the storage emulator, don't append the resource type to the app setting key
result.name :
`${result.name}_${nonNullProp(this._setting, 'resourceType').toUpperCase()}`;
let appSettingKey: string = `${result.name}_${nonNullProp(this._setting, 'resourceType').toUpperCase()}`;
appSettingKey = appSettingKey.replace(/[^a-z0-9_\.]/gi, ''); // remove invalid chars
setBindingSetting(context, this._setting, appSettingKey);
await setLocalAppSetting(context, context.projectPath, appSettingKey, result.connectionString);
Expand Down
20 changes: 17 additions & 3 deletions src/commands/addBinding/settingSteps/LocalAppSettingListStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,30 @@ import { EventHubListStep } from './eventHub/EventHubListStep';
import { ServiceBusConnectionCreateStep } from './serviceBus/ServiceBusConnectionCreateStep';
import { ServiceBusListStep } from './serviceBus/ServiceBusListStep';


const showHiddenValuesItem = { label: localize('showHiddenValues', '$(eye) Show hidden values'), data: 'hiddenValues' }
const hideHiddenValuesItem = { label: localize('hideHiddenValues', '$(eye-closed) Hide hidden values'), data: 'hiddenValues' }
export class LocalAppSettingListStep extends BindingSettingStepBase {
private _showHiddenValues: boolean = false;
public async promptCore(context: IBindingWizardContext): Promise<BindingSettingValue> {
const localSettingsPath: string = path.join(context.projectPath, localSettingsFileName);
const settings: ILocalSettingsJson = await getLocalSettingsJson(context, localSettingsPath);
const existingSettings: [string, string][] = settings.Values ? Object.entries(settings.Values) : [];

let picks: IAzureQuickPickItem<string | undefined>[] = [{ label: localize('newAppSetting', '$(plus) Create new local app setting'), data: undefined }];
picks = picks.concat(existingSettings.map((s: [string, string]) => { return { data: s[0], label: s[0], description: s[1] }; }));
let result: string | undefined;
const placeHolder: string = localize('selectAppSetting', 'Select the app setting with your {1} string from "{0}"', localSettingsFileName, this._setting.label);
return (await context.ui.showQuickPick(picks, { placeHolder })).data;
do {
let picks: IAzureQuickPickItem<string | undefined>[] = [{ label: localize('newAppSetting', '$(plus) Create new local app setting'), data: undefined }];
picks = picks.concat(existingSettings.map((s: [string, string]) => { return { data: s[0], label: s[0], description: this._showHiddenValues ? s[1] : '******' }; }));
picks.push(this._showHiddenValues ? hideHiddenValuesItem : showHiddenValuesItem);
result = (await context.ui.showQuickPick(picks, { placeHolder })).data;
if (result === 'hiddenValues') {
this._showHiddenValues = !this._showHiddenValues;
picks.pop();
} else {
return result;
}
} while (true);
}

public async getSubWizard(context: IBindingWizardContext): Promise<IWizardOptions<IBindingWizardContext> | undefined> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { KnownAccessRights, type AccessKeys, type AuthorizationRule, type EventH
import { type StorageAccount, type StorageAccountListKeysResult, type StorageManagementClient } from "@azure/arm-storage";
import { getResourceGroupFromId, uiUtils, type IStorageAccountWizardContext } from "@microsoft/vscode-azext-azureutils";
import { nonNullProp, nonNullValue, type ISubscriptionContext } from "@microsoft/vscode-azext-utils";
import { ConnectionKey, localSettingsFileName, localStorageEmulatorConnectionString } from "../../../constants";
import { localSettingsFileName, localStorageEmulatorConnectionString } from "../../../constants";
import { defaultDescription } from "../../../constants-nls";
import { ext } from "../../../extensionVariables";
import { localize } from "../../../localize";
Expand All @@ -24,7 +24,7 @@ export interface IResourceResult {
export async function getStorageConnectionString(context: IStorageAccountWizardContext & { useStorageEmulator?: boolean }): Promise<IResourceResult> {
if (context.useStorageEmulator) {
return {
name: ConnectionKey.Storage,
name: 'AZURITE',
connectionString: localStorageEmulatorConnectionString
}
}
Expand Down

0 comments on commit f25be51

Please sign in to comment.