]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/confirm/confirm.component.ts
Fixes #574 account link width on video view (#665)
[github/Chocobozzz/PeerTube.git] / client / src / app / core / confirm / confirm.component.ts
index 0515d969aa7575d4021ccc306a32d7bb4ef32714..02b38489a9b264083758203b2f561bd0d0671156 100644 (file)
@@ -3,24 +3,28 @@ import { Component, HostListener, OnInit, ViewChild } from '@angular/core'
 import { ModalDirective } from 'ngx-bootstrap/modal'
 
 import { ConfirmService } from './confirm.service'
-
-export interface ConfigChangedEvent {
-  columns: { [id: string]: { isDisplayed: boolean } }
-  config: { resultsPerPage: number }
-}
+import { I18n } from '@ngx-translate/i18n-polyfill'
 
 @Component({
   selector: 'my-confirm',
   templateUrl: './confirm.component.html',
-  styles: [ '.button { padding: 0 13px; }' ]
+  styleUrls: [ './confirm.component.scss' ]
 })
 export class ConfirmComponent implements OnInit {
   @ViewChild('confirmModal') confirmModal: ModalDirective
 
   title = ''
   message = ''
+  expectedInputValue = ''
+  inputLabel = ''
 
-  constructor (private confirmService: ConfirmService) {
+  inputValue = ''
+  confirmButtonText = ''
+
+  constructor (
+    private confirmService: ConfirmService,
+    private i18n: I18n
+  ) {
     // Empty
   }
 
@@ -31,10 +35,15 @@ export class ConfirmComponent implements OnInit {
     }
 
     this.confirmService.showConfirm.subscribe(
-      ({ title, message }) => {
+      ({ title, message, expectedInputValue, inputLabel, confirmButtonText }) => {
         this.title = title
         this.message = message
 
+        this.inputLabel = inputLabel
+        this.expectedInputValue = expectedInputValue
+
+        this.confirmButtonText = confirmButtonText || this.i18n('Confirm')
+
         this.showModal()
       }
     )
@@ -52,6 +61,13 @@ export class ConfirmComponent implements OnInit {
     this.hideModal()
   }
 
+  isConfirmationDisabled () {
+    // No input validation
+    if (!this.inputLabel || !this.expectedInputValue) return false
+
+    return this.expectedInputValue !== this.inputValue
+  }
+
   showModal () {
     this.confirmModal.show()
   }