Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload profiles when new profiles are created #9084

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions tabby-settings/src/components/profilesSettingsTab.component.pug
Expand Up @@ -12,14 +12,16 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
[(ngModel)]='config.store.terminal.profile',
(ngModelChange)='config.save()',
)
option(
*ngFor='let profile of profiles',
[ngValue]='profile.id'
) {{profile.name}}
option(
*ngFor='let profile of builtinProfiles',
[ngValue]='profile.id'
) {{profile.name}}
optgroup([label]='"Custom Profiles"|translate', *ngIf='customProfiles?.length > 0')
option(
*ngFor='let profile of customProfiles',
[ngValue]='profile.id'
) {{profile.name}}
optgroup([label]='"Built-in Profiles"|translate')
option(
*ngFor='let profile of builtinProfiles',
[ngValue]='profile.id'
) {{profile.name}}

.d-flex.mb-3
.input-group
Expand Down
15 changes: 11 additions & 4 deletions tabby-settings/src/components/profilesSettingsTab.component.ts
Expand Up @@ -20,7 +20,9 @@ interface CollapsableProfileGroup extends ProfileGroup {
})
export class ProfilesSettingsTabComponent extends BaseComponent {
builtinProfiles: PartialProfile<Profile>[] = []
profiles: PartialProfile<Profile>[] = []
templateProfiles: PartialProfile<Profile>[] = []
customProfiles: PartialProfile<Profile>[] = []
profileGroups: PartialProfileGroup<CollapsableProfileGroup>[]
filter = ''
Platform = Platform
Expand All @@ -40,12 +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 @@ -240,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