Skip to content

Commit

Permalink
Merge pull request #9084 from Ranhiru/reload-profiles-when-new-profil…
Browse files Browse the repository at this point in the history
…es-are-created
  • Loading branch information
Eugeny committed Oct 9, 2023
2 parents e68bd6c + f3196ac commit 2b8fed1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
[(ngModel)]='config.store.terminal.profile',
(ngModelChange)='config.save()',
)
optgroup([label]='"Custom Profiles"|translate', *ngIf='customProfiles?.length > 0')
optgroup([label]='"Custom Profiles"|translate', *ngIf='customProfiles?.length > 0')
option(
*ngFor='let profile of customProfiles',
[ngValue]='profile.id'
Expand Down
13 changes: 9 additions & 4 deletions tabby-settings/src/components/profilesSettingsTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface CollapsableProfileGroup extends ProfileGroup {
})
export class ProfilesSettingsTabComponent extends BaseComponent {
builtinProfiles: PartialProfile<Profile>[] = []
profiles: PartialProfile<Profile>[] = []
templateProfiles: PartialProfile<Profile>[] = []
customProfiles: PartialProfile<Profile>[] = []
profileGroups: PartialProfileGroup<CollapsableProfileGroup>[]
Expand All @@ -41,13 +42,17 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
}

async ngOnInit (): Promise<void> {
this.refresh()
await this.refreshProfileGroups()
await this.refreshProfiles()
this.subscribeUntilDestroyed(this.config.changed$, () => this.refreshProfileGroups())
this.subscribeUntilDestroyed(this.config.changed$, () => this.refreshProfiles())
}

async refreshProfiles (): Promise<void> {
this.builtinProfiles = (await this.profilesService.getProfiles()).filter(x => x.isBuiltin)
this.customProfiles = (await this.profilesService.getProfiles()).filter(x => !x.isBuiltin)
this.templateProfiles = this.builtinProfiles.filter(x => x.isTemplate)
this.builtinProfiles = this.builtinProfiles.filter(x => !x.isTemplate)
this.refresh()
this.subscribeUntilDestroyed(this.config.changed$, () => this.refresh())
}

launchProfile (profile: PartialProfile<Profile>): void {
Expand Down Expand Up @@ -242,7 +247,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
}
}

async refresh (): Promise<void> {
async refreshProfileGroups (): Promise<void> {
const profileGroupCollapsed = JSON.parse(window.localStorage.profileGroupCollapsed ?? '{}')
const groups = await this.profilesService.getProfileGroups({ includeNonUserGroup: true, includeProfiles: true })
groups.sort((a, b) => a.name.localeCompare(b.name))
Expand Down

0 comments on commit 2b8fed1

Please sign in to comment.