3 final class PhabricatorDashboardPanelViewController
4 extends PhabricatorDashboardController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
12 $id = $request->getURIData('id');
14 $panel = id(new PhabricatorDashboardPanelQuery())
19 return new Aphront404Response();
22 $can_edit = PhabricatorPolicyFilter
::hasCapability(
25 PhabricatorPolicyCapability
::CAN_EDIT
);
27 $title = $panel->getMonogram().' '.$panel->getName();
28 $crumbs = $this->buildApplicationCrumbs();
29 $crumbs->addTextCrumb(
31 $this->getApplicationURI('panel/'));
32 $crumbs->addTextCrumb($panel->getMonogram());
33 $crumbs->setBorder(true);
35 $header = $this->buildHeaderView($panel);
36 $curtain = $this->buildCurtainView($panel);
38 $usage_box = $this->newUsageView($panel);
40 $timeline = $this->buildTransactionTimeline(
42 new PhabricatorDashboardPanelTransactionQuery());
43 $timeline->setShouldTerminate(true);
45 $rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine())
48 ->setContextObject($panel)
49 ->setPanelPHID($panel->getPHID())
50 ->setParentPanelPHIDs(array())
54 $preview = id(new PHUIBoxView())
55 ->addClass('dashboard-preview-box')
56 ->appendChild($rendered_panel);
58 $view = id(new PHUITwoColumnView())
60 ->setCurtain($curtain)
61 ->setMainColumn(array(
67 return $this->newPage()
73 private function buildHeaderView(PhabricatorDashboardPanel
$panel) {
74 $viewer = $this->getViewer();
75 $id = $panel->getID();
77 $header = id(new PHUIHeaderView())
79 ->setHeader($panel->getName())
80 ->setPolicyObject($panel)
81 ->setHeaderIcon('fa-window-maximize');
83 if (!$panel->getIsArchived()) {
84 $header->setStatus('fa-check', 'bluegrey', pht('Active'));
86 $header->setStatus('fa-ban', 'red', pht('Archived'));
91 private function buildCurtainView(PhabricatorDashboardPanel
$panel) {
92 $viewer = $this->getViewer();
93 $id = $panel->getID();
95 $curtain = $this->newCurtainView($panel);
97 $can_edit = PhabricatorPolicyFilter
::hasCapability(
100 PhabricatorPolicyCapability
::CAN_EDIT
);
103 id(new PhabricatorActionView())
104 ->setName(pht('Edit Panel'))
105 ->setIcon('fa-pencil')
106 ->setHref($this->getApplicationURI("panel/edit/{$id}/"))
107 ->setDisabled(!$can_edit)
108 ->setWorkflow(!$can_edit));
110 if (!$panel->getIsArchived()) {
111 $archive_text = pht('Archive Panel');
112 $archive_icon = 'fa-ban';
114 $archive_text = pht('Activate Panel');
115 $archive_icon = 'fa-check';
119 id(new PhabricatorActionView())
120 ->setName($archive_text)
121 ->setIcon($archive_icon)
122 ->setHref($this->getApplicationURI("panel/archive/{$id}/"))
123 ->setDisabled(!$can_edit)
124 ->setWorkflow(true));
129 private function newUsageView(PhabricatorDashboardPanel
$panel) {
130 $viewer = $this->getViewer();
132 $object_phids = PhabricatorEdgeQuery
::loadDestinationPHIDs(
134 PhabricatorDashboardPanelUsedByObjectEdgeType
::EDGECONST
);
137 $handles = $viewer->loadHandles($object_phids);
143 foreach ($object_phids as $object_phid) {
144 $handle = $handles[$object_phid];
146 $icon = $handle->getIcon();
149 id(new PHUIIconView())->setIcon($icon),
150 $handle->getTypeName(),
151 $handle->renderLink(),
155 $usage_table = id(new AphrontTableView($rows))
158 'This panel is not used on any dashboard or inside any other '.
167 $header_view = id(new PHUIHeaderView())
168 ->setHeader(pht('Panel Used By'));
170 $usage_box = id(new PHUIObjectBoxView())
171 ->setTable($usage_table)
172 ->setHeader($header_view);