Skip to content

Backlogs target#23852

Open
toy wants to merge 2 commits into
devfrom
backlogs-target
Open

Backlogs target#23852
toy wants to merge 2 commits into
devfrom
backlogs-target

Conversation

@toy

@toy toy commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Ticket

Extracted from https://community.openproject.org/wp/74386

What are you trying to accomplish?

Have a class responsible for constructing and parsing target id

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces Backlogs::Target as a single place to construct and parse backlog “target_id” values (e.g., sprint:42, backlog_bucket:13, inbox) and begins migrating existing code paths to use it for safer parsing and consistent serialization.

Changes:

  • Added Backlogs::Target discriminated-union style value objects (SprintId, BucketId, InboxId) plus .for and .parse.
  • Updated Backlogs::WorkPackages::UpdateService to parse targets via Backlogs::Target.parse and pattern-match on the resulting target object.
  • Updated backlog UI components to generate target_id via Backlogs::Target (with explicit to_s) and added unit specs for Backlogs::Target.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
modules/backlogs/spec/models/backlogs/target_spec.rb Adds specs covering construction, parsing, and round-trip serialization of target ids.
modules/backlogs/app/services/backlogs/work_packages/update_service.rb Switches target parsing to Backlogs::Target.parse and matches on target objects.
modules/backlogs/app/models/backlogs/target.rb Introduces the Backlogs::Target value objects and parsing/constructor helpers.
modules/backlogs/app/components/backlogs/work_package_card_menu_component.rb Uses Backlogs::Target objects when building menu move requests (needs string serialization fix).
modules/backlogs/app/components/backlogs/sprint_component.html.erb Uses Backlogs::Target.for(sprint).to_s for drag-and-drop target_id.
modules/backlogs/app/components/backlogs/inbox_component.html.erb Uses Backlogs::Target::InboxId.to_s for drag-and-drop target_id.
modules/backlogs/app/components/backlogs/bucket_component.html.erb Uses Backlogs::Target.for(backlog_bucket).to_s for drag-and-drop target_id.

@toy toy force-pushed the backlogs-target branch from 8cc69c6 to 58e4ae0 Compare June 22, 2026 22:14
Comment on lines +64 to +65
BucketId[container.id]
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and InboxId?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

there is no model for inbox, using nil or Project instance feels odd


def to_s = "#{type}:#{id}"

def to_h = { type:, id: }

@myabc myabc Jun 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: you could extract this into a module.

Suggested change
def to_h = { type:, id: }
def to_s = "#{type}:#{id}"
def to_h = { type:, id: }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I thought about it, but it didn't feel justifiable


def to_s = "#{type}:#{id}"

def to_h = { type:, id: }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess you could also write

Suggested change
def to_h = { type:, id: }
def to_h = super.merge(type:)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes, but here explicit is just much more straightforward

SprintId = Data.define(:id) do
def type = :sprint

def to_s = "#{type}:#{id}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

to_param might be a better name here.

@toy toy Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll check if it breaks implicit usage

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It does not

@toy toy force-pushed the backlogs-target branch 2 times, most recently from 0852131 to c3b60c7 Compare June 23, 2026 20:00
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./modules/backlogs/spec/features/backlogs/create_spec.rb[1:3:2]
  • rspec ./modules/wikis/spec/features/admin/internal_provider_spec.rb[1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #23852, linked for reference only):

- `rspec ./modules/backlogs/spec/features/backlogs/create_spec.rb[1:3:2]`
- `rspec ./modules/wikis/spec/features/admin/internal_provider_spec.rb[1:1]`

Treat this as a standalone task, unrelated to PR #23852. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #23852 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @toy to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @toy, and request a review from @toy.
On every commit, set @toy as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants