mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-24 09:06:03 +00:00
Merge pull request #8926 from Clem-Fern/ref-profiles-v2
This commit is contained in:
@@ -115,10 +115,11 @@ export class ProfilesService {
|
|||||||
async writeProfile (profile: PartialProfile<Profile>): Promise<void> {
|
async writeProfile (profile: PartialProfile<Profile>): Promise<void> {
|
||||||
const cProfile = this.config.store.profiles.find(p => p.id === profile.id)
|
const cProfile = this.config.store.profiles.find(p => p.id === profile.id)
|
||||||
if (cProfile) {
|
if (cProfile) {
|
||||||
if (!profile.group) {
|
// Fully replace the config
|
||||||
delete cProfile.group
|
for (const k in cProfile) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||||
|
delete cProfile[k]
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(cProfile, profile)
|
Object.assign(cProfile, profile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -70,25 +70,24 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const profile: PartialProfile<Profile> = deepClone(base)
|
const baseProfile: PartialProfile<Profile> = deepClone(base)
|
||||||
delete profile.id
|
delete baseProfile.id
|
||||||
if (base.isTemplate) {
|
if (base.isTemplate) {
|
||||||
profile.name = ''
|
baseProfile.name = ''
|
||||||
} else if (!base.isBuiltin) {
|
} else if (!base.isBuiltin) {
|
||||||
profile.name = this.translate.instant('{name} copy', base)
|
baseProfile.name = this.translate.instant('{name} copy', base)
|
||||||
}
|
}
|
||||||
profile.isBuiltin = false
|
baseProfile.isBuiltin = false
|
||||||
profile.isTemplate = false
|
baseProfile.isTemplate = false
|
||||||
const result = await this.showProfileEditModal(profile)
|
const result = await this.showProfileEditModal(baseProfile)
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Object.assign(profile, result)
|
if (!result.name) {
|
||||||
if (!profile.name) {
|
const cfgProxy = this.profilesService.getConfigProxyForProfile(result)
|
||||||
const cfgProxy = this.profilesService.getConfigProxyForProfile(profile)
|
result.name = this.profilesService.providerForProfile(result)?.getSuggestedName(cfgProxy) ?? this.translate.instant('{name} copy', base)
|
||||||
profile.name = this.profilesService.providerForProfile(profile)?.getSuggestedName(cfgProxy) ?? this.translate.instant('{name} copy', base)
|
|
||||||
}
|
}
|
||||||
await this.profilesService.newProfile(profile)
|
await this.profilesService.newProfile(result)
|
||||||
await this.config.save()
|
await this.config.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,8 +96,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Object.assign(profile, result)
|
await this.profilesService.writeProfile(result)
|
||||||
await this.profilesService.writeProfile(profile)
|
|
||||||
await this.config.save()
|
await this.config.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,12 +117,6 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fully replace the config
|
|
||||||
for (const k in profile) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
||||||
delete profile[k]
|
|
||||||
}
|
|
||||||
|
|
||||||
result.type = provider.id
|
result.type = provider.id
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
@@ -162,8 +154,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
if (!result) {
|
if (!result) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
Object.assign(group, result)
|
await this.profilesService.writeProfileGroup(ProfilesSettingsTabComponent.collapsableIntoPartialProfileGroup(result))
|
||||||
await this.profilesService.writeProfileGroup(ProfilesSettingsTabComponent.collapsableIntoPartialProfileGroup(group))
|
|
||||||
await this.config.save()
|
await this.config.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user