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

Update Releeph for handleRequest

Summary: Updates Releeph callsites to handleRequest

Test Plan: Bounce around Releeph, cut a branch, edit a product, view history

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D14001
This commit is contained in:
Chad Little 2015-08-29 08:33:25 -07:00
parent a339e6de9e
commit 4c77ff68aa
12 changed files with 54 additions and 122 deletions

View file

@ -2,20 +2,13 @@
final class ReleephProductActionController extends ReleephProductController { final class ReleephProductActionController extends ReleephProductController {
private $id; public function handleRequest(AphrontRequest $request) {
private $action; $viewer = $request->getViewer();
$id = $request->getURIData('projectID');
public function willProcessRequest(array $data) { $action = $request->getURIData('action');
$this->id = $data['projectID'];
$this->action = $data['action'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$product = id(new ReleephProductQuery()) $product = id(new ReleephProductQuery())
->withIDs(array($this->id)) ->withIDs(array($id))
->requireCapabilities( ->requireCapabilities(
array( array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,
@ -32,7 +25,6 @@ final class ReleephProductActionController extends ReleephProductController {
$product_id = $product->getID(); $product_id = $product->getID();
$product_uri = $this->getProductViewURI($product); $product_uri = $this->getProductViewURI($product);
$action = $this->action;
switch ($action) { switch ($action) {
case 'deactivate': case 'deactivate':
case 'activate': case 'activate':

View file

@ -2,8 +2,7 @@
final class ReleephProductCreateController extends ReleephProductController { final class ReleephProductCreateController extends ReleephProductController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest();
$name = trim($request->getStr('name')); $name = trim($request->getStr('name'));
$trunk_branch = trim($request->getStr('trunkBranch')); $trunk_branch = trim($request->getStr('trunkBranch'));
$repository_phid = $request->getStr('repositoryPHID'); $repository_phid = $request->getStr('repositoryPHID');

View file

@ -2,19 +2,13 @@
final class ReleephProductEditController extends ReleephProductController { final class ReleephProductEditController extends ReleephProductController {
private $productID; public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { $id = $request->getURIData('projectID');
$this->productID = $data['projectID'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$product = id(new ReleephProductQuery()) $product = id(new ReleephProductQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->productID)) ->withIDs(array($id))
->requireCapabilities( ->requireCapabilities(
array( array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,

View file

@ -2,23 +2,17 @@
final class ReleephProductHistoryController extends ReleephProductController { final class ReleephProductHistoryController extends ReleephProductController {
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['projectID']; $viewer = $request->getViewer();
} $id = $request->getURIData('projectID');
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$product = id(new ReleephProductQuery()) $product = id(new ReleephProductQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->id)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$product) { if (!$product) {
return new Aphront404Response(); return new Aphront404Response();
@ -32,6 +26,7 @@ final class ReleephProductHistoryController extends ReleephProductController {
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('History')); $crumbs->addTextCrumb(pht('History'));
$crumbs->setBorder(true);
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(

View file

@ -2,19 +2,14 @@
final class ReleephProductListController extends ReleephController { final class ReleephProductListController extends ReleephController {
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'); $query_key = $request->getURIData('queryKey');
}
public function processRequest() {
$controller = id(new PhabricatorApplicationSearchController()) $controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey) ->setQueryKey($query_key)
->setSearchEngine(new ReleephProductSearchEngine()) ->setSearchEngine(new ReleephProductSearchEngine())
->setNavigation($this->buildSideNavView()); ->setNavigation($this->buildSideNavView());

View file

@ -2,25 +2,18 @@
final class ReleephProductViewController extends ReleephProductController { final class ReleephProductViewController extends ReleephProductController {
private $productID;
private $queryKey;
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
} }
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->productID = idx($data, 'projectID'); $id = $request->getURIData('projectID');
$this->queryKey = idx($data, 'queryKey'); $query_key = $request->getURIData('queryKey');
} $viewer = $request->getViewer();
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$product = id(new ReleephProductQuery()) $product = id(new ReleephProductQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->productID)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$product) { if (!$product) {
return new Aphront404Response(); return new Aphront404Response();
@ -28,7 +21,7 @@ final class ReleephProductViewController extends ReleephProductController {
$this->setProduct($product); $this->setProduct($product);
$controller = id(new PhabricatorApplicationSearchController()) $controller = id(new PhabricatorApplicationSearchController())
->setQueryKey($this->queryKey) ->setQueryKey($query_key)
->setPreface($this->renderPreface()) ->setPreface($this->renderPreface())
->setSearchEngine( ->setSearchEngine(
id(new ReleephBranchSearchEngine()) id(new ReleephBranchSearchEngine())

View file

@ -3,23 +3,16 @@
final class ReleephRequestActionController final class ReleephRequestActionController
extends ReleephRequestController { extends ReleephRequestController {
private $action; public function handleRequest(AphrontRequest $request) {
private $requestID; $action = $request->getURIData('action');
$id = $request->getURIData('requestID');
public function willProcessRequest(array $data) { $viewer = $request->getViewer();
$this->action = $data['action'];
$this->requestID = $data['requestID'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$request->validateCSRF(); $request->validateCSRF();
$pull = id(new ReleephRequestQuery()) $pull = id(new ReleephRequestQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->requestID)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$pull) { if (!$pull) {
return new Aphront404Response(); return new Aphront404Response();
@ -27,9 +20,6 @@ final class ReleephRequestActionController
$branch = $pull->getBranch(); $branch = $pull->getBranch();
$product = $branch->getProduct(); $product = $branch->getProduct();
$action = $this->action;
$origin_uri = '/'.$pull->getMonogram(); $origin_uri = '/'.$pull->getMonogram();
$editor = id(new ReleephRequestTransactionalEditor()) $editor = id(new ReleephRequestTransactionalEditor())

View file

@ -3,15 +3,9 @@
final class ReleephRequestCommentController final class ReleephRequestCommentController
extends ReleephRequestController { extends ReleephRequestController {
private $requestID; public function handleRequest(AphrontRequest $request) {
$id = $request->getURIData('requestID');
public function willProcessRequest(array $data) { $viewer = $request->getViewer();
$this->requestID = $data['requestID'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if (!$request->isFormPost()) { if (!$request->isFormPost()) {
return new Aphront400Response(); return new Aphront400Response();
@ -19,7 +13,7 @@ final class ReleephRequestCommentController
$pull = id(new ReleephRequestQuery()) $pull = id(new ReleephRequestQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->requestID)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$pull) { if (!$pull) {
return new Aphront404Response(); return new Aphront404Response();

View file

@ -5,20 +5,15 @@
final class ReleephRequestDifferentialCreateController final class ReleephRequestDifferentialCreateController
extends ReleephController { extends ReleephController {
private $revisionID;
private $revision; private $revision;
public function willProcessRequest(array $data) { public function handleRequest(AphrontRequest $request) {
$this->revisionID = $data['diffRevID']; $revision_id = $request->getURIData('diffRevID');
} $viewer = $request->getViewer();
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$diff_rev = id(new DifferentialRevisionQuery()) $diff_rev = id(new DifferentialRevisionQuery())
->setViewer($user) ->setViewer($viewer)
->withIDs(array($this->revisionID)) ->withIDs(array($revision_id))
->executeOne(); ->executeOne();
if (!$diff_rev) { if (!$diff_rev) {
return new Aphront404Response(); return new Aphront404Response();
@ -63,7 +58,7 @@ final class ReleephRequestDifferentialCreateController
require_celerity_resource('releeph-request-differential-create-dialog'); require_celerity_resource('releeph-request-differential-create-dialog');
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($viewer)
->setTitle(pht('Choose Releeph Branch')) ->setTitle(pht('Choose Releeph Branch'))
->setClass('releeph-request-differential-create-dialog') ->setClass('releeph-request-differential-create-dialog')
->addCancelButton('/D'.$request->getStr('D')); ->addCancelButton('/D'.$request->getStr('D'));

View file

@ -2,22 +2,16 @@
final class ReleephRequestEditController extends ReleephBranchController { final class ReleephRequestEditController extends ReleephBranchController {
private $requestID; public function handleRequest(AphrontRequest $request) {
private $branchID; $action = $request->getURIData('action');
$request_id = $request->getURIData('requestID');
$branch_id = $request->getURIData('branchID');
$viewer = $request->getViewer();
public function willProcessRequest(array $data) { if ($request_id) {
$this->requestID = idx($data, 'requestID');
$this->branchID = idx($data, 'branchID');
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
if ($this->requestID) {
$pull = id(new ReleephRequestQuery()) $pull = id(new ReleephRequestQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->requestID)) ->withIDs(array($request_id))
->requireCapabilities( ->requireCapabilities(
array( array(
PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_VIEW,
@ -34,7 +28,7 @@ final class ReleephRequestEditController extends ReleephBranchController {
} else { } else {
$branch = id(new ReleephBranchQuery()) $branch = id(new ReleephBranchQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->branchID)) ->withIDs(array($branch_id))
->executeOne(); ->executeOne();
if (!$branch) { if (!$branch) {
return new Aphront404Response(); return new Aphront404Response();
@ -77,8 +71,8 @@ final class ReleephRequestEditController extends ReleephBranchController {
$field_list->readFieldsFromStorage($pull); $field_list->readFieldsFromStorage($pull);
if ($this->branchID) { if ($branch_id) {
$cancel_uri = $this->getApplicationURI('branch/'.$this->branchID.'/'); $cancel_uri = $this->getApplicationURI('branch/'.$branch_id.'/');
} else { } else {
$cancel_uri = '/'.$pull->getMonogram(); $cancel_uri = '/'.$pull->getMonogram();
} }

View file

@ -3,9 +3,7 @@
final class ReleephRequestTypeaheadController final class ReleephRequestTypeaheadController
extends PhabricatorTypeaheadDatasourceController { extends PhabricatorTypeaheadDatasourceController {
public function processRequest() { public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest();
$query = $request->getStr('q'); $query = $request->getStr('q');
$repo_id = $request->getInt('repo'); $repo_id = $request->getInt('repo');
$since = $request->getInt('since'); $since = $request->getInt('since');

View file

@ -3,19 +3,13 @@
final class ReleephRequestViewController final class ReleephRequestViewController
extends ReleephBranchController { extends ReleephBranchController {
private $requestID; public function handleRequest(AphrontRequest $request) {
$id = $request->getURIData('requestID');
public function willProcessRequest(array $data) { $viewer = $request->getViewer();
$this->requestID = $data['requestID'];
}
public function processRequest() {
$request = $this->getRequest();
$viewer = $request->getUser();
$pull = id(new ReleephRequestQuery()) $pull = id(new ReleephRequestQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($this->requestID)) ->withIDs(array($id))
->executeOne(); ->executeOne();
if (!$pull) { if (!$pull) {
return new Aphront404Response(); return new Aphront404Response();
@ -92,7 +86,6 @@ final class ReleephRequestViewController
), ),
array( array(
'title' => $title, 'title' => $title,
'device' => true,
)); ));
} }