@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.

Clean up EditEngine implementation on Badges

Summary: Fixes T10672. Cleaning this up myself since I was responsible for the implementation.

Test Plan: Leave a comment, Edit a badge, create a badge.

Reviewers: lpriestley, epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T10672

Differential Revision: https://secure.phabricator.com/D15556

+24 -36
+2 -2
src/applications/badges/application/PhabricatorBadgesApplication.php
··· 45 45 => 'PhabricatorBadgesEditController', 46 46 'comment/(?P<id>[1-9]\d*)/' 47 47 => 'PhabricatorBadgesCommentController', 48 - 'edit/(?:(?P<id>\d+)/)?' 49 - => 'PhabricatorBadgesEditController', 48 + $this->getEditRoutePattern('edit/') 49 + => 'PhabricatorBadgesEditController', 50 50 'archive/(?:(?P<id>\d+)/)?' 51 51 => 'PhabricatorBadgesArchiveController', 52 52 'view/(?:(?P<id>\d+)/)?'
+3 -10
src/applications/badges/controller/PhabricatorBadgesListController.php
··· 16 16 protected function buildApplicationCrumbs() { 17 17 $crumbs = parent::buildApplicationCrumbs(); 18 18 19 - $can_create = $this->hasApplicationCapability( 20 - PhabricatorBadgesCreateCapability::CAPABILITY); 21 - 22 - $crumbs->addAction( 23 - id(new PHUIListItemView()) 24 - ->setName(pht('Create Badge')) 25 - ->setHref($this->getApplicationURI('create/')) 26 - ->setIcon('fa-plus-square') 27 - ->setDisabled(!$can_create) 28 - ->setWorkflow(!$can_create)); 19 + id(new PhabricatorBadgesEditEngine()) 20 + ->setViewer($this->getViewer()) 21 + ->addActionToCrumbs($crumbs); 29 22 30 23 return $crumbs; 31 24 }
+4 -22
src/applications/badges/controller/PhabricatorBadgesViewController.php
··· 60 60 ->setHandles($handles) 61 61 ->setUser($viewer); 62 62 63 - $add_comment = $this->buildCommentForm($badge); 63 + $comment_view = id(new PhabricatorBadgesEditEngine()) 64 + ->setViewer($viewer) 65 + ->buildEditEngineCommentView($badge); 64 66 65 67 $view = id(new PHUITwoColumnView()) 66 68 ->setHeader($header) ··· 68 70 ->setMainColumn(array( 69 71 $recipient_list, 70 72 $timeline, 71 - $add_comment, 73 + $comment_view, 72 74 )) 73 75 ->addPropertySection(pht('DESCRIPTION'), $details); 74 76 ··· 152 154 ->setHref($award_uri)); 153 155 154 156 return $curtain; 155 - } 156 - 157 - private function buildCommentForm(PhabricatorBadgesBadge $badge) { 158 - $viewer = $this->getViewer(); 159 - 160 - $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); 161 - 162 - $add_comment_header = $is_serious 163 - ? pht('Add Comment') 164 - : pht('Render Honors'); 165 - 166 - $draft = PhabricatorDraft::newFromUserAndKey($viewer, $badge->getPHID()); 167 - 168 - return id(new PhabricatorApplicationTransactionCommentView()) 169 - ->setUser($viewer) 170 - ->setObjectPHID($badge->getPHID()) 171 - ->setDraft($draft) 172 - ->setHeaderText($add_comment_header) 173 - ->setAction($this->getApplicationURI('/comment/'.$badge->getID().'/')) 174 - ->setSubmitButtonName(pht('Add Comment')); 175 157 } 176 158 177 159 }
+15 -2
src/applications/badges/editor/PhabricatorBadgesEditEngine.php
··· 49 49 return pht('Badge'); 50 50 } 51 51 52 + protected function getObjectCreateCancelURI($object) { 53 + return $this->getApplication()->getApplicationURI('/'); 54 + } 55 + 56 + protected function getEditorURI() { 57 + return $this->getApplication()->getApplicationURI('edit/'); 58 + } 59 + 52 60 protected function getCommentViewHeaderText($object) { 53 - return pht('Add Comment'); 61 + return pht('Render Honors'); 54 62 } 55 63 56 64 protected function getCommentViewButtonText($object) { 57 - return pht('Submit'); 65 + return pht('Salute'); 58 66 } 59 67 60 68 protected function getObjectViewURI($object) { 61 69 return $object->getViewURI(); 70 + } 71 + 72 + protected function getCreateNewObjectPolicy() { 73 + return $this->getApplication()->getPolicy( 74 + PhabricatorBadgesCreateCapability::CAPABILITY); 62 75 } 63 76 64 77 protected function buildCustomEditFields($object) {