mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-27 10:01:27 +01:00
Improve add scanner and add robot page (#14042)
Signed-off-by: AllForNothing <sshijun@vmware.com>
This commit is contained in:
parent
9a897af67e
commit
19a72cf350
@ -82,6 +82,16 @@ export class NewScannerModalComponent {
|
|||||||
return this.testMap[this.newScannerFormComponent.newScannerForm.get('url').value];
|
return this.testMap[this.newScannerFormComponent.newScannerForm.get('url').value];
|
||||||
}
|
}
|
||||||
get canTestEndpoint(): boolean {
|
get canTestEndpoint(): boolean {
|
||||||
|
if (this.newScannerFormComponent.newScannerForm.get('auth').value === "Basic") {
|
||||||
|
return this.newScannerFormComponent.newScannerForm.get('accessCredential').get('username').valid
|
||||||
|
&& this.newScannerFormComponent.newScannerForm.get('accessCredential').get('password').valid;
|
||||||
|
}
|
||||||
|
if (this.newScannerFormComponent.newScannerForm.get('auth').value === "Bearer") {
|
||||||
|
return this.newScannerFormComponent.newScannerForm.get('accessCredential').get('token').valid;
|
||||||
|
}
|
||||||
|
if (this.newScannerFormComponent.newScannerForm.get('auth').value === "APIKey") {
|
||||||
|
return this.newScannerFormComponent.newScannerForm.get('accessCredential').get('apiKey').valid;
|
||||||
|
}
|
||||||
return !this.onTesting
|
return !this.onTesting
|
||||||
&& this.newScannerFormComponent
|
&& this.newScannerFormComponent
|
||||||
&& !this.newScannerFormComponent.checkOnGoing
|
&& !this.newScannerFormComponent.checkOnGoing
|
||||||
|
@ -9,7 +9,7 @@ import { MessageHandlerService } from "../../../shared/message-handler/message-h
|
|||||||
import {
|
import {
|
||||||
ACTION_RESOURCE_I18N_MAP,
|
ACTION_RESOURCE_I18N_MAP,
|
||||||
ExpirationType,
|
ExpirationType,
|
||||||
FrontAccess, INITIAL_ACCESSES, PermissionsKinds
|
FrontAccess, INITIAL_ACCESSES, onlyHasPushPermission, PermissionsKinds
|
||||||
} from "../../../system-robot-accounts/system-robot-util";
|
} from "../../../system-robot-accounts/system-robot-util";
|
||||||
import { Robot } from "../../../../../ng-swagger-gen/models/robot";
|
import { Robot } from "../../../../../ng-swagger-gen/models/robot";
|
||||||
import { InlineAlertComponent } from "../../../shared/inline-alert/inline-alert.component";
|
import { InlineAlertComponent } from "../../../shared/inline-alert/inline-alert.component";
|
||||||
@ -81,7 +81,8 @@ export class AddRobotComponent implements OnInit, OnDestroy {
|
|||||||
this.isNameExisting = false;
|
this.isNameExisting = false;
|
||||||
this.checkNameOnGoing = true;
|
this.checkNameOnGoing = true;
|
||||||
return this.robotService.ListRobot({
|
return this.robotService.ListRobot({
|
||||||
q: encodeURIComponent(`Level=${PermissionsKinds.PROJECT},ProjectID=${this.projectId},name=${name}`)
|
q: encodeURIComponent(
|
||||||
|
`Level=${PermissionsKinds.PROJECT},ProjectID=${this.projectId},name=${this.projectName}+${name}`)
|
||||||
}).pipe(finalize(() => this.checkNameOnGoing = false));
|
}).pipe(finalize(() => this.checkNameOnGoing = false));
|
||||||
}))
|
}))
|
||||||
.subscribe(res => {
|
.subscribe(res => {
|
||||||
@ -205,7 +206,6 @@ export class AddRobotComponent implements OnInit, OnDestroy {
|
|||||||
return !flag;
|
return !flag;
|
||||||
}
|
}
|
||||||
save() {
|
save() {
|
||||||
this.saveBtnState = ClrLoadingState.LOADING;
|
|
||||||
const robot: Robot = clone(this.systemRobot);
|
const robot: Robot = clone(this.systemRobot);
|
||||||
robot.disable = false;
|
robot.disable = false;
|
||||||
robot.level = PermissionsKinds.PROJECT;
|
robot.level = PermissionsKinds.PROJECT;
|
||||||
@ -224,6 +224,12 @@ export class AddRobotComponent implements OnInit, OnDestroy {
|
|||||||
kind: PermissionsKinds.PROJECT,
|
kind: PermissionsKinds.PROJECT,
|
||||||
access: access
|
access: access
|
||||||
}];
|
}];
|
||||||
|
// Push permission must work with pull permission
|
||||||
|
if (onlyHasPushPermission(access)) {
|
||||||
|
this.inlineAlertComponent.showInlineError('SYSTEM_ROBOT.PUSH_PERMISSION_TOOLTIP');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.saveBtnState = ClrLoadingState.LOADING;
|
||||||
if (this.isEditMode) {
|
if (this.isEditMode) {
|
||||||
robot.disable = this.systemRobot.disable;
|
robot.disable = this.systemRobot.disable;
|
||||||
const opeMessage = new OperateInfo();
|
const opeMessage = new OperateInfo();
|
||||||
|
@ -16,7 +16,7 @@ import { Access } from "../../../../ng-swagger-gen/models/access";
|
|||||||
import {
|
import {
|
||||||
ACTION_RESOURCE_I18N_MAP, ExpirationType,
|
ACTION_RESOURCE_I18N_MAP, ExpirationType,
|
||||||
FrontAccess, INITIAL_ACCESSES,
|
FrontAccess, INITIAL_ACCESSES,
|
||||||
NAMESPACE_ALL_PROJECTS,
|
NAMESPACE_ALL_PROJECTS, onlyHasPushPermission,
|
||||||
PermissionsKinds,
|
PermissionsKinds,
|
||||||
} from "../system-robot-util";
|
} from "../system-robot-util";
|
||||||
import { clone } from "../../../lib/utils/utils";
|
import { clone } from "../../../lib/utils/utils";
|
||||||
@ -344,7 +344,6 @@ export class NewRobotComponent implements OnInit, OnDestroy {
|
|||||||
return !flag1;
|
return !flag1;
|
||||||
}
|
}
|
||||||
save() {
|
save() {
|
||||||
this.saveBtnState = ClrLoadingState.LOADING;
|
|
||||||
const robot: Robot = clone(this.systemRobot);
|
const robot: Robot = clone(this.systemRobot);
|
||||||
robot.disable = false;
|
robot.disable = false;
|
||||||
robot.level = PermissionsKinds.SYSTEM;
|
robot.level = PermissionsKinds.SYSTEM;
|
||||||
@ -383,6 +382,16 @@ export class NewRobotComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// Push permission must work with pull permission
|
||||||
|
if (robot.permissions && robot.permissions.length) {
|
||||||
|
for (let i = 0; i < robot.permissions.length; i++) {
|
||||||
|
if (onlyHasPushPermission(robot.permissions[i].access)) {
|
||||||
|
this.inlineAlertComponent.showInlineError('SYSTEM_ROBOT.PUSH_PERMISSION_TOOLTIP');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.saveBtnState = ClrLoadingState.LOADING;
|
||||||
if (this.isEditMode) {
|
if (this.isEditMode) {
|
||||||
robot.disable = this.systemRobot.disable;
|
robot.disable = this.systemRobot.disable;
|
||||||
const opeMessage = new OperateInfo();
|
const opeMessage = new OperateInfo();
|
||||||
|
@ -117,3 +117,21 @@ export enum ExpirationType {
|
|||||||
NEVER = 'never'
|
NEVER = 'never'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function onlyHasPushPermission(access: Access[]): boolean {
|
||||||
|
if (access && access.length) {
|
||||||
|
let hasPushPermission: boolean = false;
|
||||||
|
let hasPullPermission: boolean = false;
|
||||||
|
access.forEach( item => {
|
||||||
|
if (item.action === Action.PUSH && item.resource === Resource.ARTIFACT) {
|
||||||
|
hasPushPermission = true;
|
||||||
|
}
|
||||||
|
if (item.action === Action.PULL && item.resource === Resource.ARTIFACT) {
|
||||||
|
hasPullPermission = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (hasPushPermission && !hasPullPermission) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
@ -1669,6 +1669,7 @@
|
|||||||
"SEARCH_BY_NAME": "Robot-Account mittels Namen suchen (ohne Prefix)",
|
"SEARCH_BY_NAME": "Robot-Account mittels Namen suchen (ohne Prefix)",
|
||||||
"FINAL_PROJECT_NAME_TIP": "Der zusammengesetzte Robot-Account-Name besteht aus dem Prefix, dem Projektnamen, einem plus und dem Inhalt des Eingabefeldes.",
|
"FINAL_PROJECT_NAME_TIP": "Der zusammengesetzte Robot-Account-Name besteht aus dem Prefix, dem Projektnamen, einem plus und dem Inhalt des Eingabefeldes.",
|
||||||
"FINAL_SYSTEM_NAME_TIP": "Der zusammengesetzte systemweite Robot-Account-Name besteht aus dem Prefix und dem Inhalt des Eingabefeldes.",
|
"FINAL_SYSTEM_NAME_TIP": "Der zusammengesetzte systemweite Robot-Account-Name besteht aus dem Prefix und dem Inhalt des Eingabefeldes.",
|
||||||
"PUSH_AND_PULL": "Push&Pull"
|
"PUSH_AND_PULL": "Push",
|
||||||
|
"PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1669,6 +1669,7 @@
|
|||||||
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
||||||
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
||||||
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
||||||
"PUSH_AND_PULL": "Push&Pull"
|
"PUSH_AND_PULL": "Push",
|
||||||
|
"PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1667,6 +1667,7 @@
|
|||||||
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
||||||
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
||||||
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
||||||
"PUSH_AND_PULL": "Push&Pull"
|
"PUSH_AND_PULL": "Push",
|
||||||
|
"PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1637,6 +1637,7 @@
|
|||||||
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
||||||
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
||||||
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
||||||
"PUSH_AND_PULL": "Push&Pull"
|
"PUSH_AND_PULL": "Push",
|
||||||
|
"PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1665,7 +1665,8 @@
|
|||||||
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
||||||
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
||||||
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
||||||
"PUSH_AND_PULL": "Push&Pull"
|
"PUSH_AND_PULL": "Push",
|
||||||
|
"PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1669,6 +1669,7 @@
|
|||||||
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
||||||
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
||||||
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
||||||
"PUSH_AND_PULL": "Push&Pull"
|
"PUSH_AND_PULL": "Push",
|
||||||
|
"PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1666,6 +1666,7 @@
|
|||||||
"SEARCH_BY_NAME": "按名称(不含前缀)搜索",
|
"SEARCH_BY_NAME": "按名称(不含前缀)搜索",
|
||||||
"FINAL_PROJECT_NAME_TIP": "项目级机器人的最终名称由前缀,项目名称,一个加号以及当前输入值组成",
|
"FINAL_PROJECT_NAME_TIP": "项目级机器人的最终名称由前缀,项目名称,一个加号以及当前输入值组成",
|
||||||
"FINAL_SYSTEM_NAME_TIP": "系统级机器人的最终名称由前缀和当前输入值组成",
|
"FINAL_SYSTEM_NAME_TIP": "系统级机器人的最终名称由前缀和当前输入值组成",
|
||||||
"PUSH_AND_PULL": "推送&拉取"
|
"PUSH_AND_PULL": "推送",
|
||||||
|
"PUSH_PERMISSION_TOOLTIP": "推送权限无法单独工作,请在选择推送权限的时,确保已经勾选了拉取权限"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1653,6 +1653,7 @@
|
|||||||
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
"SEARCH_BY_NAME": "Search by name(without prefix)",
|
||||||
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
"FINAL_PROJECT_NAME_TIP": "The final project robot name consists of the prefix,the project name,a plus mark and the current input value",
|
||||||
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
"FINAL_SYSTEM_NAME_TIP": "The final system robot name consists of the prefix and the current input value",
|
||||||
"PUSH_AND_PULL": "Push&Pull"
|
"PUSH_AND_PULL": "Push",
|
||||||
|
"PUSH_PERMISSION_TOOLTIP": "Push permission can not work alone, it must work with pull permission"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user