stable
Clone or download
part of story #31091 Add the hybrid comment to manage comments This contribution aims to simplify the types definitions for the different kinds of PullRequestPresenters. How did we get here? We have several types of items to display as comments having different shapes: - timeline items: GlobalComment vs CommentOnFile vs ActionOnPullRequestEvent - file-diff inline comments We do not want to display them the same everywhere: - In the timeline we display the file in the header for CommentOnFiles - In the file-diff view, we don't - An ActionOnPullRequestEvent cannot be a thread Some info are required to be able to save a reply: - unidiff_offset, file_path, position etc. - user_id How to reduce the complexity? Since we can differentiate the different types of comments by comparing their types with the list of SupportedTimelineItemTypes, we can get rid of is_inline_comment. By reworking the type CommonComment, we are now able to have cleaner presenters: - file is now an exclusive attribute of the PullRequestInlineCommentPresenter type, it is not optional anymore - We no longer have unidiff_offset, position, file_path and is_file_diff_comment polluting the types. Before this patch, there were too much "file-diff" logic in the component. Since the comment component is in a shared lib, there is no reason to keep it in there. Now, to display a comment in the file-diff view, we build a PullRequestInlineCOmmentPresenter, and that's it. In the meantime, I've added some additional steps after a reply has been saved: When we receive the payload from the REST route, it does not have necessarily the right form, and a conversion from a NewComment to a PullRequestComment is needed to avoid having presenters with empty attributes. How to test: - No functional changes expected in: --> The angular overview --> The vue overview --> The file-diff view in sbs AND unidiff modes Which means: - In overviews: --> comments on files have the file displayed --> The link to the comment in the file works as usual --> You can reply to any comment --> You can post global comments --> Pullrequests events are displayed properly - In the [Changes] tab --> You can post new comments --> The comments have the right place --> The diffs are displayed properly Change-Id: I2de072056e19fd3667fe5f512d5466a461ee3482
Modified Files
Name | ||||
---|---|---|---|---|
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentBodyTemplate.test.ts | +2 | −2 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentBodyTemplate.ts | +12 | −2 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentController.test.ts | +23 | −28 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentFooterTemplate.test.ts | +6 | −6 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentPresenter.test.ts | +39 | −8 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentPresenter.ts | +40 | −21 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentRepliesStore.test.ts | +11 | −23 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentReplySaver.test.ts | +74 | −58 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/src/comment/PullRequestCommentReplySaver.ts | +25 | −30 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/tests/stubs/PullRequestCommentPresenterStub.ts | +18 | −26 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/pullrequest-comments/tests/stubs/SaveNewReplyToCommentStub.ts | +10 | −1 | Go to diff View file |
M | plugins/pullrequest/scripts/lib/rest-api-types/src/post-comments.ts | +3 | −3 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequest-overview/src/components/Threads/CommentPresenterBuilder.test.ts | +1 | −8 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequest-overview/src/components/Threads/CommentPresenterBuilder.ts | +23 | −23 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/comments/PullRequestCommentPresenterBuilder.test.ts | +27 | −24 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/comments/PullRequestCommentPresenterBuilder.ts | +38 | −32 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/code-collapse/collapsible-code-sections-builder.test.ts | +12 | −4 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/code-collapse/collaspible-code-sections-builder.ts | +1 | −1 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/side-by-side-diff-component.js | +3 | −1 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/diff-modes/unidiff-component.js | +4 | −2 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/file-lines/SideBySideLineState.ts | +1 | −1 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/scroll-to-comment/FileDiffCommentScroller.test.ts | +33 | −20 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/scroll-to-comment/FileDiffCommentScroller.ts | +25 | −24 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/scroll-to-comment/FileDiffCommentWidgetsMap.test.ts | +1 | −3 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/file-diff/widgets/SideBySideCodeMirrorWidgetsCreationManager.ts | +3 | −3 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/src/app/overview/timeline/timeline-service.js | +2 | −6 | Go to diff View file |
M | plugins/pullrequest/scripts/pullrequests-app/tests/stubs/PullRequestCommentPresenterStub.ts | +11 | −21 | Go to diff View file |