@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

AddCommentView

+162 -76
+2
src/__phutil_library_map__.php
··· 65 65 'ConduitAPI_user_find_Method' => 'applications/conduit/method/user/find', 66 66 'ConduitException' => 'applications/conduit/protocol/exception', 67 67 'DifferentialAction' => 'applications/differential/constants/action', 68 + 'DifferentialAddCommentView' => 'applications/differential/view/addcomment', 68 69 'DifferentialCCWelcomeMail' => 'applications/differential/mail/ccwelcome', 69 70 'DifferentialChangeType' => 'applications/differential/constants/changetype', 70 71 'DifferentialChangeset' => 'applications/differential/storage/changeset', ··· 224 225 'ConduitAPI_differential_setdiffproperty_Method' => 'ConduitAPIMethod', 225 226 'ConduitAPI_file_upload_Method' => 'ConduitAPIMethod', 226 227 'ConduitAPI_user_find_Method' => 'ConduitAPIMethod', 228 + 'DifferentialAddCommentView' => 'AphrontView', 227 229 'DifferentialCCWelcomeMail' => 'DifferentialReviewRequestMail', 228 230 'DifferentialChangeset' => 'DifferentialDAO', 229 231 'DifferentialChangesetDetailView' => 'AphrontView',
+20 -1
src/applications/differential/constants/action/DifferentialAction.php
··· 32 32 const ACTION_CREATE = 'create'; 33 33 const ACTION_ADDREVIEWERS = 'add_reviewers'; 34 34 35 - public static function getActionVerb($action) { 35 + public static function getActionPastTenseVerb($action) { 36 36 static $verbs = array( 37 37 self::ACTION_COMMENT => 'commented on', 38 38 self::ACTION_ACCEPT => 'accepted', ··· 53 53 return $verbs[$action]; 54 54 } else { 55 55 return 'brazenly "'.$action.'ed"'; 56 + } 57 + } 58 + 59 + public static function getActionVerb($action) { 60 + static $verbs = array( 61 + self::ACTION_COMMENT => 'Comment', 62 + self::ACTION_ACCEPT => "Accept Revision \xE2\x9C\x94", 63 + self::ACTION_REJECT => "Request Changes \xE2\x9C\x98", 64 + self::ACTION_ABANDON => 'Abandon Revision', 65 + self::ACTION_REQUEST => 'Request Review', 66 + self::ACTION_RECLAIM => 'Reclaim Revision', 67 + self::ACTION_RESIGN => 'Resign as Reviewer', 68 + self::ACTION_ADDREVIEWERS => 'Add Reviewers', 69 + ); 70 + 71 + if (!empty($verbs[$action])) { 72 + return $verbs[$action]; 73 + } else { 74 + return 'brazenly '.$action; 56 75 } 57 76 } 58 77
+55 -74
src/applications/differential/controller/revisionview/DifferentialRevisionViewController.php
··· 80 80 $changeset_view = new DifferentialChangesetListView(); 81 81 $changeset_view->setChangesets($changesets); 82 82 83 + $comment_form = new DifferentialAddCommentView(); 84 + $comment_form->setRevision($revision); 85 + $comment_form->setActions($this->getRevisionCommentActions($revision)); 86 + 83 87 return $this->buildStandardPageResponse( 84 88 '<div class="differential-primary-pane">'. 85 89 $revision_detail->render(). ··· 87 91 $diff_history->render(). 88 92 $toc_view->render(). 89 93 $changeset_view->render(). 94 + $comment_form->render(). 90 95 '</div>', 91 96 array( 92 97 'title' => $revision->getTitle(), ··· 210 215 return implode(', ', mpull($list, 'renderLink')); 211 216 } 212 217 218 + private function getRevisionCommentActions(DifferentialRevision $revision) { 219 + 220 + $actions = array( 221 + DifferentialAction::ACTION_COMMENT => true, 222 + ); 223 + 224 + $viewer_phid = $this->getRequest()->getUser()->getPHID(); 225 + $viewer_is_owner = ($viewer_phid == $revision->getAuthorPHID()); 226 + 227 + if ($viewer_is_owner) { 228 + switch ($revision->getStatus()) { 229 + case DifferentialRevisionStatus::NEEDS_REVIEW: 230 + $actions[DifferentialAction::ACTION_ABANDON] = true; 231 + break; 232 + case DifferentialRevisionStatus::NEEDS_REVISION: 233 + case DifferentialRevisionStatus::ACCEPTED: 234 + $actions[DifferentialAction::ACTION_ABANDON] = true; 235 + $actions[DifferentialAction::ACTION_REQUEST] = true; 236 + break; 237 + case DifferentialRevisionStatus::COMMITTED: 238 + break; 239 + case DifferentialRevisionStatus::ABANDONED: 240 + $actions[DifferentialAction::ACTION_RECLAIM] = true; 241 + break; 242 + } 243 + } else { 244 + switch ($revision->getStatus()) { 245 + case DifferentialRevisionStatus::NEEDS_REVIEW: 246 + $actions[DifferentialAction::ACTION_ACCEPT] = true; 247 + $actions[DifferentialAction::ACTION_REJECT] = true; 248 + break; 249 + case DifferentialRevisionStatus::NEEDS_REVISION: 250 + $actions[DifferentialAction::ACTION_ACCEPT] = true; 251 + break; 252 + case DifferentialRevisionStatus::ACCEPTED: 253 + $actions[DifferentialAction::ACTION_REJECT] = true; 254 + break; 255 + case DifferentialRevisionStatus::COMMITTED: 256 + case DifferentialRevisionStatus::ABANDONED: 257 + break; 258 + } 259 + } 260 + 261 + $actions[DifferentialAction::ACTION_ADDREVIEWERS] = true; 262 + 263 + return array_keys($actions); 264 + } 265 + 213 266 } 214 267 /* 215 268 269 + 270 + protected function getRevisionActions(DifferentialRevision $revision) { 216 271 217 272 $viewer_id = $this->getRequest()->getViewerContext()->getUserID(); 218 273 $viewer_is_owner = ($viewer_id == $revision->getOwnerID()); ··· 1334 1389 return $inline_comments; 1335 1390 } 1336 1391 1337 - protected function getRevisionActions(DifferentialRevision $revision) { 1338 - $actions = array( 1339 - 'none' => true, 1340 - ); 1341 1392 1342 - $viewer = $this->getRequest()->getViewerContext(); 1343 - 1344 - $viewer_is_owner = ($viewer->getUserID() == $revision->getOwnerID()); 1345 - if ($viewer_is_owner) { 1346 - switch ($revision->getStatus()) { 1347 - case DifferentialConstants::NEEDS_REVIEW: 1348 - $actions['abandon'] = true; 1349 - break; 1350 - case DifferentialConstants::NEEDS_REVISION: 1351 - $actions['abandon'] = true; 1352 - $actions['request_review'] = true; 1353 - break; 1354 - case DifferentialConstants::ACCEPTED: 1355 - $actions['abandon'] = true; 1356 - $actions['request_review'] = true; 1357 - break; 1358 - case DifferentialConstants::COMMITTED: 1359 - break; 1360 - case DifferentialConstants::ABANDONED: 1361 - $actions['reclaim'] = true; 1362 - break; 1363 - default: 1364 - throw new Exception('Unknown DifferentialRevision status.'); 1365 - } 1366 - } else { 1367 - switch ($revision->getStatus()) { 1368 - case DifferentialConstants::NEEDS_REVIEW: 1369 - $actions['accept'] = true; 1370 - $actions['reject'] = true; 1371 - break; 1372 - case DifferentialConstants::NEEDS_REVISION: 1373 - $actions['accept'] = true; 1374 - break; 1375 - case DifferentialConstants::ACCEPTED: 1376 - $actions['reject'] = true; 1377 - break; 1378 - case DifferentialConstants::COMMITTED: 1379 - break; 1380 - case DifferentialConstants::ABANDONED: 1381 - break; 1382 - default: 1383 - throw new Exception('Unknown DifferentialRevision status.'); 1384 - } 1385 - 1386 - if (in_array($viewer->getUserID(), $revision->getReviewers())) { 1387 - $actions['resign'] = true; 1388 - } 1389 - } 1390 - 1391 - // Put add reviewers at the bottom since it's rare relative to other 1392 - // actions, notably accept and reject 1393 - $actions['add_reviewers'] = true; 1394 - 1395 - static $action_names = array( 1396 - 'none' => 'Comment', 1397 - 'abandon' => 'Abandon Revision', 1398 - 'request_review' => 'Request Review', 1399 - 'reclaim' => 'Reclaim Revision', 1400 - 'accept' => "Accept Revision \xE2\x9C\x94", 1401 - 'reject' => "Request Changes \xE2\x9C\x98", 1402 - 'resign' => "Resign as Reviewer", 1403 - 'add_reviewers' => "Add Reviewers", 1404 - ); 1405 - 1406 - foreach ($actions as $key => $value) { 1407 - $actions[$key] = $action_names[$key]; 1408 - } 1409 - 1410 - return $actions; 1411 - } 1412 1393 1413 1394 protected function getRevisionStatusDisplay(DifferentialRevision $revision) { 1414 1395 $viewer_id = $this->getRequest()->getViewerContext()->getUserID();
+1
src/applications/differential/controller/revisionview/__init__.php
··· 12 12 phutil_require_module('phabricator', 'applications/differential/controller/base'); 13 13 phutil_require_module('phabricator', 'applications/differential/storage/comment'); 14 14 phutil_require_module('phabricator', 'applications/differential/storage/revision'); 15 + phutil_require_module('phabricator', 'applications/differential/view/addcomment'); 15 16 phutil_require_module('phabricator', 'applications/differential/view/changesetlistview'); 16 17 phutil_require_module('phabricator', 'applications/differential/view/difftableofcontents'); 17 18 phutil_require_module('phabricator', 'applications/differential/view/revisioncommentlist');
+66
src/applications/differential/view/addcomment/DifferentialAddCommentView.php
··· 1 + <?php 2 + 3 + /* 4 + * Copyright 2011 Facebook, Inc. 5 + * 6 + * Licensed under the Apache License, Version 2.0 (the "License"); 7 + * you may not use this file except in compliance with the License. 8 + * You may obtain a copy of the License at 9 + * 10 + * http://www.apache.org/licenses/LICENSE-2.0 11 + * 12 + * Unless required by applicable law or agreed to in writing, software 13 + * distributed under the License is distributed on an "AS IS" BASIS, 14 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 + * See the License for the specific language governing permissions and 16 + * limitations under the License. 17 + */ 18 + 19 + final class DifferentialAddCommentView extends AphrontView { 20 + 21 + private $revision; 22 + private $actions; 23 + private $actionURI; 24 + 25 + public function setRevision($revision) { 26 + $this->revision = $revision; 27 + return $this; 28 + } 29 + 30 + public function setActions(array $actions) { 31 + $this->actions = $actions; 32 + return $this; 33 + } 34 + 35 + public function setActionURI($uri) { 36 + $this->actionURI = $uri; 37 + } 38 + 39 + public function render() { 40 + 41 + $actions = array(); 42 + foreach ($this->actions as $action) { 43 + $actions[$action] = DifferentialAction::getActionVerb($action); 44 + } 45 + 46 + $form = new AphrontFormView(); 47 + $form 48 + ->setAction($this->actionURI) 49 + ->appendChild( 50 + id(new AphrontFormSelectControl()) 51 + ->setLabel('Action') 52 + ->setOptions($actions)) 53 + ->appendChild( 54 + id(new AphrontFormTextAreaControl()) 55 + ->setLabel('Comment')) 56 + ->appendChild( 57 + id(new AphrontFormSubmitControl()) 58 + ->setValue('Comment')); 59 + 60 + return 61 + '<div class="differential-panel">'. 62 + '<h1>Add Comment</h1>'. 63 + $form->render(). 64 + '</div>'; 65 + } 66 + }
+17
src/applications/differential/view/addcomment/__init__.php
··· 1 + <?php 2 + /** 3 + * This file is automatically generated. Lint this module to rebuild it. 4 + * @generated 5 + */ 6 + 7 + 8 + 9 + phutil_require_module('phabricator', 'applications/differential/constants/action'); 10 + phutil_require_module('phabricator', 'view/base'); 11 + phutil_require_module('phabricator', 'view/form/base'); 12 + phutil_require_module('phabricator', 'view/form/control/submit'); 13 + 14 + phutil_require_module('phutil', 'utils'); 15 + 16 + 17 + phutil_require_source('DifferentialAddCommentView.php');
+1 -1
src/applications/differential/view/revisioncomment/DifferentialRevisionCommentView.php
··· 46 46 $author = $comment->getAuthorPHID(); 47 47 $author = $this->handles[$author]->renderLink(); 48 48 49 - $verb = DifferentialAction::getActionVerb($comment->getAction()); 49 + $verb = DifferentialAction::getActionPastTenseVerb($comment->getAction()); 50 50 $verb = phutil_escape_html($verb); 51 51 52 52 $content = $comment->getContent();