Skip to content

Fix sprint menu permissions#22507

Closed
myabc wants to merge 1 commit into
devfrom
fix/sprint-menu-permissions
Closed

Fix sprint menu permissions#22507
myabc wants to merge 1 commit into
devfrom
fix/sprint-menu-permissions

Conversation

@myabc

@myabc myabc commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Note

This fix has been extracted from #22478

Ticket

n/a

What are you trying to accomplish?

Align sprint menu permissions with controller mutability rules.

This hides sprint mutation actions when a sprint is only visible through work package references - thus ensuring the UI no longer advertises operations the controllers will reject.

Screenshots

n/a

What approach did you choose and why?

Merge checklist

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

Copilot AI review requested due to automatic review settings March 25, 2026 17:38
Comment thread modules/backlogs/app/components/backlogs/sprint_menu_component.rb Outdated
@myabc myabc requested a review from ulferts March 25, 2026 17:42

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

Aligns the Backlogs sprint action menu with sprint “mutability” in the context of sprint sharing vs. sprints that are merely visible via work package references, so the UI doesn’t advertise sprint mutations that shouldn’t be offered.

Changes:

  • Gate “Start sprint” / “Finish sprint” actions behind a new mutable_sprint_in_project? check.
  • Gate “Edit sprint” behind show_edit_sprint_action? and update the template to use it.
  • Add a component spec covering the “visible only via work package references” scenario (mutation actions hidden).

Reviewed changes

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

File Description
modules/backlogs/spec/components/backlogs/sprint_menu_component_spec.rb Adds coverage asserting mutation actions are hidden when a sprint is only visible via WP references.
modules/backlogs/app/components/backlogs/sprint_menu_component.rb Introduces mutable_sprint_in_project? and uses it to conditionally show mutation actions.
modules/backlogs/app/components/backlogs/sprint_menu_component.html.erb Switches edit action visibility check to show_edit_sprint_action?.

end

def show_edit_sprint_action?
mutable_sprint_in_project? && user_allowed?(:create_sprints)

Copilot AI Mar 25, 2026

Copy link

Choose a reason for hiding this comment

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

show_edit_sprint_action? checks :create_sprints in the rendered project, but sprint mutations are authorized against the sprint's owning project (Sprints::BaseContract#user_authorized uses model.project). For shared sprints this can surface an “Edit sprint” action that will fail with :error_unauthorized. Consider aligning the menu with the mutation contract by checking current_user.allowed_in_project?(:create_sprints, sprint.project) (and/or using the relevant contract helper).

Suggested change
mutable_sprint_in_project? && user_allowed?(:create_sprints)
mutable_sprint_in_project? &&
current_user.allowed_in_project?(:create_sprints, sprint.project)

Copilot uses AI. Check for mistakes.
Comment thread modules/backlogs/app/components/backlogs/sprint_menu_component.rb Outdated
Hides the Move submenu and its divider entirely
when `show_move_items?` is false, rather than
rendering them in a disabled state.

Also memoizes `mutable_sprint_in_project?` in
`SprintMenuComponent` to avoid repeated queries,
and strengthens the referenced-sprint spec to test
each status branch meaningfully.
@myabc myabc force-pushed the fix/sprint-menu-permissions branch from c37e960 to 36a6634 Compare March 25, 2026 17:49
@myabc myabc closed this Jun 25, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants