mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-09 17:37:44 +01:00
Fix-20459 Wrong sbom status displayed in UI (#20460)
Signed-off-by: xuelichao <xuel@vmware.com>
This commit is contained in:
parent
be839e677c
commit
3875b1ac1d
@ -182,6 +182,7 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy {
|
|||||||
onSbomArtifactsLength: number = 0;
|
onSbomArtifactsLength: number = 0;
|
||||||
stopBtnState: ClrLoadingState = ClrLoadingState.DEFAULT;
|
stopBtnState: ClrLoadingState = ClrLoadingState.DEFAULT;
|
||||||
updateArtifactSub: Subscription;
|
updateArtifactSub: Subscription;
|
||||||
|
updateArtifactSbomSub: Subscription;
|
||||||
|
|
||||||
hiddenArray: boolean[] = getHiddenArrayFromLocalStorage(
|
hiddenArray: boolean[] = getHiddenArrayFromLocalStorage(
|
||||||
PageSizeMapKeys.ARTIFACT_LIST_TAB_COMPONENT,
|
PageSizeMapKeys.ARTIFACT_LIST_TAB_COMPONENT,
|
||||||
@ -255,6 +256,20 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (!this.updateArtifactSbomSub) {
|
||||||
|
this.updateArtifactSbomSub = this.eventService.subscribe(
|
||||||
|
HarborEvent.UPDATE_SBOM_INFO,
|
||||||
|
(artifact: Artifact) => {
|
||||||
|
if (this.artifactList && this.artifactList.length) {
|
||||||
|
this.artifactList.forEach(item => {
|
||||||
|
if (item.digest === artifact.digest) {
|
||||||
|
this.updateArtifact(artifact, item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
if (!this.deleteAccessorySub) {
|
if (!this.deleteAccessorySub) {
|
||||||
this.deleteAccessorySub = this.eventService.subscribe(
|
this.deleteAccessorySub = this.eventService.subscribe(
|
||||||
HarborEvent.DELETE_ACCESSORY,
|
HarborEvent.DELETE_ACCESSORY,
|
||||||
@ -984,22 +999,28 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateArtifact(from: Artifact, to: Artifact) {
|
||||||
|
if (from.scan_overview) {
|
||||||
|
to.scan_overview = from.scan_overview;
|
||||||
|
}
|
||||||
|
if (from.sbom_overview) {
|
||||||
|
to.sbom_overview = from.sbom_overview;
|
||||||
|
}
|
||||||
|
if (from.sbom_overview.sbom_digest) {
|
||||||
|
to.sbomDigest = from.sbom_overview.sbom_digest;
|
||||||
|
}
|
||||||
|
if (from.accessories !== undefined && from.accessories.length > 0) {
|
||||||
|
to.accessories = from.accessories;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// when finished, remove it from selectedRow
|
// when finished, remove it from selectedRow
|
||||||
scanFinished(artifact: Artifact) {
|
scanFinished(artifact: Artifact) {
|
||||||
if (this.selectedRow && this.selectedRow.length) {
|
if (this.selectedRow && this.selectedRow.length) {
|
||||||
for (let i = 0; i < this.selectedRow.length; i++) {
|
for (let i = 0; i < this.selectedRow.length; i++) {
|
||||||
if (artifact.digest === this.selectedRow[i].digest) {
|
if (artifact.digest === this.selectedRow[i].digest) {
|
||||||
if (artifact.sbom_overview) {
|
this.updateArtifact(artifact, this.selectedRow[i]);
|
||||||
this.selectedRow[i].sbom_overview =
|
|
||||||
artifact.sbom_overview;
|
|
||||||
}
|
|
||||||
if (artifact.sbom_overview.sbom_digest) {
|
|
||||||
this.selectedRow[i].sbomDigest =
|
|
||||||
artifact.sbom_overview.sbom_digest;
|
|
||||||
}
|
|
||||||
if (artifact.accessories !== undefined) {
|
|
||||||
this.selectedRow[i].accessories = artifact.accessories;
|
|
||||||
}
|
|
||||||
this.selectedRow.splice(i, 1);
|
this.selectedRow.splice(i, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -173,19 +173,22 @@ describe('ResultSbomComponent (inline template)', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show summary bar chart if status is COMPLETED', () => {
|
it('should show summary bar chart if status is COMPLETED', () => {
|
||||||
|
component.sbomOverview = { ...mockedSbomOverview };
|
||||||
component.sbomOverview.scan_status = SBOM_SCAN_STATUS.SUCCESS;
|
component.sbomOverview.scan_status = SBOM_SCAN_STATUS.SUCCESS;
|
||||||
|
component.sbomOverview.sbom_digest = mockedSbomDigest;
|
||||||
component.artifactDigest = mockedSbomDigest;
|
component.artifactDigest = mockedSbomDigest;
|
||||||
component.sbomDigest = mockedSbomDigest;
|
component.sbomDigest = mockedSbomDigest;
|
||||||
component.accessories = mockedAccessories;
|
component.accessories = mockedAccessories;
|
||||||
fixture.whenStable().then(() => {
|
fixture.whenStable().then(() => {
|
||||||
|
fixture.detectChanges();
|
||||||
const el: HTMLElement =
|
const el: HTMLElement =
|
||||||
fixture.nativeElement.querySelector('.tip-block');
|
fixture.nativeElement.querySelector('.tip-block');
|
||||||
expect(el).not.toBeNull();
|
expect(el).not.toBeNull();
|
||||||
const textContent = el.textContent;
|
const textContent = el?.textContent;
|
||||||
expect(component.sbomOverview.scan_status).toBe(
|
expect(component.sbomOverview.scan_status).toBe(
|
||||||
SBOM_SCAN_STATUS.SUCCESS
|
SBOM_SCAN_STATUS.SUCCESS
|
||||||
);
|
);
|
||||||
expect(textContent).toBe('SBOM Detail');
|
expect(textContent?.trim()).toBe('SBOM.Details');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('Test ResultSbomComponent getScanner', () => {
|
it('Test ResultSbomComponent getScanner', () => {
|
||||||
|
@ -221,6 +221,7 @@ export class ResultSbomComponent implements OnInit, OnDestroy {
|
|||||||
repositoryName: dbEncodeURIComponent(this.repoName),
|
repositoryName: dbEncodeURIComponent(this.repoName),
|
||||||
reference: this.artifactDigest,
|
reference: this.artifactDigest,
|
||||||
withSbomOverview: true,
|
withSbomOverview: true,
|
||||||
|
withAccessory: true,
|
||||||
XAcceptVulnerabilities: DEFAULT_SUPPORTED_MIME_TYPES,
|
XAcceptVulnerabilities: DEFAULT_SUPPORTED_MIME_TYPES,
|
||||||
})
|
})
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<div class="tip-wrapper width-215">
|
<div class="tip-wrapper width-120">
|
||||||
<clr-tooltip>
|
<clr-tooltip>
|
||||||
<div clrTooltipTrigger class="tip-block">
|
<div clrTooltipTrigger class="tip-block">
|
||||||
<div *ngIf="showSbomDetailLink()" class="circle-block">
|
<div *ngIf="showSbomDetailLink()" class="circle-block">
|
||||||
<a
|
<a
|
||||||
href="javascript:void(0)"
|
href="javascript:void(0)"
|
||||||
class="digest margin-left-5"
|
class="digest"
|
||||||
(click)="goIntoArtifactSbomSummaryPage()"
|
(click)="goIntoArtifactSbomSummaryPage()"
|
||||||
title="{{ 'SBOM.Details' | translate }">
|
title="{{ 'SBOM.Details' | translate }">
|
||||||
{{ 'SBOM.Details' | translate }}</a
|
{{ 'SBOM.Details' | translate }}</a
|
||||||
@ -12,13 +12,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
*ngIf="showNoSbom()"
|
*ngIf="showNoSbom()"
|
||||||
class="pl-1 margin-left-5 tip-wrapper bar-block-none shadow-none width-150">
|
class="tip-wrapper bar-block-none shadow-none width-120">
|
||||||
{{ 'SBOM.NO_SBOM' | translate }}
|
{{ 'SBOM.NO_SBOM' | translate }}
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
*ngIf="!showSbomDetailLink() && !showNoSbom()"
|
*ngIf="!showSbomDetailLink() && !showNoSbom()"
|
||||||
class="pl-1 margin-left-5 tip-wrapper bar-block-none shadow-none width-150">
|
class="tip-wrapper width-120">
|
||||||
{{ 'SBOM.COMPLETED,' | translate }}
|
{{ 'SBOM.COMPLETED' | translate }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<clr-tooltip-content
|
<clr-tooltip-content
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
.tip-wrapper {
|
.tip-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: left;
|
||||||
color: #fff;
|
text-align: left;
|
||||||
text-align: center;
|
font-size: .65rem;
|
||||||
font-size: 10px;
|
|
||||||
height: 15px;
|
height: 15px;
|
||||||
line-height: 15px;
|
line-height: 15px;
|
||||||
}
|
}
|
||||||
@ -33,12 +32,8 @@ hr {
|
|||||||
margin-left: 5px;
|
margin-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.width-215 {
|
.width-120 {
|
||||||
width: 215px;
|
width: 120px;
|
||||||
}
|
|
||||||
|
|
||||||
.width-150 {
|
|
||||||
width: 150px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.level-border>div{
|
.level-border>div{
|
||||||
|
@ -79,11 +79,11 @@ export class SbomTipHistogramComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showSbomDetailLink(): boolean {
|
showSbomDetailLink(): boolean {
|
||||||
return this.sbomDigest && this.getSbomAccessories.length > 0;
|
return this.sbomDigest && this.getSbomAccessories().length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
showNoSbom(): boolean {
|
showNoSbom(): boolean {
|
||||||
return !this.sbomDigest && this.getSbomAccessories.length === 0;
|
return !this.sbomDigest && this.getSbomAccessories().length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
isThemeLight() {
|
isThemeLight() {
|
||||||
|
Loading…
Reference in New Issue
Block a user