Skip to content

refactor: introduce separate classes for threads and comments

Tomas Vik requested to merge 317-prepare-threads-and-comments into main

This MR is preparation for #317 (closed). It creates GitLabComment and GitLabThread classes, that are going to serve as models for comments and threads in VS Code MR review.

Design choice

We'll implement the MR comment interactions as methods on the comment and thread classes. The main reason is that we need to heavily conform to the VS Code Extension API, because we don't have a control over the whole commenting life-cycle.

  1. We create a CommentController - the implementation is not ours.
  2. We create a CommentThread - the implementation is not ours.
  3. Then we set commentThread.comments with our implementation of Comment

Then we loose control over what's happening to these models.

When user triggers an action on a thread or a comment, our actions will get CommentThread(VS Code implementation) or GitLabComment (our implementation) as an argument.

These classes then need to be able to handle the action, e.g. GitLabComment.delete()

How to review

The MR is separated into commits that have long comments in their commit messages. I recommend reviewing commit-by-commit.

  1. First commit only restructures tests without changing them
  2. Second commit introduces the GitLabComment class
  3. Third commit is the most involved. It takes large chunks of thread-related functionality from mr_item_model.ts and creates a separate class GitLabThread
  4. Fourth commit adds an integration test
Edited by Tomas Vik

Merge request reports