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

Make the default view of dashboards be just the dashboard

Summary: Fixes T4985, add manage page, change view page to show only panels. Arguably, PhabricatorDashboardArrangeController is no longer necessary. Also, still trying to figure out if I updated all flows that involve "arrange/{id}". Probably missed some. Also not sure of the Manage Dashboard icon. Please advise.

Test Plan: Create dashboard, add panels, "view/{id}" should show just panels, Manage Dashboard should show timeline and edit links.

Reviewers: #blessed_reviewers, epriestley, chad

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T4985

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

authored by

lkassianik and committed by
epriestley
63024148 f896dc53

+180 -193
+2 -2
src/__phutil_library_map__.php
··· 1463 1463 'PhabricatorDaemonTaskGarbageCollector' => 'applications/daemon/garbagecollector/PhabricatorDaemonTaskGarbageCollector.php', 1464 1464 'PhabricatorDashboard' => 'applications/dashboard/storage/PhabricatorDashboard.php', 1465 1465 'PhabricatorDashboardAddPanelController' => 'applications/dashboard/controller/PhabricatorDashboardAddPanelController.php', 1466 - 'PhabricatorDashboardArrangeController' => 'applications/dashboard/controller/PhabricatorDashboardArrangeController.php', 1467 1466 'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php', 1468 1467 'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php', 1469 1468 'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php', ··· 1471 1470 'PhabricatorDashboardInstallController' => 'applications/dashboard/controller/PhabricatorDashboardInstallController.php', 1472 1471 'PhabricatorDashboardLayoutConfig' => 'applications/dashboard/layoutconfig/PhabricatorDashboardLayoutConfig.php', 1473 1472 'PhabricatorDashboardListController' => 'applications/dashboard/controller/PhabricatorDashboardListController.php', 1473 + 'PhabricatorDashboardManageController' => 'applications/dashboard/controller/PhabricatorDashboardManageController.php', 1474 1474 'PhabricatorDashboardMovePanelController' => 'applications/dashboard/controller/PhabricatorDashboardMovePanelController.php', 1475 1475 'PhabricatorDashboardPHIDTypeDashboard' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php', 1476 1476 'PhabricatorDashboardPHIDTypePanel' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php', ··· 4258 4258 1 => 'PhabricatorPolicyInterface', 4259 4259 ), 4260 4260 'PhabricatorDashboardAddPanelController' => 'PhabricatorDashboardController', 4261 - 'PhabricatorDashboardArrangeController' => 'PhabricatorDashboardController', 4262 4261 'PhabricatorDashboardController' => 'PhabricatorController', 4263 4262 'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO', 4264 4263 'PhabricatorDashboardEditController' => 'PhabricatorDashboardController', 4265 4264 'PhabricatorDashboardInstall' => 'PhabricatorDashboardDAO', 4266 4265 'PhabricatorDashboardInstallController' => 'PhabricatorDashboardController', 4267 4266 'PhabricatorDashboardListController' => 'PhabricatorDashboardController', 4267 + 'PhabricatorDashboardManageController' => 'PhabricatorDashboardController', 4268 4268 'PhabricatorDashboardMovePanelController' => 'PhabricatorDashboardController', 4269 4269 'PhabricatorDashboardPHIDTypeDashboard' => 'PhabricatorPHIDType', 4270 4270 'PhabricatorDashboardPHIDTypePanel' => 'PhabricatorPHIDType',
+1 -1
src/applications/dashboard/application/PhabricatorApplicationDashboard.php
··· 21 21 '(?:query/(?P<queryKey>[^/]+)/)?' 22 22 => 'PhabricatorDashboardListController', 23 23 'view/(?P<id>\d+)/' => 'PhabricatorDashboardViewController', 24 - 'arrange/(?P<id>\d+)/' => 'PhabricatorDashboardArrangeController', 24 + 'manage/(?P<id>\d+)/' => 'PhabricatorDashboardManageController', 25 25 'create/' => 'PhabricatorDashboardEditController', 26 26 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardEditController', 27 27 'install/(?P<id>\d+)/' => 'PhabricatorDashboardInstallController',
+2 -7
src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
··· 26 26 return new Aphront404Response(); 27 27 } 28 28 29 - if ($request->getStr('src', 'edit') == 'edit') { 30 - $redirect_uri = $this->getApplicationURI( 31 - 'view/'.$dashboard->getID().'/'); 32 - } else { 33 - $redirect_uri = $this->getApplicationURI( 34 - 'arrange/'.$dashboard->getID().'/'); 35 - } 29 + $redirect_uri = $this->getApplicationURI( 30 + 'manage/'.$dashboard->getID().'/'); 36 31 $layout_config = $dashboard->getLayoutConfigObject(); 37 32 38 33 $v_panel = $request->getStr('panel');
-54
src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php
··· 1 - <?php 2 - 3 - final class PhabricatorDashboardArrangeController 4 - extends PhabricatorDashboardController { 5 - 6 - private $id; 7 - 8 - public function willProcessRequest(array $data) { 9 - $this->id = $data['id']; 10 - } 11 - 12 - public function processRequest() { 13 - $request = $this->getRequest(); 14 - $viewer = $request->getUser(); 15 - 16 - $dashboard = id(new PhabricatorDashboardQuery()) 17 - ->setViewer($viewer) 18 - ->withIDs(array($this->id)) 19 - ->needPanels(true) 20 - ->requireCapabilities( 21 - array( 22 - PhabricatorPolicyCapability::CAN_VIEW, 23 - PhabricatorPolicyCapability::CAN_EDIT, 24 - )) 25 - ->executeOne(); 26 - if (!$dashboard) { 27 - return new Aphront404Response(); 28 - } 29 - 30 - $title = $dashboard->getName(); 31 - $crumbs = $this->buildApplicationCrumbs(); 32 - $crumbs->addTextCrumb( 33 - pht('Dashboard %d', $dashboard->getID()), 34 - $this->getApplicationURI('view/'.$dashboard->getID().'/')); 35 - $crumbs->addTextCrumb(pht('Arrange')); 36 - 37 - $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) 38 - ->setViewer($viewer) 39 - ->setDashboard($dashboard) 40 - ->setArrangeMode(true) 41 - ->renderDashboard(); 42 - 43 - return $this->buildApplicationPage( 44 - array( 45 - $crumbs, 46 - $rendered_dashboard, 47 - ), 48 - array( 49 - 'title' => $title, 50 - 'device' => true, 51 - )); 52 - } 53 - 54 - }
+3 -6
src/applications/dashboard/controller/PhabricatorDashboardEditController.php
··· 46 46 $crumbs->addTextCrumb('Create Dashboard'); 47 47 } else { 48 48 $id = $dashboard->getID(); 49 - $cancel_uri = $this->getApplicationURI('view/'.$id.'/'); 49 + $cancel_uri = $this->getApplicationURI('manage/'.$id.'/'); 50 50 51 51 $title = pht('Edit Dashboard %d', $dashboard->getID()); 52 52 $header = pht('Edit Dashboard "%s"', $dashboard->getName()); ··· 94 94 ->setContentSourceFromRequest($request) 95 95 ->applyTransactions($dashboard, $xactions); 96 96 97 - if ($is_new) { 98 - $uri = $this->getApplicationURI('arrange/'.$dashboard->getID().'/'); 99 - } else { 100 - $uri = $this->getApplicationURI('view/'.$dashboard->getID().'/'); 101 - } 97 + $uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/'); 98 + 102 99 return id(new AphrontRedirectResponse())->setURI($uri); 103 100 } catch (PhabricatorApplicationTransactionValidationException $ex) { 104 101 $validation_exception = $ex;
+161
src/applications/dashboard/controller/PhabricatorDashboardManageController.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardManageController 4 + extends PhabricatorDashboardController { 5 + 6 + private $id; 7 + 8 + public function willProcessRequest(array $data) { 9 + $this->id = $data['id']; 10 + } 11 + 12 + public function processRequest() { 13 + $request = $this->getRequest(); 14 + $viewer = $request->getUser(); 15 + $id = $this->id; 16 + $dashboard_uri = $this->getApplicationURI('view/'.$id.'/'); 17 + 18 + $dashboard = id(new PhabricatorDashboardQuery()) 19 + ->setViewer($viewer) 20 + ->withIDs(array($this->id)) 21 + ->needPanels(true) 22 + ->executeOne(); 23 + if (!$dashboard) { 24 + return new Aphront404Response(); 25 + } 26 + 27 + $title = $dashboard->getName(); 28 + 29 + $crumbs = $this->buildApplicationCrumbs(); 30 + $crumbs->addTextCrumb( 31 + pht('Dashboard %d', $dashboard->getID()), 32 + $dashboard_uri); 33 + $crumbs->addTextCrumb(pht('Manage')); 34 + 35 + $header = $this->buildHeaderView($dashboard); 36 + $actions = $this->buildActionView($dashboard); 37 + $properties = $this->buildPropertyView($dashboard); 38 + $timeline = $this->buildTransactions($dashboard); 39 + 40 + $properties->setActionList($actions); 41 + $box = id(new PHUIObjectBoxView()) 42 + ->setHeader($header) 43 + ->addPropertyList($properties); 44 + 45 + $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) 46 + ->setViewer($viewer) 47 + ->setDashboard($dashboard) 48 + ->setArrangeMode(true) 49 + ->renderDashboard(); 50 + 51 + return $this->buildApplicationPage( 52 + array( 53 + $crumbs, 54 + $box, 55 + $timeline, 56 + $rendered_dashboard, 57 + ), 58 + array( 59 + 'title' => $title, 60 + 'device' => true, 61 + )); 62 + } 63 + 64 + private function buildHeaderView(PhabricatorDashboard $dashboard) { 65 + $viewer = $this->getRequest()->getUser(); 66 + 67 + return id(new PHUIHeaderView()) 68 + ->setUser($viewer) 69 + ->setHeader($dashboard->getName()) 70 + ->setPolicyObject($dashboard); 71 + } 72 + 73 + private function buildActionView(PhabricatorDashboard $dashboard) { 74 + $viewer = $this->getRequest()->getUser(); 75 + $id = $dashboard->getID(); 76 + 77 + $actions = id(new PhabricatorActionListView()) 78 + ->setObjectURI($this->getApplicationURI('view/'.$dashboard->getID().'/')) 79 + ->setUser($viewer); 80 + 81 + $can_edit = PhabricatorPolicyFilter::hasCapability( 82 + $viewer, 83 + $dashboard, 84 + PhabricatorPolicyCapability::CAN_EDIT); 85 + 86 + $actions->addAction( 87 + id(new PhabricatorActionView()) 88 + ->setName(pht('Edit Dashboard')) 89 + ->setIcon('fa-pencil') 90 + ->setHref($this->getApplicationURI("edit/{$id}/")) 91 + ->setDisabled(!$can_edit) 92 + ->setWorkflow(!$can_edit)); 93 + 94 + $installed_dashboard = id(new PhabricatorDashboardInstall()) 95 + ->loadOneWhere( 96 + 'objectPHID = %s AND applicationClass = %s', 97 + $viewer->getPHID(), 98 + 'PhabricatorApplicationHome'); 99 + if ($installed_dashboard && 100 + $installed_dashboard->getDashboardPHID() == $dashboard->getPHID()) { 101 + $title_install = pht('Uninstall Dashboard'); 102 + $href_install = "uninstall/{$id}/"; 103 + } else { 104 + $title_install = pht('Install Dashboard'); 105 + $href_install = "install/{$id}/"; 106 + } 107 + $actions->addAction( 108 + id(new PhabricatorActionView()) 109 + ->setName($title_install) 110 + ->setIcon('fa-wrench') 111 + ->setHref($this->getApplicationURI($href_install)) 112 + ->setWorkflow(true)); 113 + 114 + return $actions; 115 + } 116 + 117 + private function buildPropertyView(PhabricatorDashboard $dashboard) { 118 + $viewer = $this->getRequest()->getUser(); 119 + 120 + $properties = id(new PHUIPropertyListView()) 121 + ->setUser($viewer) 122 + ->setObject($dashboard); 123 + 124 + $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( 125 + $viewer, 126 + $dashboard); 127 + 128 + $properties->addProperty( 129 + pht('Editable By'), 130 + $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); 131 + 132 + $panel_phids = $dashboard->getPanelPHIDs(); 133 + $this->loadHandles($panel_phids); 134 + 135 + $properties->addProperty( 136 + pht('Panels'), 137 + $this->renderHandlesForPHIDs($panel_phids)); 138 + 139 + return $properties; 140 + } 141 + 142 + private function buildTransactions(PhabricatorDashboard $dashboard) { 143 + $viewer = $this->getRequest()->getUser(); 144 + 145 + $xactions = id(new PhabricatorDashboardTransactionQuery()) 146 + ->setViewer($viewer) 147 + ->withObjectPHIDs(array($dashboard->getPHID())) 148 + ->execute(); 149 + 150 + $engine = id(new PhabricatorMarkupEngine()) 151 + ->setViewer($viewer); 152 + 153 + $timeline = id(new PhabricatorApplicationTransactionView()) 154 + ->setUser($viewer) 155 + ->setObjectPHID($dashboard->getPHID()) 156 + ->setTransactions($xactions); 157 + 158 + return $timeline; 159 + } 160 + 161 + }
+1 -1
src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
··· 182 182 $request = $this->getRequest(); 183 183 $dashboard_id = $request->getInt('dashboardID'); 184 184 if ($dashboard_id) { 185 - $uri = $this->getApplicationURI('arrange/'.$dashboard_id.'/'); 185 + $uri = $this->getApplicationURI('manage/'.$dashboard_id.'/'); 186 186 } else { 187 187 $uri = '/'.$panel->getMonogram(); 188 188 }
+1 -1
src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php
··· 36 36 } 37 37 38 38 $redirect_uri = $this->getApplicationURI( 39 - 'arrange/'.$dashboard->getID().'/'); 39 + 'manage/'.$dashboard->getID().'/'); 40 40 $layout_config = $dashboard->getLayoutConfigObject(); 41 41 42 42 if ($request->isFormPost()) {
+9 -121
src/applications/dashboard/controller/PhabricatorDashboardViewController.php
··· 26 26 $crumbs = $this->buildApplicationCrumbs(); 27 27 $crumbs->addTextCrumb(pht('Dashboard %d', $dashboard->getID())); 28 28 29 - $header = $this->buildHeaderView($dashboard); 30 - $actions = $this->buildActionView($dashboard); 31 - $properties = $this->buildPropertyView($dashboard); 32 - $timeline = $this->buildTransactions($dashboard); 33 - 34 - $properties->setActionList($actions); 35 - $box = id(new PHUIObjectBoxView()) 36 - ->setHeader($header) 37 - ->addPropertyList($properties); 38 - 39 29 $rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) 40 30 ->setViewer($viewer) 41 31 ->setDashboard($dashboard) ··· 44 34 return $this->buildApplicationPage( 45 35 array( 46 36 $crumbs, 47 - $box, 48 - $timeline, 49 37 $rendered_dashboard, 50 38 ), 51 39 array( ··· 54 42 )); 55 43 } 56 44 57 - private function buildHeaderView(PhabricatorDashboard $dashboard) { 58 - $viewer = $this->getRequest()->getUser(); 59 - 60 - return id(new PHUIHeaderView()) 61 - ->setUser($viewer) 62 - ->setHeader($dashboard->getName()) 63 - ->setPolicyObject($dashboard); 64 - } 65 - 66 - private function buildActionView(PhabricatorDashboard $dashboard) { 67 - $viewer = $this->getRequest()->getUser(); 68 - $id = $dashboard->getID(); 69 - 70 - $actions = id(new PhabricatorActionListView()) 71 - ->setObjectURI($this->getApplicationURI('view/'.$dashboard->getID().'/')) 72 - ->setUser($viewer); 73 - 74 - $can_edit = PhabricatorPolicyFilter::hasCapability( 75 - $viewer, 76 - $dashboard, 77 - PhabricatorPolicyCapability::CAN_EDIT); 78 - 79 - $actions->addAction( 80 - id(new PhabricatorActionView()) 81 - ->setName(pht('Edit Dashboard')) 82 - ->setIcon('fa-pencil') 83 - ->setHref($this->getApplicationURI("edit/{$id}/")) 84 - ->setDisabled(!$can_edit) 85 - ->setWorkflow(!$can_edit)); 86 - 87 - $actions->addAction( 88 - id(new PhabricatorActionView()) 89 - ->setName(pht('Arrange Dashboard')) 90 - ->setIcon('fa-arrows') 91 - ->setHref($this->getApplicationURI("arrange/{$id}/")) 92 - ->setDisabled(!$can_edit) 93 - ->setWorkflow(!$can_edit)); 94 - 95 - $installed_dashboard = id(new PhabricatorDashboardInstall()) 96 - ->loadOneWhere( 97 - 'objectPHID = %s AND applicationClass = %s', 98 - $viewer->getPHID(), 99 - 'PhabricatorApplicationHome'); 100 - if ($installed_dashboard && 101 - $installed_dashboard->getDashboardPHID() == $dashboard->getPHID()) { 102 - $title_install = pht('Uninstall Dashboard'); 103 - $href_install = "uninstall/{$id}/"; 104 - } else { 105 - $title_install = pht('Install Dashboard'); 106 - $href_install = "install/{$id}/"; 107 - } 108 - $actions->addAction( 109 - id(new PhabricatorActionView()) 110 - ->setName($title_install) 111 - ->setIcon('fa-wrench') 112 - ->setHref($this->getApplicationURI($href_install)) 113 - ->setWorkflow(true)); 45 + public function buildApplicationCrumbs() { 46 + $crumbs = parent::buildApplicationCrumbs(); 47 + $id = $this->id; 114 48 115 - $actions->addAction( 116 - id(new PhabricatorActionView()) 117 - ->setName(pht('Add Panel')) 118 - ->setIcon('fa-plus') 119 - ->setHref($this->getApplicationURI("addpanel/{$id}/")) 120 - ->setDisabled(!$can_edit) 121 - ->setWorkflow(true)); 122 - 123 - return $actions; 124 - } 125 - 126 - private function buildPropertyView(PhabricatorDashboard $dashboard) { 127 - $viewer = $this->getRequest()->getUser(); 49 + $crumbs->addAction( 50 + id(new PHUIListItemView()) 51 + ->setIcon('fa-th') 52 + ->setName(pht('Manage Dashboard')) 53 + ->setHref($this->getApplicationURI()."manage/{$id}/")); 128 54 129 - $properties = id(new PHUIPropertyListView()) 130 - ->setUser($viewer) 131 - ->setObject($dashboard); 132 - 133 - $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( 134 - $viewer, 135 - $dashboard); 136 - 137 - $properties->addProperty( 138 - pht('Editable By'), 139 - $descriptions[PhabricatorPolicyCapability::CAN_EDIT]); 140 - 141 - $panel_phids = $dashboard->getPanelPHIDs(); 142 - $this->loadHandles($panel_phids); 143 - 144 - $properties->addProperty( 145 - pht('Panels'), 146 - $this->renderHandlesForPHIDs($panel_phids)); 147 - 148 - return $properties; 149 - } 150 - 151 - private function buildTransactions(PhabricatorDashboard $dashboard) { 152 - $viewer = $this->getRequest()->getUser(); 153 - 154 - $xactions = id(new PhabricatorDashboardTransactionQuery()) 155 - ->setViewer($viewer) 156 - ->withObjectPHIDs(array($dashboard->getPHID())) 157 - ->execute(); 158 - 159 - $engine = id(new PhabricatorMarkupEngine()) 160 - ->setViewer($viewer); 161 - 162 - $timeline = id(new PhabricatorApplicationTransactionView()) 163 - ->setUser($viewer) 164 - ->setObjectPHID($dashboard->getPHID()) 165 - ->setTransactions($xactions); 166 - 167 - return $timeline; 55 + return $crumbs; 168 56 } 169 57 170 58 }