/// <inheritdoc/>
 public async Task AddComment(IPullRequestReviewCommentModel comment)
 {
     PullRequest.ReviewComments = PullRequest.ReviewComments
                                  .Concat(new[] { comment })
                                  .ToList();
     await Update(PullRequest);
 }
Exemplo n.º 2
0
        async Task ReplaceComment(IPullRequestReviewCommentModel comment)
        {
            PullRequest.ReviewComments = PullRequest.ReviewComments
                                         .Select(model => model.Id == comment.Id ? comment: model)
                                         .ToList();

            await Update(PullRequest);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PullRequestReviewCommentViewModel"/> class.
 /// </summary>
 /// <param name="session">The pull request session.</param>
 /// <param name="thread">The thread that the comment is a part of.</param>
 /// <param name="currentUser">The current user.</param>
 /// <param name="model">The comment model.</param>
 public PullRequestReviewCommentViewModel(
     IPullRequestSession session,
     ICommentThreadViewModel thread,
     IAccount currentUser,
     IPullRequestReviewCommentModel model)
     : this(session, thread, currentUser, model.Id, model.NodeId, model.Body, CommentEditState.None, model.User, model.CreatedAt, model.IsPending)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CommentViewModel"/> class.
 /// </summary>
 /// <param name="thread">The thread that the comment is a part of.</param>
 /// <param name="currentUser">The current user.</param>
 /// <param name="model">The comment model.</param>
 public InlineCommentViewModel(
     ICommentThreadViewModel thread,
     IAccount currentUser,
     IPullRequestReviewCommentModel model)
     : base(thread, currentUser, model)
 {
     CommitSha = model.OriginalCommitId;
     DiffLine  = model.OriginalPosition.Value;
 }
Exemplo n.º 5
0
        public PullRequestReviewFileCommentViewModel(
            IPullRequestEditorService editorService,
            IPullRequestSession session,
            IPullRequestReviewCommentModel model)
        {
            Guard.ArgumentNotNull(editorService, nameof(editorService));
            Guard.ArgumentNotNull(session, nameof(session));
            Guard.ArgumentNotNull(model, nameof(model));

            this.editorService = editorService;
            this.session       = session;
            this.model         = model;

            Open = ReactiveCommand.CreateAsyncTask(DoOpen);
        }
Exemplo n.º 6
0
        static PullRequestReviewCommentViewModel CreateTarget(
            IPullRequestSession session    = null,
            ICommentThreadViewModel thread = null,
            IAccount currentUser           = null,
            IPullRequestReviewCommentModel pullRequestReviewCommentModel = null)
        {
            session = session ?? CreateSession();
            thread  = thread ?? CreateThread();

            currentUser = currentUser ?? Substitute.For <IAccount>();
            pullRequestReviewCommentModel = pullRequestReviewCommentModel ?? Substitute.For <IPullRequestReviewCommentModel>();

            return(new PullRequestReviewCommentViewModel(
                       session,
                       thread,
                       currentUser,
                       pullRequestReviewCommentModel));
        }
Exemplo n.º 7
0
 public PullRequestReviewCommentCacheItem(IPullRequestReviewCommentModel comment)
 {
     Id     = comment.Id;
     NodeId = comment.NodeId;
     PullRequestReviewId = comment.PullRequestReviewId;
     Path             = comment.Path;
     Position         = comment.Position;
     OriginalPosition = comment.OriginalPosition;
     CommitId         = comment.CommitId;
     OriginalCommitId = comment.OriginalCommitId;
     DiffHunk         = comment.DiffHunk;
     User             = new AccountCacheItem
     {
         Login     = comment.User.Login,
         AvatarUrl = comment.User.AvatarUrl,
     };
     Body      = comment.Body;
     CreatedAt = comment.CreatedAt;
     IsPending = comment.IsPending;
 }