Skip to content

Conversation

@falconlee236
Copy link

@falconlee236 falconlee236 commented Nov 8, 2025

What this PR does

  • Enables adding/removing a label across all currently selected artifacts (multi-select).
  • Keeps the Add Labels action enabled when multiple items are selected, even if some already have labels.
  • Uses the intersection of labels across the selection to drive the selector’s checked state.

Why

  • Fixes a bug where only the first selected artifact was updated and the action became disabled on multi-select.

How (high level)

  • Bind the label selector’s ownedLabels to the intersection across selectedRow instead of selectedRow[0].
  • Change enablement logic to allow the action whenever at least one row is selected (permission-gated).
  • Fan out addLabel/removeLabel across all selected artifacts using existing per-artifact APIs (no backend changes).
image

Issue being fixed

Fixes #19422

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/ignore-for-release, release-note/new-feature, release-note/update, release-note/enhancement, release-note/community, release-note/breaking-change, release-note/docs, release-note/infra, release-note/deprecation"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

…abels enabled on multi-select, Fixes goharbor#19422

Signed-off-by: falconlee236 <[email protected]>
@falconlee236 falconlee236 changed the title UI: support bulk add/remove labels for selected artifacts; keep “Add Labels” enabled on multi-select [FEAT] support bulk add/remove labels for selected artifacts; keep “Add Labels” enabled on multi-select Nov 8, 2025
@falconlee236 falconlee236 changed the title [FEAT] support bulk add/remove labels for selected artifacts; keep “Add Labels” enabled on multi-select FEAT: support bulk add/remove labels for selected artifacts; keep “Add Labels” enabled on multi-select Nov 8, 2025
@chlins chlins requested a review from Copilot November 10, 2025 03:13
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances label management functionality to support bulk operations when multiple artifacts are selected. Previously, labels could only be added/removed for a single artifact at a time, and label selection was limited when multiple items were selected.

  • Introduces selectedCommonLabels getter to compute labels shared across all selected artifacts
  • Refactors addLabel() and removeLabel() to process multiple artifacts using forkJoin
  • Simplifies canAddLabel() logic to allow label operations on multiple selections

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
artifact-list-tab.component.ts Adds common label computation logic, refactors label add/remove methods to support bulk operations via forkJoin, and simplifies canAddLabel check
artifact-list-tab.component.html Updates label selector to use computed common labels instead of first selected item's labels

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +551 to +559
forkJoin(ops)
.pipe(finalize(() => (this.inprogress = false)))
.subscribe({
next: () => this.refresh(),
error: err => {
this.errorHandlerService.error(err);
this.refresh();
},
});
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When forkJoin receives an empty array, it completes immediately with an empty array. However, the guard at line 547 prevents this. The real issue is that forkJoin will fail if ANY of the operations fail, meaning only the first error will be reported and refresh() will be called once. If multiple operations fail, users won't see all errors. Consider using forkJoin with individual error handling via catchError on each observable, or switch to a pattern that reports all failures.

Copilot uses AI. Check for mistakes.
Comment on lines +579 to +587
forkJoin(ops)
.pipe(finalize(() => (this.inprogress = false)))
.subscribe({
next: () => this.refresh(),
error: err => {
this.errorHandlerService.error(err);
this.refresh();
},
});
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as in addLabel: forkJoin will fail fast on the first error, meaning if multiple remove operations fail, only the first error will be reported to users. Consider using forkJoin with individual error handling via catchError on each observable to report all failures, or use a different pattern that doesn't fail fast.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Nov 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.55%. Comparing base (c8c11b4) to head (020dd34).
⚠️ Report is 594 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #22553       +/-   ##
===========================================
+ Coverage   45.36%   68.55%   +23.18%     
===========================================
  Files         244      821      +577     
  Lines       13333   101822    +88489     
  Branches     2719        0     -2719     
===========================================
+ Hits         6049    69799    +63750     
- Misses       6983    28140    +21157     
- Partials      301     3883     +3582     
Flag Coverage Δ
unittests 68.55% <ø> (+23.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1053 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@MinerYang
Copy link
Contributor

Hi @bupd ,

Could you please help to review this PR^ Thanks.

Signed-off-by: falconlee236 <[email protected]>
@falconlee236
Copy link
Author

Hi @MinerYang,
Please Review My PR. Or Can I get some tips how to be received review in my PR
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better labels handling through UI

4 participants