1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 20:10:55 +01:00

Modernize tag and branch controllers in Diffusion

Summary: Ref T4245. Prepares these controllers to accept alternate identifers, plus minor spacing and layout fixes.

Test Plan: Viewed tags, viewed branches.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4245

Differential Revision: https://secure.phabricator.com/D14941
This commit is contained in:
epriestley 2016-01-05 05:00:22 -08:00
parent fb3b4ee532
commit 7de17fb75e
5 changed files with 63 additions and 48 deletions

View file

@ -64,7 +64,7 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
'(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController', '(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController',
'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController', 'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController',
), ),
'(?P<callsign>[A-Z]+)/' => array( '(?P<repositoryCallsign>(?P<callsign>[A-Z]+))/' => array(
'' => 'DiffusionRepositoryController', '' => 'DiffusionRepositoryController',
'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController', 'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController',

View file

@ -6,15 +6,18 @@ final class DiffusionBranchTableController extends DiffusionController {
return true; return true;
} }
protected function processDiffusionRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$drequest = $this->getDiffusionRequest(); $response = $this->loadDiffusionContext();
$viewer = $request->getUser(); if ($response) {
return $response;
}
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository(); $repository = $drequest->getRepository();
$pager = new PHUIPagerView(); $pager = id(new PHUIPagerView())
$pager->setURI($request->getRequestURI(), 'offset'); ->readFromRequest($request);
$pager->setOffset($request->getInt('offset'));
// TODO: Add support for branches that contain commit // TODO: Add support for branches that contain commit
$branches = $this->callConduitWithDiffusionRequest( $branches = $this->callConduitWithDiffusionRequest(
@ -57,17 +60,19 @@ final class DiffusionBranchTableController extends DiffusionController {
'branches' => true, 'branches' => true,
)); ));
return $this->buildApplicationPage( $pager_box = $this->renderTablePagerBox($pager);
return $this->newPage()
->setTitle(
array( array(
$crumbs,
$content,
$pager,
),
array(
'title' => array(
pht('Branches'), pht('Branches'),
$repository->getDisplayName(), $repository->getDisplayName(),
), ))
->setCrumbs($crumbs)
->appendChild(
array(
$content,
$pager_box,
)); ));
} }

View file

@ -61,23 +61,16 @@ abstract class DiffusionController extends PhabricatorController {
$identifier = (int)$request->getURIData('repositoryID'); $identifier = (int)$request->getURIData('repositoryID');
} }
$blob = $request->getURIData('dblob'); $params = array(
if (strlen($blob)) { 'repository' => $identifier,
$parsed = DiffusionRequest::parseRequestBlob($blob); 'user' => $viewer,
} else { 'blob' => $request->getURIData('dblob'),
$parsed = array(
'commit' => $request->getURIData('commit'), 'commit' => $request->getURIData('commit'),
'path' => $request->getURIData('path'), 'path' => $request->getURIData('path'),
'line' => $request->getURIData('line'), 'line' => $request->getURIData('line'),
'branch' => $request->getURIData('branch'), 'branch' => $request->getURIData('branch'),
'lint' => $request->getStr('lint'), 'lint' => $request->getStr('lint'),
); );
}
$params = array(
'repository' => $identifier,
'user' => $viewer,
) + $parsed;
$drequest = DiffusionRequest::newFromDictionary($params); $drequest = DiffusionRequest::newFromDictionary($params);
@ -286,4 +279,10 @@ abstract class DiffusionController extends PhabricatorController {
->appendChild($body); ->appendChild($body);
} }
protected function renderTablePagerBox(PHUIPagerView $pager) {
return id(new PHUIBoxView())
->addMargin(PHUI::MARGIN_LARGE)
->appendChild($pager);
}
} }

View file

@ -6,22 +6,25 @@ final class DiffusionTagListController extends DiffusionController {
return true; return true;
} }
protected function processDiffusionRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$drequest = $this->getDiffusionRequest(); $response = $this->loadDiffusionContext();
$viewer = $request->getUser(); if ($response) {
return $response;
}
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository(); $repository = $drequest->getRepository();
$pager = new PHUIPagerView(); $pager = id(new PHUIPagerView())
$pager->setURI($request->getRequestURI(), 'offset'); ->readFromRequest($request);
$pager->setOffset($request->getInt('offset'));
$params = array( $params = array(
'limit' => $pager->getPageSize() + 1, 'limit' => $pager->getPageSize() + 1,
'offset' => $pager->getOffset(), 'offset' => $pager->getOffset(),
); );
if ($drequest->getSymbolicCommit()) { if (strlen($drequest->getSymbolicCommit())) {
$is_commit = true; $is_commit = true;
$params['commit'] = $drequest->getSymbolicCommit(); $params['commit'] = $drequest->getSymbolicCommit();
} else { } else {
@ -79,17 +82,19 @@ final class DiffusionTagListController extends DiffusionController {
'commit' => $drequest->getSymbolicCommit(), 'commit' => $drequest->getSymbolicCommit(),
)); ));
return $this->buildApplicationPage( $pager_box = $this->renderTablePagerBox($pager);
return $this->newPage()
->setTitle(
array( array(
$crumbs,
$content,
$pager,
),
array(
'title' => array(
pht('Tags'), pht('Tags'),
$repository->getDisplayName(), $repository->getDisplayName(),
), ))
->setCrumbs($crumbs)
->appendChild(
array(
$content,
$pager_box,
)); ));
} }

View file

@ -225,6 +225,12 @@ abstract class DiffusionRequest extends Phobject {
* @task new * @task new
*/ */
final private function initializeFromDictionary(array $data) { final private function initializeFromDictionary(array $data) {
$blob = idx($data, 'blob');
if (strlen($blob)) {
$blob = self::parseRequestBlob($blob, $this->supportsBranches());
$data = $blob + $data;
}
$this->path = idx($data, 'path'); $this->path = idx($data, 'path');
$this->line = idx($data, 'line'); $this->line = idx($data, 'line');
$this->initFromConduit = idx($data, 'initFromConduit', true); $this->initFromConduit = idx($data, 'initFromConduit', true);