Page MenuHomePhorge

No OneTemporary

diff --git a/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php b/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
index ceeeb1fc5c..3e733edb3e 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
@@ -1,107 +1,101 @@
<?php
final class PhabricatorDashboardAddPanelController
extends PhabricatorDashboardController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$redirect_uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/');
$v_panel = $request->getStr('panel');
$e_panel = true;
$errors = array();
if ($request->isFormPost()) {
if (strlen($v_panel)) {
$panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
->withIDs(array($v_panel))
->executeOne();
if (!$panel) {
$errors[] = pht('No such panel!');
$e_panel = pht('Invalid');
}
} else {
$errors[] = pht('Select a panel to add.');
$e_panel = pht('Required');
}
if (!$errors) {
PhabricatorDashboardTransactionEditor::addPanelToDashboard(
$viewer,
PhabricatorContentSource::newFromRequest($request),
$panel,
$dashboard,
$request->getInt('column', 0));
return id(new AphrontRedirectResponse())->setURI($redirect_uri);
}
}
$panels = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
->withArchived(false)
->execute();
if (!$panels) {
return $this->newDialog()
->setTitle(pht('No Panels Exist Yet'))
->appendParagraph(
pht(
'You have not created any dashboard panels yet, so you can not '.
'add an existing panel.'))
->appendParagraph(
pht('Instead, add a new panel.'))
->addCancelButton($redirect_uri);
}
$panel_options = array();
foreach ($panels as $panel) {
$panel_options[$panel->getID()] = pht(
'%s %s',
$panel->getMonogram(),
$panel->getName());
}
$form = id(new AphrontFormView())
->setUser($viewer)
->addHiddenInput('column', $request->getInt('column'))
->appendRemarkupInstructions(
pht('Choose a panel to add to this dashboard:'))
->appendChild(
id(new AphrontFormSelectControl())
->setName('panel')
->setLabel(pht('Panel'))
->setValue($v_panel)
->setError($e_panel)
->setOptions($panel_options));
return $this->newDialog()
->setTitle(pht('Add Panel'))
->setErrors($errors)
->appendChild($form->buildLayoutView())
->addCancelButton($redirect_uri)
->addSubmitButton(pht('Add Panel'));
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardCopyController.php b/src/applications/dashboard/controller/PhabricatorDashboardCopyController.php
index d1d7583f4c..6b89915c76 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardCopyController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardCopyController.php
@@ -1,68 +1,62 @@
<?php
final class PhabricatorDashboardCopyController
extends PhabricatorDashboardController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->needPanels(true)
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$manage_uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/');
if ($request->isFormPost()) {
$copy = PhabricatorDashboard::initializeNewDashboard($viewer);
$copy = PhabricatorDashboard::copyDashboard($copy, $dashboard);
$copy->setName(pht('Copy of %s', $copy->getName()));
// Set up all the edges for the new dashboard.
$xactions = array();
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
->setNewValue(
array(
'=' => array_fuse($dashboard->getPanelPHIDs()),
));
$editor = id(new PhabricatorDashboardTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true)
->applyTransactions($copy, $xactions);
$manage_uri = $this->getApplicationURI('edit/'.$copy->getID().'/');
return id(new AphrontRedirectResponse())->setURI($manage_uri);
}
return $this->newDialog()
->setTitle(pht('Copy Dashboard'))
->appendParagraph(
pht(
'Create a copy of the dashboard "%s"?',
phutil_tag('strong', array(), $dashboard->getName())))
->addCancelButton($manage_uri)
->addSubmitButton(pht('Create Copy'));
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
index 9838728bf1..16fdac5577 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardEditController.php
@@ -1,361 +1,355 @@
<?php
final class PhabricatorDashboardEditController
extends PhabricatorDashboardController {
- private $id;
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
-
- if ($this->id) {
+ if ($id) {
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->needPanels(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
$dashboard->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
$v_projects = array_reverse($v_projects);
$is_new = false;
} else {
if (!$request->getStr('edit')) {
if ($request->isFormPost()) {
switch ($request->getStr('template')) {
case 'empty':
break;
default:
return $this->processBuildTemplateRequest($request);
}
} else {
return $this->processTemplateRequest($request);
}
}
$dashboard = PhabricatorDashboard::initializeNewDashboard($viewer);
$v_projects = array();
$is_new = true;
}
$crumbs = $this->buildApplicationCrumbs();
if ($is_new) {
$title = pht('Create Dashboard');
$header = pht('Create Dashboard');
$button = pht('Create Dashboard');
$cancel_uri = $this->getApplicationURI();
$crumbs->addTextCrumb(pht('Create Dashboard'));
} else {
$id = $dashboard->getID();
$cancel_uri = $this->getApplicationURI('manage/'.$id.'/');
$title = pht('Edit Dashboard %d', $dashboard->getID());
$header = pht('Edit Dashboard "%s"', $dashboard->getName());
$button = pht('Save Changes');
$crumbs->addTextCrumb(pht('Dashboard %d', $id), $cancel_uri);
$crumbs->addTextCrumb(pht('Edit'));
}
$v_name = $dashboard->getName();
$v_layout_mode = $dashboard->getLayoutConfigObject()->getLayoutMode();
$e_name = true;
$validation_exception = null;
if ($request->isFormPost() && $request->getStr('edit')) {
$v_name = $request->getStr('name');
$v_layout_mode = $request->getStr('layout_mode');
$v_view_policy = $request->getStr('viewPolicy');
$v_edit_policy = $request->getStr('editPolicy');
$v_projects = $request->getArr('projects');
$xactions = array();
$type_name = PhabricatorDashboardTransaction::TYPE_NAME;
$type_layout_mode = PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE;
$type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit_policy = PhabricatorTransactions::TYPE_EDIT_POLICY;
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_name)
->setNewValue($v_name);
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_layout_mode)
->setNewValue($v_layout_mode);
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_view_policy)
->setNewValue($v_view_policy);
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType($type_edit_policy)
->setNewValue($v_edit_policy);
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $proj_edge_type)
->setNewValue(array('=' => array_fuse($v_projects)));
try {
$editor = id(new PhabricatorDashboardTransactionEditor())
->setActor($viewer)
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
->applyTransactions($dashboard, $xactions);
$uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/');
return id(new AphrontRedirectResponse())->setURI($uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
$e_name = $validation_exception->getShortMessage($type_name);
$dashboard->setViewPolicy($v_view_policy);
$dashboard->setEditPolicy($v_edit_policy);
}
}
$policies = id(new PhabricatorPolicyQuery())
->setViewer($viewer)
->setObject($dashboard)
->execute();
$layout_mode_options =
PhabricatorDashboardLayoutConfig::getLayoutModeSelectOptions();
$form = id(new AphrontFormView())
->setUser($viewer)
->addHiddenInput('edit', true)
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Name'))
->setName('name')
->setValue($v_name)
->setError($e_name))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('viewPolicy')
->setPolicyObject($dashboard)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setPolicies($policies))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('editPolicy')
->setPolicyObject($dashboard)
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
->setPolicies($policies))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Layout Mode'))
->setName('layout_mode')
->setValue($v_layout_mode)
->setOptions($layout_mode_options));
$form->appendControl(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Projects'))
->setName('projects')
->setValue($v_projects)
->setDatasource(new PhabricatorProjectDatasource()));
$form->appendChild(
id(new AphrontFormSubmitControl())
->setValue($button)
->addCancelButton($cancel_uri));
$box = id(new PHUIObjectBoxView())
->setHeaderText($header)
->setForm($form)
->setValidationException($validation_exception);
return $this->buildApplicationPage(
array(
$crumbs,
$box,
),
array(
'title' => $title,
));
}
private function processTemplateRequest(AphrontRequest $request) {
$viewer = $request->getUser();
$template_control = id(new AphrontFormRadioButtonControl())
->setName(pht('template'))
->setValue($request->getStr('template', 'empty'))
->addButton(
'empty',
pht('Empty'),
pht('Start with a blank canvas.'))
->addButton(
'simple',
pht('Simple Template'),
pht(
'Start with a simple dashboard with a welcome message, a feed of '.
'recent events, and a few starter panels.'));
$form = id(new AphrontFormView())
->setUser($viewer)
->appendRemarkupInstructions(
pht('Choose a dashboard template to start with.'))
->appendChild($template_control);
return $this->newDialog()
->setTitle(pht('Create Dashboard'))
->setWidth(AphrontDialogView::WIDTH_FORM)
->appendChild($form->buildLayoutView())
->addCancelButton('/dashboard/')
->addSubmitButton(pht('Continue'));
}
private function processBuildTemplateRequest(AphrontRequest $request) {
$viewer = $request->getUser();
$template = $request->getStr('template');
$bare_panel = PhabricatorDashboardPanel::initializeNewPanel($viewer);
$panel_phids = array();
switch ($template) {
case 'simple':
$v_name = pht('New Simple Dashboard');
$welcome_panel = $this->newPanel(
$request,
$viewer,
'text',
pht('Welcome'),
array(
'text' => pht(
"This is a simple template dashboard. You can edit this panel ".
"to change this text and replace it with a welcome message, or ".
"leave this placeholder text as-is to give your dashboard a ".
"rustic, authentic feel.\n\n".
"You can drag, remove, add, and edit panels to customize the ".
"rest of this dashboard to show the information you want.\n\n".
"To install this dashboard on the home page, use the ".
"**Install Dashboard** action link above."),
));
$panel_phids[] = $welcome_panel->getPHID();
$feed_panel = $this->newPanel(
$request,
$viewer,
'query',
pht('Recent Activity'),
array(
'class' => 'PhabricatorFeedSearchEngine',
'key' => 'all',
));
$panel_phids[] = $feed_panel->getPHID();
$task_panel = $this->newPanel(
$request,
$viewer,
'query',
pht('Recent Tasks'),
array(
'class' => 'ManiphestTaskSearchEngine',
'key' => 'all',
));
$panel_phids[] = $task_panel->getPHID();
$commit_panel = $this->newPanel(
$request,
$viewer,
'query',
pht('Recent Commits'),
array(
'class' => 'PhabricatorCommitSearchEngine',
'key' => 'all',
));
$panel_phids[] = $commit_panel->getPHID();
$mode_2_and_1 = PhabricatorDashboardLayoutConfig::MODE_THIRDS_AND_THIRD;
$layout = id(new PhabricatorDashboardLayoutConfig())
->setLayoutMode($mode_2_and_1)
->setPanelLocation(0, $welcome_panel->getPHID())
->setPanelLocation(0, $task_panel->getPHID())
->setPanelLocation(0, $commit_panel->getPHID())
->setPanelLocation(1, $feed_panel->getPHID());
break;
default:
throw new Exception(pht('Unknown dashboard template %s!', $template));
}
// Create the dashboard.
$dashboard = PhabricatorDashboard::initializeNewDashboard($viewer)
->setLayoutConfigFromObject($layout);
$xactions = array();
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType(PhabricatorDashboardTransaction::TYPE_NAME)
->setNewValue($v_name);
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
->setNewValue(
array(
'+' => array_fuse($panel_phids),
));
$editor = id(new PhabricatorDashboardTransactionEditor())
->setActor($viewer)
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
->applyTransactions($dashboard, $xactions);
$manage_uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/');
return id(new AphrontRedirectResponse())
->setURI($manage_uri);
}
private function newPanel(
AphrontRequest $request,
PhabricatorUser $viewer,
$type,
$name,
array $properties) {
$panel = PhabricatorDashboardPanel::initializeNewPanel($viewer)
->setPanelType($type)
->setProperties($properties);
$xactions = array();
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
->setTransactionType(PhabricatorDashboardPanelTransaction::TYPE_NAME)
->setNewValue($name);
$editor = id(new PhabricatorDashboardPanelTransactionEditor())
->setActor($viewer)
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
->applyTransactions($panel, $xactions);
return $panel;
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardHistoryController.php b/src/applications/dashboard/controller/PhabricatorDashboardHistoryController.php
index bdd2e03b87..ab303b23e6 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardHistoryController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardHistoryController.php
@@ -1,54 +1,48 @@
<?php
final class PhabricatorDashboardHistoryController
extends PhabricatorDashboardController {
- private $id;
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
- $id = $this->id;
$dashboard_view_uri = $this->getApplicationURI('view/'.$id.'/');
$dashboard_manage_uri = $this->getApplicationURI('manage/'.$id.'/');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$title = $dashboard->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
$crumbs->addTextCrumb(
pht('Dashboard %d', $dashboard->getID()),
$dashboard_view_uri);
$crumbs->addTextCrumb(
pht('Manage'),
$dashboard_manage_uri);
$crumbs->addTextCrumb(pht('History'));
$timeline = $this->buildTransactionTimeline(
$dashboard,
new PhabricatorDashboardTransactionQuery());
$timeline->setShouldTerminate(true);
return $this->buildApplicationPage(
array(
$crumbs,
$timeline,
),
array(
'title' => $title,
));
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php b/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php
index 4d028e9fb9..504aacaac8 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardInstallController.php
@@ -1,152 +1,148 @@
<?php
final class PhabricatorDashboardInstallController
extends PhabricatorDashboardController {
private $id;
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $this->id = $request->getURIData('id');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$dashboard_phid = $dashboard->getPHID();
$object_phid = $request->getStr('objectPHID', $viewer->getPHID());
switch ($object_phid) {
case PhabricatorHomeApplication::DASHBOARD_DEFAULT:
if (!$viewer->getIsAdmin()) {
return new Aphront404Response();
}
break;
default:
$object = id(new PhabricatorObjectQuery())
->setViewer($viewer)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->withPHIDs(array($object_phid))
->executeOne();
if (!$object) {
return new Aphront404Response();
}
break;
}
$installer_phid = $viewer->getPHID();
$application_class = $request->getStr(
'applicationClass',
'PhabricatorHomeApplication');
if ($request->isFormPost()) {
$dashboard_install = id(new PhabricatorDashboardInstall())
->loadOneWhere(
'objectPHID = %s AND applicationClass = %s',
$object_phid,
$application_class);
if (!$dashboard_install) {
$dashboard_install = id(new PhabricatorDashboardInstall())
->setObjectPHID($object_phid)
->setApplicationClass($application_class);
}
$dashboard_install
->setInstallerPHID($installer_phid)
->setDashboardPHID($dashboard_phid)
->save();
return id(new AphrontRedirectResponse())
->setURI($this->getRedirectURI($application_class, $object_phid));
}
$dialog = $this->newDialog()
->setTitle(pht('Install Dashboard'))
->addHiddenInput('objectPHID', $object_phid)
->addCancelButton($this->getCancelURI($application_class, $object_phid))
->addSubmitButton(pht('Install Dashboard'));
switch ($application_class) {
case 'PhabricatorHomeApplication':
if ($viewer->getPHID() == $object_phid) {
if ($viewer->getIsAdmin()) {
$dialog->setWidth(AphrontDialogView::WIDTH_FORM);
$form = id(new AphrontFormView())
->setUser($viewer)
->appendRemarkupInstructions(
pht('Choose where to install this dashboard.'))
->appendChild(
id(new AphrontFormRadioButtonControl())
->setName('objectPHID')
->setValue(PhabricatorHomeApplication::DASHBOARD_DEFAULT)
->addButton(
PhabricatorHomeApplication::DASHBOARD_DEFAULT,
pht('Default Dashboard for All Users'),
pht(
'Install this dashboard as the global default dashboard '.
'for all users. Users can install a personal dashboard '.
'to replace it. All users who have not configured '.
'a personal dashboard will be affected by this change.'))
->addButton(
$viewer->getPHID(),
pht('Personal Home Page Dashboard'),
pht(
'Install this dashboard as your personal home page '.
'dashboard. Only you will be affected by this change.')));
$dialog->appendChild($form->buildLayoutView());
} else {
$dialog->appendParagraph(
pht('Install this dashboard on your home page?'));
}
} else {
$dialog->appendParagraph(
pht(
'Install this dashboard as the home page dashboard for %s?',
phutil_tag(
'strong',
array(),
$viewer->renderHandle($object_phid))));
}
break;
default:
throw new Exception(
pht(
'Unknown dashboard application class "%s"!',
$application_class));
}
return $dialog;
}
private function getCancelURI($application_class, $object_phid) {
$uri = null;
switch ($application_class) {
case 'PhabricatorHomeApplication':
$uri = '/dashboard/view/'.$this->id.'/';
break;
}
return $uri;
}
private function getRedirectURI($application_class, $object_phid) {
$uri = null;
switch ($application_class) {
case 'PhabricatorHomeApplication':
$uri = '/';
break;
}
return $uri;
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardListController.php b/src/applications/dashboard/controller/PhabricatorDashboardListController.php
index c3f418dfbe..60e6d83ab4 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardListController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardListController.php
@@ -1,54 +1,51 @@
<?php
final class PhabricatorDashboardListController
extends PhabricatorDashboardController {
- private $queryKey;
-
public function shouldAllowPublic() {
return true;
}
- public function willProcessRequest(array $data) {
- $this->queryKey = idx($data, 'queryKey');
- }
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $query_key = $request->getURIData('queryKey');
- public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController())
- ->setQueryKey($this->queryKey)
+ ->setQueryKey($query_key)
->setSearchEngine(new PhabricatorDashboardSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function buildSideNavView() {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new PhabricatorDashboardSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());
$nav->addLabel(pht('Panels'));
$nav->addFilter('panel/', pht('Manage Panels'));
$nav->selectFilter(null);
return $nav;
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addAction(
id(new PHUIListItemView())
->setIcon('fa-plus-square')
->setName(pht('Create Dashboard'))
->setHref($this->getApplicationURI().'create/'));
return $crumbs;
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardMovePanelController.php b/src/applications/dashboard/controller/PhabricatorDashboardMovePanelController.php
index a0bb30046b..d1962517f9 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardMovePanelController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardMovePanelController.php
@@ -1,77 +1,71 @@
<?php
final class PhabricatorDashboardMovePanelController
extends PhabricatorDashboardController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$column_id = $request->getStr('columnID');
$panel_phid = $request->getStr('objectPHID');
$after_phid = $request->getStr('afterPHID');
$before_phid = $request->getStr('beforePHID');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->needPanels(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$panels = mpull($dashboard->getPanels(), null, 'getPHID');
$panel = idx($panels, $panel_phid);
if (!$panel) {
return new Aphront404Response();
}
$layout_config = $dashboard->getLayoutConfigObject();
$layout_config->removePanel($panel_phid);
$panel_location_grid = $layout_config->getPanelLocations();
$column_phids = idx($panel_location_grid, $column_id, array());
$column_phids = array_values($column_phids);
if ($column_phids) {
$insert_at = 0;
foreach ($column_phids as $index => $phid) {
if ($phid === $before_phid) {
$insert_at = $index;
break;
}
if ($phid === $after_phid) {
$insert_at = $index + 1;
break;
}
}
$new_column_phids = $column_phids;
array_splice(
$new_column_phids,
$insert_at,
0,
array($panel_phid));
} else {
$new_column_phids = array(0 => $panel_phid);
}
$panel_location_grid[$column_id] = $new_column_phids;
$layout_config->setPanelLocations($panel_location_grid);
$dashboard->setLayoutConfigFromObject($layout_config);
$dashboard->save();
return id(new AphrontAjaxResponse())->setContent('');
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php
index 8f819d7a37..8710539c49 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php
@@ -1,66 +1,60 @@
<?php
final class PhabricatorDashboardPanelArchiveController
extends PhabricatorDashboardController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$panel) {
return new Aphront404Response();
}
$next_uri = '/'.$panel->getMonogram();
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
->setTransactionType(PhabricatorDashboardPanelTransaction::TYPE_ARCHIVE)
->setNewValue((int)!$panel->getIsArchived());
id(new PhabricatorDashboardPanelTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->applyTransactions($panel, $xactions);
return id(new AphrontRedirectResponse())->setURI($next_uri);
}
if ($panel->getIsArchived()) {
$title = pht('Activate Panel?');
$body = pht(
'This panel will be reactivated and appear in other interfaces as '.
'an active panel.');
$submit_text = pht('Activate Panel');
} else {
$title = pht('Archive Panel?');
$body = pht(
'This panel will be archived and no longer appear in lists of active '.
'panels.');
$submit_text = pht('Archive Panel');
}
return $this->newDialog()
->setTitle($title)
->appendParagraph($body)
->addSubmitButton($submit_text)
->addCancelButton($next_uri);
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
index 8ec942a34a..beccd3551a 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
@@ -1,455 +1,449 @@
<?php
final class PhabricatorDashboardPanelEditController
extends PhabricatorDashboardController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
// If the user is trying to create a panel directly on a dashboard, make
// sure they have permission to see and edit the dashboard.
$dashboard_id = $request->getInt('dashboardID');
$dashboard = null;
if ($dashboard_id) {
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($dashboard_id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$manage_uri = $this->getApplicationURI('manage/'.$dashboard_id.'/');
}
- if ($this->id) {
+ if ($id) {
$is_create = false;
if ($dashboard) {
$capabilities = array(
PhabricatorPolicyCapability::CAN_VIEW,
);
} else {
$capabilities = array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
);
}
$panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->requireCapabilities($capabilities)
->executeOne();
if (!$panel) {
return new Aphront404Response();
}
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
$panel->getPHID(),
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
$v_projects = array_reverse($v_projects);
if ($dashboard) {
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$panel,
PhabricatorPolicyCapability::CAN_EDIT);
if (!$can_edit) {
if ($request->isFormPost() && $request->getBool('copy')) {
$panel = $this->copyPanel(
$request,
$dashboard,
$panel);
} else {
return $this->processPanelCloneRequest(
$request,
$dashboard,
$panel);
}
}
}
} else {
$is_create = true;
$panel = PhabricatorDashboardPanel::initializeNewPanel($viewer);
$types = PhabricatorDashboardPanelType::getAllPanelTypes();
$type = $request->getStr('type');
if (empty($types[$type])) {
return $this->processPanelTypeRequest($request);
}
$v_projects = array();
$panel->setPanelType($type);
}
if ($is_create) {
$title = pht('New Panel');
$header = pht('Create New Panel');
$button = pht('Create Panel');
if ($dashboard) {
$cancel_uri = $manage_uri;
} else {
$cancel_uri = $this->getApplicationURI('panel/');
}
} else {
$title = pht('Edit %s', $panel->getMonogram());
$header = pht('Edit %s %s', $panel->getMonogram(), $panel->getName());
$button = pht('Save Panel');
if ($dashboard) {
$cancel_uri = $manage_uri;
} else {
$cancel_uri = '/'.$panel->getMonogram();
}
}
$v_name = $panel->getName();
$e_name = true;
$field_list = PhabricatorCustomField::getObjectFields(
$panel,
PhabricatorCustomField::ROLE_EDIT);
$field_list
->setViewer($viewer)
->readFieldsFromStorage($panel);
if ($is_create && !$request->isFormPost()) {
$panel->requireImplementation()->initializeFieldsFromRequest(
$panel,
$field_list,
$request);
}
$validation_exception = null;
// NOTE: We require 'edit' to distinguish between the "Choose a Type"
// and "Create a Panel" dialogs.
if ($request->isFormPost() && $request->getBool('edit')) {
$v_name = $request->getStr('name');
$v_view_policy = $request->getStr('viewPolicy');
$v_edit_policy = $request->getStr('editPolicy');
$v_projects = $request->getArr('projects');
$type_name = PhabricatorDashboardPanelTransaction::TYPE_NAME;
$type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_edit_policy = PhabricatorTransactions::TYPE_EDIT_POLICY;
$xactions = array();
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
->setTransactionType($type_name)
->setNewValue($v_name);
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
->setTransactionType($type_view_policy)
->setNewValue($v_view_policy);
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
->setTransactionType($type_edit_policy)
->setNewValue($v_edit_policy);
$proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $proj_edge_type)
->setNewValue(array('=' => array_fuse($v_projects)));
$field_xactions = $field_list->buildFieldTransactionsFromRequest(
new PhabricatorDashboardPanelTransaction(),
$request);
$xactions = array_merge($xactions, $field_xactions);
try {
$editor = id(new PhabricatorDashboardPanelTransactionEditor())
->setActor($viewer)
->setContinueOnNoEffect(true)
->setContentSourceFromRequest($request)
->applyTransactions($panel, $xactions);
// If we're creating a panel directly on a dashboard, add it now.
if ($dashboard) {
PhabricatorDashboardTransactionEditor::addPanelToDashboard(
$viewer,
PhabricatorContentSource::newFromRequest($request),
$panel,
$dashboard,
$request->getInt('column', 0));
}
if ($dashboard) {
$done_uri = $manage_uri;
} else {
$done_uri = '/'.$panel->getMonogram();
}
return id(new AphrontRedirectResponse())->setURI($done_uri);
} catch (PhabricatorApplicationTransactionValidationException $ex) {
$validation_exception = $ex;
$e_name = $validation_exception->getShortMessage($type_name);
$panel->setViewPolicy($v_view_policy);
$panel->setEditPolicy($v_edit_policy);
}
}
// NOTE: We're setting the submit URI explicitly because we need to edit
// a different panel if we just cloned the original panel.
if ($is_create) {
$submit_uri = $this->getApplicationURI('panel/edit/');
} else {
$submit_uri = $this->getApplicationURI('panel/edit/'.$panel->getID().'/');
}
$policies = id(new PhabricatorPolicyQuery())
->setViewer($viewer)
->setObject($panel)
->execute();
$form = id(new AphrontFormView())
->setUser($viewer)
->setAction($submit_uri)
->addHiddenInput('edit', true)
->addHiddenInput('dashboardID', $request->getInt('dashboardID'))
->addHiddenInput('column', $request->getInt('column'))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Name'))
->setName('name')
->setValue($v_name)
->setError($e_name))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('viewPolicy')
->setPolicyObject($panel)
->setCapability(PhabricatorPolicyCapability::CAN_VIEW)
->setPolicies($policies))
->appendChild(
id(new AphrontFormPolicyControl())
->setName('editPolicy')
->setPolicyObject($panel)
->setCapability(PhabricatorPolicyCapability::CAN_EDIT)
->setPolicies($policies));
$form->appendControl(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Projects'))
->setName('projects')
->setValue($v_projects)
->setDatasource(new PhabricatorProjectDatasource()));
$field_list->appendFieldsToForm($form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Panels'),
$this->getApplicationURI('panel/'));
if ($is_create) {
$crumbs->addTextCrumb(pht('New Panel'));
$form->addHiddenInput('type', $panel->getPanelType());
} else {
$crumbs->addTextCrumb(
$panel->getMonogram(),
'/'.$panel->getMonogram());
$crumbs->addTextCrumb(pht('Edit'));
}
if ($request->isAjax()) {
return $this->newDialog()
->setTitle($header)
->setSubmitURI($submit_uri)
->setWidth(AphrontDialogView::WIDTH_FORM)
->setValidationException($validation_exception)
->appendChild($form->buildLayoutView())
->addCancelButton($cancel_uri)
->addSubmitButton($button);
} else {
$form
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($button)
->addCancelButton($cancel_uri));
}
$box = id(new PHUIObjectBoxView())
->setHeaderText($header)
->setValidationException($validation_exception)
->setForm($form);
return $this->buildApplicationPage(
array(
$crumbs,
$box,
),
array(
'title' => $title,
));
}
private function processPanelTypeRequest(AphrontRequest $request) {
$viewer = $request->getUser();
$types = PhabricatorDashboardPanelType::getAllPanelTypes();
$v_type = null;
$errors = array();
if ($request->isFormPost()) {
$v_type = $request->getStr('type');
if (!isset($types[$v_type])) {
$errors[] = pht('You must select a type of panel to create.');
}
}
$cancel_uri = $this->getApplicationURI('panel/');
if (!$v_type) {
$v_type = key($types);
}
$panel_types = id(new AphrontFormRadioButtonControl())
->setName('type')
->setValue($v_type);
foreach ($types as $key => $type) {
$panel_types->addButton(
$key,
$type->getPanelTypeName(),
$type->getPanelTypeDescription());
}
$form = id(new AphrontFormView())
->setUser($viewer)
->addHiddenInput('dashboardID', $request->getInt('dashboardID'))
->addHiddenInput('column', $request->getInt('column'))
->appendRemarkupInstructions(
pht(
'Choose the type of dashboard panel to create:'))
->appendChild($panel_types);
if ($request->isAjax()) {
return $this->newDialog()
->setTitle(pht('Add New Panel'))
->setWidth(AphrontDialogView::WIDTH_FORM)
->setErrors($errors)
->appendChild($form->buildLayoutView())
->addCancelbutton($cancel_uri)
->addSubmitButton(pht('Continue'));
} else {
$form->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Continue'))
->addCancelButton($cancel_uri));
}
$title = pht('Create Dashboard Panel');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Panels'),
$this->getApplicationURI('panel/'));
$crumbs->addTextCrumb(pht('New Panel'));
$box = id(new PHUIObjectBoxView())
->setHeaderText($title)
->setFormErrors($errors)
->setForm($form);
return $this->buildApplicationPage(
array(
$crumbs,
$box,
),
array(
'title' => $title,
));
}
private function processPanelCloneRequest(
AphrontRequest $request,
PhabricatorDashboard $dashboard,
PhabricatorDashboardPanel $panel) {
$viewer = $request->getUser();
$manage_uri = $this->getApplicationURI('manage/'.$dashboard->getID().'/');
return $this->newDialog()
->setTitle(pht('Copy Panel?'))
->addHiddenInput('copy', true)
->addHiddenInput('dashboardID', $request->getInt('dashboardID'))
->addHiddenInput('column', $request->getInt('column'))
->appendParagraph(
pht(
'You do not have permission to edit this dashboard panel, but you '.
'can make a copy and edit that instead. If you choose to copy the '.
'panel, the original will be replaced with the new copy on this '.
'dashboard.'))
->appendParagraph(
pht(
'Do you want to make a copy of this panel?'))
->addCancelButton($manage_uri)
->addSubmitButton(pht('Copy Panel'));
}
private function copyPanel(
AphrontRequest $request,
PhabricatorDashboard $dashboard,
PhabricatorDashboardPanel $panel) {
$viewer = $request->getUser();
$copy = PhabricatorDashboardPanel::initializeNewPanel($viewer);
$copy = PhabricatorDashboardPanel::copyPanel($copy, $panel);
$copy->openTransaction();
$copy->save();
// TODO: This should record a transaction on the panel copy, too.
$xactions = array();
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
->setNewValue(
array(
'+' => array(
$copy->getPHID() => $copy->getPHID(),
),
'-' => array(
$panel->getPHID() => $panel->getPHID(),
),
));
$layout_config = $dashboard->getLayoutConfigObject();
$layout_config->replacePanel($panel->getPHID(), $copy->getPHID());
$dashboard->setLayoutConfigFromObject($layout_config);
$dashboard->save();
$editor = id(new PhabricatorDashboardTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnMissingFields(true)
->setContinueOnNoEffect(true)
->applyTransactions($dashboard, $xactions);
$copy->saveTransaction();
return $copy;
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php
index 5b2a50c6b4..e612c26d2a 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelListController.php
@@ -1,53 +1,51 @@
<?php
final class PhabricatorDashboardPanelListController
extends PhabricatorDashboardController {
private $queryKey;
public function shouldAllowPublic() {
return true;
}
- public function willProcessRequest(array $data) {
- $this->queryKey = idx($data, 'queryKey');
- }
+ public function handleRequest(AphrontRequest $request) {
+ $query_key = $request->getURIData('queryKey');
- public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController())
- ->setQueryKey($this->queryKey)
+ ->setQueryKey($query_key)
->setSearchEngine(new PhabricatorDashboardPanelSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function buildSideNavView() {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
id(new PhabricatorDashboardPanelSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());
$nav->selectFilter(null);
return $nav;
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Panels'), $this->getApplicationURI().'panel/');
$crumbs->addAction(
id(new PHUIListItemView())
->setIcon('fa-plus-square')
->setName(pht('Create Panel'))
->setHref($this->getApplicationURI().'panel/create/'));
return $crumbs;
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php
index c46dad47c9..b1718421ea 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelRenderController.php
@@ -1,75 +1,69 @@
<?php
final class PhabricatorDashboardPanelRenderController
extends PhabricatorDashboardController {
- private $id;
-
public function shouldAllowPublic() {
return true;
}
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->executeOne();
if (!$panel) {
return new Aphront404Response();
}
if ($request->isAjax()) {
$parent_phids = $request->getStrList('parentPanelPHIDs', null);
if ($parent_phids === null) {
throw new Exception(
pht(
'Required parameter `parentPanelPHIDs` is not present in '.
'request.'));
}
} else {
$parent_phids = array();
}
$rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine())
->setViewer($viewer)
->setPanel($panel)
->setParentPanelPHIDs($parent_phids)
->setHeaderMode($request->getStr('headerMode'))
->setDashboardID($request->getInt('dashboardID'))
->renderPanel();
if ($request->isAjax()) {
return id(new AphrontAjaxResponse())
->setContent(
array(
'panelMarkup' => hsprintf('%s', $rendered_panel),
));
}
$crumbs = $this->buildApplicationCrumbs()
->addTextCrumb(pht('Panels'), $this->getApplicationURI('panel/'))
->addTextCrumb($panel->getMonogram(), '/'.$panel->getMonogram())
->addTextCrumb(pht('Standalone View'));
$view = id(new PHUIBoxView())
->addClass('dashboard-view')
->appendChild($rendered_panel);
return $this->buildApplicationPage(
array(
$crumbs,
$view,
),
array(
'title' => array(pht('Panel'), $panel->getName()),
));
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
index 6641ea4246..f22b60ca75 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
@@ -1,180 +1,174 @@
<?php
final class PhabricatorDashboardPanelViewController
extends PhabricatorDashboardController {
- private $id;
-
public function shouldAllowPublic() {
return true;
}
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->executeOne();
if (!$panel) {
return new Aphront404Response();
}
$title = $panel->getMonogram().' '.$panel->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
pht('Panels'),
$this->getApplicationURI('panel/'));
$crumbs->addTextCrumb($panel->getMonogram());
$header = $this->buildHeaderView($panel);
$actions = $this->buildActionView($panel);
$properties = $this->buildPropertyView($panel);
$timeline = $this->buildTransactionTimeline(
$panel,
new PhabricatorDashboardPanelTransactionQuery());
$timeline->setShouldTerminate(true);
$properties->setActionList($actions);
$box = id(new PHUIObjectBoxView())
->setHeader($header)
->addPropertyList($properties);
$rendered_panel = id(new PhabricatorDashboardPanelRenderingEngine())
->setViewer($viewer)
->setPanel($panel)
->setParentPanelPHIDs(array())
->renderPanel();
$view = id(new PHUIBoxView())
->addMargin(PHUI::MARGIN_LARGE_LEFT)
->addMargin(PHUI::MARGIN_LARGE_RIGHT)
->addMargin(PHUI::MARGIN_LARGE_TOP)
->appendChild($rendered_panel);
return $this->buildApplicationPage(
array(
$crumbs,
$box,
$view,
$timeline,
),
array(
'title' => $title,
));
}
private function buildHeaderView(PhabricatorDashboardPanel $panel) {
$viewer = $this->getRequest()->getUser();
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($panel->getName())
->setPolicyObject($panel);
if (!$panel->getIsArchived()) {
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
} else {
$header->setStatus('fa-ban', 'red', pht('Archived'));
}
return $header;
}
private function buildActionView(PhabricatorDashboardPanel $panel) {
$viewer = $this->getRequest()->getUser();
$id = $panel->getID();
$actions = id(new PhabricatorActionListView())
->setObjectURI('/'.$panel->getMonogram())
->setObject($panel)
->setUser($viewer);
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$panel,
PhabricatorPolicyCapability::CAN_EDIT);
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Panel'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI("panel/edit/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
if (!$panel->getIsArchived()) {
$archive_text = pht('Archive Panel');
$archive_icon = 'fa-ban';
} else {
$archive_text = pht('Activate Panel');
$archive_icon = 'fa-check';
}
$actions->addAction(
id(new PhabricatorActionView())
->setName($archive_text)
->setIcon($archive_icon)
->setHref($this->getApplicationURI("panel/archive/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow(true));
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('View Standalone'))
->setIcon('fa-eye')
->setHref($this->getApplicationURI("panel/render/{$id}/")));
return $actions;
}
private function buildPropertyView(PhabricatorDashboardPanel $panel) {
$viewer = $this->getRequest()->getUser();
$properties = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($panel);
$descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions(
$viewer,
$panel);
$panel_type = $panel->getImplementation();
if ($panel_type) {
$type_name = $panel_type->getPanelTypeName();
} else {
$type_name = phutil_tag(
'em',
array(),
nonempty($panel->getPanelType(), pht('null')));
}
$properties->addProperty(
pht('Panel Type'),
$type_name);
$properties->addProperty(
pht('Editable By'),
$descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
$dashboard_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$panel->getPHID(),
PhabricatorDashboardPanelHasDashboardEdgeType::EDGECONST);
$does_not_appear = pht(
'This panel does not appear on any dashboards.');
$properties->addProperty(
pht('Appears On'),
$dashboard_phids
? $viewer->renderHandleList($dashboard_phids)
: phutil_tag('em', array(), $does_not_appear));
return $properties;
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php b/src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php
index 2d3c2b7831..2fa8e83a10 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php
@@ -1,82 +1,76 @@
<?php
final class PhabricatorDashboardRemovePanelController
extends PhabricatorDashboardController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->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(
'manage/'.$dashboard->getID().'/');
$layout_config = $dashboard->getLayoutConfigObject();
if ($request->isFormPost()) {
$xactions = array();
$xactions[] = id(new PhabricatorDashboardTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue(
'edge:type',
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
->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'));
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php b/src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php
index 4bf7b6675b..fbb0a437fa 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardUninstallController.php
@@ -1,137 +1,131 @@
<?php
final class PhabricatorDashboardUninstallController
extends PhabricatorDashboardController {
- private $id;
-
- public function willProcessRequest(array $data) {
- $this->id = idx($data, 'id');
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
- ->withIDs(array($this->id))
+ ->withIDs(array($id))
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$dashboard_phid = $dashboard->getPHID();
$object_phid = $request->getStr('objectPHID', $viewer->getPHID());
$object = id(new PhabricatorObjectQuery())
->setViewer($viewer)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->withPHIDs(array($object_phid))
->executeOne();
if (!$object) {
return new Aphront404Response();
}
$application_class = $request->getStr(
'applicationClass',
'PhabricatorHomeApplication');
$dashboard_install = id(new PhabricatorDashboardInstall())
->loadOneWhere(
'objectPHID = %s AND applicationClass = %s',
$object_phid,
$application_class);
if (!$dashboard_install) {
return new Aphront404Response();
}
if ($dashboard_install->getDashboardPHID() != $dashboard_phid) {
return new Aphront404Response();
}
$installer_phid = $viewer->getPHID();
if ($request->isFormPost()) {
$dashboard_install->delete();
return id(new AphrontRedirectResponse())
->setURI($this->getRedirectURI($application_class, $object_phid));
}
$body = $this->getBodyContent(
$application_class,
$object_phid,
$installer_phid);
$form = id(new AphrontFormView())
->setUser($viewer)
->appendChild($body);
return $this->newDialog()
->setTitle(pht('Uninstall Dashboard'))
->appendChild($form->buildLayoutView())
->addCancelButton($this->getCancelURI(
- $application_class, $object_phid))
+ $application_class, $object_phid, $id))
->addSubmitButton(pht('Uninstall Dashboard'));
}
private function getBodyContent(
$application_class,
$object_phid,
$installer_phid) {
$viewer = $this->getViewer();
$body = array();
switch ($application_class) {
case 'PhabricatorHomeApplication':
if ($installer_phid == $object_phid) {
$body[] = phutil_tag(
'p',
array(),
pht(
'Are you sure you want to uninstall this dashboard as your '.
'home page?'));
$body[] = phutil_tag(
'p',
array(),
pht(
'You will be re-directed to your bland, default home page if '.
'you choose to uninstall this dashboard.'));
} else {
$body[] = phutil_tag(
'p',
array(),
pht(
'Are you sure you want to uninstall this dashboard as the home '.
'page for %s?',
$viewer->renderHandle($object_phid)));
}
break;
}
return $body;
}
- private function getCancelURI($application_class, $object_phid) {
+ private function getCancelURI($application_class, $object_phid, $id) {
$uri = null;
switch ($application_class) {
case 'PhabricatorHomeApplication':
- $uri = '/dashboard/view/'.$this->id.'/';
+ $uri = '/dashboard/view/'.$id.'/';
break;
}
return $uri;
}
private function getRedirectURI($application_class, $object_phid) {
$uri = null;
switch ($application_class) {
case 'PhabricatorHomeApplication':
$uri = '/';
break;
}
return $uri;
}
}
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardViewController.php b/src/applications/dashboard/controller/PhabricatorDashboardViewController.php
index c2353eeef8..4caa68d2e5 100644
--- a/src/applications/dashboard/controller/PhabricatorDashboardViewController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardViewController.php
@@ -1,81 +1,77 @@
<?php
final class PhabricatorDashboardViewController
extends PhabricatorDashboardController {
private $id;
public function shouldAllowPublic() {
return true;
}
- public function willProcessRequest(array $data) {
- $this->id = $data['id'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $this->id = $request->getURIData('id');
$dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer)
->withIDs(array($this->id))
->needPanels(true)
->executeOne();
if (!$dashboard) {
return new Aphront404Response();
}
$title = $dashboard->getName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->setBorder(true);
$crumbs->addTextCrumb(pht('Dashboard %d', $dashboard->getID()));
if ($dashboard->getPanelPHIDs()) {
$rendered_dashboard = id(new PhabricatorDashboardRenderingEngine())
->setViewer($viewer)
->setDashboard($dashboard)
->renderDashboard();
} else {
$rendered_dashboard = $this->buildEmptyView();
}
return $this->buildApplicationPage(
array(
$crumbs,
$rendered_dashboard,
),
array(
'title' => $title,
));
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$id = $this->id;
$crumbs->addAction(
id(new PHUIListItemView())
->setIcon('fa-th')
->setName(pht('Manage Dashboard'))
->setHref($this->getApplicationURI("manage/{$id}/")));
return $crumbs;
}
public function buildEmptyView() {
$id = $this->id;
$manage_uri = $this->getApplicationURI("manage/{$id}/");
return id(new PHUIInfoView())
->setSeverity(PHUIInfoView::SEVERITY_NODATA)
->appendChild(
pht('This dashboard has no panels '.
'yet. Use %s to add panels.',
phutil_tag(
'a',
array('href' => $manage_uri),
pht('Manage Dashboard'))));
}
}

File Metadata

Mime Type
text/x-diff
Expires
Sun, Jan 19, 16:46 (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126623
Default Alt Text
(68 KB)

Event Timeline