]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/moderation/video-abuse-list/moderation-comment-modal.component.ts
Add ListOverflow component to prevent sub-menu overflow
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / moderation / video-abuse-list / moderation-comment-modal.component.ts
index 34ab384d134792afa5fb2db47f9d5194f540134a..29f90194baeb9744fdec1c7bb1372a20a97633bc 100644 (file)
@@ -1,5 +1,5 @@
 import { Component, EventEmitter, OnInit, Output, ViewChild } from '@angular/core'
-import { NotificationsService } from 'angular2-notifications'
+import { Notifier } from '@app/core'
 import { FormReactive, VideoAbuseService, VideoAbuseValidatorsService } from '../../../shared'
 import { I18n } from '@ngx-translate/i18n-polyfill'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@@ -13,7 +13,7 @@ import { VideoAbuse } from '../../../../../../shared/models/videos'
   styleUrls: [ './moderation-comment-modal.component.scss' ]
 })
 export class ModerationCommentModalComponent extends FormReactive implements OnInit {
-  @ViewChild('modal') modal: NgbModal
+  @ViewChild('modal', { static: true }) modal: NgbModal
   @Output() commentUpdated = new EventEmitter<string>()
 
   private abuseToComment: VideoAbuse
@@ -22,7 +22,7 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
   constructor (
     protected formValidatorService: FormValidatorService,
     private modalService: NgbModal,
-    private notificationsService: NotificationsService,
+    private notifier: Notifier,
     private videoAbuseService: VideoAbuseService,
     private videoAbuseValidatorsService: VideoAbuseValidatorsService,
     private i18n: I18n
@@ -38,36 +38,33 @@ export class ModerationCommentModalComponent extends FormReactive implements OnI
 
   openModal (abuseToComment: VideoAbuse) {
     this.abuseToComment = abuseToComment
-    this.openedModal = this.modalService.open(this.modal)
+    this.openedModal = this.modalService.open(this.modal, { centered: true })
 
     this.form.patchValue({
       moderationComment: this.abuseToComment.moderationComment
     })
   }
 
-  hideModerationCommentModal () {
+  hide () {
     this.abuseToComment = undefined
     this.openedModal.close()
     this.form.reset()
   }
 
   async banUser () {
-    const moderationComment: string = this.form.value['moderationComment']
+    const moderationComment: string = this.form.value[ 'moderationComment' ]
 
     this.videoAbuseService.updateVideoAbuse(this.abuseToComment, { moderationComment })
-      .subscribe(
-        () => {
-          this.notificationsService.success(
-            this.i18n('Success'),
-            this.i18n('Comment updated.')
-          )
+        .subscribe(
+          () => {
+            this.notifier.success(this.i18n('Comment updated.'))
 
-          this.commentUpdated.emit(moderationComment)
-          this.hideModerationCommentModal()
-        },
+            this.commentUpdated.emit(moderationComment)
+            this.hide()
+          },
 
-          err => this.notificationsService.error(this.i18n('Error'), err.message)
-      )
+          err => this.notifier.error(err.message)
+        )
   }
 
 }