mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22: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:
parent
fb3b4ee532
commit
7de17fb75e
5 changed files with 63 additions and 48 deletions
|
@ -64,7 +64,7 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
|
|||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController',
|
||||
'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController',
|
||||
),
|
||||
'(?P<callsign>[A-Z]+)/' => array(
|
||||
'(?P<repositoryCallsign>(?P<callsign>[A-Z]+))/' => array(
|
||||
'' => 'DiffusionRepositoryController',
|
||||
|
||||
'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController',
|
||||
|
|
|
@ -6,15 +6,18 @@ final class DiffusionBranchTableController extends DiffusionController {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$viewer = $request->getUser();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$response = $this->loadDiffusionContext();
|
||||
if ($response) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$viewer = $this->getViewer();
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$pager = new PHUIPagerView();
|
||||
$pager->setURI($request->getRequestURI(), 'offset');
|
||||
$pager->setOffset($request->getInt('offset'));
|
||||
$pager = id(new PHUIPagerView())
|
||||
->readFromRequest($request);
|
||||
|
||||
// TODO: Add support for branches that contain commit
|
||||
$branches = $this->callConduitWithDiffusionRequest(
|
||||
|
@ -57,17 +60,19 @@ final class DiffusionBranchTableController extends DiffusionController {
|
|||
'branches' => true,
|
||||
));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$pager_box = $this->renderTablePagerBox($pager);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle(
|
||||
array(
|
||||
$crumbs,
|
||||
$content,
|
||||
$pager,
|
||||
),
|
||||
array(
|
||||
'title' => array(
|
||||
pht('Branches'),
|
||||
$repository->getDisplayName(),
|
||||
),
|
||||
))
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
$content,
|
||||
$pager_box,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -61,23 +61,16 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
$identifier = (int)$request->getURIData('repositoryID');
|
||||
}
|
||||
|
||||
$blob = $request->getURIData('dblob');
|
||||
if (strlen($blob)) {
|
||||
$parsed = DiffusionRequest::parseRequestBlob($blob);
|
||||
} else {
|
||||
$parsed = array(
|
||||
$params = array(
|
||||
'repository' => $identifier,
|
||||
'user' => $viewer,
|
||||
'blob' => $request->getURIData('dblob'),
|
||||
'commit' => $request->getURIData('commit'),
|
||||
'path' => $request->getURIData('path'),
|
||||
'line' => $request->getURIData('line'),
|
||||
'branch' => $request->getURIData('branch'),
|
||||
'lint' => $request->getStr('lint'),
|
||||
);
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'repository' => $identifier,
|
||||
'user' => $viewer,
|
||||
) + $parsed;
|
||||
|
||||
$drequest = DiffusionRequest::newFromDictionary($params);
|
||||
|
||||
|
@ -286,4 +279,10 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
->appendChild($body);
|
||||
}
|
||||
|
||||
protected function renderTablePagerBox(PHUIPagerView $pager) {
|
||||
return id(new PHUIBoxView())
|
||||
->addMargin(PHUI::MARGIN_LARGE)
|
||||
->appendChild($pager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,22 +6,25 @@ final class DiffusionTagListController extends DiffusionController {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected function processDiffusionRequest(AphrontRequest $request) {
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$viewer = $request->getUser();
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$response = $this->loadDiffusionContext();
|
||||
if ($response) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$viewer = $this->getViewer();
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$repository = $drequest->getRepository();
|
||||
|
||||
$pager = new PHUIPagerView();
|
||||
$pager->setURI($request->getRequestURI(), 'offset');
|
||||
$pager->setOffset($request->getInt('offset'));
|
||||
$pager = id(new PHUIPagerView())
|
||||
->readFromRequest($request);
|
||||
|
||||
$params = array(
|
||||
'limit' => $pager->getPageSize() + 1,
|
||||
'offset' => $pager->getOffset(),
|
||||
);
|
||||
|
||||
if ($drequest->getSymbolicCommit()) {
|
||||
if (strlen($drequest->getSymbolicCommit())) {
|
||||
$is_commit = true;
|
||||
$params['commit'] = $drequest->getSymbolicCommit();
|
||||
} else {
|
||||
|
@ -79,17 +82,19 @@ final class DiffusionTagListController extends DiffusionController {
|
|||
'commit' => $drequest->getSymbolicCommit(),
|
||||
));
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
$pager_box = $this->renderTablePagerBox($pager);
|
||||
|
||||
return $this->newPage()
|
||||
->setTitle(
|
||||
array(
|
||||
$crumbs,
|
||||
$content,
|
||||
$pager,
|
||||
),
|
||||
array(
|
||||
'title' => array(
|
||||
pht('Tags'),
|
||||
$repository->getDisplayName(),
|
||||
),
|
||||
))
|
||||
->setCrumbs($crumbs)
|
||||
->appendChild(
|
||||
array(
|
||||
$content,
|
||||
$pager_box,
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -225,6 +225,12 @@ abstract class DiffusionRequest extends Phobject {
|
|||
* @task new
|
||||
*/
|
||||
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->line = idx($data, 'line');
|
||||
$this->initFromConduit = idx($data, 'initFromConduit', true);
|
||||
|
|
Loading…
Reference in a new issue