2014-05-19 14:04:26 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorDashboardRemovePanelController
|
|
|
|
extends PhabricatorDashboardController {
|
|
|
|
|
2015-07-22 13:27:30 -07:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $request->getViewer();
|
|
|
|
$id = $request->getURIData('id');
|
2014-05-19 14:04:26 -07:00
|
|
|
|
|
|
|
$dashboard = id(new PhabricatorDashboardQuery())
|
|
|
|
->setViewer($viewer)
|
2015-07-22 13:27:30 -07:00
|
|
|
->withIDs(array($id))
|
2014-05-19 14:04:26 -07:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
|
|
|
if (!$dashboard) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$v_panel = $request->getStr('panelPHID');
|
|
|
|
$panel = id(new PhabricatorDashboardPanelQuery())
|
|
|
|
->setViewer($viewer)
|
|
|
|
->withPHIDs(array($v_panel))
|
|
|
|
->executeOne();
|
|
|
|
if (!$panel) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
$redirect_uri = $this->getApplicationURI(
|
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
|
|
|
'manage/'.$dashboard->getID().'/');
|
2014-05-19 14:04:26 -07:00
|
|
|
$layout_config = $dashboard->getLayoutConfigObject();
|
|
|
|
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$xactions = array();
|
|
|
|
$xactions[] = id(new PhabricatorDashboardTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
|
|
|
->setMetadataValue(
|
|
|
|
'edge:type',
|
2015-01-02 10:11:59 +11:00
|
|
|
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
|
2014-05-19 14:04:26 -07:00
|
|
|
->setNewValue(
|
|
|
|
array(
|
|
|
|
'-' => array(
|
|
|
|
$panel->getPHID() => $panel->getPHID(),
|
|
|
|
),
|
|
|
|
));
|
|
|
|
|
|
|
|
$layout_config->removePanel($panel->getPHID());
|
|
|
|
$dashboard->setLayoutConfigFromObject($layout_config);
|
|
|
|
|
|
|
|
$editor = id(new PhabricatorDashboardTransactionEditor())
|
|
|
|
->setActor($viewer)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->setContinueOnMissingFields(true)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->applyTransactions($dashboard, $xactions);
|
|
|
|
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($redirect_uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->addHiddenInput('confirm', true)
|
|
|
|
->addHiddenInput('panelPHID', $v_panel)
|
|
|
|
->appendChild(pht('Are you sure you want to remove this panel?'));
|
|
|
|
|
|
|
|
return $this->newDialog()
|
|
|
|
->setTitle(pht('Remove Panel %s', $panel->getMonogram()))
|
|
|
|
->appendChild($form->buildLayoutView())
|
|
|
|
->addCancelButton($redirect_uri)
|
|
|
|
->addSubmitButton(pht('Remove Panel'));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|