mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-08 13:30:02 +00:00
ref(core): profiles.services deleteBulkProfiles filter with predicate function
This commit is contained in:
parent
5e5c80832d
commit
0128013308
@ -143,8 +143,8 @@ export class ProfilesService {
|
|||||||
* Delete all Profiles from config using option filter
|
* Delete all Profiles from config using option filter
|
||||||
* arg: options { group: string } -> options used to filter which profile have to be deleted
|
* arg: options { group: string } -> options used to filter which profile have to be deleted
|
||||||
*/
|
*/
|
||||||
async deleteBulkProfiles (options: { group: string }): Promise<void> {
|
async deleteBulkProfiles (filter: (p: PartialProfile<Profile>) => boolean): Promise<void> {
|
||||||
for (const profile of this.config.store.profiles.filter(p => p.group === options.group)) {
|
for (const profile of this.config.store.profiles.filter(filter)) {
|
||||||
this.providerForProfile(profile)?.deleteProfile(this.getConfigProxyForProfile(profile))
|
this.providerForProfile(profile)?.deleteProfile(this.getConfigProxyForProfile(profile))
|
||||||
|
|
||||||
const profileHotkeyName = ProfilesService.getProfileHotkeyName(profile)
|
const profileHotkeyName = ProfilesService.getProfileHotkeyName(profile)
|
||||||
@ -156,7 +156,7 @@ export class ProfilesService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.config.store.profiles = this.config.store.profiles.filter(p => p.group !== options.group)
|
this.config.store.profiles = this.config.store.profiles.filter(!filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
async openNewTabForProfile <P extends Profile> (profile: PartialProfile<P>): Promise<BaseTabComponent|null> {
|
async openNewTabForProfile <P extends Profile> (profile: PartialProfile<P>): Promise<BaseTabComponent|null> {
|
||||||
@ -480,7 +480,7 @@ export class ProfilesService {
|
|||||||
async deleteProfileGroup (group: PartialProfileGroup<ProfileGroup>, options?: { deleteProfiles?: boolean }): Promise<void> {
|
async deleteProfileGroup (group: PartialProfileGroup<ProfileGroup>, options?: { deleteProfiles?: boolean }): Promise<void> {
|
||||||
this.config.store.groups = this.config.store.groups.filter(g => g.id !== group.id)
|
this.config.store.groups = this.config.store.groups.filter(g => g.id !== group.id)
|
||||||
if (options?.deleteProfiles) {
|
if (options?.deleteProfiles) {
|
||||||
await this.deleteBulkProfiles({ group: group.id })
|
await this.deleteBulkProfiles((p) => p.group === group.id)
|
||||||
} else {
|
} else {
|
||||||
for (const profile of this.config.store.profiles.filter(x => x.group === group.id)) {
|
for (const profile of this.config.store.profiles.filter(x => x.group === group.id)) {
|
||||||
delete profile.group
|
delete profile.group
|
||||||
|
Loading…
x
Reference in New Issue
Block a user