From af49a6999c75b4be9f905f7ff1821e742056def2 Mon Sep 17 00:00:00 2001 From: AllForNothing Date: Wed, 7 Aug 2019 15:26:20 +0800 Subject: [PATCH] fix issue and add new templats for tag-retention Signed-off-by: AllForNothing --- .../add-rule/add-rule.component.html | 6 +-- .../add-rule/add-rule.component.ts | 42 +++++++++++-------- .../tag-retention/tag-retention.service.ts | 7 +++- src/portal/src/i18n/lang/en-us-lang.json | 16 ++++--- src/portal/src/i18n/lang/es-es-lang.json | 6 ++- src/portal/src/i18n/lang/fr-fr-lang.json | 6 ++- src/portal/src/i18n/lang/pt-br-lang.json | 6 ++- src/portal/src/i18n/lang/zh-cn-lang.json | 14 ++++--- 8 files changed, 67 insertions(+), 36 deletions(-) diff --git a/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.html b/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.html index bd57b1987..397883cab 100644 --- a/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.html +++ b/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.html @@ -41,16 +41,16 @@
- {{getI18nKey(unit)|translate}} + {{getI18nKey(unit)|translate}}
- +
diff --git a/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.ts b/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.ts index 9ef601ad7..c08c71e11 100644 --- a/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.ts +++ b/src/portal/src/app/project/tag-retention/add-rule/add-rule.component.ts @@ -128,27 +128,19 @@ export class AddRuleComponent implements OnInit, OnDestroy { } canNotAdd(): boolean { - if (this.rule.template === 'always' - && this.rule.scope_selectors.repository[0].pattern - && this.rule.tag_selectors[0].pattern) { - return false; + if (!this.isAdd) { + return compareValue(this.editRuleOrigin, this.rule); } - if (this.isAdd) { - if (this.rule.template - && this.rule.params[this.template] - && this.rule.scope_selectors.repository[0].pattern - && this.rule.tag_selectors[0].pattern) { - return false; - } + if (!this.hasParam()) { + return !(this.rule.template + && this.rule.scope_selectors.repository[0].pattern + && this.rule.tag_selectors[0].pattern); } else { - if (this.rule.template - && this.rule.params[this.template] - && this.rule.scope_selectors.repository[0].pattern - && this.rule.tag_selectors[0].pattern && !compareValue(this.editRuleOrigin, this.rule)) { - return false; - } + return !(this.rule.template + && this.rule.params[this.template] + && this.rule.scope_selectors.repository[0].pattern + && this.rule.tag_selectors[0].pattern); } - return true; } open() { @@ -171,4 +163,18 @@ export class AddRuleComponent implements OnInit, OnDestroy { getI18nKey(str: string) { 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; + } } diff --git a/src/portal/src/app/project/tag-retention/tag-retention.service.ts b/src/portal/src/app/project/tag-retention/tag-retention.service.ts index 7133195b8..0792fb622 100644 --- a/src/portal/src/app/project/tag-retention/tag-retention.service.ts +++ b/src/portal/src/app/project/tag-retention/tag-retention.service.ts @@ -28,10 +28,14 @@ export class TagRetentionService { "latestPushedK": "RULE_NAME_3", "latestPulledN": "RULE_NAME_4", "always": "RULE_NAME_5", + "dayspl": "RULE_NAME_6", + "daysps": "RULE_NAME_7", "the images from the last # days": "RULE_TEMPLATE_1", "the most recent active # images": "RULE_TEMPLATE_2", "the most recently pushed # images": "RULE_TEMPLATE_3", "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", "repoExcludes": "EXC", "matches": "MAT", @@ -40,7 +44,8 @@ export class TagRetentionService { "withoutLabels": "WITHOUT", "COUNT": "UNIT_COUNT", "DAYS": "UNIT_DAY", - "none": "NONE" + "none": "NONE", + "nothing": "NONE" }; constructor( diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index d16c25246..a7149b21a 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -1123,11 +1123,11 @@ "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.", "BY_WHAT": "By image count or number of days", - "RULE_TEMPLATE_1": "the images from the last # days", - "RULE_TEMPLATE_2": "the most recent active # images", - "RULE_TEMPLATE_3": "the most recently pushed # images", - "RULE_TEMPLATE_4": "the most recently pulled # images", - "RULE_TEMPLATE_5": "always", + "RULE_TEMPLATE_1": " the images from the last # days", + "RULE_TEMPLATE_2": " the most recent active # images", + "RULE_TEMPLATE_3": " the most recently pushed # images", + "RULE_TEMPLATE_4": " the most recently pulled # images", + "RULE_TEMPLATE_5": " always", "ACTION_RETAIN": " retain", "UNIT_DAY": "DAYS", "UNIT_COUNT": "COUNT", @@ -1166,7 +1166,11 @@ "TRIGGER": "Schedule", "RETAINED": "Retained", "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" } } diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index 789e35071..347f5bbfe 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -1164,7 +1164,11 @@ "TRIGGER": "Schedule", "RETAINED": "Retained", "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" } } diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index 3a63e1124..47d94defa 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -1136,7 +1136,11 @@ "TRIGGER": "Schedule", "RETAINED": "Retained", "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" } } diff --git a/src/portal/src/i18n/lang/pt-br-lang.json b/src/portal/src/i18n/lang/pt-br-lang.json index 71c45af79..8f7118975 100644 --- a/src/portal/src/i18n/lang/pt-br-lang.json +++ b/src/portal/src/i18n/lang/pt-br-lang.json @@ -1161,7 +1161,11 @@ "TRIGGER": "Schedule", "RETAINED": "Retained", "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" } diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index 6c7d57b6c..a9e249150 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -1128,15 +1128,15 @@ "UNIT_DAY": "天数", "UNIT_COUNT": "个数", "NUMBER": "数量", - "IN_REPOSITORIES": "适用于仓库", + "IN_REPOSITORIES": "应用到仓库", "REP_SEPARATOR": "使用逗号分隔repos,repo*和**", "TAGS": "Tags", "MATCHES_TAGS": "匹配tags", - "MATCHES_EXCEPT_TAGS": "反匹配tags", + "MATCHES_EXCEPT_TAGS": "排除tags", "TAG_SEPARATOR": "使用逗号分割tags,tag*,**,or regex", "LABELS": "标签", "MATCHES_LABELS": "匹配标签", - "MATCHES_EXCEPT_LABELS": "反匹配标签", + "MATCHES_EXCEPT_LABELS": "排除标签", "REP_LABELS": "使用逗号分割标签", "RETENTION_RUN": "运行保留策略", "RETENTION_RUN_EXPLAIN": "执行保留策略将对该项目中的镜像产生反向影响,受影响的镜像tags将会被删除。您可选择取消或者使用模拟运行,或者点击运行以继续。", @@ -1151,7 +1151,7 @@ "EXCLUDES": "排除", "MATCHES": "匹配", "REPO": "仓库", - "EXC": "反匹配", + "EXC": "排除", "MAT": "匹配", "AND": "且", "WITH": "有", @@ -1162,7 +1162,11 @@ "TRIGGER": "定时执行", "RETAINED": "保留数", "TOTAL": "总数", - "NONE": "空" + "NONE": "空", + "RULE_NAME_6": "最近{{number}}天被拉取过的镜像", + "RULE_NAME_7": "最近{{number}}天被推送过的镜像", + "RULE_TEMPLATE_6": "最近#天被拉取过的镜像", + "RULE_TEMPLATE_7": "最近#天被推送过的镜像" } }