mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 06:20:56 +01:00
Update Harbormaster for handleRequest
Summary: Updates Harbormaster for handleRequest over processRequest Test Plan: Went through various Harbormaster areas, buildables, actions. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D14255
This commit is contained in:
parent
bb37ad65a2
commit
02f42628c3
5 changed files with 22 additions and 46 deletions
|
@ -3,24 +3,15 @@
|
||||||
final class HarbormasterBuildActionController
|
final class HarbormasterBuildActionController
|
||||||
extends HarbormasterController {
|
extends HarbormasterController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
private $action;
|
$viewer = $this->getViewer();
|
||||||
private $via;
|
$id = $request->getURIData('id');
|
||||||
|
$action = $request->getURIData('action');
|
||||||
public function willProcessRequest(array $data) {
|
$via = $request->getURIData('via');
|
||||||
$this->id = $data['id'];
|
|
||||||
$this->action = $data['action'];
|
|
||||||
$this->via = idx($data, 'via');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$viewer = $request->getUser();
|
|
||||||
$command = $this->action;
|
|
||||||
|
|
||||||
$build = id(new HarbormasterBuildQuery())
|
$build = id(new HarbormasterBuildQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
@ -31,7 +22,7 @@ final class HarbormasterBuildActionController
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($command) {
|
switch ($action) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
$can_issue = $build->canRestartBuild();
|
$can_issue = $build->canRestartBuild();
|
||||||
break;
|
break;
|
||||||
|
@ -48,7 +39,7 @@ final class HarbormasterBuildActionController
|
||||||
return new Aphront400Response();
|
return new Aphront400Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($this->via) {
|
switch ($via) {
|
||||||
case 'buildable':
|
case 'buildable':
|
||||||
$return_uri = '/'.$build->getBuildable()->getMonogram();
|
$return_uri = '/'.$build->getBuildable()->getMonogram();
|
||||||
break;
|
break;
|
||||||
|
@ -66,14 +57,14 @@ final class HarbormasterBuildActionController
|
||||||
|
|
||||||
$xaction = id(new HarbormasterBuildTransaction())
|
$xaction = id(new HarbormasterBuildTransaction())
|
||||||
->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)
|
->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)
|
||||||
->setNewValue($command);
|
->setNewValue($action);
|
||||||
|
|
||||||
$editor->applyTransactions($build, array($xaction));
|
$editor->applyTransactions($build, array($xaction));
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($command) {
|
switch ($action) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
if ($can_issue) {
|
if ($can_issue) {
|
||||||
$title = pht('Really restart build?');
|
$title = pht('Really restart build?');
|
||||||
|
|
|
@ -3,22 +3,14 @@
|
||||||
final class HarbormasterBuildableActionController
|
final class HarbormasterBuildableActionController
|
||||||
extends HarbormasterController {
|
extends HarbormasterController {
|
||||||
|
|
||||||
private $id;
|
public function handleRequest(AphrontRequest $request) {
|
||||||
private $action;
|
$viewer = $this->getViewer();
|
||||||
|
$id = $request->getURIData('id');
|
||||||
public function willProcessRequest(array $data) {
|
$action = $request->getURIData('action');
|
||||||
$this->id = $data['id'];
|
|
||||||
$this->action = $data['action'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$request = $this->getRequest();
|
|
||||||
$viewer = $request->getUser();
|
|
||||||
$command = $this->action;
|
|
||||||
|
|
||||||
$buildable = id(new HarbormasterBuildableQuery())
|
$buildable = id(new HarbormasterBuildableQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withIDs(array($this->id))
|
->withIDs(array($id))
|
||||||
->needBuilds(true)
|
->needBuilds(true)
|
||||||
->requireCapabilities(
|
->requireCapabilities(
|
||||||
array(
|
array(
|
||||||
|
@ -33,7 +25,7 @@ final class HarbormasterBuildableActionController
|
||||||
$issuable = array();
|
$issuable = array();
|
||||||
|
|
||||||
foreach ($buildable->getBuilds() as $build) {
|
foreach ($buildable->getBuilds() as $build) {
|
||||||
switch ($command) {
|
switch ($action) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
if ($build->canRestartBuild()) {
|
if ($build->canRestartBuild()) {
|
||||||
$issuable[] = $build;
|
$issuable[] = $build;
|
||||||
|
@ -69,7 +61,7 @@ final class HarbormasterBuildableActionController
|
||||||
|
|
||||||
$xaction = id(new HarbormasterBuildableTransaction())
|
$xaction = id(new HarbormasterBuildableTransaction())
|
||||||
->setTransactionType(HarbormasterBuildableTransaction::TYPE_COMMAND)
|
->setTransactionType(HarbormasterBuildableTransaction::TYPE_COMMAND)
|
||||||
->setNewValue($command);
|
->setNewValue($action);
|
||||||
|
|
||||||
$editor->applyTransactions($buildable, array($xaction));
|
$editor->applyTransactions($buildable, array($xaction));
|
||||||
|
|
||||||
|
@ -82,14 +74,14 @@ final class HarbormasterBuildableActionController
|
||||||
foreach ($issuable as $build) {
|
foreach ($issuable as $build) {
|
||||||
$xaction = id(new HarbormasterBuildTransaction())
|
$xaction = id(new HarbormasterBuildTransaction())
|
||||||
->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)
|
->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)
|
||||||
->setNewValue($command);
|
->setNewValue($action);
|
||||||
$build_editor->applyTransactions($build, array($xaction));
|
$build_editor->applyTransactions($build, array($xaction));
|
||||||
}
|
}
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($command) {
|
switch ($action) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
if ($issuable) {
|
if ($issuable) {
|
||||||
$title = pht('Really restart all builds?');
|
$title = pht('Really restart all builds?');
|
||||||
|
|
|
@ -2,19 +2,13 @@
|
||||||
|
|
||||||
final class HarbormasterBuildableListController extends HarbormasterController {
|
final class HarbormasterBuildableListController extends HarbormasterController {
|
||||||
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function processRequest() {
|
|
||||||
$controller = id(new PhabricatorApplicationSearchController())
|
$controller = id(new PhabricatorApplicationSearchController())
|
||||||
->setQueryKey($this->queryKey)
|
->setQueryKey($request->getURIData('queryKey'))
|
||||||
->setSearchEngine(new HarbormasterBuildableSearchEngine())
|
->setSearchEngine(new HarbormasterBuildableSearchEngine())
|
||||||
->setNavigation($this->buildSideNavView());
|
->setNavigation($this->buildSideNavView());
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ final class HarbormasterPlanViewController extends HarbormasterPlanController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $this->getviewer();
|
$viewer = $this->getviewer();
|
||||||
|
|
||||||
$id = $request->getURIData('id');
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
$plan = id(new HarbormasterBuildPlanQuery())
|
$plan = id(new HarbormasterBuildPlanQuery())
|
||||||
|
|
|
@ -4,11 +4,11 @@ final class HarbormasterStepEditController extends HarbormasterController {
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
|
$id = $request->getURIData('id');
|
||||||
|
|
||||||
$this->requireApplicationCapability(
|
$this->requireApplicationCapability(
|
||||||
HarbormasterManagePlansCapability::CAPABILITY);
|
HarbormasterManagePlansCapability::CAPABILITY);
|
||||||
|
|
||||||
$id = $request->getURIData('id');
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$step = id(new HarbormasterBuildStepQuery())
|
$step = id(new HarbormasterBuildStepQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
|
|
Loading…
Reference in a new issue