Skip to content

[DREAM-791] Migrate type ordering to sortable-lists - #25586

Open
myabc wants to merge 3 commits into
devfrom
code-maintenance/dream-791-work-package-types-sortable-lists
Open

myabc wants to merge 3 commits into
devfrom
code-maintenance/dream-791-work-package-types-sortable-lists

Conversation

@myabc

@myabc myabc commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Ticket

https://community.openproject.org/wp/DREAM-791

What are you trying to accomplish?

Migrate work package type ordering to sortable-lists while retaining pagination and the existing grouped variant presentation.

What approach did you choose and why?

  • Drag within the visible page using validated relative anchors; dropping first on page 2 stays on page 2.
  • Keep server-backed menu moves global, refresh the current page through morphing, and preserve page context through lazy menus and pagination links.
  • Add header-handle wiring and grouped-list drag feedback. Variants remain alphabetically ordered.

Form configuration is separate in DREAM-859.

AI involvement

Collaborative

Merge checklist

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

@github-actions github-actions Bot added the ai: Directed 🪄 A human specified the requirements and AI implemented most of it; They validated via testing. label Sep 24, 2026
@myabc
myabc requested a lite review from Copilot September 24, 2026 19:48
@myabc
myabc force-pushed the code-maintenance/dream-791-work-package-types-sortable-lists branch from df4892f to beafede Compare September 24, 2026 19:50

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.

Copilot review overview

🟡 Changes recommended

Two moderate findings remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Migrates work package type ordering to the shared sortable-lists system while preserving pagination, grouped variants, and server-backed move actions.

Changes:

  • Adds anchor-based drag ordering and paginated move handling.
  • Updates sortable markup, handles, drag feedback, and pagination context.
  • Expands request, component, controller, and browser coverage.

Two moderate findings remain: legacy group selectors need migration or compatibility support, and single-type rows can still initiate dragging.

File Summary
spec/​requests/​work_package_types/​type_ordering_spec.rb Covers ordering requests and validation.
spec/​features/​types/​variants_index_spec.rb Updates grouped-list browser coverage.
spec/​features/​types/​type_ordering_spec.rb Covers paginated browser ordering.
spec/​controllers/​work_package_types/​types_controller_spec.rb Updates controller ordering expectations.
spec/​components/​work_package_types/​types/​type_actions_component_spec.rb Tests paginated move menus.
spec/​components/​work_package_types/​types/​grouped_list_component_spec.rb Tests sortable markup and context URLs.
spec/​components/​open_project/​common/​border_box_list_component_spec.rb Tests drag-handle argument forwarding.
app/​views/​work_package_types/​types/​index.html.erb Passes pagination context.
app/​models/​type.rb Enables anchor-based ordering.
app/​controllers/​work_package_types/​types_controller.rb Handles paginated drag and menu reordering.
app/​components/​work_package_types/​types/​type_actions_component.rb Preserves pagination in move menus.
app/​components/​work_package_types/​types/​grouped_list_component.sass Adds drag feedback styling.
app/​components/​work_package_types/​types/​grouped_list_component.rb Configures sortable groups and URLs.
app/​components/​work_package_types/​types/​grouped_list_component.html.erb Renders sortable grouped-list markup and pagination.
app/​components/​open_project/​common/​border_box_list_component/​header.rb Supports drag-handle configuration.
app/​components/​open_project/​common/​border_box_list_component/​header.html.erb Forwards drag-handle configuration.
app/​components/​_index.sass Imports sortable-list styles.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread app/components/work_package_types/types/grouped_list_component.rb Outdated
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/notifications/navigation_spec.rb[1:1:1]
  • rspec ./spec/features/projects/creation_wizard/wizard_from_template_flow_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 #25586, linked for reference only):

- `rspec ./spec/features/notifications/navigation_spec.rb[1:1:1]`
- `rspec ./spec/features/projects/creation_wizard/wizard_from_template_flow_spec.rb[1:1]`

Treat this as a standalone task, unrelated to PR #25586. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #25586 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 @myabc 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 @myabc, and request a review from @myabc.
On every commit, set @myabc 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.

@myabc
myabc marked this pull request as ready for review September 25, 2026 07:29
@myabc myabc added this to the 18.0.x milestone Sep 25, 2026
Base automatically changed from code-maintenance/dream-789-enumerations-sortable-lists to dev September 25, 2026 07:53
@myabc
myabc requested a review from bsatarnejad September 25, 2026 11:31
@lwassermann
lwassermann self-requested a review September 28, 2026 10:32

@lwassermann lwassermann 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.

There seems to be something broken with the expansion. Dragging around some items closes all unfolded Types. Be they dragged or just other elements in the list. That feels quite annoying. Is there something we could do about that?

Reloading the page also closes everything and also feels annoying. Expanding is just not added to the URL 😅

We do have list_id in the sortable list params. But still we handle the page_args separately in the links. That feels like we have two different ways to handling the same problem. Scoping the list we're operating in. Maybe they belong together?

Some small comments, but nothing that should block this from being rolled out 👍 💯

form_arguments: { method: :post }
tag: :button,
href: move_types_path(type, **page_args, expand: expanded_type_id),
form_arguments: { method: :post, inputs: [{ name: "type[move_to]", value: move_to.to_s }] }

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.

Am I right in assuming that we can't use SortableList::MoveMenu here because of the additional page_args and expanded_type_id arguments? Or is it the first/last detection that is limited for paginated lists?

@myabc myabc Sep 30, 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.

Right — SortableLists::MoveMenu works out availability and moves from the visible DOM siblings, so it can't move across pages. Paginated statuses use the same server-backed menu approach. Menus now carry page and expansion context (91023d0).

(Server-backed move menus are hand-rolled in statuses, types, project phase definitions, CF hierarchy items and backlogs. A sibling SortableLists::ServerMoveMenu mixin could share the directions and gating; I'll fold that into the helpers follow-up.)

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.

FYI, I've created DREAM-880 for this.

Comment thread app/controllers/work_package_types/types_controller.rb Outdated
Comment thread app/controllers/work_package_types/types_controller.rb Outdated
params[:list_type] == ::Type.model_name.param_key &&
(params[:list_id].nil? || params[:list_id] == "") &&
params.key?(:prev_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.

This check and the surrounding methods seem to exist wherever we use sortable_lists. Even if we do copy them out or overwrite them in some controllers, I feel like we should create helpers for these. I was already tempted on my PR. Seeing it here again reinforces that feeling. But that is probably out of scope for this PR, because of how many places it would already change.

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.

Good point. I'll add a work package for this.

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.

Added DREAM-879.

Comment thread app/controllers/work_package_types/types_controller.rb Outdated
Comment thread spec/components/work_package_types/types/type_actions_component_spec.rb Outdated
Comment thread spec/features/types/type_ordering_spec.rb Outdated
Comment thread spec/features/types/type_ordering_spec.rb Outdated
Comment thread spec/features/types/type_ordering_spec.rb Outdated
Comment thread spec/requests/work_package_types/type_ordering_spec.rb Outdated
Adds a drag_handle_arguments option to the Border Box list header and
forwards it to the Primer drag handle, so sortable lists can mark the
header handle as their drag target without wrapping the header.

https://community.openproject.org/wp/DREAM-791
@myabc
myabc force-pushed the code-maintenance/dream-791-work-package-types-sortable-lists branch from bfe7ddd to f0d7561 Compare September 30, 2026 20:35
@myabc
myabc requested a review from lwassermann September 30, 2026 20:36
Comment thread app/controllers/work_package_types/types_controller.rb Fixed
Replaces the generic drag-and-drop wiring on the type index with
sortable lists. Drops are validated relative anchors; a blank anchor
places the type at the start of the current page, so dragging on
later pages stays on that page. The list morphs in place and keeps
page and expansion context in its drop URL and pagination links.
A lone type is fixed in place.

Moves the type index feature specs onto the page object, which finds
groups by exact title.

https://community.openproject.org/wp/DREAM-791
Carries page and expansion context into the lazy type menus and posts
menu moves with it. Moves stay global, and the server now answers with
a morph of the current page instead of redirecting to the first page.
Removes the unused type_move permitted parameter.

https://community.openproject.org/wp/DREAM-791
@myabc
myabc force-pushed the code-maintenance/dream-791-work-package-types-sortable-lists branch from f0d7561 to 91023d0 Compare September 30, 2026 21:06
@myabc myabc added maintenance ruby Pull requests that update Ruby code needs review and removed DO NOT MERGE labels Sep 30, 2026
@github-actions github-actions Bot added ai: Collaborative 💻 AI generated a substantial part of the code; A human reviewed and understands every line. and removed ai: Directed 🪄 A human specified the requirements and AI implemented most of it; They validated via testing. labels Sep 30, 2026

This branch has not been deployed

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

Labels

ai: Collaborative 💻 AI generated a substantial part of the code; A human reviewed and understands every line. maintenance needs review ruby Pull requests that update Ruby code

Development

Successfully merging this pull request may close these issues.

4 participants