1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Make branch status more clear on Diffusion branches view

Summary:
See PHI1225. Ref T13277. In Diffusion, show "default", "permanent", or "not permanent" when looking at branches.

For repositories with 100 or fewer branches, put default and permanent branches on top.

Test Plan: {F6426814}

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: leoluk

Maniphest Tasks: T13277

Differential Revision: https://secure.phabricator.com/D20493
This commit is contained in:
epriestley 2019-05-03 10:10:25 -07:00
parent e059997e53
commit c5ecc388a2
2 changed files with 51 additions and 2 deletions

View file

@ -37,6 +37,12 @@ final class DiffusionBranchTableController extends DiffusionController {
$branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches);
// If there is one page of results or fewer, sort branches so the default
// branch is on top and permanent branches are below it.
if (!$pager->getOffset() && !$pager->getHasMorePages()) {
$branches = $this->sortBranches($repository, $branches);
}
$content = null;
if (!$branches) {
$content = $this->renderStatusMessage(
@ -97,4 +103,38 @@ final class DiffusionBranchTableController extends DiffusionController {
->appendChild($view);
}
private function sortBranches(
PhabricatorRepository $repository,
array $branches) {
$publisher = $repository->newPublisher();
$default_branch = $repository->getDefaultBranch();
$vectors = array();
foreach ($branches as $key => $branch) {
$short_name = $branch->getShortName();
if ($short_name === $default_branch) {
$order_default = 0;
} else {
$order_default = 1;
}
if ($publisher->shouldPublishRef($branch)) {
$order_permanent = 0;
} else {
$order_permanent = 1;
}
$vectors[$key] = id(new PhutilSortVector())
->addInt($order_default)
->addInt($order_permanent)
->addString($short_name);
}
$vectors = msortv($vectors, 'getSelf');
return array_select_keys($branches, array_keys($vectors));
}
}

View file

@ -33,10 +33,11 @@ final class DiffusionBranchListView extends DiffusionView {
Javelin::initBehavior('phabricator-tooltips');
$list = id(new PHUIObjectItemListView())
->setFlush(true)
->addClass('diffusion-history-list')
->addClass('diffusion-branch-list');
$publisher = $repository->newPublisher();
foreach ($this->branches as $branch) {
$build_view = null;
$button_bar = new PHUIButtonBarView();
@ -116,8 +117,16 @@ final class DiffusionBranchListView extends DiffusionView {
));
if ($branch->getShortName() == $repository->getDefaultBranch()) {
$item->setStatusIcon('fa-code-fork', pht('Default Branch'));
$item->setStatusIcon('fa-star', pht('Default Branch'));
} else {
if ($publisher->shouldPublishRef($branch)) {
$item->setStatusIcon('fa-code-fork', pht('Permanent Ref'));
} else {
$item->setStatusIcon(
'fa-folder-open-o grey', pht('Not a Permanent Ref'));
}
}
$item->addAttribute(array($datetime));
if ($can_close_branches) {