mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-21 02:48:00 +00:00
wip ref(core): getProfileGroups create non editable group for built-in profile
This commit is contained in:
@@ -410,11 +410,13 @@ export class ProfilesService {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (includeNonUserGroup) {
|
if (includeNonUserGroup) {
|
||||||
const builtIn: PartialProfileGroup<ProfileGroup> = {
|
const builtInGroups: PartialProfileGroup<ProfileGroup>[] = []
|
||||||
|
builtInGroups.push({
|
||||||
id: 'built-in',
|
id: 'built-in',
|
||||||
name: this.translate.instant('Built-in'),
|
name: this.translate.instant('Built-in'),
|
||||||
editable: false,
|
editable: false,
|
||||||
}
|
profiles: [],
|
||||||
|
})
|
||||||
|
|
||||||
const ungrouped: PartialProfileGroup<ProfileGroup> = {
|
const ungrouped: PartialProfileGroup<ProfileGroup> = {
|
||||||
id: 'ungrouped',
|
id: 'ungrouped',
|
||||||
@@ -423,13 +425,25 @@ export class ProfilesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (includeProfiles) {
|
if (includeProfiles) {
|
||||||
builtIn.profiles = profiles.filter(p => p.isBuiltin)
|
for (const profile of profiles.filter(p => p.isBuiltin)) {
|
||||||
profiles = profiles.filter(p => !p.isBuiltin)
|
let group: PartialProfileGroup<ProfileGroup> | undefined = builtInGroups.find(g => g.id === slugify(profile.group ?? 'built-in'))
|
||||||
|
if (!group) {
|
||||||
ungrouped.profiles = profiles
|
group = {
|
||||||
|
id: `${slugify(profile.group!)}`,
|
||||||
|
name: `${profile.group!}`,
|
||||||
|
editable: false,
|
||||||
|
profiles: [],
|
||||||
|
}
|
||||||
|
builtInGroups.push(group)
|
||||||
}
|
}
|
||||||
|
|
||||||
groups.push(builtIn)
|
group.profiles!.push(profile)
|
||||||
|
}
|
||||||
|
|
||||||
|
ungrouped.profiles = profiles.filter(p => !p.isBuiltin)
|
||||||
|
}
|
||||||
|
|
||||||
|
groups = groups.concat(builtInGroups)
|
||||||
groups.push(ungrouped)
|
groups.push(ungrouped)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -144,7 +144,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
const profileGroupCollapsed = JSON.parse(window.localStorage.profileGroupCollapsed ?? '{}')
|
const profileGroupCollapsed = JSON.parse(window.localStorage.profileGroupCollapsed ?? '{}')
|
||||||
const groups = await this.profilesService.getProfileGroups(true, true)
|
const groups = await this.profilesService.getProfileGroups(true, true)
|
||||||
groups.sort((a, b) => a.name.localeCompare(b.name))
|
groups.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
groups.sort((a, b) => (a.id === 'built-in' ? 1 : 0) - (b.id === 'built-in' ? 1 : 0))
|
groups.sort((a, b) => (a.id === 'built-in' || !a.editable ? 1 : 0) - (b.id === 'built-in' || !b.editable ? 1 : 0))
|
||||||
groups.sort((a, b) => (a.id === 'ungrouped' ? 0 : 1) - (b.id === 'ungrouped' ? 0 : 1))
|
groups.sort((a, b) => (a.id === 'ungrouped' ? 0 : 1) - (b.id === 'ungrouped' ? 0 : 1))
|
||||||
this.profileGroups = groups.map(g => ProfilesSettingsTabComponent.intoPartialCollapsableProfileGroup(g, profileGroupCollapsed[g.id] ?? false))
|
this.profileGroups = groups.map(g => ProfilesSettingsTabComponent.intoPartialCollapsableProfileGroup(g, profileGroupCollapsed[g.id] ?? false))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user