Skip to content

Delete task from work item API

Mario Celi requested to merge 346132-work-item-delete-task into master

What does this MR do and why?

Related to #346132 (closed)

Specialized mutation to remove a task from a task list in an issue's description. User need to have permission to update the issue and to delete the work item. If user allowed to perform the operation, the mutation should remove the task list item from the description, delete the task from the DB and the associated issue link should also be deleted via cascade.

How to set up and validate locally

  1. Run bundle exec rails console
  2. Run Feature.enable(:work_items)
  3. Create a work item (issue) with a task list in the description. Use the convert to work item button next to the checkbox. Inspect the task list to find line start and end in the data-sourcepos attribute
  4. Execute a GraphQL query like
mutation {
  workItemDeleteTask(
    input: {
      # id of the issue holding the task list in the description
      id: "gid://gitlab/WorkItem/1",
      # lock version should be the current lock version of the work item
      lockVersion: 2,
      # id of the newly created work item
      taskData: { id: "gid://gitlab/WorkItem/2", lineNumberStart: 1, lineNumberEnd: 1 }
    }
  ) {
    workItem {
      id
      description
    }
  }
}

MR acceptance checklist

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

Related to #346132 (closed)

Edited by Mario Celi

Merge request reports

Loading