disable scan button in tag detail page if login with normal user role

Signed-off-by: Meina Zhou <meinaz@vmware.com>
This commit is contained in:
Meina Zhou 2018-10-23 14:34:00 +08:00
parent 07712d37fd
commit 7f6917a2c1
7 changed files with 17 additions and 7 deletions

View File

@ -69,7 +69,7 @@
</section>
<section class="detail-section">
<div class="vulnerability-block">
<hbr-vulnerabilities-grid [repositoryId]="repositoryId" [tagId]="tagId"></hbr-vulnerabilities-grid>
<hbr-vulnerabilities-grid [repositoryId]="repositoryId" [tagId]="tagId" [withAdminRole]="withAdminRole"></hbr-vulnerabilities-grid>
</div>
<div>
<ng-content></ng-content>

View File

@ -23,6 +23,7 @@ export class TagDetailComponent implements OnInit {
@Input() repositoryId: string;
@Input() withAdmiral: boolean;
@Input() withClair: boolean;
@Input() withAdminRole: boolean;
tagDetails: Tag = {
name: "--",
size: "--",

View File

@ -10,7 +10,7 @@
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<clr-datagrid>
<clr-dg-action-bar>
<button type="button" class="btn btn-sm btn-secondary" (click)="scanNow()"><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]="!withAdminRole" (click)="scanNow()"><clr-icon shape="shield-check" size="16"></clr-icon>&nbsp;{{'VULNERABILITY.SCAN_NOW' | translate}}</button>
</clr-dg-action-bar>
<clr-dg-column [clrDgField]="'id'">{{'VULNERABILITY.GRID.COLUMN_ID' | translate}}</clr-dg-column>
<clr-dg-column [clrDgField]="'severity'">{{'VULNERABILITY.GRID.COLUMN_SEVERITY' | translate}}</clr-dg-column>

View File

@ -20,6 +20,7 @@ export class ResultGridComponent implements OnInit {
@Input() tagId: string;
@Input() repositoryId: string;
@Input() withAdminRole: boolean;
constructor(
private scanningService: ScanningResultService,

View File

@ -57,7 +57,4 @@
background: transparent;
flex-wrap: wrap;
margin-top:-20px;
.login {
background:transparent;
}
}

View File

@ -4,5 +4,10 @@
<a (click)="goBackRep()">< {{'REPOSITORY.REPOSITORIES'| translate}}</a>
<a (click)="goBack(repositoryId)">< {{repositoryId}}</a>
</div>
<hbr-tag-detail (backEvt)="goBack($event)" [tagId]="tagId" [withClair]="withClair" [withAdmiral]="withAdmiral" [repositoryId]="repositoryId"></hbr-tag-detail>
<hbr-tag-detail (backEvt)="goBack($event)"
[tagId]="tagId"
[withClair]="withClair"
[withAdmiral]="withAdmiral"
[repositoryId]="repositoryId"
[withAdminRole]="withAdminRole"></hbr-tag-detail>
</div>

View File

@ -14,6 +14,7 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import {AppConfigService} from "../../app-config.service";
import { SessionService } from '../../shared/session.service';
@Component({
selector: 'repository',
@ -28,7 +29,8 @@ export class TagDetailPageComponent implements OnInit {
constructor(
private route: ActivatedRoute,
private appConfigService: AppConfigService,
private router: Router
private router: Router,
private session: SessionService
) {
}
@ -46,6 +48,10 @@ export class TagDetailPageComponent implements OnInit {
return this.appConfigService.getConfig().with_clair;
}
get withAdminRole(): boolean {
return this.session.getCurrentUser().has_admin_role;
}
goBack(tag: string): void {
this.router.navigate(["harbor", "projects", this.projectId, "repositories", tag]);
}