1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-09 16:32:39 +01:00

Basic Differential revision feedback view.

This commit is contained in:
epriestley 2011-01-30 10:37:36 -08:00
parent 39a976ae7f
commit c55b1ed9bb
23 changed files with 361 additions and 44 deletions

View file

@ -82,7 +82,7 @@ celerity_register_resource_map(array(
),
'phabricator-standard-page-view' =>
array(
'uri' => '/res/1f93ada7/rsrc/css/application/base/standard-page-view.css',
'uri' => '/res/fb02fb0e/rsrc/css/application/base/standard-page-view.css',
'type' => 'css',
'requires' =>
array(
@ -107,6 +107,24 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/application/differential/core.css',
),
'differential-revision-comment-list-css' =>
array(
'uri' => '/res/a1c117db/rsrc/css/application/differential/revision-comment-list.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-comment-list.css',
),
'differential-revision-comment-css' =>
array(
'uri' => '/res/d9924857/rsrc/css/application/differential/revision-comment.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/differential/revision-comment.css',
),
'differential-revision-detail-css' =>
array(
'uri' => '/res/230a67c6/rsrc/css/application/differential/revision-detail.css',
@ -247,7 +265,7 @@ celerity_register_resource_map(array(
), array (
'packages' =>
array (
'4efe7b58' =>
'364a306c' =>
array (
'name' => 'core.pkg.css',
'symbols' =>
@ -264,7 +282,7 @@ celerity_register_resource_map(array(
9 => 'aphront-typeahead-control-css',
10 => 'phabricator-directory-css',
),
'uri' => '/res/pkg/4efe7b58/core.pkg.css',
'uri' => '/res/pkg/364a306c/core.pkg.css',
'type' => 'css',
),
'69b11588' =>
@ -284,17 +302,17 @@ celerity_register_resource_map(array(
),
'reverse' =>
array (
'phabricator-core-css' => '4efe7b58',
'phabricator-core-buttons-css' => '4efe7b58',
'phabricator-standard-page-view' => '4efe7b58',
'aphront-dialog-view-css' => '4efe7b58',
'aphront-form-view-css' => '4efe7b58',
'aphront-panel-view-css' => '4efe7b58',
'aphront-side-nav-view-css' => '4efe7b58',
'aphront-table-view-css' => '4efe7b58',
'aphront-tokenizer-control-css' => '4efe7b58',
'aphront-typeahead-control-css' => '4efe7b58',
'phabricator-directory-css' => '4efe7b58',
'phabricator-core-css' => '364a306c',
'phabricator-core-buttons-css' => '364a306c',
'phabricator-standard-page-view' => '364a306c',
'aphront-dialog-view-css' => '364a306c',
'aphront-form-view-css' => '364a306c',
'aphront-panel-view-css' => '364a306c',
'aphront-side-nav-view-css' => '364a306c',
'aphront-table-view-css' => '364a306c',
'aphront-tokenizer-control-css' => '364a306c',
'aphront-typeahead-control-css' => '364a306c',
'phabricator-directory-css' => '364a306c',
'differential-core-view-css' => '69b11588',
'differential-changeset-view-css' => '69b11588',
'differential-revision-detail-css' => '69b11588',

View file

@ -72,6 +72,7 @@ phutil_register_library_map(array(
'DifferentialChangesetListView' => 'applications/differential/view/changesetlistview',
'DifferentialChangesetParser' => 'applications/differential/parser/changeset',
'DifferentialChangesetViewController' => 'applications/differential/controller/changesetview',
'DifferentialComment' => 'applications/differential/storage/comment',
'DifferentialController' => 'applications/differential/controller/base',
'DifferentialDAO' => 'applications/differential/storage/base',
'DifferentialDiff' => 'applications/differential/storage/diff',
@ -86,6 +87,8 @@ phutil_register_library_map(array(
'DifferentialNewDiffMail' => 'applications/differential/mail/newdiff',
'DifferentialReviewRequestMail' => 'applications/differential/mail/reviewrequest',
'DifferentialRevision' => 'applications/differential/storage/revision',
'DifferentialRevisionCommentListView' => 'applications/differential/view/revisioncommentlist',
'DifferentialRevisionCommentView' => 'applications/differential/view/revisioncomment',
'DifferentialRevisionControlSystem' => 'applications/differential/constants/revisioncontrolsystem',
'DifferentialRevisionDetailView' => 'applications/differential/view/revisiondetail',
'DifferentialRevisionEditController' => 'applications/differential/controller/revisionedit',
@ -226,6 +229,7 @@ phutil_register_library_map(array(
'DifferentialChangesetDetailView' => 'AphrontView',
'DifferentialChangesetListView' => 'AphrontView',
'DifferentialChangesetViewController' => 'DifferentialController',
'DifferentialComment' => 'DifferentialDAO',
'DifferentialController' => 'PhabricatorController',
'DifferentialDAO' => 'PhabricatorLiskDAO',
'DifferentialDiff' => 'DifferentialDAO',
@ -238,6 +242,8 @@ phutil_register_library_map(array(
'DifferentialNewDiffMail' => 'DifferentialReviewRequestMail',
'DifferentialReviewRequestMail' => 'DifferentialMail',
'DifferentialRevision' => 'DifferentialDAO',
'DifferentialRevisionCommentListView' => 'AphrontView',
'DifferentialRevisionCommentView' => 'AphrontView',
'DifferentialRevisionDetailView' => 'AphrontView',
'DifferentialRevisionEditController' => 'DifferentialController',
'DifferentialRevisionListController' => 'DifferentialController',

View file

@ -33,7 +33,7 @@ class ConduitAPI_differential_creatediff_Method extends ConduitAPIMethod {
'sourceControlBaseRevision' => 'required string',
'parentRevisionID' => 'optional revisionid',
'creationMethod' => 'optional string',
'ownerPHID' => 'optional phid',
'authorPHID' => 'optional phid',
'arcanistProject' => 'optional string',
'lintStatus' =>
'required enum<none, skip, okay, warn, fail>',
@ -65,7 +65,7 @@ class ConduitAPI_differential_creatediff_Method extends ConduitAPIMethod {
$diff->setBranch($request->getValue('branch'));
$diff->setCreationMethod($request->getValue('creationMethod'));
$diff->setOwnerPHID($request->getValue('ownerPHID'));
$diff->setAuthorPHID($request->getValue('authorPHID'));
$parent_id = $request->getValue('parentRevisionID');
if ($parent_id) {

View file

@ -49,7 +49,7 @@ final class DifferentialAction {
self::ACTION_ADDREVIEWERS => 'added reviewers to',
);
if (empty($verbs[$action])) {
if (!empty($verbs[$action])) {
return $verbs[$action];
} else {
return 'brazenly "'.$action.'ed"';

View file

@ -145,7 +145,7 @@ class DifferentialRevisionListController extends DifferentialController {
phutil_escape_html($revision->getTitle())),
phutil_escape_html($status),
number_format($revision->getLineCount()),
$revision->getOwnerPHID(),
$revision->getAuthorPHID(),
'TODO',
$revision->getDateModified(),
$revision->getDateCreated(),

View file

@ -41,26 +41,23 @@ class DifferentialRevisionViewController extends DifferentialController {
$changesets = $target->loadChangesets();
$comments = $revision->loadComments();
$comments = array_merge(
$this->getImplicitComments($revision),
$comments);
$object_phids = array_merge(
$revision->getReviewers(),
$revision->getCCPHIDs(),
array(
$revision->getOwnerPHID(),
$revision->getAuthorPHID(),
$request->getUser()->getPHID(),
));
),
mpull($comments, 'getAuthorPHID'));
$handles = id(new PhabricatorObjectHandleData($object_phids))
->loadHandles();
$diff_history = new DifferentialRevisionUpdateHistoryView();
$diff_history->setDiffs($diffs);
$toc_view = new DifferentialDiffTableOfContentsView();
$toc_view->setChangesets($changesets);
$changeset_view = new DifferentialChangesetListView();
$changeset_view->setChangesets($changesets);
$revision_detail = new DifferentialRevisionDetailView();
$revision_detail->setRevision($revision);
@ -70,9 +67,23 @@ class DifferentialRevisionViewController extends DifferentialController {
$actions = $this->getRevisionActions($revision);
$revision_detail->setActions($actions);
$comment_view = new DifferentialRevisionCommentListView();
$comment_view->setComments($comments);
$comment_view->setHandles($handles);
$diff_history = new DifferentialRevisionUpdateHistoryView();
$diff_history->setDiffs($diffs);
$toc_view = new DifferentialDiffTableOfContentsView();
$toc_view->setChangesets($changesets);
$changeset_view = new DifferentialChangesetListView();
$changeset_view->setChangesets($changesets);
return $this->buildStandardPageResponse(
'<div class="differential-primary-pane">'.
$revision_detail->render().
$comment_view->render().
$diff_history->render().
$toc_view->render().
$changeset_view->render().
@ -82,6 +93,32 @@ class DifferentialRevisionViewController extends DifferentialController {
));
}
private function getImplicitComments(DifferentialRevision $revision) {
$template = new DifferentialComment();
$template->setAuthorPHID($revision->getAuthorPHID());
$template->setRevisionID($revision->getID());
$template->setDateCreated($revision->getDateCreated());
$comments = array();
if (strlen($revision->getSummary())) {
$summary_comment = clone $template;
$summary_comment->setContent($revision->getSummary());
$summary_comment->setAction(DifferentialAction::ACTION_SUMMARIZE);
$comments[] = $summary_comment;
}
if (strlen($revision->getTestPlan())) {
$testplan_comment = clone $template;
$testplan_comment->setContent($revision->getTestPlan());
$testplan_comment->setAction(DifferentialAction::ACTION_TESTPLAN);
$comments[] = $testplan_comment;
}
return $comments;
}
private function getRevisionProperties(
DifferentialRevision $revision,
DifferentialDiff $diff,
@ -93,7 +130,7 @@ class DifferentialRevisionViewController extends DifferentialController {
$status = DifferentialRevisionStatus::getNameForRevisionStatus($status);
$properties['Revision Status'] = '<strong>'.$status.'</strong>';
$author = $handles[$revision->getOwnerPHID()];
$author = $handles[$revision->getAuthorPHID()];
$properties['Author'] = $author->renderLink();
$properties['Reviewers'] = $this->renderHandleLinkList(
@ -125,7 +162,7 @@ class DifferentialRevisionViewController extends DifferentialController {
private function getRevisionActions(DifferentialRevision $revision) {
$viewer_phid = $this->getRequest()->getUser()->getPHID();
$viewer_is_owner = ($revision->getOwnerPHID() == $viewer_phid);
$viewer_is_owner = ($revision->getAuthorPHID() == $viewer_phid);
$viewer_is_reviewer = in_array($viewer_phid, $revision->getReviewers());
$viewer_is_cc = in_array($viewer_phid, $revision->getCCPHIDs());
$status = $revision->getStatus();

View file

@ -7,11 +7,14 @@
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'applications/differential/constants/action');
phutil_require_module('phabricator', 'applications/differential/constants/revisionstatus');
phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/revision');
phutil_require_module('phabricator', 'applications/differential/view/changesetlistview');
phutil_require_module('phabricator', 'applications/differential/view/difftableofcontents');
phutil_require_module('phabricator', 'applications/differential/view/revisioncommentlist');
phutil_require_module('phabricator', 'applications/differential/view/revisiondetail');
phutil_require_module('phabricator', 'applications/differential/view/revisionupdatehistory');
phutil_require_module('phabricator', 'applications/phid/handle/data');

View file

@ -60,13 +60,13 @@ class DifferentialRevisionListData {
break;
case self::QUERY_OPEN_OWNED:
$this->revisions = $this->loadAllWhere(
'revision.status in (%Ld) AND revision.ownerPHID in (%Ls)',
'revision.status in (%Ld) AND revision.authorPHID in (%Ls)',
$this->getOpenStatuses(),
$this->ids);
break;
case self::QUERY_COMMITTABLE:
$this->revisions = $this->loadAllWhere(
'revision.status in (%Ld) AND revision.ownerPHID in (%Ls)',
'revision.status in (%Ld) AND revision.authorPHID in (%Ls)',
array(
DifferentialRevisionStatus::ACCEPTED,
),
@ -85,12 +85,12 @@ class DifferentialRevisionListData {
break;
case self::QUERY_OWNED:
$this->revisions = $this->loadAllWhere(
'revision.ownerPHID in (%Ls)',
'revision.authorPHID in (%Ls)',
$this->ids);
break;
case self::QUERY_OWNED_OR_REVIEWER:
$this->revisions = $this->loadAllWhereJoinReview(
'revision.ownerPHID in (%Ls) OR relationship.objectPHID in (%Ls)',
'revision.authorPHID in (%Ls) OR relationship.objectPHID in (%Ls)',
$this->ids,
$this->ids);
break;
@ -99,7 +99,7 @@ class DifferentialRevisionListData {
$data = queryfx_all(
$rev->establishConnection('r'),
'SELECT revision.* FROM %T revision
WHERE revision.ownerPHID in (%Ls)
WHERE revision.authorPHID in (%Ls)
AND revision.status in (%Ld)
UNION ALL
@ -135,7 +135,7 @@ class DifferentialRevisionListData {
$data = queryfx_all(
$rev->establishConnection('r'),
'SELECT revision.* FROM %T revision
WHERE revision.ownerPHID in (%Ls)
WHERE revision.authorPHID in (%Ls)
AND revision.status IN (%Ld)
UNION ALL

View file

@ -204,8 +204,8 @@ class DifferentialRevisionEditor {
if ($revision->getTitle() === null) {
$revision->setTitle('Untitled Revision');
}
if ($revision->getOwnerPHID() === null) {
$revision->setOwnerPHID($this->getActorPHID());
if ($revision->getAuthorPHID() === null) {
$revision->setAuthorPHID($this->getActorPHID());
}
$revision->save();
@ -315,7 +315,7 @@ class DifferentialRevisionEditor {
array_keys($add['rev']),
$this->actorPHID);
// Add the owner to the relevant set of users so they get a copy of the
// Add the author to the relevant set of users so they get a copy of the
// email.
if (!$this->silentUpdate) {
if ($is_new) {

View file

@ -0,0 +1,26 @@
<?php
/*
* Copyright 2011 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.
*/
class DifferentialComment extends DifferentialDAO {
protected $authorPHID;
protected $revisionID;
protected $action;
protected $content;
}

View file

@ -0,0 +1,12 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/differential/storage/base');
phutil_require_source('DifferentialComment.php');

View file

@ -19,7 +19,7 @@
class DifferentialDiff extends DifferentialDAO {
protected $revisionID;
protected $ownerPHID;
protected $authorPHID;
protected $sourceMachine;
protected $sourcePath;

View file

@ -27,7 +27,7 @@ class DifferentialRevision extends DifferentialDAO {
protected $blameRevision;
protected $phid;
protected $ownerPHID;
protected $authorPHID;
protected $dateCommitted;
@ -60,6 +60,15 @@ class DifferentialRevision extends DifferentialDAO {
$this->getID());
}
public function loadComments() {
if (!$this->getID()) {
return array();
}
return id(new DifferentialComment())->loadAllWhere(
'revisionID = %d',
$this->getID());
}
public function loadRelationships() {
if (!$this->getID()) {
$this->relationships = array();

View file

@ -7,6 +7,7 @@
phutil_require_module('phabricator', 'applications/differential/storage/base');
phutil_require_module('phabricator', 'applications/differential/storage/comment');
phutil_require_module('phabricator', 'applications/differential/storage/diff');
phutil_require_module('phabricator', 'applications/phid/storage/phid');
phutil_require_module('phabricator', 'storage/qsprintf');

View file

@ -0,0 +1,80 @@
<?php
/*
* Copyright 2011 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 DifferentialRevisionCommentView extends AphrontView {
private $comment;
private $handles;
public function setComment($comment) {
$this->comment = $comment;
return $this;
}
public function setHandles(array $handles) {
$this->handles = $handles;
return $this;
}
public function render() {
require_celerity_resource('differential-revision-comment-css');
$comment = $this->comment;
$action = $comment->getAction();
$action_class = 'differential-comment-action-'.phutil_escape_html($action);
$date = date('F jS, Y g:i:s A', $comment->getDateCreated());
$author = $comment->getAuthorPHID();
$author = $this->handles[$author]->renderLink();
$verb = DifferentialAction::getActionVerb($comment->getAction());
$verb = phutil_escape_html($verb);
$content = $comment->getContent();
if (strlen(rtrim($content))) {
$title = "{$author} {$verb} this revision:";
$content = phutil_escape_html($content);
} else {
$title = null;
$content =
'<div class="differential-comment-nocontent">'.
"<p>{$author} {$verb} this revision.</p>".
'</div>';
}
return
'<div class="differential-comment '.$action_class.'">'.
'<div class="differential-comment-head">'.
'<div class="differential-comment-date">'.$date.'</div>'.
'<div class="differential-comment-title">'.$title.'</div>'.
'</div>'.
'<div class="differential-comment-body">'.
'<div class="differential-comment-core">'.
'<div class="differential-comment-content">'.
$content.
'</div>'.
'</div>'.
'</div>'.
'</div>';
}
}

View file

@ -0,0 +1,16 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/differential/constants/action');
phutil_require_module('phabricator', 'infratructure/celerity/api');
phutil_require_module('phabricator', 'view/base');
phutil_require_module('phutil', 'markup');
phutil_require_source('DifferentialRevisionCommentView.php');

View file

@ -0,0 +1,52 @@
<?php
/*
* Copyright 2011 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 DifferentialRevisionCommentListView extends AphrontView {
private $comments;
private $handles;
public function setComments($comments) {
$this->comments = $comments;
return $this;
}
public function setHandles(array $handles) {
$this->handles = $handles;
return $this;
}
public function render() {
require_celerity_resource('differential-revision-comment-list-css');
$comments = array();
foreach ($this->comments as $comment) {
$view = new DifferentialRevisionCommentView();
$view->setComment($comment);
$view->setHandles($this->handles);
$comments[] = $view->render();
}
return
'<div>'.
implode("\n", $comments).
'</div>';
}
}

View file

@ -0,0 +1,14 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'applications/differential/view/revisioncomment');
phutil_require_module('phabricator', 'infratructure/celerity/api');
phutil_require_module('phabricator', 'view/base');
phutil_require_source('DifferentialRevisionCommentListView.php');

View file

@ -28,7 +28,7 @@ final class AphrontRequestFailureView extends AphrontView {
final public function render() {
require_celerity_resource('aphront-request-failure-view-css');
return
'<div class="aphront-request-failure-view">'.
'<div class="aphront-request-failure-head">'.

View file

@ -6,6 +6,7 @@
phutil_require_module('phabricator', 'infratructure/celerity/api');
phutil_require_module('phabricator', 'view/base');
phutil_require_module('phutil', 'markup');

View file

@ -6,7 +6,6 @@
.phabricator-standard-page {
background: #ffffff;
border-bottom: 1px solid #888888;
font-size: 14px;
-webkit-box-shadow: 0 0 6px #000;
-mox-box-shadow: 0 0 6px #000;

View file

@ -0,0 +1,4 @@
/**
* @provides differential-revision-comment-list-css
*/

View file

@ -0,0 +1,39 @@
/**
* @provides differential-revision-comment-css
*/
.differential-comment-date {
color: #666666;
float: right;
font-size: 11px;
margin: 0em;
padding-top: 6px;
}
.differential-comment-title {
font-weight: bold;
height: 16px;
margin: 4px 0em 0em 0em;
padding: 4px 0em;
position: relative;
}
.differential-comment-body {
min-height: 56px;
padding-left: 62px;
background-repeat: no-repeat;
background-position: 6px 0px;
margin-bottom: 14px;
}
.differential-comment-content {
background: #fbfbfb;
border-color: #c3c3c3;
border-style: solid;
border-width: 1px 10px 1px 10px;
clear: both;
line-height: 1.4em;
margin: 0em;
padding: .3em 5px .4em 1.25em;
}