Trigger epic dates update when adding or removing a child epic
What does this MR do and why?
Related to #459990 (closed)
When changing an epic's hierarchy we need to call Epics::UpdateDatesService
to recalculate the epic's date. This call is currently missing when adding or removing a single child epic (it only works when adding multiple child epics) so this MR fixes that.
Also, this MR adds a condition in the places where we're calling this service, to skip the call if the epic is being synced because in that case the dates are updates along the work item in WorkItems::Widgets::RolledupDatesService::HierarchyUpdateService
Summary of changes:
- Refactor the
Epics::UpdateDatesService
call inEE:IssuableLinks::CreateService
to move the condition to a separate methodskip_epic_dates_update?
. - Override this new method in
EpicIssues::CreateService
andEpicLinks::CreateService
to not call the dates service if the epic is being synced to the work item (andwork_items_rolledup_dates
FF is enabled - context: !151751 (comment 1900410272)) - Update
EpicLinks::CreateService
to also update the epic dates when a single child epic is added. This was missing because the method that calls this servicelink_issuables
is not used when linking a single child. For this case, the dates service is called fromupdate_inherited_dates
, which contains the abovementioned condition. - Update
EpicLinks::DestroyService
to callEpics::UpdateDatesService
when a child is removed. This was missing for child epics but already implemented for child issues inEpicIssues::DestroyService#after_destroy
and the condition to skip the call when syncing was added in !151356 (merged)
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
Screen_Recording_2024-05-07_at_15.39.24
How to set up and validate locally
- Create an epic Parent Epic and update its dates to inherited
- Create an additional epic Child Epic [May] and change its dates to fixed setting start date as
May 1st
and the end date asMay 31st
. - Add this epic as a child of Parent Epic and verify that the parent dates are set to May (requires reloading the page)
- Finally, remove the child and verify that the parent's dates are updated to None.
To verify that Epics::UpdateDatesService
is skipped when syncing the epic, visit the work item view http://gdk.test:3000/groups/GROUP_PATH/-/work_items/PARENT_EPIC_IID
and repeat the same steps but this time check that WorkItems::RolledupDates::UpdateRolledupDatesWorker
is called instead.