Skip to content

Add validation for restrictions on work item links

Related to #424880 (closed)

What does this MR do and why?

This MR adds the model validation in RelatedWorkItemLink for the default work item link restrictions (added in !133452 (merged)).

Type Can be related to Can block Can be blocked by
Epic Epic, Issue, Task, Objective, Key Result Epic, Issue, Task, Objective, Key Result Epic, Issue, Task
Issue Epic, Issue, Task, Objective, Key Result Epic, Issue, Task, Objective, Key Result Epic, Issue, Task
Task Epic, Issue, Task, Objective, Key Result Epic, Issue, Task, Objective, Key Result Epic, Issue, Task
Objective Epic, Issue, Task, Objective, Key Result Objective, Key Result Epic, Issue, Task, Objective, Key Result
Key Result Epic, Issue, Task, Objective, Key Result Objective, Key Result Epic, Issue, Task, Objective, Key Result

This validation checks that the types being linked are present in the work_item_related_link_restrictions table and returns an error if they are not. Although there will be existing records for this model, the feature is still behind the FF linked_work_items and not available for GA.

How to set up and validate locally

  1. Using rails console enable the feature flags
Feature.enable(:linked_work_items)
Feature.enable(:okrs_mvc)
  1. Still in rails console create work items of different types
Click to expand
author, project = User.first, Project.first
task_type = WorkItems::Type.find_by(base_type: 'task')
requirement_type = WorkItems::Type.find_by(base_type: 'requirement')
objective_type = WorkItems::Type.find_by(base_type: 'objective')
key_result_type = WorkItems::Type.find_by(base_type: 'key_result')

task = WorkItem.create!(title: "Task", project: project, author: author, work_item_type: task_type)
task = WorkItem.create!(title: "Requirement", project: project, author: author, work_item_type: requirement_type)
objective = WorkItem.create!(title: "Objective", project: project, author: author, work_item_type: objective_type)
key_result = WorkItem.create!(title: "Objective", project: project, author: author, work_item_type: key_result_type)
  1. Visit the task http://GDK_URL/<group_path>/<project_path>/-/work_items/<task_iid> and verify that validation works as expected:

Screen_Recording_2023-10-12_at_15.37.15

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eugenia Grieff

Merge request reports