Show a toast when a milestone is deleted

What does this MR do and why?

Shows a "Milestone deleted." toast after a milestone is deleted, from either the milestones list or a milestone detail page, for both project and group milestones. Today the user gets no success feedback; the milestone just disappears from the list.

Root cause of the missing feedback being non-trivial: the delete modal removes the milestone with an XHR (axios.delete) and the browser transparently follows the controller's HTML redirect. That intermediate response renders the full milestones index, which consumes any flash message, and the page the user actually sees is a second, fresh fetch of the same URL (visitUrl(response.request.responseURL)). A plain flash[:toast] in the destroy action would never survive to the user.

The fix:

  • Both destroy actions set flash[:toast] and gain a format.json response returning the milestones index as redirect_url.
  • The delete modal requests JSON and navigates to the returned URL. Nothing renders in between, so the flash survives and the layout's existing toast mechanism (.js-toast-message) shows it on arrival.
  • Side benefit: the milestones index is now fetched once instead of twice per deletion.
  • The legacy format.js { head :ok } responses are removed from both destroy actions: nothing requests them (the Vue modal replaced the UJS flow; no remote: true milestone links or script-format callers exist in app code or specs). Removing them is also what makes setting the flash once above respond_to safe; with the js format kept, a head :ok response would leave a stale toast that pops on the user's next page load.

Consumer audit: delete_milestone_modal.vue (used by more_actions_dropdown.vue on both list and detail pages) is the only caller of the XHR flow; EE extends only search_params on the group controller, not destroy.

The end-to-end behavior (modal, JSON delete, navigation, toast rendered) is covered by spec/features/milestones/user_deletes_milestone_spec.rb in both project and group contexts, plus html/json controller examples and the component spec.

References

Screenshots or screen recordings

View Before After
Project milestones project_milestone_deleted_index project_milestone_deleted_index
Group milestones group_milestone_deleted_index group_milestone_deleted_index

How to set up and validate locally

  1. In any project or group, create a milestone (Plan > Milestones > New milestone).
  2. From the milestones list or the milestone's page, open Milestone actions and select Delete, then confirm with Delete milestone.
  3. After redirect to the milestones list, a "Milestone deleted." toast appears bottom-left.

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.

Edited by Paul W

Merge request reports

Loading
Loading