]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-modal/form-modal.component.ts
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / components / form-modal / form-modal.component.ts
index 46dd942e909fbf3094f708dbca3ec71547740451..59b0d2a8560a13060ba3284905b45b8ec5b6ddd4 100755 (executable)
@@ -1,5 +1,5 @@
 import { Component, OnInit } from '@angular/core';
-import { FormControl, ValidatorFn, Validators } from '@angular/forms';
+import { UntypedFormControl, ValidatorFn, Validators } from '@angular/forms';
 
 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
 import _ from 'lodash';
@@ -38,14 +38,14 @@ export class FormModalComponent implements OnInit {
   }
 
   createForm() {
-    const controlsConfig: Record<string, FormControl> = {};
+    const controlsConfig: Record<string, UntypedFormControl> = {};
     this.fields.forEach((field) => {
       controlsConfig[field.name] = this.createFormControl(field);
     });
     this.formGroup = this.formBuilder.group(controlsConfig);
   }
 
-  private createFormControl(field: CdFormModalFieldConfig): FormControl {
+  private createFormControl(field: CdFormModalFieldConfig): UntypedFormControl {
     let validators: ValidatorFn[] = [];
     if (_.isBoolean(field.required) && field.required) {
       validators.push(Validators.required);
@@ -53,7 +53,7 @@ export class FormModalComponent implements OnInit {
     if (field.validators) {
       validators = validators.concat(field.validators);
     }
-    return new FormControl(
+    return new UntypedFormControl(
       _.defaultTo(
         field.type === 'binary' ? this.dimlessBinaryPipe.transform(field.value) : field.value,
         null
@@ -89,6 +89,9 @@ export class FormModalComponent implements OnInit {
     if (error === 'required') {
       return $localize`This field is required.`;
     }
+    if (error === 'pattern') {
+      return $localize`Size must be a number or in a valid format. eg: 5 GiB`;
+    }
     return $localize`An error occurred.`;
   }