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
2014-05-22 10:59:46 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
final class PhabricatorDashboardManageController
|
|
|
|
|
extends PhabricatorDashboardController {
|
|
|
|
|
|
|
|
|
|
private $id;
|
|
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
|
$this->id = $data['id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
|
$viewer = $request->getUser();
|
|
|
|
|
$id = $this->id;
|
|
|
|
|
$dashboard_uri = $this->getApplicationURI('view/'.$id.'/');
|
|
|
|
|
|
2014-06-12 15:14:47 -07:00
|
|
|
// TODO: This UI should drop a lot of capabilities if the user can't
|
|
|
|
|
// edit the dashboard, but we should still let them in for "Install" and
|
|
|
|
|
// "View History".
|
|
|
|
|
|
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
2014-05-22 10:59:46 -07:00
|
|
|
$dashboard = id(new PhabricatorDashboardQuery())
|
|
|
|
|
->setViewer($viewer)
|
|
|
|
|
->withIDs(array($this->id))
|
|
|
|
|
->needPanels(true)
|
|
|
|
|
->executeOne();
|
|
|
|
|
if (!$dashboard) {
|
|
|
|
|
return new Aphront404Response();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-12 21:49:19 -07:00
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
|
$viewer,
|
|
|
|
|
$dashboard,
|
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
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
2014-05-22 10:59:46 -07:00
|
|
|
$title = $dashboard->getName();
|
|
|
|
|
|
|
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
|
pht('Dashboard %d', $dashboard->getID()),
|
|
|
|
|
$dashboard_uri);
|
|
|
|
|
$crumbs->addTextCrumb(pht('Manage'));
|
|
|
|
|
|
|
|
|
|
$header = $this->buildHeaderView($dashboard);
|
|
|
|
|
$actions = $this->buildActionView($dashboard);
|
|
|
|
|
$properties = $this->buildPropertyView($dashboard);
|
|
|
|
|
|
|
|
|
|
$properties->setActionList($actions);
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
|
->setHeader($header)
|
|
|
|
|
->addPropertyList($properties);
|
|
|
|
|
|
2014-06-12 21:49:19 -07:00
|
|
|
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.');
|
|
|
|
|
|
|
|
|
|
$box->setErrorView(
|
|
|
|
|
id(new AphrontErrorView())
|
|
|
|
|
->setSeverity(AphrontErrorView::SEVERITY_NOTICE)
|
|
|
|
|
->setErrors(array($no_edit)));
|
|
|
|
|
}
|
|
|
|
|
|
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
2014-05-22 10:59:46 -07:00
|
|
|
$rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())
|
|
|
|
|
->setViewer($viewer)
|
|
|
|
|
->setDashboard($dashboard)
|
2014-06-12 21:49:19 -07:00
|
|
|
->setArrangeMode($can_edit)
|
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
2014-05-22 10:59:46 -07:00
|
|
|
->renderDashboard();
|
|
|
|
|
|
|
|
|
|
return $this->buildApplicationPage(
|
|
|
|
|
array(
|
|
|
|
|
$crumbs,
|
|
|
|
|
$box,
|
|
|
|
|
$rendered_dashboard,
|
|
|
|
|
),
|
|
|
|
|
array(
|
|
|
|
|
'title' => $title,
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildHeaderView(PhabricatorDashboard $dashboard) {
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
|
|
return id(new PHUIHeaderView())
|
|
|
|
|
->setUser($viewer)
|
|
|
|
|
->setHeader($dashboard->getName())
|
|
|
|
|
->setPolicyObject($dashboard);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildActionView(PhabricatorDashboard $dashboard) {
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
$id = $dashboard->getID();
|
|
|
|
|
|
|
|
|
|
$actions = id(new PhabricatorActionListView())
|
|
|
|
|
->setObjectURI($this->getApplicationURI('view/'.$dashboard->getID().'/'))
|
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
|
|
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
|
|
|
|
$viewer,
|
|
|
|
|
$dashboard,
|
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
|
|
|
|
2014-06-22 08:05:27 -07:00
|
|
|
$actions->addAction(
|
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
|
->setName(pht('View Dashboard'))
|
|
|
|
|
->setIcon('fa-columns')
|
|
|
|
|
->setHref($this->getApplicationURI("view/{$id}/")));
|
|
|
|
|
|
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
2014-05-22 10:59:46 -07:00
|
|
|
$actions->addAction(
|
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
|
->setName(pht('Edit Dashboard'))
|
|
|
|
|
->setIcon('fa-pencil')
|
|
|
|
|
->setHref($this->getApplicationURI("edit/{$id}/"))
|
|
|
|
|
->setDisabled(!$can_edit)
|
|
|
|
|
->setWorkflow(!$can_edit));
|
|
|
|
|
|
2014-06-12 21:49:19 -07:00
|
|
|
$actions->addAction(
|
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
|
->setName(pht('Copy Dashboard'))
|
|
|
|
|
->setIcon('fa-files-o')
|
|
|
|
|
->setHref($this->getApplicationURI("copy/{$id}/"))
|
|
|
|
|
->setWorkflow(true));
|
|
|
|
|
|
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
2014-05-22 10:59:46 -07:00
|
|
|
$installed_dashboard = id(new PhabricatorDashboardInstall())
|
|
|
|
|
->loadOneWhere(
|
|
|
|
|
'objectPHID = %s AND applicationClass = %s',
|
|
|
|
|
$viewer->getPHID(),
|
2014-07-23 10:03:09 +10:00
|
|
|
'PhabricatorHomeApplication');
|
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
2014-05-22 10:59:46 -07:00
|
|
|
if ($installed_dashboard &&
|
|
|
|
|
$installed_dashboard->getDashboardPHID() == $dashboard->getPHID()) {
|
|
|
|
|
$title_install = pht('Uninstall Dashboard');
|
|
|
|
|
$href_install = "uninstall/{$id}/";
|
|
|
|
|
} else {
|
|
|
|
|
$title_install = pht('Install Dashboard');
|
|
|
|
|
$href_install = "install/{$id}/";
|
|
|
|
|
}
|
|
|
|
|
$actions->addAction(
|
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
|
->setName($title_install)
|
|
|
|
|
->setIcon('fa-wrench')
|
|
|
|
|
->setHref($this->getApplicationURI($href_install))
|
|
|
|
|
->setWorkflow(true));
|
|
|
|
|
|
2014-05-24 12:29:27 -07:00
|
|
|
$actions->addAction(
|
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
|
->setName(pht('View History'))
|
|
|
|
|
->setIcon('fa-history')
|
|
|
|
|
->setHref($this->getApplicationURI("history/{$id}/")));
|
|
|
|
|
|
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
2014-05-22 10:59:46 -07:00
|
|
|
return $actions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function buildPropertyView(PhabricatorDashboard $dashboard) {
|
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
|
|
$properties = id(new PHUIPropertyListView())
|
|
|
|
|
->setUser($viewer)
|
|
|
|
|
->setObject($dashboard);
|
|
|
|
|
|
|
|
|
|
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
|
|
|
|
|
$viewer,
|
|
|
|
|
$dashboard);
|
|
|
|
|
|
|
|
|
|
$properties->addProperty(
|
|
|
|
|
pht('Editable By'),
|
|
|
|
|
$descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
|
|
|
|
|
|
|
|
|
|
$panel_phids = $dashboard->getPanelPHIDs();
|
|
|
|
|
$this->loadHandles($panel_phids);
|
|
|
|
|
|
|
|
|
|
$properties->addProperty(
|
|
|
|
|
pht('Panels'),
|
|
|
|
|
$this->renderHandlesForPHIDs($panel_phids));
|
|
|
|
|
|
|
|
|
|
return $properties;
|
|
|
|
|
}
|
2014-07-23 10:03:09 +10:00
|
|
|
|
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
2014-05-22 10:59:46 -07:00
|
|
|
}
|