1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02:00

Improve display of "Added Reviewers" and "Added CCs" in Differential, link diffs

Summary:
When a comments add reviewers or CCs, we just dump that sort of nastily into the
body. Put it in the header like Maniphest instead.

Also, record the diff associated with "update" actions and link to it (T871).

Test Plan: {F8546} {F8547}

Reviewers: btrahan, davidreuss

Reviewed By: davidreuss

CC: aran, epriestley

Maniphest Tasks: T871

Differential Revision: https://secure.phabricator.com/D1659
This commit is contained in:
epriestley 2012-02-22 08:03:48 -08:00
parent e48b290094
commit 17965cc8be
4 changed files with 55 additions and 31 deletions

View file

@ -663,7 +663,11 @@ class DifferentialRevisionEditor {
->setAuthorPHID($this->getActorPHID())
->setRevisionID($revision_id)
->setContent($this->getComments())
->setAction('update');
->setAction(DifferentialAction::ACTION_UPDATE)
->setMetadata(
array(
DifferentialComment::METADATA_DIFF_ID => $this->getDiff()->getID(),
));
if ($this->contentSource) {
$comment->setContentSource($this->contentSource);

View file

@ -1,7 +1,7 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,6 +20,7 @@ class DifferentialComment extends DifferentialDAO {
const METADATA_ADDED_REVIEWERS = 'added-reviewers';
const METADATA_ADDED_CCS = 'added-ccs';
const METADATA_DIFF_ID = 'diff-id';
protected $authorPHID;
protected $revisionID;

View file

@ -29,7 +29,7 @@ class DifferentialChangesetListView extends AphrontView {
private $symbolIndexes = array();
private $repository;
private $diff;
private $vsMap;
private $vsMap = array();
public function setChangesets($changesets) {
$this->changesets = $changesets;

View file

@ -127,12 +127,6 @@ final class DifferentialRevisionCommentView extends AphrontView {
$info = implode(' &middot; ', array_filter($info));
$author = $this->handles[$comment->getAuthorPHID()];
$author_link = $author->renderLink();
$verb = DifferentialAction::getActionPastTenseVerb($comment->getAction());
$verb = phutil_escape_html($verb);
$content = $comment->getContent();
$head_content = null;
$hide_comments = true;
@ -157,8 +151,6 @@ final class DifferentialRevisionCommentView extends AphrontView {
'</div>';
}
$title = "{$author_link} {$verb} this revision.";
if ($this->inlines) {
$hide_comments = false;
$inline_render = array();
@ -282,39 +274,65 @@ final class DifferentialRevisionCommentView extends AphrontView {
$inline_render = null;
}
$author = $this->handles[$comment->getAuthorPHID()];
$author_link = $author->renderLink();
$background = null;
$uri = $author->getImageURI();
if ($uri) {
$background = "background-image: url('{$uri}');";
}
$metadata_blocks = array();
$metadata = $comment->getMetadata();
$added_reviewers = idx(
$metadata,
DifferentialComment::METADATA_ADDED_REVIEWERS);
if ($added_reviewers) {
$reviewers = 'Added reviewers: '.$this->renderHandleList(
$added_reviewers);
$metadata_blocks[] = $reviewers;
}
$added_ccs = idx(
$metadata,
DifferentialComment::METADATA_ADDED_CCS);
if ($added_ccs) {
$ccs = 'Added CCs: '.$this->renderHandleList($added_ccs);
$metadata_blocks[] = $ccs;
$verb = DifferentialAction::getActionPastTenseVerb($comment->getAction());
$verb = phutil_escape_html($verb);
$actions = array();
switch ($comment->getAction()) {
case DifferentialAction::ACTION_ADDCCS:
$actions[] = "{$author_link} added CCs: ".
$this->renderHandleList($added_ccs).".";
$added_ccs = null;
break;
case DifferentialAction::ACTION_ADDREVIEWERS:
$actions[] = "{$author_link} added reviewers: ".
$this->renderHandleList($added_reviewers).".";
$added_reviewers = null;
break;
case DifferentialAction::ACTION_UPDATE:
$diff_id = idx($metadata, DifferentialComment::METADATA_DIFF_ID);
if ($diff_id) {
$diff_link = phutil_render_tag(
'a',
array(
'href' => '/D'.$comment->getRevisionID().'?id='.$diff_id,
),
'Diff #'.phutil_escape_html($diff_id));
$actions[] = "{$author_link} updated this revision to {$diff_link}.";
} else {
$actions[] = "{$author_link} {$verb} this revision.";
}
break;
default:
$actions[] = "{$author_link} {$verb} this revision.";
break;
}
if ($metadata_blocks) {
$hide_comments = false;
$metadata_blocks =
'<div class="differential-comment-metadata">'.
implode("\n", $metadata_blocks).
'</div>';
} else {
$metadata_blocks = null;
if ($added_reviewers) {
$actions[] = "{$author_link} added reviewers: ".
$this->renderHandleList($added_reviewers).".";
}
if ($added_ccs) {
$actions[] = "{$author_link} added CCs: ".
$this->renderHandleList($added_ccs).".";
}
$hide_comments_class = ($hide_comments ? 'hide' : '');
@ -328,11 +346,12 @@ final class DifferentialRevisionCommentView extends AphrontView {
'<div class="differential-comment-detail '.$action_class.'">'.
'<div class="differential-comment-header">'.
'<span class="differential-comment-info">'.$info.'</span>'.
'<span class="differential-comment-title">'.$title.'</span>'.
'<span class="differential-comment-title">'.
implode('<br />', $actions).
'</span>'.
'</div>'.
'<div class="differential-comment-content '.$hide_comments_class.'">'.
$head_content.
$metadata_blocks.
'<div class="differential-comment-core">'.
$content.
'</div>'.