mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-20 02:18:01 +00:00
wip ref(core): ProfileGroup avoid direct config interraction outside of profiles.services
This commit is contained in:
@@ -36,7 +36,7 @@ export class EditProfileModalComponent<P extends Profile> {
|
||||
private modalInstance: NgbActiveModal,
|
||||
) {
|
||||
if (!this.defaultsMode) {
|
||||
this.profilesService.getProfileGroups().then(groups => {
|
||||
this.profilesService.getProfileGroups().then(groups => {
|
||||
this.groups = groups
|
||||
this.profileGroup = groups.find(g => g.id === this.profile.group)
|
||||
})
|
||||
@@ -97,9 +97,9 @@ export class EditProfileModalComponent<P extends Profile> {
|
||||
if (typeof this.profileGroup === 'string') {
|
||||
const newGroup: PartialProfileGroup<ProfileGroup> = {
|
||||
id: uuidv4(),
|
||||
name: this.profileGroup
|
||||
name: this.profileGroup,
|
||||
}
|
||||
this.groups.push(newGroup)
|
||||
this.profilesService.writeProfileGroup(newGroup, false)
|
||||
this.profileGroup = newGroup
|
||||
}
|
||||
this.profile.group = this.profileGroup.id
|
||||
|
@@ -167,7 +167,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
const result = await modal.result
|
||||
if (result) {
|
||||
group.name = result.value
|
||||
await this.config.save()
|
||||
await this.profilesService.writeProfileGroup(group)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +184,8 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
cancelId: 1,
|
||||
},
|
||||
)).response === 0) {
|
||||
if ((await this.platform.showMessageBox(
|
||||
let deleteProfiles = false
|
||||
if ((group.profiles?.length ?? 0) > 0 && (await this.platform.showMessageBox(
|
||||
{
|
||||
type: 'warning',
|
||||
message: this.translate.instant('Delete the group\'s profiles?'),
|
||||
@@ -195,14 +196,11 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
||||
defaultId: 0,
|
||||
cancelId: 0,
|
||||
},
|
||||
)).response === 0) {
|
||||
for (const profile of this.profiles.filter(x => x.group === group.id)) {
|
||||
delete profile.group
|
||||
}
|
||||
} else {
|
||||
this.config.store.profiles = this.config.store.profiles.filter(x => x.group !== group.id)
|
||||
)).response !== 0) {
|
||||
deleteProfiles = true
|
||||
}
|
||||
await this.config.save()
|
||||
|
||||
await this.profilesService.deleteProfileGroup(group, true, deleteProfiles)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user