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

Let dashboard panels render in a very basic way

Summary: Ref T3583. This implements very primitive panel rendering on the panel detail page, and an ajaxable standalone view.

Test Plan:
{F149135}

{F149136}

{F149137}

{F149138}

Reviewers: chad, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3583

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

+126
+4
src/__phutil_library_map__.php
··· 1443 1443 'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php', 1444 1444 'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php', 1445 1445 'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php', 1446 + 'PhabricatorDashboardPanelRenderController' => 'applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php', 1447 + 'PhabricatorDashboardPanelRenderingEngine' => 'applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php', 1446 1448 'PhabricatorDashboardPanelSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php', 1447 1449 'PhabricatorDashboardPanelTransaction' => 'applications/dashboard/storage/PhabricatorDashboardPanelTransaction.php', 1448 1450 'PhabricatorDashboardPanelTransactionEditor' => 'applications/dashboard/editor/PhabricatorDashboardPanelTransactionEditor.php', ··· 4253 4255 1 => 'PhabricatorApplicationSearchResultsControllerInterface', 4254 4256 ), 4255 4257 'PhabricatorDashboardPanelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 4258 + 'PhabricatorDashboardPanelRenderController' => 'PhabricatorDashboardController', 4259 + 'PhabricatorDashboardPanelRenderingEngine' => 'Phobject', 4256 4260 'PhabricatorDashboardPanelSearchEngine' => 'PhabricatorApplicationSearchEngine', 4257 4261 'PhabricatorDashboardPanelTransaction' => 'PhabricatorApplicationTransaction', 4258 4262 'PhabricatorDashboardPanelTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
+1
src/applications/dashboard/application/PhabricatorApplicationDashboard.php
··· 29 29 => 'PhabricatorDashboardPanelListController', 30 30 'create/' => 'PhabricatorDashboardPanelCreateController', 31 31 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardPanelEditController', 32 + 'render/(?P<id>\d+)/' => 'PhabricatorDashboardPanelRenderController', 32 33 ), 33 34 ), 34 35 );
+53
src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelRenderController 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 + $panel = id(new PhabricatorDashboardPanelQuery()) 17 + ->setViewer($viewer) 18 + ->withIDs(array($this->id)) 19 + ->executeOne(); 20 + if (!$panel) { 21 + return new Aphront404Response(); 22 + } 23 + 24 + $rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine()) 25 + ->setViewer($viewer) 26 + ->setPanel($panel) 27 + ->renderPanel(); 28 + 29 + if ($request->isAjax()) { 30 + return id(new AphrontAjaxResponse()) 31 + ->setContent( 32 + array( 33 + 'panelMarkup' => $rendered_panel, 34 + )); 35 + } 36 + 37 + $crumbs = $this->buildApplicationCrumbs() 38 + ->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/')) 39 + ->addTextCrumb($panel->getMonogram(), '/'.$panel->getMonogram()) 40 + ->addTextCrumb(pht('Standalone View')); 41 + 42 + return $this->buildApplicationPage( 43 + array( 44 + $crumbs, 45 + $rendered_panel, 46 + ), 47 + array( 48 + 'title' => array(pht('Panel'), $panel->getName()), 49 + 'device' => true, 50 + )); 51 + } 52 + 53 + }
+12
src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
··· 38 38 ->setHeader($header) 39 39 ->addPropertyList($properties); 40 40 41 + $rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine()) 42 + ->setViewer($viewer) 43 + ->setPanel($panel) 44 + ->renderPanel(); 45 + 41 46 return $this->buildApplicationPage( 42 47 array( 43 48 $crumbs, 44 49 $box, 45 50 $timeline, 51 + $rendered_panel, 46 52 ), 47 53 array( 48 54 'title' => $title, ··· 79 85 ->setHref($this->getApplicationURI("panel/edit/{$id}/")) 80 86 ->setDisabled(!$can_edit) 81 87 ->setWorkflow(!$can_edit)); 88 + 89 + $actions->addAction( 90 + id(new PhabricatorActionView()) 91 + ->setName(pht('View Standalone')) 92 + ->setIcon('preview') 93 + ->setHref($this->getApplicationURI("panel/render/{$id}/"))); 82 94 83 95 return $actions; 84 96 }
+47
src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelRenderingEngine extends Phobject { 4 + 5 + private $panel; 6 + private $viewer; 7 + 8 + public function setViewer(PhabricatorUser $viewer) { 9 + $this->viewer = $viewer; 10 + return $this; 11 + } 12 + 13 + public function setPanel(PhabricatorDashboardPanel $panel) { 14 + $this->panel = $panel; 15 + return $this; 16 + } 17 + 18 + public function renderPanel() { 19 + $panel = $this->panel; 20 + $viewer = $this->viewer; 21 + 22 + if (!$panel) { 23 + return $this->renderErrorPanel( 24 + pht('Missing Panel'), 25 + pht('This panel does not exist.')); 26 + } 27 + 28 + $panel_type = $panel->getImplementation(); 29 + if (!$panel_type) { 30 + return $this->renderErrorPanel( 31 + $panel->getName(), 32 + pht( 33 + 'This panel has type "%s", but that panel type is not known to '. 34 + 'Phabricator.', 35 + $panel->getPanelType())); 36 + } 37 + 38 + return $panel_type->renderPanel($viewer, $panel); 39 + } 40 + 41 + private function renderErrorPanel($title, $body) { 42 + return id(new PHUIObjectBoxView()) 43 + ->setHeaderText($title) 44 + ->setFormErrors(array($body)); 45 + } 46 + 47 + }
+9
src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
··· 39 39 return $types; 40 40 } 41 41 42 + public function renderPanel( 43 + PhabricatorUser $viewer, 44 + PhabricatorDashboardPanel $panel) { 45 + 46 + return id(new PHUIObjectBoxView()) 47 + ->setHeaderText($panel->getName()) 48 + ->appendChild(pht('TODO: Panel content goes here.')); 49 + } 50 + 42 51 }