Merge pull request #9148 from AllForNothing/add-member-nightly

Improve project name validator when adding new project
This commit is contained in:
danfengliu 2019-09-19 17:13:31 +08:00 committed by GitHub
commit c360e71d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View File

@ -3,16 +3,21 @@
<div class="modal-body modal-height"> <div class="modal-body modal-height">
<inline-alert></inline-alert> <inline-alert></inline-alert>
<form #projectForm="ngForm" class="clr-form clr-form-horizontal"> <form #projectForm="ngForm" class="clr-form clr-form-horizontal">
<clr-input-container> <div class="clr-form-control">
<label class="required">{{'PROJECT.NAME' | translate}}</label> <label class="required clr-control-label">{{'PROJECT.NAME' | translate}}</label>
<input clrInput type="text" id="create_project_name" [(ngModel)]="project.name" name="create_project_name" class="input-width" <div class="clr-control-container" [class.clr-error]="!isNameValid">
required pattern="^[a-z0-9]+(?:[._-][a-z0-9]+)*$" minlength="2" #projectName="ngModel" autocomplete="off" <div class="clr-input-wrapper">
(keyup)='handleValidation()'> <input type="text" id="create_project_name" [(ngModel)]="project.name" name="create_project_name" class="clr-input input-width"
<clr-control-error *ngIf="!isNameValid" class="tooltip-content"> required pattern="^[a-z0-9]+(?:[._-][a-z0-9]+)*$" minlength="2" #projectName="ngModel" autocomplete="off"
{{ nameTooltipText | translate }} (keyup)='handleValidation()'>
</clr-control-error> <clr-icon class="clr-validate-icon" shape="exclamation-circle"></clr-icon>
<span class="spinner spinner-inline" [hidden]="!checkOnGoing"></span> <span class="spinner spinner-inline" [hidden]="!checkOnGoing"></span>
</clr-input-container> </div>
<clr-control-error *ngIf="!isNameValid" class="tooltip-content">
{{ nameTooltipText | translate }}
</clr-control-error>
</div>
</div>
<clr-checkbox-container> <clr-checkbox-container>
<label class="form-group-label-override">{{'PROJECT.ACCESS_LEVEL' | translate}} <label class="form-group-label-override">{{'PROJECT.ACCESS_LEVEL' | translate}}
<clr-tooltip> <clr-tooltip>
@ -41,7 +46,6 @@
<clr-control-error class="tooltip-content"> <clr-control-error class="tooltip-content">
{{ 'PROJECT.COUNT_QUOTA_TIP' | translate }} {{ 'PROJECT.COUNT_QUOTA_TIP' | translate }}
</clr-control-error> </clr-control-error>
<span class="spinner spinner-inline" [hidden]="!checkOnGoing"></span>
</clr-input-container> </clr-input-container>
<div class="clr-form-control" *ngIf="isSystemAdmin"> <div class="clr-form-control" *ngIf="isSystemAdmin">
<label for="create_project_storage_limit" class="required clr-control-label">{{'PROJECT.STORAGE_QUOTA' | translate}} <label for="create_project_storage_limit" class="required clr-control-label">{{'PROJECT.STORAGE_QUOTA' | translate}}
@ -76,4 +80,4 @@
<button type="button" class="btn btn-outline" (click)="onCancel()">{{'BUTTON.CANCEL' | translate}}</button> <button type="button" class="btn btn-outline" (click)="onCancel()">{{'BUTTON.CANCEL' | translate}}</button>
<button type="button" class="btn btn-primary" [disabled]="!isValid" (click)="onSubmit()">{{'BUTTON.OK' | translate}}</button> <button type="button" class="btn btn-primary" [disabled]="!isValid" (click)="onSubmit()">{{'BUTTON.OK' | translate}}</button>
</div> </div>
</clr-modal> </clr-modal>

View File

@ -89,6 +89,7 @@ export class CreateProjectComponent implements OnInit, OnChanges, OnDestroy {
this.isNameValid = cont.valid; this.isNameValid = cont.valid;
if (this.isNameValid) { if (this.isNameValid) {
// Check exiting from backend // Check exiting from backend
this.checkOnGoing = true;
this.projectService this.projectService
.checkProjectExists(cont.value) .checkProjectExists(cont.value)
.subscribe(() => { .subscribe(() => {