Differential D17326 Diff 41682 src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/controller/PhabricatorDashboardArrangeController.php
- This file was added.
<?php | |||||
final class PhabricatorDashboardArrangeController | |||||
extends PhabricatorDashboardProfileController { | |||||
public function shouldAllowPublic() { | |||||
return true; | |||||
} | |||||
public function handleRequest(AphrontRequest $request) { | |||||
$viewer = $request->getViewer(); | |||||
$id = $request->getURIData('id'); | |||||
$dashboard = id(new PhabricatorDashboardQuery()) | |||||
->setViewer($viewer) | |||||
->withIDs(array($id)) | |||||
->needPanels(true) | |||||
->executeOne(); | |||||
if (!$dashboard) { | |||||
return new Aphront404Response(); | |||||
} | |||||
$this->setDashboard($dashboard); | |||||
$can_edit = PhabricatorPolicyFilter::hasCapability( | |||||
$viewer, | |||||
$dashboard, | |||||
PhabricatorPolicyCapability::CAN_EDIT); | |||||
$title = $dashboard->getName(); | |||||
$crumbs = $this->buildApplicationCrumbs(); | |||||
$crumbs->addTextCrumb(pht('Arrange')); | |||||
$header = $this->buildHeaderView(); | |||||
$info_view = null; | |||||
if (!$can_edit) { | |||||
$no_edit = pht( | |||||
'You do not have permission to edit this dashboard. If you want to '. | |||||
'make changes, make a copy first.'); | |||||
$info_view = id(new PHUIInfoView()) | |||||
chad: This page I think doesn't show up if you can't edit it, so .... I can remove these and 404 the… | |||||
Not Done Inline ActionsI prefer showing-but-disabling the options over hiding them (eliminates "how do I edit dashboards?", "why can't I edit this dashboard?" support questions) but if you hide them you can just 404 this. (I believe we are also pretty consistent about showing and disabling unavailable options across other applications and contexts; there isn't an obvious rule to me why this stuff should be hidden when unavailable if, say, "Edit Task" isn't also hidden when unavailable.) epriestley: I prefer showing-but-disabling the options over hiding them (eliminates "how do I edit… | |||||
->setSeverity(PHUIInfoView::SEVERITY_NOTICE) | |||||
->setErrors(array($no_edit)); | |||||
} | |||||
$rendered_dashboard = id(new PhabricatorDashboardRenderingEngine()) | |||||
->setViewer($viewer) | |||||
->setDashboard($dashboard) | |||||
->setArrangeMode($can_edit) | |||||
->renderDashboard(); | |||||
$dashboard_box = id(new PHUIBoxView()) | |||||
->addClass('dashboard-preview-box') | |||||
->appendChild($rendered_dashboard); | |||||
$view = id(new PHUITwoColumnView()) | |||||
->setHeader($header) | |||||
->setFooter(array( | |||||
$info_view, | |||||
$dashboard_box, | |||||
)); | |||||
$navigation = $this->buildSideNavView('arrange'); | |||||
return $this->newPage() | |||||
->setTitle($title) | |||||
->setCrumbs($crumbs) | |||||
->setNavigation($navigation) | |||||
->appendChild($view); | |||||
} | |||||
} |
This page I think doesn't show up if you can't edit it, so .... I can remove these and 404 the page? Or just leave it.