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