Merge pull request #8831 from jwangyangls/add-pleaseholder-hub

Add placeholder in registry page when select helm-hub
This commit is contained in:
jwangyangls 2019-08-28 13:40:01 +08:00 committed by GitHub
commit 81c1e9892a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 7 deletions

View File

@ -45,10 +45,10 @@
<label for="destination_url" class="col-md-4 form-group-label-override required">{{ 'DESTINATION.URL' | <label for="destination_url" class="col-md-4 form-group-label-override required">{{ 'DESTINATION.URL' |
translate }}</label> translate }}</label>
<label class="col-md-8" for="destination_url" aria-haspopup="true" role="tooltip" [class.invalid]="targetEndpoint?.errors && (targetEndpoint?.dirty || targetEndpoint?.touched)" <label class="col-md-8" for="destination_url" aria-haspopup="true" role="tooltip" [class.invalid]="targetEndpoint?.errors && (targetEndpoint?.dirty || targetEndpoint?.touched)"
[class.valid]="targetEndpoint?.valid" class="tooltip tooltip-validation tooltip-sm tooltip-bottom-left"> [class.valid]="targetEndpoint?.valid" class="tooltip tooltip-validation tooltip-sm tooltip-bottom-left clr-select-wrapper">
<input *ngIf="!endpointList.length" type="text" id="destination_url" [disabled]="testOngoing || urlDisabled" [readonly]="!editable" [(ngModel)]="target.url" <input *ngIf="!endpointList.length" type="text" id="destination_url" [disabled]="testOngoing || urlDisabled" [readonly]="!editable" [(ngModel)]="target.url"
size="25" name="endpointUrl" #targetEndpoint="ngModel" required placeholder="http(s)://192.168.1.1"> size="25" name="endpointUrl" #targetEndpoint="ngModel" required placeholder="http(s)://192.168.1.1">
<select *ngIf="endpointList.length" [(ngModel)]="target.url" name="endpointUrl" #targetEndpoint="ngModel"> <select *ngIf="endpointList.length" [(ngModel)]="target.url" class="clr-select" name="endpointUrl" #targetEndpoint="ngModel">
<option class="display-none" value=""></option> <option class="display-none" value=""></option>
<option *ngFor="let endpoint of endpointList" value="{{endpoint.value}}">{{endpoint.key}}</option> <option *ngFor="let endpoint of endpointList" value="{{endpoint.value}}">{{endpoint.key}}</option>
</select> </select>

View File

@ -34,6 +34,14 @@ import { clone, compareValue, isEmptyObject } from "../utils";
const FAKE_PASSWORD = "rjGcfuRu"; const FAKE_PASSWORD = "rjGcfuRu";
const FAKE_JSON_KEY = "No Change"; const FAKE_JSON_KEY = "No Change";
const DOCKERHUB_URL = "https://hub.docker.com"; const DOCKERHUB_URL = "https://hub.docker.com";
const HELM_HUB_URL = "https://hub.helm.sh";
const HELM_HUB_ACCESS_KEY = "_json_key";
const REGISTRY_NAME_LIST = {
DOCKER_HUB: "docker-hub",
HELM_HUB: "helm-hub",
GOOGLE_GCR: "google-gcr",
AWS_ECR: "aws-ecr"
};
@Component({ @Component({
selector: "hbr-create-edit-endpoint", selector: "hbr-create-edit-endpoint",
templateUrl: "./create-edit-endpoint.component.html", templateUrl: "./create-edit-endpoint.component.html",
@ -214,19 +222,22 @@ export class CreateEditEndpointComponent
adapterChange($event): void { adapterChange($event): void {
let selectValue = this.targetForm.controls.adapter.value; let selectValue = this.targetForm.controls.adapter.value;
if (selectValue === 'docker-hub') { if (selectValue === REGISTRY_NAME_LIST.DOCKER_HUB) {
this.urlDisabled = true; this.urlDisabled = true;
this.targetForm.controls.endpointUrl.setValue(DOCKERHUB_URL); this.targetForm.controls.endpointUrl.setValue(DOCKERHUB_URL);
} else if (selectValue === REGISTRY_NAME_LIST.HELM_HUB) {
this.urlDisabled = true;
this.targetForm.controls.endpointUrl.setValue(HELM_HUB_URL);
} else { } else {
this.urlDisabled = false; this.urlDisabled = false;
this.targetForm.controls.endpointUrl.setValue(""); this.targetForm.controls.endpointUrl.setValue("");
} }
if (selectValue === 'google-gcr') { if (selectValue === REGISTRY_NAME_LIST.GOOGLE_GCR) {
this.targetForm.controls.access_key.setValue("_json_key"); this.targetForm.controls.access_key.setValue(HELM_HUB_ACCESS_KEY);
} else { } else {
this.targetForm.controls.access_key.setValue(""); this.targetForm.controls.access_key.setValue("");
} }
if (selectValue === 'google-gcr') { if (selectValue === REGISTRY_NAME_LIST.GOOGLE_GCR) {
this.endpointList = [ this.endpointList = [
{ {
key: "gcr.io", key: "gcr.io",
@ -245,7 +256,7 @@ export class CreateEditEndpointComponent
value: "https://asia.gcr.io" value: "https://asia.gcr.io"
} }
]; ];
} else if (selectValue === 'aws-ecr') { } else if (selectValue === REGISTRY_NAME_LIST.AWS_ECR) {
this.endpointList = [ this.endpointList = [
{ {
key: "ap-northeast-1", key: "ap-northeast-1",