pull/227022/head
Sandeep Somavarapu 2024-08-29 00:29:36 +02:00 committed by GitHub
parent b3cbbb453d
commit 015878c11c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 18 deletions

View File

@ -92,6 +92,7 @@ export class UserDataProfilesEditor extends EditorPane implements IUserDataProfi
private profileWidget: ProfileWidget | undefined;
private model: UserDataProfilesEditorModel | undefined;
private templates: readonly IProfileTemplateInfo[] = [];
constructor(
group: IEditorGroup,
@ -207,7 +208,7 @@ export class UserDataProfilesEditor extends EditorPane implements IUserDataProfi
actions: {
getActions: () => {
const actions: IAction[] = [];
if (this.model?.templates.length) {
if (this.templates.length) {
actions.push(new SubmenuAction('from.template', localize('from template', "From Template"), this.getCreateFromTemplateActions()));
actions.push(new Separator());
}
@ -225,15 +226,13 @@ export class UserDataProfilesEditor extends EditorPane implements IUserDataProfi
}
private getCreateFromTemplateActions(): IAction[] {
return this.model
? this.model.templates.map(template =>
new Action(
`template:${template.url}`,
template.name,
undefined,
true,
() => this.createNewProfile(URI.parse(template.url))))
: [];
return this.templates.map(template =>
new Action(
`template:${template.url}`,
template.name,
undefined,
true,
() => this.createNewProfile(URI.parse(template.url))));
}
private registerListeners(): void {
@ -343,9 +342,12 @@ export class UserDataProfilesEditor extends EditorPane implements IUserDataProfi
override async setInput(input: UserDataProfilesEditorInput, options: IEditorOptions | undefined, context: IEditorOpenContext, token: CancellationToken): Promise<void> {
await super.setInput(input, options, context, token);
this.model = await input.resolve();
if (this.profileWidget) {
this.profileWidget.templates = this.model.templates;
}
this.model.getTemplates().then(templates => {
this.templates = templates;
if (this.profileWidget) {
this.profileWidget.templates = templates;
}
});
this.updateProfilesList();
this._register(this.model.onDidChange(element =>
this.updateProfilesList(element)));

View File

@ -713,8 +713,7 @@ export class UserDataProfilesEditorModel extends EditorModel {
private _onDidChange = this._register(new Emitter<AbstractUserDataProfileElement | undefined>());
readonly onDidChange = this._onDidChange.event;
private _templates: IProfileTemplateInfo[] | undefined;
get templates(): readonly IProfileTemplateInfo[] { return this._templates ?? []; }
private templates: Promise<readonly IProfileTemplateInfo[]> | undefined;
constructor(
@IUserDataProfileService private readonly userDataProfileService: IUserDataProfileService,
@ -761,9 +760,11 @@ export class UserDataProfilesEditorModel extends EditorModel {
}
}
override async resolve(): Promise<void> {
await super.resolve();
this._templates = await this.userDataProfileManagementService.getBuiltinProfileTemplates();
getTemplates(): Promise<readonly IProfileTemplateInfo[]> {
if (!this.templates) {
this.templates = this.userDataProfileManagementService.getBuiltinProfileTemplates();
}
return this.templates;
}
private createProfileElement(profile: IUserDataProfile): [UserDataProfileElement, DisposableStore] {