Set correct parent for legacy epic and sync relative_position
What does this MR do and why?
Fixes an issue when creating a new epic work item underneath an epic
where it did not set the parent_id
correctly for legacy epics.
We can't rely on the WorkItems::ParentLinks::CreateService
to set the parent_id
and relative_position
because the Epic record
does not exist at that time.
Instead of creating the epic record before the work item, we now set the
parent_id
and relative_position
based on the ParentLink of the work
item on creation.
It also fixes an issue with not correctly setting the relative_position
when creating issues or assigning existing issues/epics within a work
item. This was because we call relate_issuables
to move the issuable
to the bottom of the list but didn't adjust the relative_position
on the legacy EpicIssue
or Epic
.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
before | after |
How to set up and validate locally
- Enable/Disable the following feature flags:
Feature.enable(:namespace_level_work_items)
Feature.enable(:sync_work_item_to_epic)
Feature.disable(:make_synced_work_item_read_only)
- Create a new epic (it will create a work item epic)
- Create/assign issues and epics in the hierarchy
- Go to the legacy epic by replacing
/work_items/
with/epics
in the URL - Make sure all items are listed and in the correct order