Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix#8925: unable to set back a value to the inherited default value on profile #8926

Merged
merged 2 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tabby-core/src/services/profiles.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ export class ProfilesService {
async writeProfile (profile: PartialProfile<Profile>): Promise<void> {
const cProfile = this.config.store.profiles.find(p => p.id === profile.id)
if (cProfile) {
if (!profile.group) {
delete cProfile.group
// Fully replace the config
for (const k in cProfile) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete cProfile[k]
}

Object.assign(cProfile, profile)
}
}
Expand Down
35 changes: 13 additions & 22 deletions tabby-settings/src/components/profilesSettingsTab.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,24 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
return
}
}
const profile: PartialProfile<Profile> = deepClone(base)
delete profile.id
const baseProfile: PartialProfile<Profile> = deepClone(base)
delete baseProfile.id
if (base.isTemplate) {
profile.name = ''
baseProfile.name = ''
} else if (!base.isBuiltin) {
profile.name = this.translate.instant('{name} copy', base)
baseProfile.name = this.translate.instant('{name} copy', base)
}
profile.isBuiltin = false
profile.isTemplate = false
const result = await this.showProfileEditModal(profile)
baseProfile.isBuiltin = false
baseProfile.isTemplate = false
const result = await this.showProfileEditModal(baseProfile)
if (!result) {
return
}
Object.assign(profile, result)
if (!profile.name) {
const cfgProxy = this.profilesService.getConfigProxyForProfile(profile)
profile.name = this.profilesService.providerForProfile(profile)?.getSuggestedName(cfgProxy) ?? this.translate.instant('{name} copy', base)
if (!result.name) {
const cfgProxy = this.profilesService.getConfigProxyForProfile(result)
result.name = this.profilesService.providerForProfile(result)?.getSuggestedName(cfgProxy) ?? this.translate.instant('{name} copy', base)
}
await this.profilesService.newProfile(profile)
await this.profilesService.newProfile(result)
await this.config.save()
}

Expand All @@ -97,8 +96,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
if (!result) {
return
}
Object.assign(profile, result)
await this.profilesService.writeProfile(profile)
await this.profilesService.writeProfile(result)
await this.config.save()
}

Expand All @@ -119,12 +117,6 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
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
return result
}
Expand Down Expand Up @@ -162,8 +154,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
if (!result) {
return
}
Object.assign(group, result)
await this.profilesService.writeProfileGroup(ProfilesSettingsTabComponent.collapsableIntoPartialProfileGroup(group))
await this.profilesService.writeProfileGroup(ProfilesSettingsTabComponent.collapsableIntoPartialProfileGroup(result))
await this.config.save()
}

Expand Down