1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 05:12:41 +01:00

Modernize more Diffusion controllers

Summary: Ref T4245. Standardize how context is read, minor updates / modernizations / consistency tweaks.

Test Plan:
  - Viewed a change.
  - Viewed brnaches.
  - Edited a commit.
  - Viewed tags.
  - Viewed history.
  - Added, edited and deleted a mirror.
  - Viewed push events.
  - Viewed a particular event.
  - Viewed ref disambiguation.
  - Viewed repository list.
  - Ran automation test.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14944
This commit is contained in:
epriestley 2016-01-05 08:13:05 -08:00
parent f1c298203a
commit 2bfc5ff92e
12 changed files with 144 additions and 149 deletions

View file

@ -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) {

View file

@ -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();

View file

@ -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);
}
}

View file

@ -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();

View file

@ -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) {

View file

@ -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())

View file

@ -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(

View file

@ -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) {

View file

@ -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();
}
}

View file

@ -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);
}
}

View file

@ -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() {

View file

@ -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())