Skip to content

Commit

Permalink
appsettings: Add changes to add local setting node to workspace view (#…
Browse files Browse the repository at this point in the history
…1878)

* changes for localSetting

* localize ish
  • Loading branch information
motm32 authored Jan 30, 2025
1 parent 986c89b commit 8eec250
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions appsettings/src/tree/AppSettingsTreeItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import type { StringDictionary } from '@azure/arm-appservice';
import { AzExtParentTreeItem, AzExtTreeItem, createContextValue, IActionContext, ICreateChildImplContext, TreeItemIconPath } from '@microsoft/vscode-azext-utils';
import { AzExtParentTreeItem, AzExtTreeItem, createContextValue, GenericTreeItem, IActionContext, ICreateChildImplContext, TreeItemIconPath } from '@microsoft/vscode-azext-utils';
import * as vscode from 'vscode';
import { ThemeIcon } from 'vscode';
import { AppSettingsClientProvider, IAppSettingsClient } from '../IAppSettingsClient';
Expand Down Expand Up @@ -52,21 +52,26 @@ interface AppSettingsTreeItemOptions {

export class AppSettingsTreeItem extends AzExtParentTreeItem {
public static contextValue: string = 'applicationSettings';
public readonly label: string = 'Application Settings';
public label: string = vscode.l10n.t('Application Settings');
public readonly childTypeLabel: string = 'App Setting';
public readonly clientProvider: AppSettingsClientProvider;
public readonly supportsSlots: boolean;
public suppressMaskLabel: boolean = true;
private _settings: StringDictionary | undefined;
private readonly _settingsToHide: string[] | undefined;
public readonly contextValuesToAdd: string[];
public isLocalSetting: boolean;

constructor(parent: AzExtParentTreeItem, clientProvider: AppSettingsClientProvider, public readonly extensionPrefix: string, options?: AppSettingsTreeItemOptions) {
super(parent);
this.clientProvider = clientProvider;
this.supportsSlots = options?.supportsSlots ?? true;
this._settingsToHide = options?.settingsToHide;
this.contextValuesToAdd = options?.contextValuesToAdd || [];
this.isLocalSetting = this.contextValuesToAdd.includes('localSettings');
if (this.isLocalSetting) {
this.label = vscode.l10n.t('Local Settings');
}
}

public get id(): string {
Expand All @@ -87,6 +92,14 @@ export class AppSettingsTreeItem extends AzExtParentTreeItem {
public async loadMoreChildrenImpl(_clearCache: boolean, context: IActionContext): Promise<AzExtTreeItem[]> {
const client = await this.clientProvider.createClient(context);
this._settings = await client.listApplicationSettings();
if (this._settings.properties && Object.keys(this._settings.properties).length === 0 && this.isLocalSetting) {
return [new GenericTreeItem(this, {
label: vscode.l10n.t('No local settings found'),
iconPath: new ThemeIcon('info'),
contextValue: 'noLocalSettings'
})];
}

const treeItems: AppSettingTreeItem[] = [];
const properties: { [name: string]: string } = this._settings.properties || {};
await Promise.all(Object.keys(properties).map(async (key: string) => {
Expand Down

0 comments on commit 8eec250

Please sign in to comment.