From 59fd605f2d000a1e4f72cc77646fd2de0e43bc46 Mon Sep 17 00:00:00 2001 From: Antoine Date: Fri, 23 Aug 2024 04:26:45 +0000 Subject: [PATCH 1/3] fix: adds label for multiple selected artifacts Signed-off-by: Antoine Signed-off-by: anthony --- .../artifact-list-tab.component.ts | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts index cf3d1c7dd5b..4e6615688fe 100644 --- a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts +++ b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts @@ -527,25 +527,27 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { } addLabel(label: Label) { if (!this.inprogress) { - const params: NewArtifactService.AddLabelParams = { - projectName: this.projectName, - repositoryName: dbEncodeURIComponent(this.repoName), - reference: this.selectedRow[0].digest, - label: label, - }; this.inprogress = true; - this.newArtifactService - .addLabel(params) - .pipe(finalize(() => (this.inprogress = false))) - .subscribe({ - next: res => { - this.refresh(); - }, - error: err => { - this.refresh(); - this.errorHandlerService.error(err); - }, - }); + this.selectedRow.forEach((artifact: Artifact) => { + const params: NewArtifactService.AddLabelParams = { + projectName: this.projectName, + repositoryName: dbEncodeURIComponent(this.repoName), + reference: artifact.digest, + label: label, + }; + this.newArtifactService + .addLabel(params) + .pipe(finalize(() => (this.inprogress = false))) + .subscribe({ + next: res => { + this.refresh(); + }, + error: err => { + this.refresh(); + this.errorHandlerService.error(err); + }, + }); + }) } } removeLabel(label: Label) { From 80e4088ffbdba821554063385522a71654a88ced Mon Sep 17 00:00:00 2001 From: Antoine Date: Sat, 24 Aug 2024 23:05:39 -0400 Subject: [PATCH 2/3] pr ci fixes Signed-off-by: anthony --- .../artifact-list-tab/artifact-list-tab.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts index 4e6615688fe..c83a9dfb661 100644 --- a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts +++ b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts @@ -547,7 +547,7 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { this.errorHandlerService.error(err); }, }); - }) + }); } } removeLabel(label: Label) { From 0e3caf9228234f0abe0d7f22cb00fa7ee8e41c28 Mon Sep 17 00:00:00 2001 From: Antoine Date: Wed, 18 Sep 2024 22:44:24 -0400 Subject: [PATCH 3/3] forkjoin approach Signed-off-by: anthony --- .../artifact-list-tab.component.ts | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts index c83a9dfb661..40005f527e8 100644 --- a/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts +++ b/src/portal/src/app/base/project/repository/artifact/artifact-list-page/artifact-list/artifact-list-tab/artifact-list-tab.component.ts @@ -528,26 +528,30 @@ export class ArtifactListTabComponent implements OnInit, OnDestroy { addLabel(label: Label) { if (!this.inprogress) { this.inprogress = true; - this.selectedRow.forEach((artifact: Artifact) => { + const labelRequests = this.selectedRow.map((artifact: Artifact) => { const params: NewArtifactService.AddLabelParams = { projectName: this.projectName, repositoryName: dbEncodeURIComponent(this.repoName), reference: artifact.digest, label: label, }; - this.newArtifactService + + return this + .newArtifactService .addLabel(params) - .pipe(finalize(() => (this.inprogress = false))) - .subscribe({ - next: res => { - this.refresh(); - }, - error: err => { - this.refresh(); - this.errorHandlerService.error(err); - }, - }); - }); + .pipe(catchError(error => { + this.errorHandlerService.error(error); + return of(error); + })); + }) + + forkJoin(labelRequests) + .pipe(finalize(() => { this.inprogress = false; })) + .subscribe({ + complete: () => { + this.refresh(); + } + }); } } removeLabel(label: Label) {