Merge pull request #8591 from AllForNothing/translate

fix issue and add new templats for tag-retention
This commit is contained in:
Will Sun 2019-08-08 09:59:58 +08:00 committed by GitHub
commit b364ad89ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 67 additions and 36 deletions

View File

@ -41,16 +41,16 @@
<div class="clr-select-wrapper w-100"> <div class="clr-select-wrapper w-100">
<select [(ngModel)]="template" class="clr-select w-100"> <select [(ngModel)]="template" class="clr-select w-100">
<option *ngFor="let t of metadata?.templates" <option *ngFor="let t of metadata?.templates"
value="{{t?.rule_template}}">{{getI18nKey(t?.display_text)|translate}}</option> value="{{t?.rule_template}}">{{getI18nKey(t?.action)|translate}}{{getI18nKey(t?.display_text)|translate}}</option>
</select> </select>
</div> </div>
</div> </div>
<div class="clr-col-3"> <div class="clr-col-3">
<div class="over-line"> <div class="over-line">
<span *ngIf="template !=='always' && template !=='none'">{{getI18nKey(unit)|translate}}</span> <span *ngIf="hasParam()">{{getI18nKey(unit)|translate}}</span>
</div> </div>
<div class="w-100 disabled"> <div class="w-100 disabled">
<input *ngIf="template !=='always'&& template !=='none'" [(ngModel)]="num" class="clr-input w-100"> <input *ngIf="hasParam()" [(ngModel)]="num" class="clr-input w-100">
</div> </div>
</div> </div>
</div> </div>

View File

@ -128,28 +128,20 @@ export class AddRuleComponent implements OnInit, OnDestroy {
} }
canNotAdd(): boolean { canNotAdd(): boolean {
if (this.rule.template === 'always' if (!this.isAdd) {
&& this.rule.scope_selectors.repository[0].pattern return compareValue(this.editRuleOrigin, this.rule);
&& this.rule.tag_selectors[0].pattern) {
return false;
} }
if (this.isAdd) { if (!this.hasParam()) {
if (this.rule.template return !(this.rule.template
&& this.rule.params[this.template]
&& this.rule.scope_selectors.repository[0].pattern && this.rule.scope_selectors.repository[0].pattern
&& this.rule.tag_selectors[0].pattern) { && this.rule.tag_selectors[0].pattern);
return false;
}
} else { } else {
if (this.rule.template return !(this.rule.template
&& this.rule.params[this.template] && this.rule.params[this.template]
&& this.rule.scope_selectors.repository[0].pattern && this.rule.scope_selectors.repository[0].pattern
&& this.rule.tag_selectors[0].pattern && !compareValue(this.editRuleOrigin, this.rule)) { && this.rule.tag_selectors[0].pattern);
return false;
} }
} }
return true;
}
open() { open() {
this.addRuleOpened = true; this.addRuleOpened = true;
@ -171,4 +163,18 @@ export class AddRuleComponent implements OnInit, OnDestroy {
getI18nKey(str: string) { getI18nKey(str: string) {
return this.tagRetentionService.getI18nKey(str); return this.tagRetentionService.getI18nKey(str);
} }
hasParam(): boolean {
if (this.metadata && this.metadata.templates) {
let flag: boolean = false;
this.metadata.templates.forEach(t => {
if (t.rule_template === this.template) {
if ( t.params && t.params.length > 0) {
flag = true;
}
}
});
return flag;
}
return false;
}
} }

View File

@ -28,10 +28,14 @@ export class TagRetentionService {
"latestPushedK": "RULE_NAME_3", "latestPushedK": "RULE_NAME_3",
"latestPulledN": "RULE_NAME_4", "latestPulledN": "RULE_NAME_4",
"always": "RULE_NAME_5", "always": "RULE_NAME_5",
"dayspl": "RULE_NAME_6",
"daysps": "RULE_NAME_7",
"the images from the last # days": "RULE_TEMPLATE_1", "the images from the last # days": "RULE_TEMPLATE_1",
"the most recent active # images": "RULE_TEMPLATE_2", "the most recent active # images": "RULE_TEMPLATE_2",
"the most recently pushed # images": "RULE_TEMPLATE_3", "the most recently pushed # images": "RULE_TEMPLATE_3",
"the most recently pulled # images": "RULE_TEMPLATE_4", "the most recently pulled # images": "RULE_TEMPLATE_4",
"pulled within the last # days": "RULE_TEMPLATE_6",
"pushed within the last # days": "RULE_TEMPLATE_7",
"repoMatches": "MAT", "repoMatches": "MAT",
"repoExcludes": "EXC", "repoExcludes": "EXC",
"matches": "MAT", "matches": "MAT",
@ -40,7 +44,8 @@ export class TagRetentionService {
"withoutLabels": "WITHOUT", "withoutLabels": "WITHOUT",
"COUNT": "UNIT_COUNT", "COUNT": "UNIT_COUNT",
"DAYS": "UNIT_DAY", "DAYS": "UNIT_DAY",
"none": "NONE" "none": "NONE",
"nothing": "NONE"
}; };
constructor( constructor(

View File

@ -1123,11 +1123,11 @@
"ADD_TITLE": "Add Tag Retention Rule", "ADD_TITLE": "Add Tag Retention Rule",
"ADD_SUBTITLE": "Specify a tag retention rule for this project. All tag retention rules are independently calculated and each rule can be applied to a selected list of repositories.", "ADD_SUBTITLE": "Specify a tag retention rule for this project. All tag retention rules are independently calculated and each rule can be applied to a selected list of repositories.",
"BY_WHAT": "By image count or number of days", "BY_WHAT": "By image count or number of days",
"RULE_TEMPLATE_1": "the images from the last # days", "RULE_TEMPLATE_1": " the images from the last # days",
"RULE_TEMPLATE_2": "the most recent active # images", "RULE_TEMPLATE_2": " the most recent active # images",
"RULE_TEMPLATE_3": "the most recently pushed # images", "RULE_TEMPLATE_3": " the most recently pushed # images",
"RULE_TEMPLATE_4": "the most recently pulled # images", "RULE_TEMPLATE_4": " the most recently pulled # images",
"RULE_TEMPLATE_5": "always", "RULE_TEMPLATE_5": " always",
"ACTION_RETAIN": " retain", "ACTION_RETAIN": " retain",
"UNIT_DAY": "DAYS", "UNIT_DAY": "DAYS",
"UNIT_COUNT": "COUNT", "UNIT_COUNT": "COUNT",
@ -1166,7 +1166,11 @@
"TRIGGER": "Schedule", "TRIGGER": "Schedule",
"RETAINED": "Retained", "RETAINED": "Retained",
"TOTAL": "Total", "TOTAL": "Total",
"NONE": "none" "NONE": " none",
"RULE_NAME_6": " the images pulled within the last {{number}} days",
"RULE_NAME_7": " the images pushed within the last {{number}} days",
"RULE_TEMPLATE_6": " the images pulled within the last # days",
"RULE_TEMPLATE_7": " the images pushed within the last # days"
} }
} }

View File

@ -1164,7 +1164,11 @@
"TRIGGER": "Schedule", "TRIGGER": "Schedule",
"RETAINED": "Retained", "RETAINED": "Retained",
"TOTAL": "Total", "TOTAL": "Total",
"NONE": "none" "NONE": "none",
"RULE_NAME_6": " the images pulled within the last {{number}} days",
"RULE_NAME_7": " the images pushed within the last {{number}} days",
"RULE_TEMPLATE_6": " the images pulled within the last # days",
"RULE_TEMPLATE_7": " the images pushed within the last # days"
} }
} }

View File

@ -1136,7 +1136,11 @@
"TRIGGER": "Schedule", "TRIGGER": "Schedule",
"RETAINED": "Retained", "RETAINED": "Retained",
"TOTAL": "Total", "TOTAL": "Total",
"NONE": "none" "NONE": "none",
"RULE_NAME_6": " the images pulled within the last {{number}} days",
"RULE_NAME_7": " the images pushed within the last {{number}} days",
"RULE_TEMPLATE_6": " the images pulled within the last # days",
"RULE_TEMPLATE_7": " the images pushed within the last # days"
} }
} }

View File

@ -1161,7 +1161,11 @@
"TRIGGER": "Schedule", "TRIGGER": "Schedule",
"RETAINED": "Retained", "RETAINED": "Retained",
"TOTAL": "Total", "TOTAL": "Total",
"NONE": "none" "NONE": "none",
"RULE_NAME_6": " the images pulled within the last {{number}} days",
"RULE_NAME_7": " the images pushed within the last {{number}} days",
"RULE_TEMPLATE_6": " the images pulled within the last # days",
"RULE_TEMPLATE_7": " the images pushed within the last # days"
} }

View File

@ -1128,15 +1128,15 @@
"UNIT_DAY": "天数", "UNIT_DAY": "天数",
"UNIT_COUNT": "个数", "UNIT_COUNT": "个数",
"NUMBER": "数量", "NUMBER": "数量",
"IN_REPOSITORIES": "适用于仓库", "IN_REPOSITORIES": "应用到仓库",
"REP_SEPARATOR": "使用逗号分隔repos,repo*和**", "REP_SEPARATOR": "使用逗号分隔repos,repo*和**",
"TAGS": "Tags", "TAGS": "Tags",
"MATCHES_TAGS": "匹配tags", "MATCHES_TAGS": "匹配tags",
"MATCHES_EXCEPT_TAGS": "反匹配tags", "MATCHES_EXCEPT_TAGS": "排除tags",
"TAG_SEPARATOR": "使用逗号分割tags,tag*,**,or regex", "TAG_SEPARATOR": "使用逗号分割tags,tag*,**,or regex",
"LABELS": "标签", "LABELS": "标签",
"MATCHES_LABELS": "匹配标签", "MATCHES_LABELS": "匹配标签",
"MATCHES_EXCEPT_LABELS": "反匹配标签", "MATCHES_EXCEPT_LABELS": "排除标签",
"REP_LABELS": "使用逗号分割标签", "REP_LABELS": "使用逗号分割标签",
"RETENTION_RUN": "运行保留策略", "RETENTION_RUN": "运行保留策略",
"RETENTION_RUN_EXPLAIN": "执行保留策略将对该项目中的镜像产生反向影响受影响的镜像tags将会被删除。您可选择取消或者使用模拟运行或者点击运行以继续。", "RETENTION_RUN_EXPLAIN": "执行保留策略将对该项目中的镜像产生反向影响受影响的镜像tags将会被删除。您可选择取消或者使用模拟运行或者点击运行以继续。",
@ -1151,7 +1151,7 @@
"EXCLUDES": "排除", "EXCLUDES": "排除",
"MATCHES": "匹配", "MATCHES": "匹配",
"REPO": "仓库", "REPO": "仓库",
"EXC": "反匹配", "EXC": "排除",
"MAT": "匹配", "MAT": "匹配",
"AND": "且", "AND": "且",
"WITH": "有", "WITH": "有",
@ -1162,7 +1162,11 @@
"TRIGGER": "定时执行", "TRIGGER": "定时执行",
"RETAINED": "保留数", "RETAINED": "保留数",
"TOTAL": "总数", "TOTAL": "总数",
"NONE": "空" "NONE": "空",
"RULE_NAME_6": "最近{{number}}天被拉取过的镜像",
"RULE_NAME_7": "最近{{number}}天被推送过的镜像",
"RULE_TEMPLATE_6": "最近#天被拉取过的镜像",
"RULE_TEMPLATE_7": "最近#天被推送过的镜像"
} }
} }