mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-23 21:09:52 +00:00
feat(settings): Eugeny/tabby#7265 add a button to reset global & groups settings to defaults
This commit is contained in:
parent
c108476262
commit
f369b140c6
@ -19,10 +19,13 @@
|
|||||||
.description(translate) These apply to all profiles of a given type in this group
|
.description(translate) These apply to all profiles of a given type in this group
|
||||||
|
|
||||||
.list-group.mt-3.mb-3.content-box
|
.list-group.mt-3.mb-3.content-box
|
||||||
a.list-group-item.list-group-item-action(
|
a.list-group-item.list-group-item-action.d-flex.align-items-center(
|
||||||
(click)='editDefaults(provider)',
|
(click)='editDefaults(provider)',
|
||||||
*ngFor='let provider of providers'
|
*ngFor='let provider of providers'
|
||||||
) {{provider.name|translate}}
|
) {{provider.name|translate}}
|
||||||
|
.me-auto
|
||||||
|
button.btn.btn-link.hover-reveal.ms-1((click)='$event.stopPropagation(); deleteDefaults(provider)')
|
||||||
|
i.fas.fa-trash-arrow-up
|
||||||
|
|
||||||
.modal-footer
|
.modal-footer
|
||||||
button.btn.btn-primary((click)='save()', translate) Save
|
button.btn.btn-primary((click)='save()', translate) Save
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||||
import { Component, Input } from '@angular/core'
|
import { Component, Input } from '@angular/core'
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { ConfigProxy, ProfileGroup, Profile, ProfileProvider } from 'tabby-core'
|
import { ConfigProxy, ProfileGroup, Profile, ProfileProvider, PlatformService, TranslateService } from 'tabby-core'
|
||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
@Component({
|
@Component({
|
||||||
@ -13,6 +13,8 @@ export class EditProfileGroupModalComponent<G extends ProfileGroup> {
|
|||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private modalInstance: NgbActiveModal,
|
private modalInstance: NgbActiveModal,
|
||||||
|
private platform: PlatformService,
|
||||||
|
private translate: TranslateService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
save () {
|
save () {
|
||||||
@ -26,6 +28,24 @@ export class EditProfileGroupModalComponent<G extends ProfileGroup> {
|
|||||||
editDefaults (provider: ProfileProvider<Profile>) {
|
editDefaults (provider: ProfileProvider<Profile>) {
|
||||||
this.modalInstance.close({ group: this.group, provider })
|
this.modalInstance.close({ group: this.group, provider })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteDefaults (provider: ProfileProvider<Profile>): Promise<void> {
|
||||||
|
if ((await this.platform.showMessageBox(
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
message: this.translate.instant('Restore settings to inherited defaults ?'),
|
||||||
|
buttons: [
|
||||||
|
this.translate.instant('Delete'),
|
||||||
|
this.translate.instant('Keep'),
|
||||||
|
],
|
||||||
|
defaultId: 1,
|
||||||
|
cancelId: 1,
|
||||||
|
},
|
||||||
|
)).response === 0) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||||
|
delete this.group.defaults?.[provider.id]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditProfileGroupModalComponentResult<G extends ProfileGroup> {
|
export interface EditProfileGroupModalComponentResult<G extends ProfileGroup> {
|
||||||
|
@ -177,9 +177,12 @@ ul.nav-tabs(ngbNav, #nav='ngbNav')
|
|||||||
.description(translate) These apply to all profiles of a given type
|
.description(translate) These apply to all profiles of a given type
|
||||||
|
|
||||||
.list-group.mt-3.mb-3.content-box
|
.list-group.mt-3.mb-3.content-box
|
||||||
a.list-group-item.list-group-item-action(
|
a.list-group-item.list-group-item-action.d-flex.align-items-center(
|
||||||
(click)='editDefaults(provider)',
|
(click)='editDefaults(provider)',
|
||||||
*ngFor='let provider of profileProviders'
|
*ngFor='let provider of profileProviders'
|
||||||
) {{provider.name|translate}}
|
) {{provider.name|translate}}
|
||||||
|
.me-auto
|
||||||
|
button.btn.btn-link.hover-reveal.ms-1((click)='$event.stopPropagation(); deleteDefaults(provider)')
|
||||||
|
i.fas.fa-trash-arrow-up
|
||||||
|
|
||||||
div([ngbNavOutlet]='nav')
|
div([ngbNavOutlet]='nav')
|
||||||
|
@ -308,6 +308,24 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
await this.config.save()
|
await this.config.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteDefaults (provider: ProfileProvider<Profile>): Promise<void> {
|
||||||
|
if ((await this.platform.showMessageBox(
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
message: this.translate.instant('Restore settings to defaults ?'),
|
||||||
|
buttons: [
|
||||||
|
this.translate.instant('Delete'),
|
||||||
|
this.translate.instant('Keep'),
|
||||||
|
],
|
||||||
|
defaultId: 1,
|
||||||
|
cancelId: 1,
|
||||||
|
},
|
||||||
|
)).response === 0) {
|
||||||
|
this.profilesService.setProviderDefaults(provider, {})
|
||||||
|
await this.config.save()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
blacklistProfile (profile: PartialProfile<Profile>): void {
|
blacklistProfile (profile: PartialProfile<Profile>): void {
|
||||||
this.config.store.profileBlacklist = [...this.config.store.profileBlacklist, profile.id]
|
this.config.store.profileBlacklist = [...this.config.store.profileBlacklist, profile.id]
|
||||||
this.config.save()
|
this.config.save()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user