mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-25 03:22:58 +03:00
Preserve profile groups collapse state.
use local storage rather than config store Remove config save and toggleGroupCollapse not to be async
This commit is contained in:
parent
a5282eaf8c
commit
6e09931952
@ -36,7 +36,7 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
||||
ng-container(*ngFor='let group of profileGroups')
|
||||
ng-container(*ngIf='isGroupVisible(group)')
|
||||
.list-group-item.list-group-item-action.d-flex.align-items-center(
|
||||
(click)='group.collapsed = !group.collapsed'
|
||||
(click)='toggleGroupCollapse(group)'
|
||||
)
|
||||
.fa.fa-fw.fa-chevron-right(*ngIf='group.collapsed')
|
||||
.fa.fa-fw.fa-chevron-down(*ngIf='!group.collapsed')
|
||||
|
@ -143,6 +143,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
refresh (): void {
|
||||
this.profiles = this.config.store.profiles
|
||||
this.profileGroups = []
|
||||
const profileGroupCollapsed = JSON.parse(window.localStorage.profileGroupCollapsed ?? '{}')
|
||||
|
||||
for (const profile of this.profiles) {
|
||||
let group = this.profileGroups.find(x => x.name === profile.group)
|
||||
@ -151,7 +152,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
name: profile.group,
|
||||
profiles: [],
|
||||
editable: true,
|
||||
collapsed: false,
|
||||
collapsed: profileGroupCollapsed[profile.group ?? ''] ?? false,
|
||||
}
|
||||
this.profileGroups.push(group)
|
||||
}
|
||||
@ -160,12 +161,14 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
|
||||
this.profileGroups.sort((a, b) => a.name?.localeCompare(b.name ?? '') ?? -1)
|
||||
|
||||
this.profileGroups.push({
|
||||
const builtIn = {
|
||||
name: this.translate.instant('Built-in'),
|
||||
profiles: this.builtinProfiles,
|
||||
editable: false,
|
||||
collapsed: false,
|
||||
})
|
||||
}
|
||||
builtIn.collapsed = profileGroupCollapsed[builtIn.name ?? ''] ?? false
|
||||
this.profileGroups.push(builtIn)
|
||||
}
|
||||
|
||||
async editGroup (group: ProfileGroup): Promise<void> {
|
||||
@ -246,6 +249,13 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
}[this.profilesService.providerForProfile(profile)?.id ?? ''] ?? 'warning'
|
||||
}
|
||||
|
||||
toggleGroupCollapse (group: ProfileGroup): void {
|
||||
group.collapsed = !group.collapsed
|
||||
const profileGroupCollapsed = JSON.parse(window.localStorage.profileGroupCollapsed ?? '{}')
|
||||
profileGroupCollapsed[group.name ?? ''] = group.collapsed
|
||||
window.localStorage.profileGroupCollapsed = JSON.stringify(profileGroupCollapsed)
|
||||
}
|
||||
|
||||
async editDefaults (provider: ProfileProvider<Profile>): Promise<void> {
|
||||
const modal = this.ngbModal.open(
|
||||
EditProfileModalComponent,
|
||||
|
Loading…
Reference in New Issue
Block a user