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

Build Badges View page into more of a profile

Summary: Ref T10798. Cleans up the UI a little and adds a sidenav.

Test Plan: Review badge and recipients in sandbox.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T10798

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

+187 -54
+5 -2
src/__phutil_library_map__.php
··· 2027 2027 'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php', 2028 2028 'PhabricatorBadgesMailReceiver' => 'applications/badges/mail/PhabricatorBadgesMailReceiver.php', 2029 2029 'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php', 2030 + 'PhabricatorBadgesProfileController' => 'applications/badges/controller/PhabricatorBadgesProfileController.php', 2030 2031 'PhabricatorBadgesQuality' => 'applications/badges/constants/PhabricatorBadgesQuality.php', 2031 2032 'PhabricatorBadgesQuery' => 'applications/badges/query/PhabricatorBadgesQuery.php', 2033 + 'PhabricatorBadgesRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRecipientsController.php', 2032 2034 'PhabricatorBadgesRecipientsListView' => 'applications/badges/view/PhabricatorBadgesRecipientsListView.php', 2033 2035 'PhabricatorBadgesRemoveRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRemoveRecipientsController.php', 2034 2036 'PhabricatorBadgesReplyHandler' => 'applications/badges/mail/PhabricatorBadgesReplyHandler.php', ··· 6942 6944 'PhabricatorPolicyInterface', 6943 6945 'PhabricatorApplicationTransactionInterface', 6944 6946 'PhabricatorSubscribableInterface', 6945 - 'PhabricatorTokenReceiverInterface', 6946 6947 'PhabricatorFlaggableInterface', 6947 6948 'PhabricatorDestructibleInterface', 6948 6949 'PhabricatorConduitResultInterface', ··· 6964 6965 'PhabricatorBadgesListController' => 'PhabricatorBadgesController', 6965 6966 'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver', 6966 6967 'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType', 6968 + 'PhabricatorBadgesProfileController' => 'PhabricatorController', 6967 6969 'PhabricatorBadgesQuality' => 'Phobject', 6968 6970 'PhabricatorBadgesQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 6971 + 'PhabricatorBadgesRecipientsController' => 'PhabricatorBadgesProfileController', 6969 6972 'PhabricatorBadgesRecipientsListView' => 'AphrontView', 6970 6973 'PhabricatorBadgesRemoveRecipientsController' => 'PhabricatorBadgesController', 6971 6974 'PhabricatorBadgesReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', ··· 6975 6978 'PhabricatorBadgesTransaction' => 'PhabricatorApplicationTransaction', 6976 6979 'PhabricatorBadgesTransactionComment' => 'PhabricatorApplicationTransactionComment', 6977 6980 'PhabricatorBadgesTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 6978 - 'PhabricatorBadgesViewController' => 'PhabricatorBadgesController', 6981 + 'PhabricatorBadgesViewController' => 'PhabricatorBadgesProfileController', 6979 6982 'PhabricatorBarePageUIExample' => 'PhabricatorUIExample', 6980 6983 'PhabricatorBarePageView' => 'AphrontPageView', 6981 6984 'PhabricatorBaseURISetupCheck' => 'PhabricatorSetupCheck',
+8 -5
src/applications/badges/application/PhabricatorBadgesApplication.php
··· 47 47 => 'PhabricatorBadgesArchiveController', 48 48 'view/(?:(?P<id>\d+)/)?' 49 49 => 'PhabricatorBadgesViewController', 50 - 'recipients/(?P<id>[1-9]\d*)/' 51 - => 'PhabricatorBadgesEditRecipientsController', 52 - 'recipients/(?P<id>[1-9]\d*)/remove/' 53 - => 'PhabricatorBadgesRemoveRecipientsController', 54 - 50 + 'recipients/' => array( 51 + '(?P<id>[1-9]\d*)/' 52 + => 'PhabricatorBadgesRecipientsController', 53 + '(?P<id>[1-9]\d*)/add/' 54 + => 'PhabricatorBadgesEditRecipientsController', 55 + '(?P<id>[1-9]\d*)/remove/' 56 + => 'PhabricatorBadgesRemoveRecipientsController', 57 + ), 55 58 ), 56 59 ); 57 60 }
+3 -3
src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
··· 22 22 return new Aphront404Response(); 23 23 } 24 24 25 - $view_uri = $this->getApplicationURI('view/'.$badge->getID().'/'); 25 + $view_uri = $this->getApplicationURI('recipients/'.$badge->getID().'/'); 26 26 $awards = $badge->getAwards(); 27 27 $recipient_phids = mpull($awards, 'getRecipientPHID'); 28 28 ··· 79 79 ->appendControl( 80 80 id(new AphrontFormTokenizerControl()) 81 81 ->setName('phids') 82 - ->setLabel(pht('Add Recipients')) 82 + ->setLabel(pht('Recipients')) 83 83 ->setDatasource(new PhabricatorPeopleDatasource())); 84 84 } 85 85 86 86 $dialog = id(new AphrontDialogView()) 87 87 ->setUser($viewer) 88 - ->setTitle(pht('Award Badges')) 88 + ->setTitle(pht('Add Recipients')) 89 89 ->appendForm($form) 90 90 ->addCancelButton($view_uri) 91 91 ->addSubmitButton(pht('Add Recipients'));
+88
src/applications/badges/controller/PhabricatorBadgesProfileController.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorBadgesProfileController 4 + extends PhabricatorController { 5 + 6 + private $badge; 7 + 8 + public function setBadge(PhabricatorBadgesBadge $badge) { 9 + $this->badge = $badge; 10 + return $this; 11 + } 12 + 13 + public function getBadge() { 14 + return $this->badge; 15 + } 16 + 17 + public function buildApplicationMenu() { 18 + return $this->buildSideNavView()->getMenu(); 19 + } 20 + 21 + protected function buildHeaderView() { 22 + $viewer = $this->getViewer(); 23 + $badge = $this->getBadge(); 24 + $id = $badge->getID(); 25 + 26 + if ($badge->isArchived()) { 27 + $status_icon = 'fa-ban'; 28 + $status_color = 'dark'; 29 + } else { 30 + $status_icon = 'fa-check'; 31 + $status_color = 'bluegrey'; 32 + } 33 + $status_name = idx( 34 + PhabricatorBadgesBadge::getStatusNameMap(), 35 + $badge->getStatus()); 36 + 37 + return id(new PHUIHeaderView()) 38 + ->setHeader($badge->getName()) 39 + ->setUser($viewer) 40 + ->setPolicyObject($badge) 41 + ->setStatus($status_icon, $status_color, $status_name) 42 + ->setHeaderIcon('fa-trophy'); 43 + } 44 + 45 + protected function buildApplicationCrumbs() { 46 + $badge = $this->getBadge(); 47 + $id = $badge->getID(); 48 + $badge_uri = $this->getApplicationURI("/view/{$id}/"); 49 + 50 + $crumbs = parent::buildApplicationCrumbs(); 51 + $crumbs->addTextCrumb($badge->getName(), $badge_uri); 52 + $crumbs->setBorder(true); 53 + return $crumbs; 54 + } 55 + 56 + protected function buildSideNavView($filter = null) { 57 + $viewer = $this->getViewer(); 58 + $badge = $this->getBadge(); 59 + $id = $badge->getID(); 60 + 61 + $can_edit = PhabricatorPolicyFilter::hasCapability( 62 + $viewer, 63 + $badge, 64 + PhabricatorPolicyCapability::CAN_EDIT); 65 + 66 + $nav = id(new AphrontSideNavFilterView()) 67 + ->setBaseURI(new PhutilURI($this->getApplicationURI())); 68 + 69 + $nav->addLabel(pht('Badge')); 70 + 71 + $nav->addFilter( 72 + 'view', 73 + pht('View Badge'), 74 + $this->getApplicationURI("/view/{$id}/"), 75 + 'fa-trophy'); 76 + 77 + $nav->addFilter( 78 + 'recipients', 79 + pht('View Recipients'), 80 + $this->getApplicationURI("/recipients/{$id}/"), 81 + 'fa-group'); 82 + 83 + $nav->selectFilter($filter); 84 + 85 + return $nav; 86 + } 87 + 88 + }
+58
src/applications/badges/controller/PhabricatorBadgesRecipientsController.php
··· 1 + <?php 2 + 3 + final class PhabricatorBadgesRecipientsController 4 + extends PhabricatorBadgesProfileController { 5 + 6 + public function shouldAllowPublic() { 7 + return true; 8 + } 9 + 10 + public function handleRequest(AphrontRequest $request) { 11 + $viewer = $request->getViewer(); 12 + $id = $request->getURIData('id'); 13 + 14 + $badge = id(new PhabricatorBadgesQuery()) 15 + ->setViewer($viewer) 16 + ->withIDs(array($id)) 17 + ->needRecipients(true) 18 + ->executeOne(); 19 + if (!$badge) { 20 + return new Aphront404Response(); 21 + } 22 + 23 + $this->setBadge($badge); 24 + 25 + $crumbs = $this->buildApplicationCrumbs(); 26 + $crumbs->addTextCrumb(pht('Recipients')); 27 + $crumbs->setBorder(true); 28 + $title = $badge->getName(); 29 + 30 + $header = $this->buildHeaderView(); 31 + 32 + $awards = $badge->getAwards(); 33 + $recipient_phids = mpull($awards, 'getRecipientPHID'); 34 + $recipient_phids = array_reverse($recipient_phids); 35 + $handles = $this->loadViewerHandles($recipient_phids); 36 + 37 + $recipient_list = id(new PhabricatorBadgesRecipientsListView()) 38 + ->setBadge($badge) 39 + ->setHandles($handles) 40 + ->setUser($viewer); 41 + 42 + $view = id(new PHUITwoColumnView()) 43 + ->setHeader($header) 44 + ->setFooter(array( 45 + $recipient_list, 46 + )); 47 + 48 + $navigation = $this->buildSideNavView('recipients'); 49 + 50 + return $this->newPage() 51 + ->setTitle($title) 52 + ->setCrumbs($crumbs) 53 + ->setPageObjectPHIDs(array($badge->getPHID())) 54 + ->setNavigation($navigation) 55 + ->appendChild($view); 56 + } 57 + 58 + }
+8 -34
src/applications/badges/controller/PhabricatorBadgesViewController.php
··· 1 1 <?php 2 2 3 3 final class PhabricatorBadgesViewController 4 - extends PhabricatorBadgesController { 4 + extends PhabricatorBadgesProfileController { 5 5 6 6 public function shouldAllowPublic() { 7 7 return true; ··· 14 14 $badge = id(new PhabricatorBadgesQuery()) 15 15 ->setViewer($viewer) 16 16 ->withIDs(array($id)) 17 - ->needRecipients(true) 18 17 ->executeOne(); 19 18 if (!$badge) { 20 19 return new Aphront404Response(); 21 20 } 22 21 22 + $this->setBadge($badge); 23 + 23 24 $crumbs = $this->buildApplicationCrumbs(); 24 - $crumbs->addTextCrumb($badge->getName()); 25 - $crumbs->setBorder(true); 26 25 $title = $badge->getName(); 27 26 28 - if ($badge->isArchived()) { 29 - $status_icon = 'fa-ban'; 30 - $status_color = 'dark'; 31 - } else { 32 - $status_icon = 'fa-check'; 33 - $status_color = 'bluegrey'; 34 - } 35 - $status_name = idx( 36 - PhabricatorBadgesBadge::getStatusNameMap(), 37 - $badge->getStatus()); 38 - 39 - $header = id(new PHUIHeaderView()) 40 - ->setHeader($badge->getName()) 41 - ->setUser($viewer) 42 - ->setPolicyObject($badge) 43 - ->setStatus($status_icon, $status_color, $status_name) 44 - ->setHeaderIcon('fa-trophy'); 45 - 27 + $header = $this->buildHeaderView(); 46 28 $curtain = $this->buildCurtain($badge); 47 29 $details = $this->buildDetailsView($badge); 48 30 ··· 50 32 $badge, 51 33 new PhabricatorBadgesTransactionQuery()); 52 34 53 - $awards = $badge->getAwards(); 54 - $recipient_phids = mpull($awards, 'getRecipientPHID'); 55 - $recipient_phids = array_reverse($recipient_phids); 56 - $handles = $this->loadViewerHandles($recipient_phids); 57 - 58 - $recipient_list = id(new PhabricatorBadgesRecipientsListView()) 59 - ->setBadge($badge) 60 - ->setHandles($handles) 61 - ->setUser($viewer); 62 - 63 35 $comment_view = id(new PhabricatorBadgesEditEngine()) 64 36 ->setViewer($viewer) 65 37 ->buildEditEngineCommentView($badge); ··· 68 40 ->setHeader($header) 69 41 ->setCurtain($curtain) 70 42 ->setMainColumn(array( 71 - $recipient_list, 72 43 $timeline, 73 44 $comment_view, 74 45 )) 75 46 ->addPropertySection(pht('Description'), $details); 76 47 48 + $navigation = $this->buildSideNavView('view'); 49 + 77 50 return $this->newPage() 78 51 ->setTitle($title) 79 52 ->setCrumbs($crumbs) 80 53 ->setPageObjectPHIDs(array($badge->getPHID())) 54 + ->setNavigation($navigation) 81 55 ->appendChild($view); 82 56 } 83 57 ··· 116 90 $id = $badge->getID(); 117 91 $edit_uri = $this->getApplicationURI("/edit/{$id}/"); 118 92 $archive_uri = $this->getApplicationURI("/archive/{$id}/"); 119 - $award_uri = $this->getApplicationURI("/recipients/{$id}/"); 93 + $award_uri = $this->getApplicationURI("/recipients/{$id}/add/"); 120 94 121 95 $curtain = $this->newCurtainView($badge); 122 96
-9
src/applications/badges/storage/PhabricatorBadgesBadge.php
··· 5 5 PhabricatorPolicyInterface, 6 6 PhabricatorApplicationTransactionInterface, 7 7 PhabricatorSubscribableInterface, 8 - PhabricatorTokenReceiverInterface, 9 8 PhabricatorFlaggableInterface, 10 9 PhabricatorDestructibleInterface, 11 10 PhabricatorConduitResultInterface, ··· 158 157 159 158 public function isAutomaticallySubscribed($phid) { 160 159 return ($this->creatorPHID == $phid); 161 - } 162 - 163 - 164 - /* -( PhabricatorTokenReceiverInterface )---------------------------------- */ 165 - 166 - 167 - public function getUsersToNotifyOfTokenGiven() { 168 - return array($this->getCreatorPHID()); 169 160 } 170 161 171 162
+4
src/applications/badges/storage/PhabricatorBadgesTransaction.php
··· 38 38 39 39 $type = $this->getTransactionType(); 40 40 switch ($type) { 41 + case PhabricatorTransactions::TYPE_CREATE: 42 + return pht( 43 + '%s created this badge.', 44 + $this->renderHandleLink($author_phid)); 41 45 case self::TYPE_NAME: 42 46 if ($old === null) { 43 47 return pht(
+13 -1
src/applications/badges/view/PhabricatorBadgesRecipientsListView.php
··· 27 27 $badge, 28 28 PhabricatorPolicyCapability::CAN_EDIT); 29 29 30 + $award_button = id(new PHUIButtonView()) 31 + ->setTag('a') 32 + ->setIcon('fa-plus') 33 + ->setText(pht('Add Recipents')) 34 + ->setWorkflow(true) 35 + ->setDisabled(!$can_edit) 36 + ->setHref('/badges/recipients/'.$badge->getID().'/add/'); 37 + 38 + $header = id(new PHUIHeaderView()) 39 + ->setHeader(pht('Recipients')) 40 + ->addActionLink($award_button); 41 + 30 42 $list = id(new PHUIObjectItemListView()) 31 43 ->setNoDataString(pht('This badge does not have any recipients.')) 32 44 ->setFlush(true); ··· 62 74 } 63 75 64 76 $box = id(new PHUIObjectBoxView()) 65 - ->setHeaderText(pht('Recipients')) 77 + ->setHeader($header) 66 78 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 67 79 ->setObjectList($list); 68 80