From 7dc27ab4ebee28dbe59369eb81ee6fc8e95c87d3 Mon Sep 17 00:00:00 2001 From: Yogi_Wang Date: Tue, 25 Feb 2020 10:36:24 +0800 Subject: [PATCH] Fix some detail function 1.change common property to Extra Attributes; 2.fix delete repo bug 3.disable index artifact action(nothing changed when refactoring the route completely) 4.annotations show in artifact list 5.add validation in add tag Signed-off-by: Yogi_Wang --- .../artifact-list-tab.component.html | 42 ++++++++----- .../artifact-list-tab.component.spec.ts | 24 +++----- .../artifact-list-tab.component.ts | 21 ++++++- .../artifact-list.component.spec.ts | 3 +- .../artifact-list/artifact-list.component.ts | 12 ++-- .../artifact-common-properties.component.html | 2 +- .../artifact-common-properties.component.ts | 25 +------- .../artifact/artifact-summary.component.html | 2 +- .../artifact-tag/artifact-tag.component.html | 12 ++-- .../artifact-tag/artifact-tag.component.ts | 2 +- .../repository/artifact/artifact.service.ts | 2 +- .../project/repository/artifact/artifact.ts | 61 ++----------------- .../repository-gridview.component.ts | 6 +- .../result-bar-chart.component.ts | 13 ++-- src/portal/src/i18n/lang/en-us-lang.json | 5 +- src/portal/src/i18n/lang/es-es-lang.json | 5 +- src/portal/src/i18n/lang/fr-fr-lang.json | 5 +- src/portal/src/i18n/lang/pt-br-lang.json | 5 +- src/portal/src/i18n/lang/tr-tr-lang.json | 5 +- src/portal/src/i18n/lang/zh-cn-lang.json | 5 +- .../images/{cnab.svg => artifact-cnab.svg} | 0 .../src/lib/services/channel.service.ts | 2 +- 22 files changed, 105 insertions(+), 154 deletions(-) rename src/portal/src/images/{cnab.svg => artifact-cnab.svg} (100%) 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 bd8e4ec57..b80dfa78b 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 @@ -71,7 +71,7 @@ [(clrDgSelected)]="selectedRow"> @@ -82,11 +82,11 @@
+ [clrDisabled]="!(selectedRow.length==1&& !depth)" (click)="showDigestId()"> {{'REPOSITORY.COPY_DIGEST_ID' | translate}}
@@ -116,10 +116,10 @@
{{'REPOSITORY.RETAG' | translate}}
+ (click)="deleteArtifact()" id="artifact-list-delete" [clrDisabled]="!hasDeleteImagePermission||!selectedRow.length || depth"> {{'REPOSITORY.DELETE' | translate}}
@@ -128,14 +128,12 @@ {{'REPOSITORY.ARTIFACTS_COUNT' | translate}} - {{'REPOSITORY.PLATFORM' | translate}} + {{'REPOSITORY.PLATFORM' | translate}} {{'REPOSITORY.TAGS_COUNT' | translate}} {{'REPOSITORY.SIZE' | translate}} - {{'REPOSITORY.VULNERABILITY' | translate}} {{'REPOSITORY.SIGNED' | translate}} - - + {{'ARTIFACT.ANNOTATION' | translate}} {{'REPOSITORY.LABELS' | translate}} {{'REPOSITORY.PUSH_TIME' | translate}} {{'REPOSITORY.PULL_TIME' | translate}} @@ -166,7 +164,7 @@ - +
{{artifact.extra_attrs?.os}}/{{artifact.extra_attrs?.architecture}}
@@ -243,11 +241,27 @@
- +
diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts index 2c49b74ed..2652f51b4 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.spec.ts @@ -22,7 +22,7 @@ import { UserPermissionService, USERSTATICPERMISSION } from "../../../../../../lib/services"; -import { Artifact, Reference } from "../../../artifact/artifact"; +import { ArtifactFront as Artifact } from "../../../artifact/artifact"; import { IServiceConfig, SERVICE_CONFIG } from "../../../../../../lib/entities/service.config"; import { SharedModule } from "../../../../../../lib/utils/shared/shared.module"; import { LabelPieceComponent } from "../../../../../../lib/components/label-piece/label-piece.component"; @@ -82,21 +82,19 @@ describe("ArtifactListTabComponent (inline template)", () => { { "id": 1, type: 'image', - repository: "goharbor/harbor-portal", tags: [{ - id: '1', + id: 1, name: 'tag1', - artifact_id: 1, - upload_time: '2020-01-06T09:40:08.036866579Z', + artifact_id: 1 }, { - id: '2', + id: 2, name: 'tag2', artifact_id: 2, pull_time: '2020-01-06T09:40:08.036866579Z', push_time: '2020-01-06T09:40:08.036866579Z', - },], - references: [new Reference(1), new Reference(2)], + }], + references: [], media_type: 'string', "digest": "sha256:4875cda368906fd670c9629b5e416ab3d6c0292015f3c3f12ef37dc9a32fc8d4", "size": 20372934, @@ -141,22 +139,20 @@ describe("ArtifactListTabComponent (inline template)", () => { { "id": 1, type: 'image', - repository: "goharbor/harbor-portal", tags: [{ - id: '1', + id: 1, name: 'tag1', - artifact_id: 1, - upload_time: '2020-01-06T09:40:08.036866579Z', + artifact_id: 1 }, { - id: '2', + id: 2, name: 'tag2', artifact_id: 2, pull_time: '2020-01-06T09:40:08.036866579Z', push_time: '2020-01-06T09:40:08.036866579Z', } ], - references: [new Reference(1), new Reference(2)], + references: [], media_type: 'string', "digest": "sha256:3e33e3e3", "size": 20372934, diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts index 8c40c72b7..a1d679332 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts @@ -61,7 +61,7 @@ import { } from "../../../../../../lib/entities/shared.const"; import { operateChanges, OperateInfo, OperationState } from "../../../../../../lib/components/operation/operate"; import { errorHandler } from "../../../../../../lib/utils/shared/shared.utils"; -import { Artifact } from "../../../artifact/artifact"; +import { ArtifactFront as Artifact } from "../../../artifact/artifact"; import { Project } from "../../../../project"; import { ArtifactService as NewArtifactService } from "../../../../../../../ng-swagger-gen/services/artifact.service"; export interface LabelState { @@ -82,7 +82,6 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { projectName: string; @Input() memberRoleID: number; @Input() repoName: string; - referArtifactArray: string[] = []; @Input() isEmbedded: boolean; @Input() hasSignedIn: boolean; @Input() isGuest: boolean; @@ -373,6 +372,7 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { this.loading = false; })).subscribe(artifacts => { this.artifactList = artifacts; + this.getArtifactAnnotationsArray(this.artifactList); }, error => { this.errorHandlerService.error(error); }); @@ -391,6 +391,7 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { } } this.artifactList = res.body; + this.getArtifactAnnotationsArray(this.artifactList); }, error => { // error this.errorHandlerService.error(error); @@ -401,7 +402,21 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { refresh() { this.doSearchArtifactNames(""); } - + getArtifactAnnotationsArray(artifactList: Artifact[]) { + artifactList.forEach(artifact => { + artifact.annotationsArray = []; + if (artifact.annotations) { + for (const key in artifact.annotations) { + if (artifact.annotations.hasOwnProperty(key)) { + const annotation = artifact.annotations[key]; + artifact.annotationsArray.push(`${key} : ${annotation}`); + } + } + // todo : cannot support Object.entries + // artifact.annotationsArray = Object.entries(artifact.annotations).map(item => `${item[0]} : ${item[1]}`); + } + }); + } getAllLabels(): void { forkJoin(this.labelService.getGLabels(), this.labelService.getPLabels(this.projectId)).subscribe(results => { results.forEach(labels => { diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list.component.spec.ts b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list.component.spec.ts index e88067007..101106724 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list.component.spec.ts +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list.component.spec.ts @@ -85,7 +85,8 @@ describe('ArtifactListComponent (inline template)', () => { } ]; let newRepositoryService = { - updateRepository: () => of(null) + updateRepository: () => of(null), + getRepository: () => of({description: ''}) }; let mockRepo: Repository = { metadata: { xTotalCount: 2 }, diff --git a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list.component.ts b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list.component.ts index 8a4e6753a..1267831c9 100644 --- a/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list.component.ts +++ b/src/portal/src/app/project/repository/artifact-list-page/artifact-list/artifact-list.component.ts @@ -118,12 +118,14 @@ export class ArtifactListComponent implements OnInit { } retrieve(state?: State) { - this.repositoryService.getRepositories(this.projectId, this.repoName) + let params: NewRepositoryService.GetRepositoryParams = { + projectName: this.projectName, + repositoryName: this.repoName + }; + this.newRepositoryService.getRepository(params) .subscribe(response => { - if (response.metadata.xTotalCount > 0) { - this.orgImageInfo = response.data[0].description; - this.imageInfo = response.data[0].description; - } + this.orgImageInfo = response.description; + this.imageInfo = response.description; }, error => this.errorHandler.error(error)); this.systemInfoService.getSystemInfo() .subscribe(systemInfo => this.systemInfo = systemInfo, error => this.errorHandler.error(error)); diff --git a/src/portal/src/app/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.html b/src/portal/src/app/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.html index 032fff5ac..535be9fdc 100644 --- a/src/portal/src/app/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.html +++ b/src/portal/src/app/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.html @@ -1,5 +1,5 @@ -

{{'ARTIFACT.COMMON_PROPERTIES' | translate}}

+

{{'ARTIFACT.EXTRA_PROPERTIES' | translate}}

{{'ARTIFACT.COMMON_ALL' | translate}} diff --git a/src/portal/src/app/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.ts b/src/portal/src/app/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.ts index 415a23abf..93858ef6d 100644 --- a/src/portal/src/app/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.ts +++ b/src/portal/src/app/project/repository/artifact/artifact-common-properties/artifact-common-properties.component.ts @@ -33,30 +33,7 @@ export class ArtifactCommonPropertiesComponent implements OnInit, OnChanges { ngOnChanges(changes: SimpleChanges) { if (changes && changes["artifactDetails"]) { if (this.artifactDetails) { - if (this.artifactDetails.type) { - this.commonProperties[Types.TYPE] = this.artifactDetails.type; - } - if (this.artifactDetails.media_type) { - this.commonProperties[Types.MEDIA_TYPE] = this.artifactDetails.media_type; - } - if (this.artifactDetails.manifest_media_type) { - this.commonProperties[Types.MANIFEST_MEDIA_TYPE] = this.artifactDetails.manifest_media_type; - } - if (this.artifactDetails.digest) { - this.commonProperties[Types.DIGEST] = this.artifactDetails.digest; - } - if (this.artifactDetails.size) { - this.commonProperties[Types.SIZE] = formatSize(this.artifactDetails.size.toString()); - } - if (this.artifactDetails.push_time) { - this.commonProperties[Types.PUSH_TIME] = new DatePipe(this.translate.currentLang) - .transform(this.artifactDetails.push_time, 'short'); - } - if (this.artifactDetails.pull_time) { - this.commonProperties[Types.PULL_TIME] = new DatePipe(this.translate.currentLang) - .transform(this.artifactDetails.pull_time, 'short'); - } - Object.assign(this.commonProperties, this.artifactDetails.extra_attrs, this.artifactDetails.annotations); + Object.assign(this.commonProperties, this.artifactDetails.extra_attrs); for (let name in this.commonProperties) { if (this.commonProperties.hasOwnProperty(name)) { if (this.commonProperties[name] && this.commonProperties[name] instanceof Object) { diff --git a/src/portal/src/app/project/repository/artifact/artifact-summary.component.html b/src/portal/src/app/project/repository/artifact/artifact-summary.component.html index 32196c749..d6c81d650 100644 --- a/src/portal/src/app/project/repository/artifact/artifact-summary.component.html +++ b/src/portal/src/app/project/repository/artifact/artifact-summary.component.html @@ -18,7 +18,7 @@
- + diff --git a/src/portal/src/app/project/repository/artifact/artifact-tag/artifact-tag.component.html b/src/portal/src/app/project/repository/artifact/artifact-tag/artifact-tag.component.html index 352822dbf..6c94710cb 100644 --- a/src/portal/src/app/project/repository/artifact/artifact-tag/artifact-tag.component.html +++ b/src/portal/src/app/project/repository/artifact/artifact-tag/artifact-tag.component.html @@ -7,17 +7,19 @@ -
- +