// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "ReviewComments.generated.h" class FJsonObject; UENUM() enum class EReviewCommentTaskState : uint8 { // regular comment (not a task) Comment, // unaddressed task Open, // completed task Addressed, // verified completed task (documentation is limited so I'm not positive on this one) Verified, }; // swarm stores shelved file reviews separately from comments on submitted CLs UENUM() enum class EReviewTopicType : uint8 { // shelved for review Review, // change is already submitted Change, // this should never happen Unrecognised }; struct KISMET_API FReviewCommentContext { public: // file being commented on TOptional File; // what version of the file this comment is associated with TOptional Version; // (text only) preview of text being commented on TOptional> Content; // (text only) line number on left panel of this comment TOptional LeftLine; // (text only) line number on right panel of this comment TOptional RightLine; // id of the comment that this one is replying to TOptional ReplyTo; // category this comment will appear under in the diff results TOptional Category; FString ToJson() const; TSharedPtr ToJsonObject() const; static FReviewCommentContext FromJson(const FString& Json); static FReviewCommentContext FromJson(const TSharedPtr& JsonObject); }; struct KISMET_API FReviewTopic { public: FString ChangelistNum; EReviewTopicType TopicType; // returns topic in format "TopicType/ChangelistNum" FString ToString() const; static FReviewTopic FromString(const FString& ReviewTopic); bool operator==(const FReviewTopic& Other) const { return ChangelistNum == Other.ChangelistNum; } }; inline uint32 GetTypeHash(const FReviewTopic& Topic) { return GetTypeHash(Topic.ChangelistNum); } struct KISMET_API FReviewComment { public: // info about CL being commented on TOptional Topic; // unique id associated with this comment TOptional CommentID; // the comment text TOptional Body; // names of all users who have liked this comment TOptional> Likes; // names of all users who have marked the comment as read TOptional> ReadBy; // signifies whether this is a task and if it's been addressed TOptional TaskState; // comment author TOptional User; // when the comment was created TOptional CreatedTime; // when the comment was last edited TOptional EditedTime; // when the comment was created TOptional UpdatedTime; // metadata about the comment FReviewCommentContext Context; // flags bool bIsClosed : 1 = false; FString ToJson() const; TSharedPtr ToJsonObject() const; static FReviewComment FromJson(const FString& Json); static FReviewComment FromJson(const TSharedPtr& JsonObject); }; class KISMET_API IReviewCommentAPI : public TSharedFromThis { public: DECLARE_DELEGATE_TwoParams(OnGetCommentsComplete, const TArray&, const FString& /*ErrorMessage*/) DECLARE_DELEGATE_TwoParams(OnPostCommentComplete, const FReviewComment&, const FString& /*ErrorMessage*/) DECLARE_DELEGATE_TwoParams(OnEditCommentComplete, const FReviewComment&, const FString& /*ErrorMessage*/) DECLARE_DELEGATE_TwoParams(OnGetReviewTopicForCLComplete, const FReviewTopic&, const FString& /*ErrorMessage*/) virtual ~IReviewCommentAPI() = default; // returns the name of the user logged in virtual FString GetUsername() const = 0; virtual void GetComments(const FReviewTopic& Topic, const OnGetCommentsComplete& OnComplete) const = 0; // Body must be set; username will get set by PostComment virtual void PostComment(FReviewComment& Comment, const OnPostCommentComplete& OnComplete, bool bSilenceNotification = false) const = 0; // all unset members will be left unchanged. virtual void EditComment(const FReviewComment& Comment, const OnEditCommentComplete& OnComplete, bool bSilenceNotification = false) const = 0; // retrieves the review associated with a CL. virtual void GetReviewTopicForCL(const FString &ChangelistNum, const OnGetReviewTopicForCLComplete& OnComplete) const = 0; // retrieves the review associated with a CL. If there is none, it creates a new review and returns that. virtual void GetOrCreateReviewTopicForCL(const FString &ChangelistNum, const OnGetReviewTopicForCLComplete& OnComplete) const = 0; };