1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +01: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()) ->setAuthorPHID($this->getActorPHID())
->setRevisionID($revision_id) ->setRevisionID($revision_id)
->setContent($this->getComments()) ->setContent($this->getComments())
->setAction('update'); ->setAction(DifferentialAction::ACTION_UPDATE)
->setMetadata(
array(
DifferentialComment::METADATA_DIFF_ID => $this->getDiff()->getID(),
));
if ($this->contentSource) { if ($this->contentSource) {
$comment->setContentSource($this->contentSource); $comment->setContentSource($this->contentSource);

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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_REVIEWERS = 'added-reviewers';
const METADATA_ADDED_CCS = 'added-ccs'; const METADATA_ADDED_CCS = 'added-ccs';
const METADATA_DIFF_ID = 'diff-id';
protected $authorPHID; protected $authorPHID;
protected $revisionID; protected $revisionID;

View file

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

View file

@ -127,12 +127,6 @@ final class DifferentialRevisionCommentView extends AphrontView {
$info = implode(' &middot; ', array_filter($info)); $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(); $content = $comment->getContent();
$head_content = null; $head_content = null;
$hide_comments = true; $hide_comments = true;
@ -157,8 +151,6 @@ final class DifferentialRevisionCommentView extends AphrontView {
'</div>'; '</div>';
} }
$title = "{$author_link} {$verb} this revision.";
if ($this->inlines) { if ($this->inlines) {
$hide_comments = false; $hide_comments = false;
$inline_render = array(); $inline_render = array();
@ -282,39 +274,65 @@ final class DifferentialRevisionCommentView extends AphrontView {
$inline_render = null; $inline_render = null;
} }
$author = $this->handles[$comment->getAuthorPHID()];
$author_link = $author->renderLink();
$background = null; $background = null;
$uri = $author->getImageURI(); $uri = $author->getImageURI();
if ($uri) { if ($uri) {
$background = "background-image: url('{$uri}');"; $background = "background-image: url('{$uri}');";
} }
$metadata_blocks = array();
$metadata = $comment->getMetadata(); $metadata = $comment->getMetadata();
$added_reviewers = idx( $added_reviewers = idx(
$metadata, $metadata,
DifferentialComment::METADATA_ADDED_REVIEWERS); DifferentialComment::METADATA_ADDED_REVIEWERS);
if ($added_reviewers) {
$reviewers = 'Added reviewers: '.$this->renderHandleList(
$added_reviewers);
$metadata_blocks[] = $reviewers;
}
$added_ccs = idx( $added_ccs = idx(
$metadata, $metadata,
DifferentialComment::METADATA_ADDED_CCS); DifferentialComment::METADATA_ADDED_CCS);
if ($added_ccs) {
$ccs = 'Added CCs: '.$this->renderHandleList($added_ccs); $verb = DifferentialAction::getActionPastTenseVerb($comment->getAction());
$metadata_blocks[] = $ccs; $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) { if ($added_reviewers) {
$hide_comments = false; $actions[] = "{$author_link} added reviewers: ".
$metadata_blocks = $this->renderHandleList($added_reviewers).".";
'<div class="differential-comment-metadata">'. }
implode("\n", $metadata_blocks).
'</div>'; if ($added_ccs) {
} else { $actions[] = "{$author_link} added CCs: ".
$metadata_blocks = null; $this->renderHandleList($added_ccs).".";
} }
$hide_comments_class = ($hide_comments ? 'hide' : ''); $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-detail '.$action_class.'">'.
'<div class="differential-comment-header">'. '<div class="differential-comment-header">'.
'<span class="differential-comment-info">'.$info.'</span>'. '<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>'.
'<div class="differential-comment-content '.$hide_comments_class.'">'. '<div class="differential-comment-content '.$hide_comments_class.'">'.
$head_content. $head_content.
$metadata_blocks.
'<div class="differential-comment-core">'. '<div class="differential-comment-core">'.
$content. $content.
'</div>'. '</div>'.