Adding confirmation before disconnect
This commit is contained in:
parent
79c0ec42ea
commit
732c123d44
@ -1,11 +1,12 @@
|
|||||||
import { Component, OnDestroy, OnInit } from '@angular/core'
|
import { Component, OnDestroy, OnInit } from '@angular/core'
|
||||||
import { FormControl, FormGroup } from '@angular/forms'
|
import { FormControl, FormGroup } from '@angular/forms'
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { ProfileService } from 'src/app/services/profile.service'
|
import { ProfileService } from 'src/app/services/profile.service'
|
||||||
import { SocialAccount, SocialAccountProvider } from 'src/app/data/user-profile'
|
import { SocialAccount, SocialAccountProvider } from 'src/app/data/user-profile'
|
||||||
import { ToastService } from 'src/app/services/toast.service'
|
import { ToastService } from 'src/app/services/toast.service'
|
||||||
import { Subject, takeUntil } from 'rxjs'
|
import { Subject, takeUntil } from 'rxjs'
|
||||||
import { Clipboard } from '@angular/cdk/clipboard'
|
import { Clipboard } from '@angular/cdk/clipboard'
|
||||||
|
import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dialog.component'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'pngx-profile-edit-dialog',
|
selector: 'pngx-profile-edit-dialog',
|
||||||
@ -46,7 +47,8 @@ export class ProfileEditDialogComponent implements OnInit, OnDestroy {
|
|||||||
private profileService: ProfileService,
|
private profileService: ProfileService,
|
||||||
public activeModal: NgbActiveModal,
|
public activeModal: NgbActiveModal,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private clipboard: Clipboard
|
private clipboard: Clipboard,
|
||||||
|
private modalService: NgbModal
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@ -196,19 +198,30 @@ export class ProfileEditDialogComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disconnectSocialAccount(id: number): void {
|
disconnectSocialAccount(id: number): void {
|
||||||
this.profileService
|
let modal = this.modalService.open(ConfirmDialogComponent, {
|
||||||
.disconnectSocialAccount(id)
|
backdrop: 'static',
|
||||||
.pipe(takeUntil(this.unsubscribeNotifier))
|
})
|
||||||
.subscribe({
|
modal.componentInstance.title = $localize`Confirm disconnecting the social account`
|
||||||
next: (id: number) => {
|
modal.componentInstance.messageBold = $localize`The social account will be disconnected and can no longer be used to log in.`
|
||||||
this.socialAccounts = this.socialAccounts.filter((a) => a.id != id)
|
modal.componentInstance.message = $localize`This operation cannot be undone but you can connect the account again.`
|
||||||
},
|
modal.componentInstance.btnClass = 'btn-danger'
|
||||||
error: (error) => {
|
modal.componentInstance.btnCaption = $localize`Proceed`
|
||||||
this.toastService.showError(
|
modal.componentInstance.confirmClicked.subscribe(() => {
|
||||||
$localize`Error disconnecting social account`,
|
modal.componentInstance.buttonsEnabled = false
|
||||||
error
|
this.profileService
|
||||||
)
|
.disconnectSocialAccount(id)
|
||||||
},
|
.pipe(takeUntil(this.unsubscribeNotifier))
|
||||||
})
|
.subscribe({
|
||||||
|
next: (id: number) => {
|
||||||
|
this.socialAccounts = this.socialAccounts.filter((a) => a.id != id)
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
this.toastService.showError(
|
||||||
|
$localize`Error disconnecting social account`,
|
||||||
|
error
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user