Add CurrentUserTodos widget
What does this MR do and why?
Related issue: #393784 (closed)
This adds the CurrentUserTodos
widget to query all the todos for the current user for the given Work Item.
Database
Migrate
rails db:migrate:up:main VERSION=20230317162059
WARNING: This version of GitLab depends on gitlab-shell 14.18.0, but you're running 14.17.0. Please update gitlab-shell.
main: == 20230317162059 AddCurrentUserTodosWorkItemWidget: migrating ================
main: == 20230317162059 AddCurrentUserTodosWorkItemWidget: migrated (0.0285s) =======
bin/rails c
pry(main)> WorkItems::WidgetDefinition.where(widget_type: "current_user_todos")
WorkItems::WidgetDefinition Load (0.5ms) SELECT "work_item_widget_definitions".* FROM "work_item_widget_definitions" WHERE "work_item_widget_definitions"."widget_type" = 15 /*application:console,db_config_name:main,console_hostname:MacBook-GitLab.local,console_username:nicolas,line:bin/rails:4:in `<main>'*/
=> [#<WorkItems::WidgetDefinition:0x000000013b935f08 id: 394, namespace_id: nil, work_item_type_id: 1, widget_type: "current_user_todos", disabled: false, name: "Current user todos">,
#<WorkItems::WidgetDefinition:0x000000013b96ec90 id: 395, namespace_id: nil, work_item_type_id: 2, widget_type: "current_user_todos", disabled: false, name: "Current user todos">,
#<WorkItems::WidgetDefinition:0x000000013b96ebc8 id: 396, namespace_id: nil, work_item_type_id: 3, widget_type: "current_user_todos", disabled: false, name: "Current user todos">,
#<WorkItems::WidgetDefinition:0x000000013b96eb00 id: 397, namespace_id: nil, work_item_type_id: 4, widget_type: "current_user_todos", disabled: false, name: "Current user todos">,
#<WorkItems::WidgetDefinition:0x000000013b96ea38 id: 398, namespace_id: nil, work_item_type_id: 5, widget_type: "current_user_todos", disabled: false, name: "Current user todos">,
#<WorkItems::WidgetDefinition:0x000000013b96e920 id: 399, namespace_id: nil, work_item_type_id: 3186, widget_type: "current_user_todos", disabled: false, name: "Current user todos">,
#<WorkItems::WidgetDefinition:0x000000013b96e858 id: 400, namespace_id: nil, work_item_type_id: 3187, widget_type: "current_user_todos", disabled: false, name: "Current user todos">]
Rollback
rails db:migrate:down:main VERSION=20230317162059
WARNING: This version of GitLab depends on gitlab-shell 14.18.0, but you're running 14.17.0. Please update gitlab-shell.
main: == 20230317162059 AddCurrentUserTodosWorkItemWidget: reverting ================
main: == 20230317162059 AddCurrentUserTodosWorkItemWidget: reverted (0.0130s) =======
bin/rails c
WorkItems::WidgetDefinition.where(widget_type: "current_user_todos")
WorkItems::WidgetDefinition Load (0.4ms) SELECT "work_item_widget_definitions".* FROM "work_item_widget_definitions" WHERE "work_item_widget_definitions"."widget_type" = 15 /*application:console,db_config_name:main,console_hostname:MacBook-GitLab.local,console_username:nicolas,line:bin/rails:4:in `<main>'*/
=> []
Screenshots or screen recordings
Screen_Recording_2023-03-22_at_15.30.30
How to set up and validate locally
-
Feature.enable(:multiple_todos)
if you want to test with multiple todos for a work item - Create an Issue, OKR, or any other work item (like Tasks) and get the global Work Item ID (works also with Issues, see screen recording)
- Add todos by for example assigning you on the Work Item, or ping you by [at] mentioning yourself
- Use the following GraphQL queries and mutations to test the feature with the WorkItem ID: (http://gdk.test:3000/-/graphql-explorer)
query pendingTodos {
workItem(id: "gid://gitlab/WorkItem/740") {
id
workItemType {
id
name
}
widgets {
... on WorkItemWidgetCurrentUserTodos {
currentUserTodos(state:pending) {
edges {
node {
id
state
}
}
}
}
}
}
}
query doneTodos {
workItem(id: "gid://gitlab/WorkItem/740") {
id
workItemType {
id
name
}
widgets {
... on WorkItemWidgetCurrentUserTodos {
currentUserTodos(state:done) {
edges {
node {
id
state
}
}
}
}
}
}
}
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 Nicolas Dular