mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-06 11:08:11 +02:00
Merge pull request #8241 from jwangyangls/fixReplicationLabelFilterbug
Fix bug when no labels
This commit is contained in:
commit
432f08b5b5
@ -62,7 +62,7 @@
|
|||||||
<span class="spinner spinner-inline spinner-position" [hidden]="onGoing === false"></span>
|
<span class="spinner spinner-inline spinner-position" [hidden]="onGoing === false"></span>
|
||||||
<div formArrayName="filters">
|
<div formArrayName="filters">
|
||||||
<div class="filterSelect" *ngFor="let filter of filters.controls; let i=index">
|
<div class="filterSelect" *ngFor="let filter of filters.controls; let i=index">
|
||||||
<div [formGroupName]="i">
|
<div [formGroupName]="i" *ngIf="supportedFilters[i]?.type !=='label' || (supportedFilters[i]?.type==='label' && supportedFilterLabels?.length)">
|
||||||
<div class="width-70" >
|
<div class="width-70" >
|
||||||
<label>{{"REPLICATION." + supportedFilters[i]?.type.toUpperCase() | translate}}:</label>
|
<label>{{"REPLICATION." + supportedFilters[i]?.type.toUpperCase() | translate}}:</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,6 +32,7 @@ import { ErrorHandler } from "../error-handler/error-handler";
|
|||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
import { EndpointService } from "../service/endpoint.service";
|
import { EndpointService } from "../service/endpoint.service";
|
||||||
import { cronRegex } from "../utils";
|
import { cronRegex } from "../utils";
|
||||||
|
import { FilterType } from "../shared/shared.const";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -265,14 +266,13 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get filters(): FormArray {
|
get filters(): FormArray {
|
||||||
console.log(this.ruleForm.get("filters"));
|
|
||||||
return this.ruleForm.get("filters") as FormArray;
|
return this.ruleForm.get("filters") as FormArray;
|
||||||
}
|
}
|
||||||
setFilter(filters: Filter[]) {
|
setFilter(filters: Filter[]) {
|
||||||
const filterFGs = filters.map(filter => {
|
const filterFGs = filters.map(filter => {
|
||||||
if (filter.type === 'label') {
|
if (filter.type === FilterType.LABEL) {
|
||||||
let fbLabel = this.fb.group({
|
let fbLabel = this.fb.group({
|
||||||
type: 'label'
|
type: FilterType.LABEL
|
||||||
});
|
});
|
||||||
let filterLabel = this.fb.array(filter.value);
|
let filterLabel = this.fb.array(filter.value);
|
||||||
fbLabel.setControl('value', filterLabel);
|
fbLabel.setControl('value', filterLabel);
|
||||||
@ -286,7 +286,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initFilter(name: string) {
|
initFilter(name: string) {
|
||||||
if (name === 'label') {
|
if (name === FilterType.LABEL) {
|
||||||
const labelArray = this.fb.array([]);
|
const labelArray = this.fb.array([]);
|
||||||
const labelControl = this.fb.group({type: name});
|
const labelControl = this.fb.group({type: name});
|
||||||
labelControl.setControl('value', labelArray);
|
labelControl.setControl('value', labelArray);
|
||||||
@ -439,7 +439,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
this.ruleForm.get("trigger").get("type").setValue(this.supportedTriggers[0]);
|
this.ruleForm.get("trigger").get("type").setValue(this.supportedTriggers[0]);
|
||||||
}
|
}
|
||||||
getLabelListFromAdapter(supportedFilter) {
|
getLabelListFromAdapter(supportedFilter) {
|
||||||
if (supportedFilter.type === 'label') {
|
if (supportedFilter.type === FilterType.LABEL && supportedFilter.values) {
|
||||||
this.supportedFilterLabels = [];
|
this.supportedFilterLabels = [];
|
||||||
supportedFilter.values.forEach( value => {
|
supportedFilter.values.forEach( value => {
|
||||||
this.supportedFilterLabels.push({
|
this.supportedFilterLabels.push({
|
||||||
@ -453,7 +453,7 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
getLabelListFromRuleInfo(ruleInfo) {
|
getLabelListFromRuleInfo(ruleInfo) {
|
||||||
let labelValueObj = ruleInfo.filters.find((currentValue) => {
|
let labelValueObj = ruleInfo.filters.find((currentValue) => {
|
||||||
return currentValue.type === 'label';
|
return currentValue.type === FilterType.LABEL;
|
||||||
});
|
});
|
||||||
if (labelValueObj) {
|
if (labelValueObj) {
|
||||||
for (const labelValue of labelValueObj.value) {
|
for (const labelValue of labelValueObj.value) {
|
||||||
@ -533,8 +533,12 @@ export class CreateEditRuleComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!findTag) {
|
if (!findTag) {
|
||||||
|
if (this.supportedFilters[i].type === FilterType.LABEL) {
|
||||||
|
filtersArray.push({ type: this.supportedFilters[i].type, value: [] });
|
||||||
|
} else {
|
||||||
filtersArray.push({ type: this.supportedFilters[i].type, value: "" });
|
filtersArray.push({ type: this.supportedFilters[i].type, value: "" });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return filtersArray;
|
return filtersArray;
|
||||||
|
@ -61,6 +61,12 @@ export const CommonRoutes = {
|
|||||||
export const enum ConfirmationState {
|
export const enum ConfirmationState {
|
||||||
NA, CONFIRMED, CANCEL
|
NA, CONFIRMED, CANCEL
|
||||||
}
|
}
|
||||||
|
export const FilterType = {
|
||||||
|
NAME: "name",
|
||||||
|
TAG: "tag",
|
||||||
|
LABEL: "label",
|
||||||
|
RESOURCE: "resource"
|
||||||
|
};
|
||||||
|
|
||||||
export const enum ConfirmationButtons {
|
export const enum ConfirmationButtons {
|
||||||
CONFIRM_CANCEL, YES_NO, DELETE_CANCEL, CLOSE, REPLICATE_CANCEL, STOP_CANCEL
|
CONFIRM_CANCEL, YES_NO, DELETE_CANCEL, CLOSE, REPLICATE_CANCEL, STOP_CANCEL
|
||||||
|
Loading…
Reference in New Issue
Block a user