Add block counts to linked items widget
Related to #416768 (closed)
What does this MR do and why?
This is the following iteration for !126980 (merged) where we added a GraphQL query to expose the items linked to a work item.
Similarly to IssueType, we also want to expose the field blocked
, blockedByCount
and blockingCount
for a work item so these can now be included in the WorkItemWidgetLinkedItems
widget added in !126980 (merged).
Summary of changes
- Extend
LinkedItemsType
to add the EE scoped fieldsblocked
,blocking_count
andblocked_by_count
- Add a new
LazyLinksAggregate
file for work item links. This aggregator is used forblocked
andblocked_by_count
fields - Move
EE::IssueLink
logic toLinkableItem
concern so it can be shared withWorkItems::RelatedWorkItemLink
. This functionality will refresh the blocking count for a work item when a link is created or destroyed (used byblocking_count
field).
I have also included notes inline to explain more specific changes
:linked_work_items
Screenshots or screen recordings
How to set up and validate locally
- Using rails console enable the feature flag
Feature.enable(:linked_work_items)
- Create the work items and links
author, project = User.first, Project.first
wi_type = WorkItems::Type.find_by(base_type: 'task')
task = WorkItem.create!(title: "Source Task", project: project, author: author, work_item_type: wi_type)
blocked_task = WorkItem.create!(title: "Blocked Task", project: project, author: author, work_item_type: wi_type)
blocking_task1 = WorkItem.create!(title: "Blocking Task 1", project: project, author: author, work_item_type: wi_type)
blocking_task2 = WorkItem.create!(title: "Blocking Task 2", project: project, author: author, work_item_type: wi_type)
WorkItems::RelatedWorkItemLink.create!(source: task, target: blocked_task, link_type: 'blocks')
WorkItems::RelatedWorkItemLink.create!(source: blocking_task1, target: task, link_type: 'blocks')
WorkItems::RelatedWorkItemLink.create!(source: blocking_task2, target: task, link_type: 'blocks')
- Visit https://gdk.test:3000/-/graphql-explorer and verify that the following query returns the expected values
query
query getLinkedITems {
workItem(id: "gid://gitlab/WorkItem/NOTE_ID") {
widgets {
...on WorkItemWidgetLinkedItems {
blocked
blockingCount
blockedByCount
linkedItems {
edges {
node {
linkType
workItem {
title
}
}
}
}
}
}
}
}
response
{
"data": {
"workItem": {
"widgets": [
{
"blocked": true,
"blockingCount": 1,
"blockedByCount": 2,
"linkedItems": {
"edges": [
{
"node": {
"linkType": "blocks",
"workItem": {
"title": "Blocked Task"
}
}
},
{
"node": {
"linkType": "is_blocked_by",
"workItem": {
"title": "Blocking Task 1"
}
}
},
{
"node": {
"linkType": "is_blocked_by",
"workItem": {
"title": "Blocking Task 2"
}
}
}
]
}
},
{}
]
}
}
}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Eugenia Grieff