From 96f5caa63510ea337792eee185fea276968e2ffa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E4=B8=96=E5=86=9B?= <30999793+AllForNothing@users.noreply.github.com> Date: Fri, 8 Oct 2021 10:56:37 +0800 Subject: [PATCH] Add list artifact and list repo permissions to robot account (#15718) Signed-off-by: AllForNothing --- .../new-robot/new-robot.component.html | 2 +- .../new-robot/new-robot.component.scss | 5 ++- .../system-robot-accounts.component.ts | 4 +-- .../system-robot-util.ts | 31 ++++++++++++++----- src/portal/src/i18n/lang/de-de-lang.json | 4 ++- src/portal/src/i18n/lang/en-us-lang.json | 4 ++- src/portal/src/i18n/lang/es-es-lang.json | 4 ++- src/portal/src/i18n/lang/fr-fr-lang.json | 4 ++- src/portal/src/i18n/lang/pt-br-lang.json | 4 ++- src/portal/src/i18n/lang/tr-tr-lang.json | 4 ++- src/portal/src/i18n/lang/zh-cn-lang.json | 4 ++- src/portal/src/i18n/lang/zh-tw-lang.json | 4 ++- 12 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/portal/src/app/base/left-side-nav/system-robot-accounts/new-robot/new-robot.component.html b/src/portal/src/app/base/left-side-nav/system-robot-accounts/new-robot/new-robot.component.html index 867e61018..9279f0cca 100644 --- a/src/portal/src/app/base/left-side-nav/system-robot-accounts/new-robot/new-robot.component.html +++ b/src/portal/src/app/base/left-side-nav/system-robot-accounts/new-robot/new-robot.component.html @@ -114,7 +114,7 @@ {{getPermissions()}} {{"SYSTEM_ROBOT.PERMISSIONS" | translate}} - +
{{i18nMap[item.action] | translate}} {{i18nMap[item.resource] | translate}} diff --git a/src/portal/src/app/base/left-side-nav/system-robot-accounts/new-robot/new-robot.component.scss b/src/portal/src/app/base/left-side-nav/system-robot-accounts/new-robot/new-robot.component.scss index a001efbef..1f8222acb 100644 --- a/src/portal/src/app/base/left-side-nav/system-robot-accounts/new-robot/new-robot.component.scss +++ b/src/portal/src/app/base/left-side-nav/system-robot-accounts/new-robot/new-robot.component.scss @@ -76,4 +76,7 @@ min-height: 20px; display: flex; align-items: center; -} \ No newline at end of file +} +.dropdown-menu { + overflow-y: auto; +} diff --git a/src/portal/src/app/base/left-side-nav/system-robot-accounts/system-robot-accounts.component.ts b/src/portal/src/app/base/left-side-nav/system-robot-accounts/system-robot-accounts.component.ts index df6fc2865..88a539a3c 100644 --- a/src/portal/src/app/base/left-side-nav/system-robot-accounts/system-robot-accounts.component.ts +++ b/src/portal/src/app/base/left-side-nav/system-robot-accounts/system-robot-accounts.component.ts @@ -88,7 +88,7 @@ export class SystemRobotAccountsComponent implements OnInit, OnDestroy { })); })).subscribe(response => { this.total = Number.parseInt( - response.headers.get('x-total-count') + response.headers.get('x-total-count'), 10 ); this.robots = response.body as Robot[]; this.calculateProjects(); @@ -199,7 +199,7 @@ export class SystemRobotAccountsComponent implements OnInit, OnDestroy { .subscribe( response => { this.total = Number.parseInt( - response.headers.get('x-total-count') + response.headers.get('x-total-count'), 10 ); this.robots = response.body as Robot[]; this.calculateProjects(); diff --git a/src/portal/src/app/base/left-side-nav/system-robot-accounts/system-robot-util.ts b/src/portal/src/app/base/left-side-nav/system-robot-accounts/system-robot-util.ts index d950e7b9b..405442c63 100644 --- a/src/portal/src/app/base/left-side-nav/system-robot-accounts/system-robot-util.ts +++ b/src/portal/src/app/base/left-side-nav/system-robot-accounts/system-robot-util.ts @@ -28,16 +28,20 @@ export enum PermissionsKinds { } export enum Resource { - ARTIFACT = 'repository', + REPO = 'repository', HELM_CHART = 'helm-chart', - HELM_CHART_VERSION = 'helm-chart-version' + HELM_CHART_VERSION = 'helm-chart-version', + ARTIFACT = 'artifact' } export enum Action { PUSH = 'push', PULL = 'pull', READ = 'read', - CREATE = 'create' + CREATE = 'create', + LIST = 'list', + STOP = 'stop', + DELETE = 'delete' } export const NAMESPACE_ALL_PROJECTS: string = '*'; @@ -97,7 +101,17 @@ export const INITIAL_ACCESSES: FrontAccess[] = [ "resource": "scan", "action": "stop", "checked": true - } + }, + { + "resource": "artifact", + "action": "list", + "checked": true + }, + { + "resource": "repository", + "action": "list", + "checked": true + }, ]; export const ACTION_RESOURCE_I18N_MAP = { @@ -106,7 +120,7 @@ export const ACTION_RESOURCE_I18N_MAP = { 'read': 'SYSTEM_ROBOT.READ', 'create': 'SYSTEM_ROBOT.CREATE', 'delete': 'SYSTEM_ROBOT.DELETE', - 'repository': 'SYSTEM_ROBOT.ARTIFACT', + 'repository': 'SYSTEM_ROBOT.REPOSITORY', 'artifact': 'SYSTEM_ROBOT.ARTIFACT', 'helm-chart': 'SYSTEM_ROBOT.HELM', 'helm-chart-version': 'SYSTEM_ROBOT.HELM_VERSION', @@ -114,7 +128,8 @@ export const ACTION_RESOURCE_I18N_MAP = { 'artifact-label': 'SYSTEM_ROBOT.ARTIFACT_LABEL', 'scan': 'SYSTEM_ROBOT.SCAN', 'scanner-pull': 'SYSTEM_ROBOT.SCANNER_PULL', - 'stop': 'SYSTEM_ROBOT.STOP' + 'stop': 'SYSTEM_ROBOT.STOP', + 'list': 'SYSTEM_ROBOT.LIST' }; export enum ExpirationType { @@ -128,10 +143,10 @@ export function onlyHasPushPermission(access: Access[]): boolean { let hasPushPermission: boolean = false; let hasPullPermission: boolean = false; access.forEach( item => { - if (item.action === Action.PUSH && item.resource === Resource.ARTIFACT) { + if (item.action === Action.PUSH && item.resource === Resource.REPO) { hasPushPermission = true; } - if (item.action === Action.PULL && item.resource === Resource.ARTIFACT) { + if (item.action === Action.PULL && item.resource === Resource.REPO) { hasPullPermission = true; } }); diff --git a/src/portal/src/i18n/lang/de-de-lang.json b/src/portal/src/i18n/lang/de-de-lang.json index 730df9572..3bbc79f42 100644 --- a/src/portal/src/i18n/lang/de-de-lang.json +++ b/src/portal/src/i18n/lang/de-de-lang.json @@ -1702,6 +1702,8 @@ "FINAL_SYSTEM_NAME_TIP": "Der zusammengesetzte systemweite Robot-Account-Name besteht aus dem Prefix und dem Inhalt des Eingabefeldes.", "PUSH_AND_PULL": "Push", "PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission", - "STOP": "Stop" + "STOP": "Stop", + "LIST": "List", + "REPOSITORY": "Repository" } } diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index 4891191ac..c61441a75 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -1702,6 +1702,8 @@ "FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value", "PUSH_AND_PULL": "Push", "PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission", - "STOP": "Stop" + "STOP": "Stop", + "LIST": "List", + "REPOSITORY": "Repository" } } diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index c36f4b823..4dfca66bd 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -1701,6 +1701,8 @@ "FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value", "PUSH_AND_PULL": "Push", "PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission", - "STOP": "Stop" + "STOP": "Stop", + "LIST": "List", + "REPOSITORY": "Repository" } } diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index f64fd91b0..6a56edf0a 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -1670,6 +1670,8 @@ "FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value", "PUSH_AND_PULL": "Push", "PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission", - "STOP": "Stop" + "STOP": "Stop", + "LIST": "List", + "REPOSITORY": "Repository" } } diff --git a/src/portal/src/i18n/lang/pt-br-lang.json b/src/portal/src/i18n/lang/pt-br-lang.json index 061e461b6..76d037ec5 100644 --- a/src/portal/src/i18n/lang/pt-br-lang.json +++ b/src/portal/src/i18n/lang/pt-br-lang.json @@ -1698,7 +1698,9 @@ "FINAL_SYSTEM_NAME_TIP": "Este valor será concatenado ao prefixo do projeto.", "PUSH_AND_PULL": "Push", "PUSH_PERMISSION_TOOLTIP": "Permissões de envio (push) presume também a permissão e recebimento (pull).", - "STOP": "Stop" + "STOP": "Stop", + "LIST": "List", + "REPOSITORY": "Repository" } } diff --git a/src/portal/src/i18n/lang/tr-tr-lang.json b/src/portal/src/i18n/lang/tr-tr-lang.json index 4a93fc6e3..ac09b389c 100644 --- a/src/portal/src/i18n/lang/tr-tr-lang.json +++ b/src/portal/src/i18n/lang/tr-tr-lang.json @@ -1702,6 +1702,8 @@ "FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value", "PUSH_AND_PULL": "Push", "PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission", - "STOP": "Stop" + "STOP": "Stop", + "LIST": "List", + "REPOSITORY": "Repository" } } diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index c3b19b2de..20bb0ca46 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -1700,6 +1700,8 @@ "FINAL_SYSTEM_NAME_TIP": "系统级机器人的最终名称由前缀和当前输入值组成", "PUSH_AND_PULL": "推送", "PUSH_PERMISSION_TOOLTIP": "推送权限无法单独工作,请在选择推送权限的时,确保已经勾选了拉取权限", - "STOP": "停止" + "STOP": "停止", + "LIST": "查询", + "REPOSITORY": "仓库" } } diff --git a/src/portal/src/i18n/lang/zh-tw-lang.json b/src/portal/src/i18n/lang/zh-tw-lang.json index 7a59ded66..5308aa1cb 100644 --- a/src/portal/src/i18n/lang/zh-tw-lang.json +++ b/src/portal/src/i18n/lang/zh-tw-lang.json @@ -1687,6 +1687,8 @@ "FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value", "PUSH_AND_PULL": "Push", "PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission", - "STOP": "Stop" + "STOP": "Stop", + "LIST": "List", + "REPOSITORY": "Repository" } }