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

Add a Dashboard MenuItem

Summary: Built similar to Projects, allows setting of a Dashboard to MenuItem.

Test Plan: Add a dashboard with and without a name / icon to a Project.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+118
+2
src/__phutil_library_map__.php
··· 2471 2471 'PhabricatorDashboardPanelTransactionQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelTransactionQuery.php', 2472 2472 'PhabricatorDashboardPanelType' => 'applications/dashboard/paneltype/PhabricatorDashboardPanelType.php', 2473 2473 'PhabricatorDashboardPanelViewController' => 'applications/dashboard/controller/PhabricatorDashboardPanelViewController.php', 2474 + 'PhabricatorDashboardProfileMenuItem' => 'applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php', 2474 2475 'PhabricatorDashboardQuery' => 'applications/dashboard/query/PhabricatorDashboardQuery.php', 2475 2476 'PhabricatorDashboardQueryPanelType' => 'applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php', 2476 2477 'PhabricatorDashboardRemarkupRule' => 'applications/dashboard/remarkup/PhabricatorDashboardRemarkupRule.php', ··· 7439 7440 'PhabricatorDashboardPanelTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 7440 7441 'PhabricatorDashboardPanelType' => 'Phobject', 7441 7442 'PhabricatorDashboardPanelViewController' => 'PhabricatorDashboardController', 7443 + 'PhabricatorDashboardProfileMenuItem' => 'PhabricatorProfileMenuItem', 7442 7444 'PhabricatorDashboardQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 7443 7445 'PhabricatorDashboardQueryPanelType' => 'PhabricatorDashboardPanelType', 7444 7446 'PhabricatorDashboardRemarkupRule' => 'PhabricatorObjectRemarkupRule',
+4
src/applications/dashboard/storage/PhabricatorDashboard.php
··· 120 120 return ($this->getStatus() == self::STATUS_ARCHIVED); 121 121 } 122 122 123 + public function getViewURI() { 124 + return '/dashboard/view/'.$this->getID().'/'; 125 + } 126 + 123 127 124 128 /* -( PhabricatorApplicationTransactionInterface )------------------------- */ 125 129
+112
src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardProfileMenuItem 4 + extends PhabricatorProfileMenuItem { 5 + 6 + const MENUITEMKEY = 'dashboard'; 7 + 8 + private $dashboard; 9 + 10 + public function getMenuItemTypeIcon() { 11 + return 'fa-dashboard'; 12 + } 13 + 14 + public function getMenuItemTypeName() { 15 + return pht('Dashboard'); 16 + } 17 + 18 + public function canAddToObject($object) { 19 + return true; 20 + } 21 + 22 + public function attachDashboard($dashboard) { 23 + $this->dashboard = $dashboard; 24 + return $this; 25 + } 26 + 27 + public function getDashboard() { 28 + $dashboard = $this->dashboard; 29 + if (!$dashboard) { 30 + return null; 31 + } else if ($dashboard->isArchived()) { 32 + return null; 33 + } 34 + return $dashboard; 35 + } 36 + 37 + public function willBuildNavigationItems(array $items) { 38 + $viewer = $this->getViewer(); 39 + $dashboard_phids = array(); 40 + foreach ($items as $item) { 41 + $dashboard_phids[] = $item->getMenuItemProperty('dashboardPHID'); 42 + } 43 + 44 + $dashboards = id(new PhabricatorDashboardQuery()) 45 + ->setViewer($viewer) 46 + ->withPHIDs($dashboard_phids) 47 + ->execute(); 48 + 49 + $dashboards = mpull($dashboards, null, 'getPHID'); 50 + foreach ($items as $item) { 51 + $dashboard_phid = $item->getMenuItemProperty('dashboardPHID'); 52 + $dashboard = idx($dashboards, $dashboard_phid, null); 53 + $item->getMenuItem()->attachDashboard($dashboard); 54 + } 55 + } 56 + 57 + public function getDisplayName( 58 + PhabricatorProfileMenuItemConfiguration $config) { 59 + $dashboard = $this->getDashboard(); 60 + if (!$dashboard) { 61 + return pht('(Restricted/Invalid Dashboard)'); 62 + } 63 + if (strlen($this->getName($config))) { 64 + return $this->getName($config); 65 + } else { 66 + return $dashboard->getName(); 67 + } 68 + } 69 + 70 + public function buildEditEngineFields( 71 + PhabricatorProfileMenuItemConfiguration $config) { 72 + return array( 73 + id(new PhabricatorTextEditField()) 74 + ->setKey('name') 75 + ->setLabel(pht('Name')) 76 + ->setValue($this->getName($config)), 77 + id(new PhabricatorDatasourceEditField()) 78 + ->setKey('dashboardPHID') 79 + ->setLabel(pht('Dashboard')) 80 + ->setDatasource(new PhabricatorDashboardDatasource()) 81 + ->setSingleValue($config->getMenuItemProperty('dashboardPHID')), 82 + ); 83 + } 84 + 85 + private function getName( 86 + PhabricatorProfileMenuItemConfiguration $config) { 87 + return $config->getMenuItemProperty('name'); 88 + } 89 + 90 + protected function newNavigationMenuItems( 91 + PhabricatorProfileMenuItemConfiguration $config) { 92 + 93 + $dashboard = $this->getDashboard(); 94 + if (!$dashboard) { 95 + return array(); 96 + } 97 + 98 + $icon = $dashboard->getIcon(); 99 + $name = $this->getDisplayName($config); 100 + $href = $dashboard->getViewURI(); 101 + 102 + $item = $this->newItem() 103 + ->setHref($href) 104 + ->setName($name) 105 + ->setIcon($icon); 106 + 107 + return array( 108 + $item, 109 + ); 110 + } 111 + 112 + }