mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +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
|
||||
extends HarbormasterController {
|
||||
|
||||
private $id;
|
||||
private $action;
|
||||
private $via;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$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;
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
$action = $request->getURIData('action');
|
||||
$via = $request->getURIData('via');
|
||||
|
||||
$build = id(new HarbormasterBuildQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($this->id))
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
|
@ -31,7 +22,7 @@ final class HarbormasterBuildActionController
|
|||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
switch ($command) {
|
||||
switch ($action) {
|
||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||
$can_issue = $build->canRestartBuild();
|
||||
break;
|
||||
|
@ -48,7 +39,7 @@ final class HarbormasterBuildActionController
|
|||
return new Aphront400Response();
|
||||
}
|
||||
|
||||
switch ($this->via) {
|
||||
switch ($via) {
|
||||
case 'buildable':
|
||||
$return_uri = '/'.$build->getBuildable()->getMonogram();
|
||||
break;
|
||||
|
@ -66,14 +57,14 @@ final class HarbormasterBuildActionController
|
|||
|
||||
$xaction = id(new HarbormasterBuildTransaction())
|
||||
->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)
|
||||
->setNewValue($command);
|
||||
->setNewValue($action);
|
||||
|
||||
$editor->applyTransactions($build, array($xaction));
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
||||
}
|
||||
|
||||
switch ($command) {
|
||||
switch ($action) {
|
||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||
if ($can_issue) {
|
||||
$title = pht('Really restart build?');
|
||||
|
|
|
@ -3,22 +3,14 @@
|
|||
final class HarbormasterBuildableActionController
|
||||
extends HarbormasterController {
|
||||
|
||||
private $id;
|
||||
private $action;
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->id = $data['id'];
|
||||
$this->action = $data['action'];
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
$viewer = $request->getUser();
|
||||
$command = $this->action;
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
$action = $request->getURIData('action');
|
||||
|
||||
$buildable = id(new HarbormasterBuildableQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($this->id))
|
||||
->withIDs(array($id))
|
||||
->needBuilds(true)
|
||||
->requireCapabilities(
|
||||
array(
|
||||
|
@ -33,7 +25,7 @@ final class HarbormasterBuildableActionController
|
|||
$issuable = array();
|
||||
|
||||
foreach ($buildable->getBuilds() as $build) {
|
||||
switch ($command) {
|
||||
switch ($action) {
|
||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||
if ($build->canRestartBuild()) {
|
||||
$issuable[] = $build;
|
||||
|
@ -69,7 +61,7 @@ final class HarbormasterBuildableActionController
|
|||
|
||||
$xaction = id(new HarbormasterBuildableTransaction())
|
||||
->setTransactionType(HarbormasterBuildableTransaction::TYPE_COMMAND)
|
||||
->setNewValue($command);
|
||||
->setNewValue($action);
|
||||
|
||||
$editor->applyTransactions($buildable, array($xaction));
|
||||
|
||||
|
@ -82,14 +74,14 @@ final class HarbormasterBuildableActionController
|
|||
foreach ($issuable as $build) {
|
||||
$xaction = id(new HarbormasterBuildTransaction())
|
||||
->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)
|
||||
->setNewValue($command);
|
||||
->setNewValue($action);
|
||||
$build_editor->applyTransactions($build, array($xaction));
|
||||
}
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
||||
}
|
||||
|
||||
switch ($command) {
|
||||
switch ($action) {
|
||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||
if ($issuable) {
|
||||
$title = pht('Really restart all builds?');
|
||||
|
|
|
@ -2,19 +2,13 @@
|
|||
|
||||
final class HarbormasterBuildableListController extends HarbormasterController {
|
||||
|
||||
private $queryKey;
|
||||
|
||||
public function shouldAllowPublic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function willProcessRequest(array $data) {
|
||||
$this->queryKey = idx($data, 'queryKey');
|
||||
}
|
||||
|
||||
public function processRequest() {
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$controller = id(new PhabricatorApplicationSearchController())
|
||||
->setQueryKey($this->queryKey)
|
||||
->setQueryKey($request->getURIData('queryKey'))
|
||||
->setSearchEngine(new HarbormasterBuildableSearchEngine())
|
||||
->setNavigation($this->buildSideNavView());
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ final class HarbormasterPlanViewController extends HarbormasterPlanController {
|
|||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getviewer();
|
||||
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$plan = id(new HarbormasterBuildPlanQuery())
|
||||
|
|
|
@ -4,11 +4,11 @@ final class HarbormasterStepEditController extends HarbormasterController {
|
|||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $this->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$this->requireApplicationCapability(
|
||||
HarbormasterManagePlansCapability::CAPABILITY);
|
||||
|
||||
$id = $request->getURIData('id');
|
||||
if ($id) {
|
||||
$step = id(new HarbormasterBuildStepQuery())
|
||||
->setViewer($viewer)
|
||||
|
|
Loading…
Reference in a new issue