Use branch targets in the work item merge request modal

What does this MR do and why?

Use branch targets in the work item merge request modal

The create merge request flow in the work item development widget now suggests a target branch from the project's branch targets, matching the behaviour of the new merge request page. The lookup runs when the modal opens and whenever the source branch name changes, and is skipped in the create branch flow, where the ref is the source of the new branch.

Move the branch finder out of the pages directory, now that it has a second caller, and build its path from the generated route helper rather than reading a permission gated path from the DOM. The client cannot know whether the user is entitled to branch targets, so the index action responds with an empty target branch instead of a 404, which is what both callers already treat as nothing to apply.

References

#602567 (closed)

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. On a project with a Premium or Ultimate license, create a develop branch, then add a branch target in Settings > Merge requests > Branch targets with a name that matches the branch name you will use and target branch develop.
  2. Open an issue and change the branch name to match the target just created.
  3. The Target branch field is pre-filled with develop when the modal opens. Editing the source branch name to something that no longer matches resets it to the project default branch, the same as the new merge request page.
  4. Choose Create branch instead and confirm the Source (branch or tag) field is left alone while typing a branch name.
  5. Visit /-/merge_requests/new on the same project and confirm selecting a source branch still applies the branch target as before.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading