diff --git a/src/applications/diffusion/controller/DiffusionChangeController.php b/src/applications/diffusion/controller/DiffusionChangeController.php index 064e5cc750..86b371c38b 100644 --- a/src/applications/diffusion/controller/DiffusionChangeController.php +++ b/src/applications/diffusion/controller/DiffusionChangeController.php @@ -6,9 +6,14 @@ final class DiffusionChangeController extends DiffusionController { return true; } - protected function processDiffusionRequest(AphrontRequest $request) { - $drequest = $this->diffusionRequest; - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + + $viewer = $this->getViewer(); + $drequest = $this->getDiffusionRequest(); $content = array(); @@ -89,15 +94,18 @@ final class DiffusionChangeController extends DiffusionController { ->setHeader($header) ->addPropertyList($properties); - return $this->buildApplicationPage( - array( - $crumbs, - $object_box, - $content, - ), - array( - 'title' => pht('Change'), - )); + return $this->newPage() + ->setTitle( + array( + basename($drequest->getPath()), + $repository->getDisplayName(), + )) + ->setCrumbs($crumbs) + ->appendChild( + array( + $object_box, + $content, + )); } private function buildActionView(DiffusionRequest $drequest) { diff --git a/src/applications/diffusion/controller/DiffusionCommitBranchesController.php b/src/applications/diffusion/controller/DiffusionCommitBranchesController.php index 4f12e17656..1e5cc0ac31 100644 --- a/src/applications/diffusion/controller/DiffusionCommitBranchesController.php +++ b/src/applications/diffusion/controller/DiffusionCommitBranchesController.php @@ -6,7 +6,12 @@ final class DiffusionCommitBranchesController extends DiffusionController { return true; } - protected function processDiffusionRequest(AphrontRequest $request) { + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); diff --git a/src/applications/diffusion/controller/DiffusionCommitEditController.php b/src/applications/diffusion/controller/DiffusionCommitEditController.php index ffaf892e75..895eda4c6d 100644 --- a/src/applications/diffusion/controller/DiffusionCommitEditController.php +++ b/src/applications/diffusion/controller/DiffusionCommitEditController.php @@ -2,18 +2,24 @@ final class DiffusionCommitEditController extends DiffusionController { - protected function processDiffusionRequest(AphrontRequest $request) { - $user = $request->getUser(); - $drequest = $this->getDiffusionRequest(); + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + + $viewer = $this->getViewer(); + $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); - $commit = $drequest->loadCommit(); - $data = $commit->loadCommitData(); - $page_title = pht('Edit Diffusion Commit'); + $commit = $drequest->loadCommit(); if (!$commit) { return new Aphront404Response(); } + $data = $commit->loadCommitData(); + $page_title = pht('Edit Diffusion Commit'); + $commit_phid = $commit->getPHID(); $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; $current_proj_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( @@ -27,18 +33,21 @@ final class DiffusionCommitEditController extends DiffusionController { ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) ->setMetadataValue('edge:type', $edge_type) ->setNewValue(array('=' => array_fuse($proj_phids))); + $editor = id(new PhabricatorAuditEditor()) - ->setActor($user) + ->setActor($viewer) ->setContinueOnNoEffect(true) ->setContentSourceFromRequest($request); - $xactions = $editor->applyTransactions($commit, $xactions); + + $editor->applyTransactions($commit, $xactions); + return id(new AphrontRedirectResponse()) ->setURI($commit->getURI()); } $tokenizer_id = celerity_generate_unique_node_id(); $form = id(new AphrontFormView()) - ->setUser($user) + ->setUser($viewer) ->setAction($request->getRequestURI()->getPath()) ->appendControl( id(new AphrontFormTokenizerControl()) @@ -87,33 +96,25 @@ final class DiffusionCommitEditController extends DiffusionController { ->setValue(array($desc, " \xC2\xB7 ", $doc_link))); } + $form->appendControl( + id(new AphrontFormSubmitControl()) + ->setValue(pht('Save')) + ->addCancelButton($commit->getURI())); - Javelin::initBehavior('project-create', array( - 'tokenizerID' => $tokenizer_id, - )); - - $submit = id(new AphrontFormSubmitControl()) - ->setValue(pht('Save')) - ->addCancelButton($commit->getURI()); - $form->appendChild($submit); - - $crumbs = $this->buildCrumbs(array( - 'commit' => true, - )); + $crumbs = $this->buildCrumbs( + array( + 'commit' => true, + )); $crumbs->addTextCrumb(pht('Edit')); $form_box = id(new PHUIObjectBoxView()) ->setHeaderText($page_title) ->setForm($form); - return $this->buildApplicationPage( - array( - $crumbs, - $form_box, - ), - array( - 'title' => $page_title, - )); + return $this->newPage() + ->setTitle($page_title) + ->setCrumbs($crumbs) + ->appendChild($form_box); } } diff --git a/src/applications/diffusion/controller/DiffusionCommitTagsController.php b/src/applications/diffusion/controller/DiffusionCommitTagsController.php index 3c698f9a70..0f825a9b64 100644 --- a/src/applications/diffusion/controller/DiffusionCommitTagsController.php +++ b/src/applications/diffusion/controller/DiffusionCommitTagsController.php @@ -6,7 +6,12 @@ final class DiffusionCommitTagsController extends DiffusionController { return true; } - protected function processDiffusionRequest(AphrontRequest $request) { + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); diff --git a/src/applications/diffusion/controller/DiffusionHistoryController.php b/src/applications/diffusion/controller/DiffusionHistoryController.php index 6cca484207..edbce636c2 100644 --- a/src/applications/diffusion/controller/DiffusionHistoryController.php +++ b/src/applications/diffusion/controller/DiffusionHistoryController.php @@ -6,19 +6,24 @@ final class DiffusionHistoryController extends DiffusionController { return true; } - protected function processDiffusionRequest(AphrontRequest $request) { - $drequest = $this->diffusionRequest; - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + + $viewer = $this->getViewer(); + $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); - $page_size = $request->getInt('pagesize', 100); - $offset = $request->getInt('offset', 0); + $pager = id(new PHUIPagerView()) + ->readFromRequest($request); $params = array( 'commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), - 'offset' => $offset, - 'limit' => $page_size + 1, + 'offset' => $pager->getOffset(), + 'limit' => $pager->getPageSize() + 1, ); if (!$request->getBool('copies')) { @@ -32,13 +37,8 @@ final class DiffusionHistoryController extends DiffusionController { $history = DiffusionPathChange::newFromConduit( $history_results['pathChanges']); - $pager = new PHUIPagerView(); - $pager->setPageSize($page_size); - $pager->setOffset($offset); $history = $pager->sliceResults($history); - $pager->setURI($request->getRequestURI(), 'offset'); - $show_graph = !strlen($drequest->getPath()); $content = array(); @@ -51,7 +51,7 @@ final class DiffusionHistoryController extends DiffusionController { if ($show_graph) { $history_table->setParents($history_results['parents']); - $history_table->setIsHead($offset == 0); + $history_table->setIsHead(!$pager->getOffset()); } $history_panel = new PHUIObjectBoxView(); @@ -79,23 +79,21 @@ final class DiffusionHistoryController extends DiffusionController { 'view' => 'history', )); - $pager = id(new PHUIBoxView()) - ->addClass('ml') - ->appendChild($pager); + $pager_box = $this->renderTablePagerBox($pager); - return $this->buildApplicationPage( - array( - $crumbs, - $object_box, - $content, - $pager, - ), - array( - 'title' => array( + return $this->newPage() + ->setTitle( + array( pht('History'), - $drequest->getRepository()->getDisplayName(), - ), - )); + $repository->getDisplayName(), + )) + ->setCrumbs($crumbs) + ->appendChild( + array( + $object_box, + $content, + $pager_box, + )); } private function buildActionView(DiffusionRequest $drequest) { diff --git a/src/applications/diffusion/controller/DiffusionMirrorDeleteController.php b/src/applications/diffusion/controller/DiffusionMirrorDeleteController.php index 3a4300690e..c49cdb7517 100644 --- a/src/applications/diffusion/controller/DiffusionMirrorDeleteController.php +++ b/src/applications/diffusion/controller/DiffusionMirrorDeleteController.php @@ -3,9 +3,14 @@ final class DiffusionMirrorDeleteController extends DiffusionController { - protected function processDiffusionRequest(AphrontRequest $request) { - $viewer = $request->getUser(); - $drequest = $this->diffusionRequest; + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + + $viewer = $this->getViewer(); + $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $mirror = id(new PhabricatorRepositoryMirrorQuery()) diff --git a/src/applications/diffusion/controller/DiffusionMirrorEditController.php b/src/applications/diffusion/controller/DiffusionMirrorEditController.php index 4d5e9f139f..f5793f2afe 100644 --- a/src/applications/diffusion/controller/DiffusionMirrorEditController.php +++ b/src/applications/diffusion/controller/DiffusionMirrorEditController.php @@ -3,9 +3,14 @@ final class DiffusionMirrorEditController extends DiffusionController { - protected function processDiffusionRequest(AphrontRequest $request) { - $viewer = $request->getUser(); - $drequest = $this->diffusionRequest; + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + + $viewer = $this->getViewer(); + $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); PhabricatorPolicyFilter::requireCapability( diff --git a/src/applications/diffusion/controller/DiffusionPushEventViewController.php b/src/applications/diffusion/controller/DiffusionPushEventViewController.php index 3c5861e512..027cf16bbe 100644 --- a/src/applications/diffusion/controller/DiffusionPushEventViewController.php +++ b/src/applications/diffusion/controller/DiffusionPushEventViewController.php @@ -7,8 +7,8 @@ final class DiffusionPushEventViewController return true; } - protected function processDiffusionRequest(AphrontRequest $request) { - $viewer = $request->getUser(); + public function handleRequest(AphrontRequest $request) { + $viewer = $this->getViewer(); $event = id(new PhabricatorRepositoryPushEventQuery()) ->setViewer($viewer) @@ -57,16 +57,15 @@ final class DiffusionPushEventViewController ->setHeaderText(pht('All Pushed Updates')) ->setTable($updates_table); - return $this->buildApplicationPage( - array( - $crumbs, - $detail_box, - $commits_box, - $update_box, - ), - array( - 'title' => $title, - )); + return $this->newPage() + ->setTitle($title) + ->setCrumbs($crumbs) + ->appendChild( + array( + $detail_box, + $commits_box, + $update_box, + )); } private function buildPropertyList(PhabricatorRepositoryPushEvent $event) { diff --git a/src/applications/diffusion/controller/DiffusionPushLogListController.php b/src/applications/diffusion/controller/DiffusionPushLogListController.php index 4f2460be89..5b58881470 100644 --- a/src/applications/diffusion/controller/DiffusionPushLogListController.php +++ b/src/applications/diffusion/controller/DiffusionPushLogListController.php @@ -6,29 +6,10 @@ final class DiffusionPushLogListController extends DiffusionPushLogController { return true; } - protected function processDiffusionRequest(AphrontRequest $request) { - $request = $this->getRequest(); - $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($request->getURIData('queryKey')) - ->setSearchEngine(new PhabricatorRepositoryPushLogSearchEngine()) - ->setNavigation($this->buildSideNavView()); - - return $this->delegateToController($controller); - } - - public function buildSideNavView($for_app = false) { - $viewer = $this->getRequest()->getUser(); - - $nav = new AphrontSideNavFilterView(); - $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); - - id(new PhabricatorRepositoryPushLogSearchEngine()) - ->setViewer($viewer) - ->addNavigationItems($nav->getMenu()); - - $nav->selectFilter(null); - - return $nav; + public function handleRequest(AphrontRequest $request) { + return id(new PhabricatorRepositoryPushLogSearchEngine()) + ->setController($this) + ->buildResponse(); } } diff --git a/src/applications/diffusion/controller/DiffusionRefTableController.php b/src/applications/diffusion/controller/DiffusionRefTableController.php index dac0c3a136..8a4e274819 100644 --- a/src/applications/diffusion/controller/DiffusionRefTableController.php +++ b/src/applications/diffusion/controller/DiffusionRefTableController.php @@ -6,9 +6,13 @@ final class DiffusionRefTableController extends DiffusionController { return true; } - protected function processDiffusionRequest(AphrontRequest $request) { - $viewer = $this->getViewer(); + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + $viewer = $this->getViewer(); $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); @@ -132,18 +136,15 @@ final class DiffusionRefTableController extends DiffusionController { $crumbs = $this->buildCrumbs(array()); $crumbs->addTextCrumb(pht('Refs')); - return $this->buildApplicationPage( - array( - $crumbs, - $content, - ), - array( - 'title' => array( - pht('Refs'), - $repository->getMonogram(), + return $this->newPage() + ->setTitle( + array( $ref_name, - ), - )); + pht('Ref'), + $repository->getDisplayName(), + )) + ->setCrumbs($crumbs) + ->appendChild($content); } } diff --git a/src/applications/diffusion/controller/DiffusionRepositoryListController.php b/src/applications/diffusion/controller/DiffusionRepositoryListController.php index ec93edbc41..5897d2f162 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryListController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryListController.php @@ -6,28 +6,10 @@ final class DiffusionRepositoryListController extends DiffusionController { return true; } - protected function processDiffusionRequest(AphrontRequest $request) { - $controller = id(new PhabricatorApplicationSearchController()) - ->setQueryKey($request->getURIData('queryKey')) - ->setSearchEngine(new PhabricatorRepositorySearchEngine()) - ->setNavigation($this->buildSideNavView()); - - return $this->delegateToController($controller); - } - - public function buildSideNavView($for_app = false) { - $viewer = $this->getRequest()->getUser(); - - $nav = new AphrontSideNavFilterView(); - $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); - - id(new PhabricatorRepositorySearchEngine()) - ->setViewer($viewer) - ->addNavigationItems($nav->getMenu()); - - $nav->selectFilter(null); - - return $nav; + public function handleRequest(AphrontRequest $request) { + return id(new PhabricatorRepositorySearchEngine()) + ->setController($this) + ->buildResponse(); } protected function buildApplicationCrumbs() { diff --git a/src/applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php b/src/applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php index 6a9039889e..691564c68e 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php @@ -3,9 +3,14 @@ final class DiffusionRepositoryTestAutomationController extends DiffusionRepositoryEditController { - protected function processDiffusionRequest(AphrontRequest $request) { + public function handleRequest(AphrontRequest $request) { + $response = $this->loadDiffusionContext(); + if ($response) { + return $response; + } + $viewer = $this->getViewer(); - $drequest = $this->diffusionRequest; + $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $repository = id(new PhabricatorRepositoryQuery())