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:
@@ -6,9 +6,14 @@ final class DiffusionChangeController extends DiffusionController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$drequest = $this->diffusionRequest;
|
$response = $this->loadDiffusionContext();
|
||||||
$viewer = $request->getUser();
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
|
||||||
$content = array();
|
$content = array();
|
||||||
|
|
||||||
@@ -89,15 +94,18 @@ final class DiffusionChangeController extends DiffusionController {
|
|||||||
->setHeader($header)
|
->setHeader($header)
|
||||||
->addPropertyList($properties);
|
->addPropertyList($properties);
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->newPage()
|
||||||
array(
|
->setTitle(
|
||||||
$crumbs,
|
array(
|
||||||
$object_box,
|
basename($drequest->getPath()),
|
||||||
$content,
|
$repository->getDisplayName(),
|
||||||
),
|
))
|
||||||
array(
|
->setCrumbs($crumbs)
|
||||||
'title' => pht('Change'),
|
->appendChild(
|
||||||
));
|
array(
|
||||||
|
$object_box,
|
||||||
|
$content,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionView(DiffusionRequest $drequest) {
|
private function buildActionView(DiffusionRequest $drequest) {
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ final class DiffusionCommitBranchesController extends DiffusionController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$response = $this->loadDiffusionContext();
|
||||||
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,24 @@
|
|||||||
|
|
||||||
final class DiffusionCommitEditController extends DiffusionController {
|
final class DiffusionCommitEditController extends DiffusionController {
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$user = $request->getUser();
|
$response = $this->loadDiffusionContext();
|
||||||
$drequest = $this->getDiffusionRequest();
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
$commit = $drequest->loadCommit();
|
$commit = $drequest->loadCommit();
|
||||||
$data = $commit->loadCommitData();
|
|
||||||
$page_title = pht('Edit Diffusion Commit');
|
|
||||||
|
|
||||||
if (!$commit) {
|
if (!$commit) {
|
||||||
return new Aphront404Response();
|
return new Aphront404Response();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = $commit->loadCommitData();
|
||||||
|
$page_title = pht('Edit Diffusion Commit');
|
||||||
|
|
||||||
$commit_phid = $commit->getPHID();
|
$commit_phid = $commit->getPHID();
|
||||||
$edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
$edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
|
||||||
$current_proj_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
$current_proj_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||||
@@ -27,18 +33,21 @@ final class DiffusionCommitEditController extends DiffusionController {
|
|||||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||||
->setMetadataValue('edge:type', $edge_type)
|
->setMetadataValue('edge:type', $edge_type)
|
||||||
->setNewValue(array('=' => array_fuse($proj_phids)));
|
->setNewValue(array('=' => array_fuse($proj_phids)));
|
||||||
|
|
||||||
$editor = id(new PhabricatorAuditEditor())
|
$editor = id(new PhabricatorAuditEditor())
|
||||||
->setActor($user)
|
->setActor($viewer)
|
||||||
->setContinueOnNoEffect(true)
|
->setContinueOnNoEffect(true)
|
||||||
->setContentSourceFromRequest($request);
|
->setContentSourceFromRequest($request);
|
||||||
$xactions = $editor->applyTransactions($commit, $xactions);
|
|
||||||
|
$editor->applyTransactions($commit, $xactions);
|
||||||
|
|
||||||
return id(new AphrontRedirectResponse())
|
return id(new AphrontRedirectResponse())
|
||||||
->setURI($commit->getURI());
|
->setURI($commit->getURI());
|
||||||
}
|
}
|
||||||
|
|
||||||
$tokenizer_id = celerity_generate_unique_node_id();
|
$tokenizer_id = celerity_generate_unique_node_id();
|
||||||
$form = id(new AphrontFormView())
|
$form = id(new AphrontFormView())
|
||||||
->setUser($user)
|
->setUser($viewer)
|
||||||
->setAction($request->getRequestURI()->getPath())
|
->setAction($request->getRequestURI()->getPath())
|
||||||
->appendControl(
|
->appendControl(
|
||||||
id(new AphrontFormTokenizerControl())
|
id(new AphrontFormTokenizerControl())
|
||||||
@@ -87,33 +96,25 @@ final class DiffusionCommitEditController extends DiffusionController {
|
|||||||
->setValue(array($desc, " \xC2\xB7 ", $doc_link)));
|
->setValue(array($desc, " \xC2\xB7 ", $doc_link)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$form->appendControl(
|
||||||
|
id(new AphrontFormSubmitControl())
|
||||||
|
->setValue(pht('Save'))
|
||||||
|
->addCancelButton($commit->getURI()));
|
||||||
|
|
||||||
Javelin::initBehavior('project-create', array(
|
$crumbs = $this->buildCrumbs(
|
||||||
'tokenizerID' => $tokenizer_id,
|
array(
|
||||||
));
|
'commit' => true,
|
||||||
|
));
|
||||||
$submit = id(new AphrontFormSubmitControl())
|
|
||||||
->setValue(pht('Save'))
|
|
||||||
->addCancelButton($commit->getURI());
|
|
||||||
$form->appendChild($submit);
|
|
||||||
|
|
||||||
$crumbs = $this->buildCrumbs(array(
|
|
||||||
'commit' => true,
|
|
||||||
));
|
|
||||||
$crumbs->addTextCrumb(pht('Edit'));
|
$crumbs->addTextCrumb(pht('Edit'));
|
||||||
|
|
||||||
$form_box = id(new PHUIObjectBoxView())
|
$form_box = id(new PHUIObjectBoxView())
|
||||||
->setHeaderText($page_title)
|
->setHeaderText($page_title)
|
||||||
->setForm($form);
|
->setForm($form);
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->newPage()
|
||||||
array(
|
->setTitle($page_title)
|
||||||
$crumbs,
|
->setCrumbs($crumbs)
|
||||||
$form_box,
|
->appendChild($form_box);
|
||||||
),
|
|
||||||
array(
|
|
||||||
'title' => $page_title,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ final class DiffusionCommitTagsController extends DiffusionController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$response = $this->loadDiffusionContext();
|
||||||
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
|
|||||||
@@ -6,19 +6,24 @@ final class DiffusionHistoryController extends DiffusionController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$drequest = $this->diffusionRequest;
|
$response = $this->loadDiffusionContext();
|
||||||
$viewer = $request->getUser();
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
$page_size = $request->getInt('pagesize', 100);
|
$pager = id(new PHUIPagerView())
|
||||||
$offset = $request->getInt('offset', 0);
|
->readFromRequest($request);
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'commit' => $drequest->getCommit(),
|
'commit' => $drequest->getCommit(),
|
||||||
'path' => $drequest->getPath(),
|
'path' => $drequest->getPath(),
|
||||||
'offset' => $offset,
|
'offset' => $pager->getOffset(),
|
||||||
'limit' => $page_size + 1,
|
'limit' => $pager->getPageSize() + 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$request->getBool('copies')) {
|
if (!$request->getBool('copies')) {
|
||||||
@@ -32,13 +37,8 @@ final class DiffusionHistoryController extends DiffusionController {
|
|||||||
$history = DiffusionPathChange::newFromConduit(
|
$history = DiffusionPathChange::newFromConduit(
|
||||||
$history_results['pathChanges']);
|
$history_results['pathChanges']);
|
||||||
|
|
||||||
$pager = new PHUIPagerView();
|
|
||||||
$pager->setPageSize($page_size);
|
|
||||||
$pager->setOffset($offset);
|
|
||||||
$history = $pager->sliceResults($history);
|
$history = $pager->sliceResults($history);
|
||||||
|
|
||||||
$pager->setURI($request->getRequestURI(), 'offset');
|
|
||||||
|
|
||||||
$show_graph = !strlen($drequest->getPath());
|
$show_graph = !strlen($drequest->getPath());
|
||||||
$content = array();
|
$content = array();
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ final class DiffusionHistoryController extends DiffusionController {
|
|||||||
|
|
||||||
if ($show_graph) {
|
if ($show_graph) {
|
||||||
$history_table->setParents($history_results['parents']);
|
$history_table->setParents($history_results['parents']);
|
||||||
$history_table->setIsHead($offset == 0);
|
$history_table->setIsHead(!$pager->getOffset());
|
||||||
}
|
}
|
||||||
|
|
||||||
$history_panel = new PHUIObjectBoxView();
|
$history_panel = new PHUIObjectBoxView();
|
||||||
@@ -79,23 +79,21 @@ final class DiffusionHistoryController extends DiffusionController {
|
|||||||
'view' => 'history',
|
'view' => 'history',
|
||||||
));
|
));
|
||||||
|
|
||||||
$pager = id(new PHUIBoxView())
|
$pager_box = $this->renderTablePagerBox($pager);
|
||||||
->addClass('ml')
|
|
||||||
->appendChild($pager);
|
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->newPage()
|
||||||
array(
|
->setTitle(
|
||||||
$crumbs,
|
array(
|
||||||
$object_box,
|
|
||||||
$content,
|
|
||||||
$pager,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'title' => array(
|
|
||||||
pht('History'),
|
pht('History'),
|
||||||
$drequest->getRepository()->getDisplayName(),
|
$repository->getDisplayName(),
|
||||||
),
|
))
|
||||||
));
|
->setCrumbs($crumbs)
|
||||||
|
->appendChild(
|
||||||
|
array(
|
||||||
|
$object_box,
|
||||||
|
$content,
|
||||||
|
$pager_box,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildActionView(DiffusionRequest $drequest) {
|
private function buildActionView(DiffusionRequest $drequest) {
|
||||||
|
|||||||
@@ -3,9 +3,14 @@
|
|||||||
final class DiffusionMirrorDeleteController
|
final class DiffusionMirrorDeleteController
|
||||||
extends DiffusionController {
|
extends DiffusionController {
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getUser();
|
$response = $this->loadDiffusionContext();
|
||||||
$drequest = $this->diffusionRequest;
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
$mirror = id(new PhabricatorRepositoryMirrorQuery())
|
$mirror = id(new PhabricatorRepositoryMirrorQuery())
|
||||||
|
|||||||
@@ -3,9 +3,14 @@
|
|||||||
final class DiffusionMirrorEditController
|
final class DiffusionMirrorEditController
|
||||||
extends DiffusionController {
|
extends DiffusionController {
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getUser();
|
$response = $this->loadDiffusionContext();
|
||||||
$drequest = $this->diffusionRequest;
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
PhabricatorPolicyFilter::requireCapability(
|
PhabricatorPolicyFilter::requireCapability(
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ final class DiffusionPushEventViewController
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $request->getUser();
|
$viewer = $this->getViewer();
|
||||||
|
|
||||||
$event = id(new PhabricatorRepositoryPushEventQuery())
|
$event = id(new PhabricatorRepositoryPushEventQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
@@ -57,16 +57,15 @@ final class DiffusionPushEventViewController
|
|||||||
->setHeaderText(pht('All Pushed Updates'))
|
->setHeaderText(pht('All Pushed Updates'))
|
||||||
->setTable($updates_table);
|
->setTable($updates_table);
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->newPage()
|
||||||
array(
|
->setTitle($title)
|
||||||
$crumbs,
|
->setCrumbs($crumbs)
|
||||||
$detail_box,
|
->appendChild(
|
||||||
$commits_box,
|
array(
|
||||||
$update_box,
|
$detail_box,
|
||||||
),
|
$commits_box,
|
||||||
array(
|
$update_box,
|
||||||
'title' => $title,
|
));
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function buildPropertyList(PhabricatorRepositoryPushEvent $event) {
|
private function buildPropertyList(PhabricatorRepositoryPushEvent $event) {
|
||||||
|
|||||||
@@ -6,29 +6,10 @@ final class DiffusionPushLogListController extends DiffusionPushLogController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
return id(new PhabricatorRepositoryPushLogSearchEngine())
|
||||||
$controller = id(new PhabricatorApplicationSearchController())
|
->setController($this)
|
||||||
->setQueryKey($request->getURIData('queryKey'))
|
->buildResponse();
|
||||||
->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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,13 @@ final class DiffusionRefTableController extends DiffusionController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $this->getViewer();
|
$response = $this->loadDiffusionContext();
|
||||||
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewer = $this->getViewer();
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
@@ -132,18 +136,15 @@ final class DiffusionRefTableController extends DiffusionController {
|
|||||||
$crumbs = $this->buildCrumbs(array());
|
$crumbs = $this->buildCrumbs(array());
|
||||||
$crumbs->addTextCrumb(pht('Refs'));
|
$crumbs->addTextCrumb(pht('Refs'));
|
||||||
|
|
||||||
return $this->buildApplicationPage(
|
return $this->newPage()
|
||||||
array(
|
->setTitle(
|
||||||
$crumbs,
|
array(
|
||||||
$content,
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
'title' => array(
|
|
||||||
pht('Refs'),
|
|
||||||
$repository->getMonogram(),
|
|
||||||
$ref_name,
|
$ref_name,
|
||||||
),
|
pht('Ref'),
|
||||||
));
|
$repository->getDisplayName(),
|
||||||
|
))
|
||||||
|
->setCrumbs($crumbs)
|
||||||
|
->appendChild($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,28 +6,10 @@ final class DiffusionRepositoryListController extends DiffusionController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$controller = id(new PhabricatorApplicationSearchController())
|
return id(new PhabricatorRepositorySearchEngine())
|
||||||
->setQueryKey($request->getURIData('queryKey'))
|
->setController($this)
|
||||||
->setSearchEngine(new PhabricatorRepositorySearchEngine())
|
->buildResponse();
|
||||||
->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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function buildApplicationCrumbs() {
|
protected function buildApplicationCrumbs() {
|
||||||
|
|||||||
@@ -3,9 +3,14 @@
|
|||||||
final class DiffusionRepositoryTestAutomationController
|
final class DiffusionRepositoryTestAutomationController
|
||||||
extends DiffusionRepositoryEditController {
|
extends DiffusionRepositoryEditController {
|
||||||
|
|
||||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
|
$response = $this->loadDiffusionContext();
|
||||||
|
if ($response) {
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$drequest = $this->diffusionRequest;
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
$repository = id(new PhabricatorRepositoryQuery())
|
$repository = id(new PhabricatorRepositoryQuery())
|
||||||
|
|||||||
Reference in New Issue
Block a user