mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Show first 10 branches, then "More Branches" for commits on huge numbers of branches
Summary: Fixes T9562. We already do this for tags, but didn't have similar logic for branches. Implement that logic. Test Plan: - Set limit to 1, saw "More branches", clicked it, got the correct results. - Verified that branch table with no specified commit still works properly. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9562 Differential Revision: https://secure.phabricator.com/D15284
This commit is contained in:
parent
71be2b06a8
commit
c6d91938e8
3 changed files with 42 additions and 32 deletions
|
@ -19,13 +19,19 @@ final class DiffusionBranchTableController extends DiffusionController {
|
||||||
$pager = id(new PHUIPagerView())
|
$pager = id(new PHUIPagerView())
|
||||||
->readFromRequest($request);
|
->readFromRequest($request);
|
||||||
|
|
||||||
// TODO: Add support for branches that contain commit
|
$params = array(
|
||||||
|
'offset' => $pager->getOffset(),
|
||||||
|
'limit' => $pager->getPageSize() + 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
$contains = $drequest->getSymbolicCommit();
|
||||||
|
if (strlen($contains)) {
|
||||||
|
$params['contains'] = $contains;
|
||||||
|
}
|
||||||
|
|
||||||
$branches = $this->callConduitWithDiffusionRequest(
|
$branches = $this->callConduitWithDiffusionRequest(
|
||||||
'diffusion.branchquery',
|
'diffusion.branchquery',
|
||||||
array(
|
$params);
|
||||||
'offset' => $pager->getOffset(),
|
|
||||||
'limit' => $pager->getPageSize() + 1,
|
|
||||||
));
|
|
||||||
$branches = $pager->sliceResults($branches);
|
$branches = $pager->sliceResults($branches);
|
||||||
|
|
||||||
$branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
|
$branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
|
||||||
|
|
|
@ -15,20 +15,18 @@ final class DiffusionCommitBranchesController extends DiffusionController {
|
||||||
$drequest = $this->getDiffusionRequest();
|
$drequest = $this->getDiffusionRequest();
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
switch ($repository->getVersionControlSystem()) {
|
$branch_limit = 10;
|
||||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
$branches = DiffusionRepositoryRef::loadAllFromDictionaries(
|
||||||
$branches = array();
|
$this->callConduitWithDiffusionRequest(
|
||||||
break;
|
'diffusion.branchquery',
|
||||||
default:
|
array(
|
||||||
$branches = $this->callConduitWithDiffusionRequest(
|
'contains' => $drequest->getCommit(),
|
||||||
'diffusion.branchquery',
|
'limit' => $branch_limit + 1,
|
||||||
array(
|
)));
|
||||||
'contains' => $drequest->getCommit(),
|
|
||||||
));
|
$has_more_branches = (count($branches) > $branch_limit);
|
||||||
break;
|
$branches = array_slice($branches, 0, $branch_limit);
|
||||||
}
|
|
||||||
|
|
||||||
$branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
|
|
||||||
$branch_links = array();
|
$branch_links = array();
|
||||||
foreach ($branches as $branch) {
|
foreach ($branches as $branch) {
|
||||||
$branch_links[] = phutil_tag(
|
$branch_links[] = phutil_tag(
|
||||||
|
@ -43,6 +41,18 @@ final class DiffusionCommitBranchesController extends DiffusionController {
|
||||||
$branch->getShortName());
|
$branch->getShortName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($has_more_branches) {
|
||||||
|
$branch_links[] = phutil_tag(
|
||||||
|
'a',
|
||||||
|
array(
|
||||||
|
'href' => $drequest->generateURI(
|
||||||
|
array(
|
||||||
|
'action' => 'branches',
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
pht("More Branches\xE2\x80\xA6"));
|
||||||
|
}
|
||||||
|
|
||||||
return id(new AphrontAjaxResponse())
|
return id(new AphrontAjaxResponse())
|
||||||
->setContent($branch_links ? implode(', ', $branch_links) : pht('None'));
|
->setContent($branch_links ? implode(', ', $branch_links) : pht('None'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,20 +16,14 @@ final class DiffusionCommitTagsController extends DiffusionController {
|
||||||
$repository = $drequest->getRepository();
|
$repository = $drequest->getRepository();
|
||||||
|
|
||||||
$tag_limit = 10;
|
$tag_limit = 10;
|
||||||
switch ($repository->getVersionControlSystem()) {
|
$tags = DiffusionRepositoryTag::newFromConduit(
|
||||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
$this->callConduitWithDiffusionRequest(
|
||||||
$tags = array();
|
'diffusion.tagsquery',
|
||||||
break;
|
array(
|
||||||
default:
|
'commit' => $drequest->getCommit(),
|
||||||
$tags = DiffusionRepositoryTag::newFromConduit(
|
'limit' => $tag_limit + 1,
|
||||||
$this->callConduitWithDiffusionRequest(
|
)));
|
||||||
'diffusion.tagsquery',
|
|
||||||
array(
|
|
||||||
'commit' => $drequest->getCommit(),
|
|
||||||
'limit' => $tag_limit + 1,
|
|
||||||
)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$has_more_tags = (count($tags) > $tag_limit);
|
$has_more_tags = (count($tags) > $tag_limit);
|
||||||
$tags = array_slice($tags, 0, $tag_limit);
|
$tags = array_slice($tags, 0, $tag_limit);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue