mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Show audit comments on the Diffusion commit view
Summary: We already allow you to create comments, but we don't show them on the commit page. After style / view unification this is easy; show comments on the commit page. Test Plan: Made comments on a commit using the audit too, saw them show up in Diffusion. Reviewers: btrahan, jungejason Reviewed By: btrahan CC: aran, epriestley Maniphest Tasks: T904 Differential Revision: https://secure.phabricator.com/D1687
This commit is contained in:
parent
282d6e5ffa
commit
5f46a61e6d
11 changed files with 304 additions and 29 deletions
|
@ -258,7 +258,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'diffusion-commit-view-css' =>
|
||||
array(
|
||||
'uri' => '/res/bc39d876/rsrc/css/application/diffusion/commit-view.css',
|
||||
'uri' => '/res/d486f79a/rsrc/css/application/diffusion/commit-view.css',
|
||||
'type' => 'css',
|
||||
'requires' =>
|
||||
array(
|
||||
|
@ -1614,6 +1614,17 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'disk' => '/rsrc/css/application/slowvote/slowvote.css',
|
||||
),
|
||||
0 =>
|
||||
array(
|
||||
'uri' => '/res/b6096fdd/rsrc/js/javelin/lib/__tests__/URI.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
0 => 'javelin-uri',
|
||||
1 => 'javelin-php-serializer',
|
||||
),
|
||||
'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js',
|
||||
),
|
||||
'phabricator-standard-page-view' =>
|
||||
array(
|
||||
'uri' => '/res/7e09bbfc/rsrc/css/application/base/standard-page-view.css',
|
||||
|
@ -1625,7 +1636,7 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'phabricator-transaction-view-css' =>
|
||||
array(
|
||||
'uri' => '/res/97f9e8f2/rsrc/css/aphront/transaction.css',
|
||||
'uri' => '/res/731959fb/rsrc/css/aphront/transaction.css',
|
||||
'type' => 'css',
|
||||
'requires' =>
|
||||
array(
|
||||
|
@ -1837,30 +1848,9 @@ celerity_register_resource_map(array(
|
|||
),
|
||||
'disk' => '/rsrc/css/core/syntax.css',
|
||||
),
|
||||
0 =>
|
||||
array(
|
||||
'uri' => '/res/b6096fdd/rsrc/js/javelin/lib/__tests__/URI.js',
|
||||
'type' => 'js',
|
||||
'requires' =>
|
||||
array(
|
||||
0 => 'javelin-uri',
|
||||
1 => 'javelin-php-serializer',
|
||||
),
|
||||
'disk' => '/rsrc/js/javelin/lib/__tests__/URI.js',
|
||||
),
|
||||
), array(
|
||||
'packages' =>
|
||||
array(
|
||||
'03ef179e' =>
|
||||
array(
|
||||
'name' => 'diffusion.pkg.css',
|
||||
'symbols' =>
|
||||
array(
|
||||
0 => 'diffusion-commit-view-css',
|
||||
),
|
||||
'uri' => '/res/pkg/03ef179e/diffusion.pkg.css',
|
||||
'type' => 'css',
|
||||
),
|
||||
'080edee4' =>
|
||||
array(
|
||||
'name' => 'typeahead.pkg.js',
|
||||
|
@ -1914,6 +1904,16 @@ celerity_register_resource_map(array(
|
|||
'uri' => '/res/pkg/4fbae2af/javelin.pkg.js',
|
||||
'type' => 'js',
|
||||
),
|
||||
'61f9d480' =>
|
||||
array(
|
||||
'name' => 'diffusion.pkg.css',
|
||||
'symbols' =>
|
||||
array(
|
||||
0 => 'diffusion-commit-view-css',
|
||||
),
|
||||
'uri' => '/res/pkg/61f9d480/diffusion.pkg.css',
|
||||
'type' => 'css',
|
||||
),
|
||||
'6a6def05' =>
|
||||
array(
|
||||
'name' => 'core.pkg.css',
|
||||
|
@ -2006,7 +2006,7 @@ celerity_register_resource_map(array(
|
|||
'differential-revision-detail-css' => '8152415f',
|
||||
'differential-revision-history-css' => '8152415f',
|
||||
'differential-table-of-contents-css' => '8152415f',
|
||||
'diffusion-commit-view-css' => '03ef179e',
|
||||
'diffusion-commit-view-css' => '61f9d480',
|
||||
'javelin-behavior' => '4fbae2af',
|
||||
'javelin-behavior-aphront-basic-tokenizer' => '080edee4',
|
||||
'javelin-behavior-aphront-drag-and-drop' => 'c8aaade8',
|
||||
|
|
|
@ -279,6 +279,8 @@ phutil_register_library_map(array(
|
|||
'DiffusionBrowseQuery' => 'applications/diffusion/query/browse/base',
|
||||
'DiffusionBrowseTableView' => 'applications/diffusion/view/browsetable',
|
||||
'DiffusionChangeController' => 'applications/diffusion/controller/change',
|
||||
'DiffusionCommentListView' => 'applications/diffusion/view/commentlist',
|
||||
'DiffusionCommentView' => 'applications/diffusion/view/comment',
|
||||
'DiffusionCommitChangeTableView' => 'applications/diffusion/view/commitchangetable',
|
||||
'DiffusionCommitController' => 'applications/diffusion/controller/commit',
|
||||
'DiffusionCommitListController' => 'applications/diffusion/controller/commitlist',
|
||||
|
@ -1100,6 +1102,8 @@ phutil_register_library_map(array(
|
|||
'DiffusionBrowseFileController' => 'DiffusionController',
|
||||
'DiffusionBrowseTableView' => 'DiffusionView',
|
||||
'DiffusionChangeController' => 'DiffusionController',
|
||||
'DiffusionCommentListView' => 'AphrontView',
|
||||
'DiffusionCommentView' => 'AphrontView',
|
||||
'DiffusionCommitChangeTableView' => 'DiffusionView',
|
||||
'DiffusionCommitController' => 'DiffusionController',
|
||||
'DiffusionCommitListController' => 'DiffusionController',
|
||||
|
|
|
@ -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,13 +20,13 @@ class PhabricatorAuditActionConstants {
|
|||
|
||||
const CONCERN = 'concern';
|
||||
const ACCEPT = 'accept';
|
||||
// TODO: enable comment
|
||||
//const COMMENT = 'comment';
|
||||
const COMMENT = 'comment';
|
||||
|
||||
public static function getActionNameMap() {
|
||||
static $map = array(
|
||||
self::CONCERN => 'Have Concern',
|
||||
self::ACCEPT => 'Accept',
|
||||
self::COMMENT => 'Comment',
|
||||
self::CONCERN => 'Raise Concern',
|
||||
self::ACCEPT => 'Accept',
|
||||
);
|
||||
|
||||
return $map;
|
||||
|
|
|
@ -87,6 +87,7 @@ class DiffusionCommitController extends DiffusionController {
|
|||
}
|
||||
|
||||
$content[] = $this->buildAuditTable($commit);
|
||||
$content[] = $this->buildComments($commit);
|
||||
|
||||
$change_query = DiffusionPathChangeQuery::newFromDiffusionRequest(
|
||||
$drequest);
|
||||
|
@ -311,4 +312,21 @@ class DiffusionCommitController extends DiffusionController {
|
|||
return $panel;
|
||||
}
|
||||
|
||||
private function buildComments($commit) {
|
||||
$user = $this->getRequest()->getUser();
|
||||
$comments = id(new PhabricatorAuditComment())->loadAllWhere(
|
||||
'targetPHID = %s ORDER BY dateCreated ASC',
|
||||
$commit->getPHID());
|
||||
|
||||
$view = new DiffusionCommentListView();
|
||||
$view->setUser($user);
|
||||
$view->setComments($comments);
|
||||
|
||||
$phids = $view->getRequiredHandlePHIDs();
|
||||
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
|
||||
$view->setHandles($handles);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/audit/query/audit');
|
||||
phutil_require_module('phabricator', 'applications/audit/storage/auditcomment');
|
||||
phutil_require_module('phabricator', 'applications/audit/view/list');
|
||||
phutil_require_module('phabricator', 'applications/differential/constants/changetype');
|
||||
phutil_require_module('phabricator', 'applications/differential/view/changesetlistview');
|
||||
|
@ -14,6 +15,7 @@ phutil_require_module('phabricator', 'applications/diffusion/controller/base');
|
|||
phutil_require_module('phabricator', 'applications/diffusion/data/pathchange');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/contains/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/query/pathchange/base');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/commentlist');
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/commitchangetable');
|
||||
phutil_require_module('phabricator', 'applications/markup/engine');
|
||||
phutil_require_module('phabricator', 'applications/phid/handle/data');
|
||||
|
|
132
src/applications/diffusion/view/comment/DiffusionCommentView.php
Normal file
132
src/applications/diffusion/view/comment/DiffusionCommentView.php
Normal file
|
@ -0,0 +1,132 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class DiffusionCommentView extends AphrontView {
|
||||
|
||||
private $user;
|
||||
private $comment;
|
||||
private $commentNumber;
|
||||
private $handles;
|
||||
|
||||
public function setUser(PhabricatorUser $user) {
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setComment(PhabricatorAuditComment $comment) {
|
||||
$this->comment = $comment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setCommentNumber($comment_number) {
|
||||
$this->commentNumber = $comment_number;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
$this->handles = $handles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getHandle($phid) {
|
||||
if (empty($this->handles[$phid])) {
|
||||
throw new Exception("Unloaded handle '{$phid}'!");
|
||||
}
|
||||
return $this->handles[$phid];
|
||||
}
|
||||
|
||||
public function render() {
|
||||
$comment = $this->comment;
|
||||
$author = $this->getHandle($comment->getActorPHID());
|
||||
$author_link = $author->renderLink();
|
||||
|
||||
$actions = $this->renderActions();
|
||||
$content = $this->renderContent();
|
||||
$classes = $this->renderClasses();
|
||||
|
||||
$xaction_view = id(new PhabricatorTransactionView())
|
||||
->setUser($this->user)
|
||||
->setImageURI($author->getImageURI())
|
||||
->setActions($actions)
|
||||
->setAnchor('comment-'.$this->commentNumber, '#'.$this->commentNumber)
|
||||
->setEpoch($comment->getDateCreated())
|
||||
->appendChild($content);
|
||||
|
||||
foreach ($classes as $class) {
|
||||
$xaction_view->addClass($class);
|
||||
}
|
||||
|
||||
return $xaction_view;
|
||||
}
|
||||
|
||||
private function renderActions() {
|
||||
$comment = $this->comment;
|
||||
$author = $this->getHandle($comment->getActorPHID());
|
||||
$author_link = $author->renderLink();
|
||||
|
||||
$actions = array();
|
||||
switch ($comment->getAction()) {
|
||||
case PhabricatorAuditActionConstants::ACCEPT:
|
||||
$actions[] = "{$author_link} accepted this commit.";
|
||||
break;
|
||||
case PhabricatorAuditActionConstants::CONCERN:
|
||||
$actions[] = "{$author_link} raised concerns with this commit.";
|
||||
break;
|
||||
case PhabricatorAuditActionConstants::COMMENT:
|
||||
default:
|
||||
$actions[] = "{$author_link} commented on this commit.";
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($actions as $key => $action) {
|
||||
$actions[$key] = '<div>'.$action.'</div>';
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
|
||||
private function renderContent() {
|
||||
$comment = $this->comment;
|
||||
|
||||
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
|
||||
return
|
||||
'<div class="phabricator-remarkup">'.
|
||||
$engine->markupText($comment->getContent()).
|
||||
'</div>';
|
||||
}
|
||||
|
||||
private function renderClasses() {
|
||||
$comment = $this->comment;
|
||||
|
||||
$classes = array();
|
||||
switch ($comment->getAction()) {
|
||||
case PhabricatorAuditActionConstants::ACCEPT:
|
||||
$classes[] = 'audit-accept';
|
||||
break;
|
||||
case PhabricatorAuditActionConstants::CONCERN:
|
||||
$classes[] = 'audit-concern';
|
||||
break;
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
17
src/applications/diffusion/view/comment/__init__.php
Normal file
17
src/applications/diffusion/view/comment/__init__.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/audit/constants/action');
|
||||
phutil_require_module('phabricator', 'applications/markup/engine');
|
||||
phutil_require_module('phabricator', 'view/base');
|
||||
phutil_require_module('phabricator', 'view/layout/transaction');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionCommentView.php');
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
final class DiffusionCommentListView extends AphrontView {
|
||||
|
||||
private $user;
|
||||
private $comments;
|
||||
|
||||
public function setUser(PhabricatorUser $user) {
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setComments(array $comments) {
|
||||
$this->comments = $comments;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDs() {
|
||||
$phids = array();
|
||||
foreach ($this->comments as $comment) {
|
||||
$phids[$comment->getActorPHID()] = true;
|
||||
}
|
||||
return array_keys($phids);
|
||||
}
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
$this->handles = $handles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function render() {
|
||||
|
||||
$num = 1;
|
||||
|
||||
$comments = array();
|
||||
foreach ($this->comments as $comment) {
|
||||
$view = id(new DiffusionCommentView())
|
||||
->setComment($comment)
|
||||
->setCommentNumber($num)
|
||||
->setHandles($this->handles)
|
||||
->setUser($this->user);
|
||||
|
||||
$comments[] = $view->render();
|
||||
++$num;
|
||||
}
|
||||
|
||||
return
|
||||
'<div class="diffusion-comment-list">'.
|
||||
$this->renderSingleView($comments).
|
||||
'</div>';
|
||||
}
|
||||
|
||||
}
|
15
src/applications/diffusion/view/commentlist/__init__.php
Normal file
15
src/applications/diffusion/view/commentlist/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('phabricator', 'applications/diffusion/view/comment');
|
||||
phutil_require_module('phabricator', 'view/base');
|
||||
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('DiffusionCommentListView.php');
|
|
@ -59,6 +59,11 @@ class PhabricatorMarkupEngine {
|
|||
));
|
||||
}
|
||||
|
||||
public static function newDiffusionMarkupEngine(array $options = array()) {
|
||||
return self::newMarkupEngine(array(
|
||||
));
|
||||
}
|
||||
|
||||
public static function newProfileMarkupEngine() {
|
||||
return self::newMarkupEngine(array(
|
||||
));
|
||||
|
|
|
@ -34,3 +34,15 @@
|
|||
.diffusion-commit-message {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.diffusion-comment-list {
|
||||
margin: 2em;
|
||||
}
|
||||
|
||||
.phabricator-transaction-view .audit-accept {
|
||||
border-color: #009933;
|
||||
}
|
||||
|
||||
.phabricator-transaction-view .audit-concern {
|
||||
border-color: #aa0000;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue