diff --git a/src/portal/lib/src/image-name-input/image-name-input.component.html b/src/portal/lib/src/image-name-input/image-name-input.component.html index f2dabcb15..c62b48d0a 100644 --- a/src/portal/lib/src/image-name-input/image-name-input.component.html +++ b/src/portal/lib/src/image-name-input/image-name-input.component.html @@ -4,8 +4,13 @@
    @@ -20,8 +25,8 @@
    @@ -31,8 +36,8 @@
    diff --git a/src/portal/lib/src/image-name-input/image-name-input.component.ts b/src/portal/lib/src/image-name-input/image-name-input.component.ts index d05ad4c85..30bd4e126 100644 --- a/src/portal/lib/src/image-name-input/image-name-input.component.ts +++ b/src/portal/lib/src/image-name-input/image-name-input.component.ts @@ -1,6 +1,6 @@ import { Component, OnDestroy, OnInit } from "@angular/core"; import { Project } from "../project-policy-config/project"; -import { Observable, Subject } from "rxjs/index"; +import { Subject } from "rxjs/index"; import { debounceTime, distinctUntilChanged } from "rxjs/operators"; import { ProjectService } from "../service/project.service"; import { AbstractControl, FormBuilder, FormGroup, Validators } from "@angular/forms"; @@ -16,6 +16,9 @@ export class ImageNameInputComponent implements OnInit, OnDestroy { selectedProjectList: Project[] = []; proNameChecker: Subject = new Subject(); imageNameForm: FormGroup; + public project: string; + public repo: string; + public tag: string; constructor( private fb: FormBuilder, @@ -23,9 +26,20 @@ export class ImageNameInputComponent implements OnInit, OnDestroy { private proService: ProjectService, ) { this.imageNameForm = this.fb.group({ - projectName: ["", Validators.required], - repoName: ["", Validators.required], - tagName: ["", Validators.required], + projectName: ["", Validators.compose([ + Validators.minLength(2), + Validators.required, + Validators.pattern('^[a-z0-9]+(?:[._-][a-z0-9]+)*$') + ])], + repoName: ["", Validators.compose([ + Validators.required, + Validators.maxLength(256), + Validators.pattern('^[a-z0-9]+(?:[._-][a-z0-9]+)*(/[a-z0-9]+(?:[._-][a-z0-9]+)*)*') + ])], + tagName: ["", Validators.compose([ + Validators.required, + Validators.pattern('^[\\w][\\w.-]{0,127}$') + ])], }); } ngOnInit(): void { @@ -60,6 +74,23 @@ export class ImageNameInputComponent implements OnInit, OnDestroy { }); } + validateProjectName(): void { + let cont = this.imageNameForm.controls["projectName"]; + if (cont && cont.valid) { + this.proNameChecker.next(cont.value); + } else { + this.noProjectInfo = "PROJECT.NAME_TOOLTIP"; + } + } + + blurProjectInput(): void { + this.validateProjectName(); + } + + get form(): AbstractControl { + return this.imageNameForm; + } + get projectName(): AbstractControl { return this.imageNameForm.get("projectName"); } @@ -78,19 +109,6 @@ export class ImageNameInputComponent implements OnInit, OnDestroy { } } - validateProjectName(): void { - let cont = this.imageNameForm.controls["projectName"]; - if (cont && cont.valid) { - this.proNameChecker.next(cont.value); - } else { - this.noProjectInfo = "PROJECT.NAME_TOOLTIP"; - } - } - - blurProjectInput(): void { - this.validateProjectName(); - } - leaveProjectInput(): void { this.selectedProjectList = []; } diff --git a/src/portal/lib/src/tag/tag.component.html b/src/portal/lib/src/tag/tag.component.html index af774c7a8..b5589a390 100644 --- a/src/portal/lib/src/tag/tag.component.html +++ b/src/portal/lib/src/tag/tag.component.html @@ -11,7 +11,7 @@
- +