1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 17:22:42 +01:00

Update Dashboard for handleRequest

Summary: Updates Dashboards

Test Plan: Bounced around lists, installed, history, create panel, create dashboard, etc.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T8628

Differential Revision: https://secure.phabricator.com/D13680
This commit is contained in:
Chad Little 2015-07-22 13:27:30 -07:00
parent b72b6eb18f
commit 0bbcd3888c
15 changed files with 62 additions and 141 deletions

View file

@ -3,19 +3,13 @@
final class PhabricatorDashboardAddPanelController final class PhabricatorDashboardAddPanelController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->requireCapabilities( ->requireCapabilities(
array( array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -3,19 +3,13 @@
final class PhabricatorDashboardCopyController final class PhabricatorDashboardCopyController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->needPanels(true) ->needPanels(true)
->executeOne(); ->executeOne();
if (!$dashboard) { if (!$dashboard) {

View file

@ -3,20 +3,14 @@
final class PhabricatorDashboardEditController final class PhabricatorDashboardEditController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
public function willProcessRequest(array $data) { if ($id) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if ($this->id) {
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->needPanels(true) ->needPanels(true)
->requireCapabilities( ->requireCapabilities(
array( array(

View file

@ -3,22 +3,16 @@
final class PhabricatorDashboardHistoryController final class PhabricatorDashboardHistoryController
extends PhabricatorDashboardController { 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_view_uri = $this->getApplicationURI('view/'.$id.'/');
$dashboard_manage_uri = $this->getApplicationURI('manage/'.$id.'/'); $dashboard_manage_uri = $this->getApplicationURI('manage/'.$id.'/');
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$dashboard) { if (!$dashboard) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -5,13 +5,9 @@ final class PhabricatorDashboardInstallController
private $id; private $id;
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->id = idx($data, 'id'); $viewer = $request->getViewer();
} $this->id = $request->getURIData('id');
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)

View file

@ -3,19 +3,16 @@
final class PhabricatorDashboardListController final class PhabricatorDashboardListController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $queryKey;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->queryKey = idx($data, 'queryKey'); $viewer = $request->getViewer();
} $query_key = $request->getURIData('queryKey');
public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController()) $controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey) ->setQueryKey($query_key)
->setSearchEngine(new PhabricatorDashboardSearchEngine()) ->setSearchEngine(new PhabricatorDashboardSearchEngine())
->setNavigation($this->buildSideNavView()); ->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller); return $this->delegateToController($controller);

View file

@ -3,15 +3,9 @@
final class PhabricatorDashboardMovePanelController final class PhabricatorDashboardMovePanelController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$column_id = $request->getStr('columnID'); $column_id = $request->getStr('columnID');
$panel_phid = $request->getStr('objectPHID'); $panel_phid = $request->getStr('objectPHID');
@ -20,7 +14,7 @@ final class PhabricatorDashboardMovePanelController
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->needPanels(true) ->needPanels(true)
->requireCapabilities( ->requireCapabilities(
array( array(

View file

@ -3,19 +3,13 @@
final class PhabricatorDashboardPanelArchiveController final class PhabricatorDashboardPanelArchiveController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$panel = id(new PhabricatorDashboardPanelQuery()) $panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->requireCapabilities( ->requireCapabilities(
array( array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -3,15 +3,9 @@
final class PhabricatorDashboardPanelEditController final class PhabricatorDashboardPanelEditController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
// If the user is trying to create a panel directly on a dashboard, make // If the user is trying to create a panel directly on a dashboard, make
// sure they have permission to see and edit the dashboard. // sure they have permission to see and edit the dashboard.
@ -35,7 +29,7 @@ final class PhabricatorDashboardPanelEditController
$manage_uri = $this->getApplicationURI('manage/'.$dashboard_id.'/'); $manage_uri = $this->getApplicationURI('manage/'.$dashboard_id.'/');
} }
if ($this->id) { if ($id) {
$is_create = false; $is_create = false;
if ($dashboard) { if ($dashboard) {
@ -51,7 +45,7 @@ final class PhabricatorDashboardPanelEditController
$panel = id(new PhabricatorDashboardPanelQuery()) $panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->requireCapabilities($capabilities) ->requireCapabilities($capabilities)
->executeOne(); ->executeOne();
if (!$panel) { if (!$panel) {

View file

@ -9,13 +9,11 @@ final class PhabricatorDashboardPanelListController
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->queryKey = idx($data, 'queryKey'); $query_key = $request->getURIData('queryKey');
}
public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController()) $controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey) ->setQueryKey($query_key)
->setSearchEngine(new PhabricatorDashboardPanelSearchEngine()) ->setSearchEngine(new PhabricatorDashboardPanelSearchEngine())
->setNavigation($this->buildSideNavView()); ->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller); return $this->delegateToController($controller);

View file

@ -3,23 +3,17 @@
final class PhabricatorDashboardPanelRenderController final class PhabricatorDashboardPanelRenderController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->id = $data['id']; $viewer = $request->getViewer();
} $id = $request->getURIData('id');
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$panel = id(new PhabricatorDashboardPanelQuery()) $panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$panel) { if (!$panel) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -3,23 +3,17 @@
final class PhabricatorDashboardPanelViewController final class PhabricatorDashboardPanelViewController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->id = $data['id']; $viewer = $request->getViewer();
} $id = $request->getURIData('id');
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$panel = id(new PhabricatorDashboardPanelQuery()) $panel = id(new PhabricatorDashboardPanelQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$panel) { if (!$panel) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -3,19 +3,13 @@
final class PhabricatorDashboardRemovePanelController final class PhabricatorDashboardRemovePanelController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->requireCapabilities( ->requireCapabilities(
array( array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -3,19 +3,13 @@
final class PhabricatorDashboardUninstallController final class PhabricatorDashboardUninstallController
extends PhabricatorDashboardController { extends PhabricatorDashboardController {
private $id; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('id');
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$dashboard) { if (!$dashboard) {
return new Aphront404Response(); return new Aphront404Response();
@ -73,7 +67,7 @@ final class PhabricatorDashboardUninstallController
->setTitle(pht('Uninstall Dashboard')) ->setTitle(pht('Uninstall Dashboard'))
->appendChild($form->buildLayoutView()) ->appendChild($form->buildLayoutView())
->addCancelButton($this->getCancelURI( ->addCancelButton($this->getCancelURI(
$application_class, $object_phid)) $application_class, $object_phid, $id))
->addSubmitButton(pht('Uninstall Dashboard')); ->addSubmitButton(pht('Uninstall Dashboard'));
} }
@ -114,11 +108,11 @@ final class PhabricatorDashboardUninstallController
return $body; return $body;
} }
private function getCancelURI($application_class, $object_phid) { private function getCancelURI($application_class, $object_phid, $id) {
$uri = null; $uri = null;
switch ($application_class) { switch ($application_class) {
case 'PhabricatorHomeApplication': case 'PhabricatorHomeApplication':
$uri = '/dashboard/view/'.$this->id.'/'; $uri = '/dashboard/view/'.$id.'/';
break; break;
} }
return $uri; return $uri;

View file

@ -9,13 +9,9 @@ final class PhabricatorDashboardViewController
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->id = $data['id']; $viewer = $request->getViewer();
} $this->id = $request->getURIData('id');
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$dashboard = id(new PhabricatorDashboardQuery()) $dashboard = id(new PhabricatorDashboardQuery())
->setViewer($viewer) ->setViewer($viewer)