From 0275108cb21bab4d238d1c235cd99be417ad33e6 Mon Sep 17 00:00:00 2001 From: AllForNothing Date: Mon, 30 Mar 2020 17:22:28 +0800 Subject: [PATCH] Fix bugs for round 1 testing Signed-off-by: AllForNothing --- .../artifact-list-tab.component.html | 2 +- .../artifact-list-tab.component.scss | 3 ++ .../artifact-vulnerabilities.component.ts | 4 +++ .../result-grid.component.ts | 4 +++ .../result-tip-histogram.component.ts | 5 +-- .../project/webhook/webhook.component.html | 2 +- .../project/webhook/webhook.component.scss | 3 ++ .../app/project/webhook/webhook.component.ts | 3 ++ src/portal/src/i18n/lang/en-us-lang.json | 3 +- src/portal/src/i18n/lang/es-es-lang.json | 3 +- src/portal/src/i18n/lang/fr-fr-lang.json | 3 +- src/portal/src/i18n/lang/pt-br-lang.json | 3 +- src/portal/src/i18n/lang/tr-tr-lang.json | 3 +- src/portal/src/i18n/lang/zh-cn-lang.json | 3 +- .../project-quotas.component.html | 26 +++++++++----- .../project-quotas.component.scss | 13 ++++--- .../project-quotas.component.spec.ts | 3 +- .../project-quotas.component.ts | 34 +++++++++++-------- .../vulnerability-config.component.spec.ts | 19 ++++++++++- .../vulnerability-config.component.ts | 9 +++-- 20 files changed, 105 insertions(+), 43 deletions(-) diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.html b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.html index 19cf8a819..f72e683d1 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.html +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.html @@ -101,7 +101,7 @@ -
{{'REPOSITORY.COPY_DIGEST_ID' | translate}}
diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.scss b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.scss index ce0fdda70..ce56be263 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.scss +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.scss @@ -415,4 +415,7 @@ clr-datagrid { } } +} +.no-border:focus { + outline: none; } \ No newline at end of file diff --git a/src/portal/src/app/project/repository/artifact/artifact-additions/artifact-vulnerabilities/artifact-vulnerabilities.component.ts b/src/portal/src/app/project/repository/artifact/artifact-additions/artifact-vulnerabilities/artifact-vulnerabilities.component.ts index 2283e698c..a4eeb16c1 100644 --- a/src/portal/src/app/project/repository/artifact/artifact-additions/artifact-vulnerabilities/artifact-vulnerabilities.component.ts +++ b/src/portal/src/app/project/repository/artifact/artifact-additions/artifact-vulnerabilities/artifact-vulnerabilities.component.ts @@ -100,6 +100,10 @@ export class ArtifactVulnerabilitiesComponent implements OnInit, OnDestroy { this.scan_overview = res; if (this.scan_overview && this.scan_overview[DEFAULT_SUPPORTED_MIME_TYPE]) { this.scanningResults = this.scan_overview[DEFAULT_SUPPORTED_MIME_TYPE].vulnerabilities; + // sort + if (this.scanningResults) { + this.scanningResults.sort(((a, b) => this.getLevel(b) - this.getLevel(a))); + } this.scanner = this.scan_overview[DEFAULT_SUPPORTED_MIME_TYPE].scanner; } }, error => { diff --git a/src/portal/src/app/project/repository/vulnerability-scanning/result-grid.component.ts b/src/portal/src/app/project/repository/vulnerability-scanning/result-grid.component.ts index 106531f4f..54335b2d6 100644 --- a/src/portal/src/app/project/repository/vulnerability-scanning/result-grid.component.ts +++ b/src/portal/src/app/project/repository/vulnerability-scanning/result-grid.component.ts @@ -96,6 +96,10 @@ export class ResultGridComponent implements OnInit, OnDestroy { if (report.vulnerabilities) { this.dataCache = report.vulnerabilities; this.scanningResults = this.dataCache.filter((item: VulnerabilityItem) => item.id !== ''); + // sort + if (this.scanningResults) { + this.scanningResults.sort(((a, b) => this.getLevel(b) - this.getLevel(a))); + } return; } } diff --git a/src/portal/src/app/project/repository/vulnerability-scanning/result-tip-histogram/result-tip-histogram.component.ts b/src/portal/src/app/project/repository/vulnerability-scanning/result-tip-histogram/result-tip-histogram.component.ts index 01d9c2f67..ea2c6afc1 100644 --- a/src/portal/src/app/project/repository/vulnerability-scanning/result-tip-histogram/result-tip-histogram.component.ts +++ b/src/portal/src/app/project/repository/vulnerability-scanning/result-tip-histogram/result-tip-histogram.component.ts @@ -65,8 +65,9 @@ export class ResultTipHistogramComponent implements OnInit { } get total(): number { - if (this.vulnerabilitySummary && - this.vulnerabilitySummary.summary) { + if (this.vulnerabilitySummary + && this.vulnerabilitySummary.summary + && this.vulnerabilitySummary.summary.total) { return this.vulnerabilitySummary.summary.total; } return 0; diff --git a/src/portal/src/app/project/webhook/webhook.component.html b/src/portal/src/app/project/webhook/webhook.component.html index 77cbeb378..9a7c50da2 100644 --- a/src/portal/src/app/project/webhook/webhook.component.html +++ b/src/portal/src/app/project/webhook/webhook.component.html @@ -48,7 +48,7 @@ {{'WEBHOOK.NAME' | translate}} {{'WEBHOOK.NOTIFY_TYPE' | translate}} - {{'WEBHOOK.TARGET' | translate}} + {{'WEBHOOK.TARGET' | translate}} {{'WEBHOOK.ENABLED' | translate}} {{'WEBHOOK.EVENT_TYPES' | translate}} {{'WEBHOOK.CREATED' | translate}} diff --git a/src/portal/src/app/project/webhook/webhook.component.scss b/src/portal/src/app/project/webhook/webhook.component.scss index c1dc83ec2..ea270b6ae 100644 --- a/src/portal/src/app/project/webhook/webhook.component.scss +++ b/src/portal/src/app/project/webhook/webhook.component.scss @@ -54,4 +54,7 @@ display: flex; justify-content: flex-end; align-items: center; +} +.width-340 { + min-width: 340px!important; } \ No newline at end of file diff --git a/src/portal/src/app/project/webhook/webhook.component.ts b/src/portal/src/app/project/webhook/webhook.component.ts index 3fb067a9d..91f176ad3 100644 --- a/src/portal/src/app/project/webhook/webhook.component.ts +++ b/src/portal/src/app/project/webhook/webhook.component.ts @@ -82,6 +82,9 @@ export class WebhookComponent implements OnInit { .subscribe( response => { this.metadata = response; + if (this.metadata && this.metadata.event_type) { + this.metadata.event_type.sort(); + } }, error => { this.messageHandlerService.handleError(error); diff --git a/src/portal/src/i18n/lang/en-us-lang.json b/src/portal/src/i18n/lang/en-us-lang.json index a8b260097..dc74afe4d 100644 --- a/src/portal/src/i18n/lang/en-us-lang.json +++ b/src/portal/src/i18n/lang/en-us-lang.json @@ -1405,7 +1405,8 @@ "VIEW_DOC": "view documentation", "ALL_SCANNERS": "All scanners", "HELP_INFO_1": "The default scanner has been installed. To install other scanners refer to the ", - "HELP_INFO_2": "documentation." + "HELP_INFO_2": "documentation.", + "NO_DEFAULT_SCANNER": "No default scanner" } } diff --git a/src/portal/src/i18n/lang/es-es-lang.json b/src/portal/src/i18n/lang/es-es-lang.json index 3686fd91a..9341a367e 100644 --- a/src/portal/src/i18n/lang/es-es-lang.json +++ b/src/portal/src/i18n/lang/es-es-lang.json @@ -1402,6 +1402,7 @@ "VIEW_DOC": "view documentation", "ALL_SCANNERS": "All scanners", "HELP_INFO_1": "The default scanner has been installed. To install other scanners refer to the ", - "HELP_INFO_2": "documentation." + "HELP_INFO_2": "documentation.", + "NO_DEFAULT_SCANNER": "No default scanner" } } diff --git a/src/portal/src/i18n/lang/fr-fr-lang.json b/src/portal/src/i18n/lang/fr-fr-lang.json index 8bdee8662..e6295d17b 100644 --- a/src/portal/src/i18n/lang/fr-fr-lang.json +++ b/src/portal/src/i18n/lang/fr-fr-lang.json @@ -1372,6 +1372,7 @@ "VIEW_DOC": "view documentation", "ALL_SCANNERS": "All scanners", "HELP_INFO_1": "The default scanner has been installed. To install other scanners refer to the ", - "HELP_INFO_2": "documentation." + "HELP_INFO_2": "documentation.", + "NO_DEFAULT_SCANNER": "No default scanner" } } \ No newline at end of file diff --git a/src/portal/src/i18n/lang/pt-br-lang.json b/src/portal/src/i18n/lang/pt-br-lang.json index e455dc54d..7b11e2969 100644 --- a/src/portal/src/i18n/lang/pt-br-lang.json +++ b/src/portal/src/i18n/lang/pt-br-lang.json @@ -1400,7 +1400,8 @@ "VIEW_DOC": "view documentation", "ALL_SCANNERS": "All scanners", "HELP_INFO_1": "The default scanner has been installed. To install other scanners refer to the ", - "HELP_INFO_2": "documentation." + "HELP_INFO_2": "documentation.", + "NO_DEFAULT_SCANNER": "No default scanner" } } diff --git a/src/portal/src/i18n/lang/tr-tr-lang.json b/src/portal/src/i18n/lang/tr-tr-lang.json index ab593e220..0854eb291 100644 --- a/src/portal/src/i18n/lang/tr-tr-lang.json +++ b/src/portal/src/i18n/lang/tr-tr-lang.json @@ -1405,6 +1405,7 @@ "VIEW_DOC": "view documentation", "ALL_SCANNERS": "All scanners", "HELP_INFO_1": "The default scanner has been installed. To install other scanners refer to the ", - "HELP_INFO_2": "documentation." + "HELP_INFO_2": "documentation.", + "NO_DEFAULT_SCANNER": "No default scanner" } } diff --git a/src/portal/src/i18n/lang/zh-cn-lang.json b/src/portal/src/i18n/lang/zh-cn-lang.json index 81e2d511b..10740ad01 100644 --- a/src/portal/src/i18n/lang/zh-cn-lang.json +++ b/src/portal/src/i18n/lang/zh-cn-lang.json @@ -1400,6 +1400,7 @@ "VIEW_DOC": "查看文档", "ALL_SCANNERS": "全部扫描器", "HELP_INFO_1": "默认扫描器已安装。获取扫描器安装帮助,请查看", - "HELP_INFO_2": "文档。" + "HELP_INFO_2": "文档。", + "NO_DEFAULT_SCANNER": "未配置默认扫描器" } } diff --git a/src/portal/src/lib/components/config/project-quotas/project-quotas.component.html b/src/portal/src/lib/components/config/project-quotas/project-quotas.component.html index aa036572f..df3189ee9 100644 --- a/src/portal/src/lib/components/config/project-quotas/project-quotas.component.html +++ b/src/portal/src/lib/components/config/project-quotas/project-quotas.component.html @@ -16,23 +16,31 @@ -
- - - -
- + + +
+
+ +
+
+
+ + + +
+
+
+
{{'QUOTA.PROJECT' | translate}} {{'QUOTA.OWNER' | translate}} {{'QUOTA.COUNT' | translate }} {{'QUOTA.STORAGE' | translate }} {{'QUOTA.PLACEHOLDER' | translate }} - - - {{quota?.ref?.name}} {{quota?.ref?.owner_name}} diff --git a/src/portal/src/lib/components/config/project-quotas/project-quotas.component.scss b/src/portal/src/lib/components/config/project-quotas/project-quotas.component.scss index 03665d7f8..bf874283f 100644 --- a/src/portal/src/lib/components/config/project-quotas/project-quotas.component.scss +++ b/src/portal/src/lib/components/config/project-quotas/project-quotas.component.scss @@ -51,11 +51,6 @@ margin-bottom: .35rem; } -.refresh-div { - margin-top: auto; - cursor: pointer; -} - ::ng-deep { .progress { &.warning>progress { @@ -74,3 +69,11 @@ } } } + +.action-head-pos { + padding-right: 18px; + height: 100%; + display: flex; + justify-content: flex-end; + align-items: center; +} \ No newline at end of file diff --git a/src/portal/src/lib/components/config/project-quotas/project-quotas.component.spec.ts b/src/portal/src/lib/components/config/project-quotas/project-quotas.component.spec.ts index ad8526e21..7fa01fc27 100644 --- a/src/portal/src/lib/components/config/project-quotas/project-quotas.component.spec.ts +++ b/src/portal/src/lib/components/config/project-quotas/project-quotas.component.spec.ts @@ -124,7 +124,8 @@ describe('ProjectQuotasComponent', () => { await timeout(10); fixture.detectChanges(); await fixture.whenStable(); - component.editQuota(component.quotaList[0]); + component.selectedRow = [component.quotaList[0]]; + component.editQuota(); fixture.detectChanges(); await fixture.whenStable(); const countInput: HTMLInputElement = fixture.nativeElement.querySelector('#count'); diff --git a/src/portal/src/lib/components/config/project-quotas/project-quotas.component.ts b/src/portal/src/lib/components/config/project-quotas/project-quotas.component.ts index 76ad554dc..b2fc9058e 100644 --- a/src/portal/src/lib/components/config/project-quotas/project-quotas.component.ts +++ b/src/portal/src/lib/components/config/project-quotas/project-quotas.component.ts @@ -58,6 +58,7 @@ export class ProjectQuotasComponent implements OnChanges { } countComparator: Comparator = new CustomComparator(quotaSort.count, quotaSort.sortType); storageComparator: Comparator = new CustomComparator(quotaSort.storage, quotaSort.sortType); + selectedRow: Quota[] = []; constructor( private configService: ConfigurationService, @@ -66,21 +67,23 @@ export class ProjectQuotasComponent implements OnChanges { private router: Router, private errorHandler: ErrorHandler) { } - editQuota(quotaHardLimitValue: Quota) { - const defaultTexts = [this.translate.get('QUOTA.EDIT_PROJECT_QUOTAS') - , this.translate.get('QUOTA.SET_QUOTAS', { params: quotaHardLimitValue.ref.name }) - , this.translate.get('QUOTA.COUNT_QUOTA'), this.translate.get('QUOTA.STORAGE_QUOTA')]; - forkJoin(...defaultTexts).subscribe(res => { - const defaultTextsObj = { - editQuota: res[0], - setQuota: res[1], - countQuota: res[2], - storageQuota: res[3], - quotaHardLimitValue: quotaHardLimitValue, - isSystemDefaultQuota: false - }; - this.editQuotaDialog.openEditQuotaModal(defaultTextsObj); - }); + editQuota() { + if (this.selectedRow && this.selectedRow.length === 1) { + const defaultTexts = [this.translate.get('QUOTA.EDIT_PROJECT_QUOTAS') + , this.translate.get('QUOTA.SET_QUOTAS', { params: this.selectedRow[0].ref.name }) + , this.translate.get('QUOTA.COUNT_QUOTA'), this.translate.get('QUOTA.STORAGE_QUOTA')]; + forkJoin(...defaultTexts).subscribe(res => { + const defaultTextsObj = { + editQuota: res[0], + setQuota: res[1], + countQuota: res[2], + storageQuota: res[3], + quotaHardLimitValue: this.selectedRow[0], + isSystemDefaultQuota: false + }; + this.editQuotaDialog.openEditQuotaModal(defaultTextsObj); + }); + } } editDefaultQuota(quotaHardLimitValue: QuotaHardLimitInterface) { @@ -237,5 +240,6 @@ export class ProjectQuotasComponent implements OnChanges { }, }; this.getQuotaList(state); + this.selectedRow = []; } } diff --git a/src/portal/src/lib/components/config/vulnerability/vulnerability-config.component.spec.ts b/src/portal/src/lib/components/config/vulnerability/vulnerability-config.component.spec.ts index 4cf3c0543..a3e2dc4a7 100644 --- a/src/portal/src/lib/components/config/vulnerability/vulnerability-config.component.spec.ts +++ b/src/portal/src/lib/components/config/vulnerability/vulnerability-config.component.spec.ts @@ -8,6 +8,7 @@ import { ScanningMetrics } from "../config"; import { SharedModule } from "../../../utils/shared/shared.module"; import { ErrorHandler } from "../../../utils/error-handler"; import { CURRENT_BASE_HREF } from "../../../utils/utils"; +import { Scanner } from "../../../../app/config/scanner/scanner"; let component: VulnerabilityConfigComponent; let fixture: ComponentFixture; @@ -34,6 +35,19 @@ let mockedManualMetrics: ScanningMetrics = { }, ongoing: true }; +const mockedScanner: Scanner = { + "uuid": "ca3c27f3-72f3-11ea-9e46-0242ac170004", + "name": "clair", + "description": "", + "url": "http://10.92.161.247:8080", + "disabled": false, + "is_default": true, + "auth": "", + "skip_certVerify": false, + "use_internal_addr": true, + "create_time": "2020-03-31T02:03:18.379132Z", + "update_time": "2020-03-31T02:03:18.379135Z" +}; let fakedScanAllRepoService = { getSchedule() { return of(mockedSchedule); @@ -48,7 +62,10 @@ let fakedScanAllRepoService = { return of(true); }, getScanners() { - return of([]); + return of([mockedScanner]); + }, + getScannerMetadata() { + return of(null); } }; let fakedErrorHandler = { diff --git a/src/portal/src/lib/components/config/vulnerability/vulnerability-config.component.ts b/src/portal/src/lib/components/config/vulnerability/vulnerability-config.component.ts index 462887857..d97fa4aea 100644 --- a/src/portal/src/lib/components/config/vulnerability/vulnerability-config.component.ts +++ b/src/portal/src/lib/components/config/vulnerability/vulnerability-config.component.ts @@ -117,6 +117,8 @@ export class VulnerabilityConfigComponent implements OnInit, OnDestroy { scanners.forEach(scanner => { if (scanner.is_default) { flag = true; + this.initMetrics(); + this.getSchedule(); this.getScannerMetadata(scanner.uuid); } }); @@ -126,6 +128,11 @@ export class VulnerabilityConfigComponent implements OnInit, OnDestroy { } if (!flag) { this.onGettingUpdatedTimeStr = false; + this.translate.get("SCANNER.NO_DEFAULT_SCANNER") + .subscribe(res => { + this.errorHandler.warning(res); + } + ); } }, error => { this.onGettingUpdatedTimeStr = false; @@ -158,8 +165,6 @@ export class VulnerabilityConfigComponent implements OnInit, OnDestroy { } ngOnInit(): void { this.getScanText(); - this.getSchedule(); - this.initMetrics(); this.getScanners(); }