Merge pull request #6069 from pureshine/scan_btn

Disable scan button when vulnerability data is not ready.
This commit is contained in:
Fangyuan Cheng 2018-10-18 09:32:32 +08:00 committed by GitHub
commit 7851404d0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -40,7 +40,7 @@
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12"> <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<clr-datagrid [clrDgLoading]="loading" [class.embeded-datagrid]="isEmbedded" [(clrDgSelected)]="selectedRow"> <clr-datagrid [clrDgLoading]="loading" [class.embeded-datagrid]="isEmbedded" [(clrDgSelected)]="selectedRow">
<clr-dg-action-bar> <clr-dg-action-bar>
<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]="!(canScanNow(selectedRow) && selectedRow.length==1) || !isClairDBFullyReady" (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> <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"> <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) || isGuest" (click)="addLabels(selectedRow)" ><clr-icon shape="plus" size="16"></clr-icon>{{'REPOSITORY.ADD_LABELS' | translate}}</button>

View File

@ -56,6 +56,7 @@ import {CopyInputComponent} from "../push-image/copy-input.component";
import {LabelService} from "../service/label.service"; import {LabelService} from "../service/label.service";
import {operateChanges, OperateInfo, OperationState} from "../operation/operate"; import {operateChanges, OperateInfo, OperationState} from "../operation/operate";
import {OperationService} from "../operation/operation.service"; import {OperationService} from "../operation/operation.service";
import {SystemInfo} from "../service/index";
export interface LabelState { export interface LabelState {
iconsShow: boolean; iconsShow: boolean;
@ -124,6 +125,7 @@ export class TagComponent implements OnInit, AfterViewInit {
project_id: 0, project_id: 0,
}; };
filterOneLabel: Label = this.initFilter; filterOneLabel: Label = this.initFilter;
systemInfo: SystemInfo;
@ViewChild('confirmationDialog') @ViewChild('confirmationDialog')
@ -213,6 +215,12 @@ export class TagComponent implements OnInit, AfterViewInit {
return len > 210 ? 210 : len; return len > 210 ? 210 : len;
} }
get isClairDBFullyReady(): boolean {
return this.systemInfo &&
this.systemInfo.clair_vulnerability_status &&
this.systemInfo.clair_vulnerability_status.overall_last_update > 0;
}
doSearchTagNames(tagName: string) { doSearchTagNames(tagName: string) {
this.lastFilteredTagName = tagName; this.lastFilteredTagName = tagName;
this.currentPage = 1; this.currentPage = 1;