Merge pull request #6195 from pureshine/labels-btn

Ordinary user login is forbidden to add labels in images.
This commit is contained in:
Mia ZHOU 2018-11-02 10:03:10 +08:00 committed by GitHub
commit a20d49359b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 3 deletions

View File

@ -49,7 +49,7 @@
</button>
<clr-dropdown>
<button type="button" class="btn btn-sm btn-secondary" clrDropdownTrigger
[disabled]="!(selectedRows.length===1)">
[disabled]="!(selectedRows.length===1 && developerRoleOrAbove)">
<clr-icon shape="plus" size="16"></clr-icon>{{'REPOSITORY.ADD_LABELS' | translate}}
</button>
<clr-dropdown-menu clrPosition="bottom-left" *clrIfOpen>

View File

@ -37,7 +37,8 @@ import {
ConfirmationTargets,
ConfirmationState,
DefaultHelmIcon,
ResourceType
ResourceType,
Roles
} from "../../shared/shared.const";
@Component({
@ -48,6 +49,7 @@ import {
})
export class ChartVersionComponent implements OnInit {
signedCon: { [key: string]: any | string[] } = {};
@Input() projectRoleID: number;
@Input() projectId: number;
@Input() projectName: string;
@Input() chartName: string;
@ -321,4 +323,8 @@ export class ChartVersionComponent implements OnInit {
setTimeout(() => clearInterval(hnd), 5000);
});
}
public get developerRoleOrAbove(): boolean {
return this.projectRoleID === Roles.DEVELOPER || this.hasProjectAdminRole;
}
}

View File

@ -60,7 +60,7 @@
<button type="button" class="btn btn-sm btn-secondary" [disabled]="!(canScanNow(selectedRow) && selectedRow.length==1)" (click)="scanNow(selectedRow)"><clr-icon shape="shield-check" size="16"></clr-icon>&nbsp;{{'VULNERABILITY.SCAN_NOW' | translate}}</button>
<button type="button" class="btn btn-sm btn-secondary" [disabled]="!(selectedRow.length==1)" (click)="showDigestId(selectedRow)" ><clr-icon shape="copy" size="16"></clr-icon>&nbsp;{{'REPOSITORY.COPY_DIGEST_ID' | translate}}</button>
<clr-dropdown *ngIf="!withAdmiral">
<button type="button" class="btn btn-sm btn-secondary" clrDropdownTrigger [disabled]="!(selectedRow.length==1) || isGuest" (click)="addLabels(selectedRow)" ><clr-icon shape="plus" size="16"></clr-icon>{{'REPOSITORY.ADD_LABELS' | translate}}</button>
<button type="button" class="btn btn-sm btn-secondary" clrDropdownTrigger [disabled]="!(selectedRow.length==1 && developerRoleOrAbove)" (click)="addLabels(selectedRow)" ><clr-icon shape="plus" size="16"></clr-icon>{{'REPOSITORY.ADD_LABELS' | translate}}</button>
<clr-dropdown-menu clrPosition="bottom-left" *clrIfOpen>
<div style='display:grid'>
<label class="dropdown-header">{{'REPOSITORY.ADD_TO_IMAGE' | translate}}</label>

View File

@ -10,6 +10,7 @@
[chartName]='chartName'
[roleName]='roleName'
[hasSignedIn]='hasSignedIn'
[projectRoleID]='project_member_role_id'
[hasProjectAdminRole]='hasProjectAdminRole'
(versionClickEvt)='onVersionClick($event)'
(backEvt)='gotoChartList()'>

View File

@ -23,6 +23,7 @@ export class ListChartVersionsComponent implements OnInit {
hasSignedIn: boolean;
hasProjectAdminRole: boolean;
currentUser: SessionUser;
project_member_role_id: number;
constructor(
private route: ActivatedRoute,
@ -41,6 +42,7 @@ export class ListChartVersionsComponent implements OnInit {
this.hasProjectAdminRole = project.has_project_admin_role;
this.roleName = project.role_name;
this.projectName = project.name;
this.project_member_role_id = project.current_user_role_id;
}
}