Fetch work item to-do items in their own query

What does this MR do and why?

To-do items were part of the work item detail query even though a logged-out visitor can never have any. This moves them into a dedicated query owned by a new WorkItemTodosWidget, which skips the request entirely when the user isn't signed in. The detail query keeps only currentUserTodos { type }, which costs nothing now that the widget accessors are free, and is what the toolbar gates on.

Implementation notes

Here's a high level summary of what this MR does:

  • We've split the currentUserTodos widget from base work item query to its own query and subscription.
  • When page loads and if user is logged in, namespaceWorkItem would fetch only type for this widget, which is returned only if widget is supported on a given work item type, this also controls widget visibility like it used to in master.
  • The work_items/components/work_item_todos_widget.vue component now owns its query & subscription to fetch todo state for current user, as well as observes work item for any changes to todo state (eg; usage of /todo or /done quick actions by same user from anywhere else).
    • Having a subscription ensures that real-time behaviour or component remains intact even after query has split.
  • If you enabled work_item_features_field flag globally on GDK and access any work item anonymously, you'd still see the error Work Item not found as this MR alone won't solve that issue, it is part of a series of MRs where we're splitting widgets into their own queries.
    • currentUserTodos - This MR
    • linkedResources - !252578 (merged)
    • crmContacts - !252569 (merged)
    • Only after all 3 MRs get merged is when we'll be able to access work items anonymously with FF enabled globally, assuming something else isn't added to main query again to breach complexity. 😬

References

Screenshots or screen recordings

Logged In Anonymous

How to set up and validate locally

  1. Enable the flag with Feature.enable(:work_item_features_field).
  2. Open a work item and confirm the to-do toggle renders with the correct label.
  3. Toggle it and confirm in the network tab that only workItemUpdateCurrentUserTodos fires, with no namespaceWorkItem or workItemCurrentUserTodos refetch.
  4. Reload and confirm the state persisted.
  5. Sign out, open a public work item, and confirm workItemCurrentUserTodos is never requested.
    • Note that we're still not under the query limit so while being signed-out, you'll still see namespaceWorkItem query to fail with Query has complexity of 217, which exceeds max complexity of 200 error, but you only need to verify that workItemCurrentUserTodos is not called.
  6. Repeat signed in with the flag disabled to check the widgets path.

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 Kushal Pandya

Merge request reports

Loading
Loading