Skip to content

Add updateImageDiffNote mutation to reposition notes on images

Luke Duncalfe requested to merge 207334-reposition_note_graphql into master

What does this MR do?

This MR adds a new repositionImageDiffNote mutation which allows repositioning a DiffNote on an image.

It uses the special reposition_note permission introduced in !45957 (merged), which is an alias of admin_note unless the noteable is a Design, in which case it will be true if the user can create_note. This allows people who can comment on a Design to reposition the notes of other people, but for other noteables, only the author of the note or maintainer could reposition it.

The mutation is written to allow it to be used for DiffNotes on images for all noteables and not just Designs.

GraphQL changes

Adds a new note.userPermissions.repositionNote property to check for whether a user can reposition a note.

Adds a new mutation to reposition the note called repositionImageDiffNote.

It takes:

  • id (required)
  • position: (required)
    • x (optional)
    • y (optional)
    • width (optional)
    • height (optional)

And returns:

  • errors
  • note

Example:

mutation {
  repositionImageDiffNote(input: { id: "gid://gitlab/DiffNote/1588", position: { x: 50, y: 100 } }) {
    errors
    note {
      id
    }
  }
}

QA

First, add a note to a design.

Using GraphiQL http://127.0.0.1:3001/-/graphql-explorer, inspect the note that was created:

{
  project(fullPath: "root/my-project") {
    issue(iid: "1") {
      designCollection {
        designs {
          nodes {
            notes {
              nodes {
                id
                position {
                  x
                  y
                }
              }
            }
          }
        }
      }
    }
  }
}

Then, use the id of the note to reposition it.

mutation {
  repositionImageDiffNote(input: { id: "gid://gitlab/DiffNote/1", position: { x: 50, y: 100 } }) {
    errors
    note {
      id
    }
  }
}

Reload the design in your browser and the note should be repositioned.

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Luke Duncalfe

Merge request reports

Loading