mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 21:40:55 +01:00
Add DiffusionBranchListView for browsing branches
Summary: Adds a new DiffusionBranchListView which replaces the BranchTable when browsing all branches in Diffusion. Has all the same capabilities, but is easier to read, adds a Compare button, and plays nicely on mobile. It does take up more space, but I think that's generally OK here since we expect our branches to not be heaping piles of intern revert branches. Test Plan: Follow a few repositories with branches, like Phabricator and KDE's Krita. View layouts on mobile, tablet, desktop. Try out new compare button. {F4996207} Reviewers: epriestley Reviewed By: epriestley Subscribers: avivey, Korvin Maniphest Tasks: T12824 Differential Revision: https://secure.phabricator.com/D18113
This commit is contained in:
parent
283a95d2aa
commit
df6ad07566
6 changed files with 175 additions and 10 deletions
|
@ -71,7 +71,7 @@ return array(
|
||||||
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
|
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
|
||||||
'rsrc/css/application/differential/revision-list.css' => 'f3c47d33',
|
'rsrc/css/application/differential/revision-list.css' => 'f3c47d33',
|
||||||
'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55',
|
'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55',
|
||||||
'rsrc/css/application/diffusion/diffusion-history.css' => '6870e8c1',
|
'rsrc/css/application/diffusion/diffusion-history.css' => '4540f568',
|
||||||
'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba',
|
'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba',
|
||||||
'rsrc/css/application/diffusion/diffusion-readme.css' => '419dd5b6',
|
'rsrc/css/application/diffusion/diffusion-readme.css' => '419dd5b6',
|
||||||
'rsrc/css/application/diffusion/diffusion-source.css' => '750add59',
|
'rsrc/css/application/diffusion/diffusion-source.css' => '750add59',
|
||||||
|
@ -569,7 +569,7 @@ return array(
|
||||||
'differential-revision-history-css' => '0e8eb855',
|
'differential-revision-history-css' => '0e8eb855',
|
||||||
'differential-revision-list-css' => 'f3c47d33',
|
'differential-revision-list-css' => 'f3c47d33',
|
||||||
'differential-table-of-contents-css' => 'ae4b7a55',
|
'differential-table-of-contents-css' => 'ae4b7a55',
|
||||||
'diffusion-history-css' => '6870e8c1',
|
'diffusion-history-css' => '4540f568',
|
||||||
'diffusion-icons-css' => 'a6a1e2ba',
|
'diffusion-icons-css' => 'a6a1e2ba',
|
||||||
'diffusion-readme-css' => '419dd5b6',
|
'diffusion-readme-css' => '419dd5b6',
|
||||||
'diffusion-source-css' => '750add59',
|
'diffusion-source-css' => '750add59',
|
||||||
|
|
|
@ -613,6 +613,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionBlameConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionBlameConduitAPIMethod.php',
|
'DiffusionBlameConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionBlameConduitAPIMethod.php',
|
||||||
'DiffusionBlameQuery' => 'applications/diffusion/query/blame/DiffusionBlameQuery.php',
|
'DiffusionBlameQuery' => 'applications/diffusion/query/blame/DiffusionBlameQuery.php',
|
||||||
'DiffusionBlockHeraldAction' => 'applications/diffusion/herald/DiffusionBlockHeraldAction.php',
|
'DiffusionBlockHeraldAction' => 'applications/diffusion/herald/DiffusionBlockHeraldAction.php',
|
||||||
|
'DiffusionBranchListView' => 'applications/diffusion/view/DiffusionBranchListView.php',
|
||||||
'DiffusionBranchQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php',
|
'DiffusionBranchQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php',
|
||||||
'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php',
|
'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php',
|
||||||
'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php',
|
'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php',
|
||||||
|
@ -5584,6 +5585,7 @@ phutil_register_library_map(array(
|
||||||
'DiffusionBlameConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
'DiffusionBlameConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
||||||
'DiffusionBlameQuery' => 'DiffusionQuery',
|
'DiffusionBlameQuery' => 'DiffusionQuery',
|
||||||
'DiffusionBlockHeraldAction' => 'HeraldAction',
|
'DiffusionBlockHeraldAction' => 'HeraldAction',
|
||||||
|
'DiffusionBranchListView' => 'DiffusionView',
|
||||||
'DiffusionBranchQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
'DiffusionBranchQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
|
||||||
'DiffusionBranchTableController' => 'DiffusionController',
|
'DiffusionBranchTableController' => 'DiffusionController',
|
||||||
'DiffusionBranchTableView' => 'DiffusionView',
|
'DiffusionBranchTableView' => 'DiffusionView',
|
||||||
|
|
|
@ -48,7 +48,7 @@ final class DiffusionBranchTableController extends DiffusionController {
|
||||||
->withRepository($repository)
|
->withRepository($repository)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$table = id(new DiffusionBranchTableView())
|
$list = id(new DiffusionBranchListView())
|
||||||
->setUser($viewer)
|
->setUser($viewer)
|
||||||
->setBranches($branches)
|
->setBranches($branches)
|
||||||
->setCommits($commits)
|
->setCommits($commits)
|
||||||
|
@ -57,7 +57,7 @@ final class DiffusionBranchTableController extends DiffusionController {
|
||||||
$content = id(new PHUIObjectBoxView())
|
$content = id(new PHUIObjectBoxView())
|
||||||
->setHeaderText($repository->getName())
|
->setHeaderText($repository->getName())
|
||||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
|
||||||
->setTable($table)
|
->setTable($list)
|
||||||
->setPager($pager);
|
->setPager($pager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,10 +84,7 @@ final class DiffusionBranchTableController extends DiffusionController {
|
||||||
$repository->getDisplayName(),
|
$repository->getDisplayName(),
|
||||||
))
|
))
|
||||||
->setCrumbs($crumbs)
|
->setCrumbs($crumbs)
|
||||||
->appendChild(
|
->appendChild($view);
|
||||||
array(
|
|
||||||
$view,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
149
src/applications/diffusion/view/DiffusionBranchListView.php
Normal file
149
src/applications/diffusion/view/DiffusionBranchListView.php
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class DiffusionBranchListView extends DiffusionView {
|
||||||
|
|
||||||
|
private $branches;
|
||||||
|
private $commits = array();
|
||||||
|
|
||||||
|
public function setBranches(array $branches) {
|
||||||
|
assert_instances_of($branches, 'DiffusionRepositoryRef');
|
||||||
|
$this->branches = $branches;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCommits(array $commits) {
|
||||||
|
assert_instances_of($commits, 'PhabricatorRepositoryCommit');
|
||||||
|
$this->commits = mpull($commits, null, 'getCommitIdentifier');
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
$drequest = $this->getDiffusionRequest();
|
||||||
|
$current_branch = $drequest->getBranch();
|
||||||
|
$repository = $drequest->getRepository();
|
||||||
|
$commits = $this->commits;
|
||||||
|
$viewer = $this->getUser();
|
||||||
|
require_celerity_resource('diffusion-history-css');
|
||||||
|
|
||||||
|
$buildables = $this->loadBuildables($commits);
|
||||||
|
$have_builds = false;
|
||||||
|
|
||||||
|
$can_close_branches = ($repository->isHg());
|
||||||
|
|
||||||
|
Javelin::initBehavior('phabricator-tooltips');
|
||||||
|
|
||||||
|
$doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
|
||||||
|
$list = id(new PHUIObjectItemListView())
|
||||||
|
->setFlush(true)
|
||||||
|
->addClass('diffusion-history-list')
|
||||||
|
->addClass('diffusion-branch-list');
|
||||||
|
|
||||||
|
foreach ($this->branches as $branch) {
|
||||||
|
$build_view = null;
|
||||||
|
$button_bar = new PHUIButtonBarView();
|
||||||
|
$commit = idx($commits, $branch->getCommitIdentifier());
|
||||||
|
if ($commit) {
|
||||||
|
$details = $commit->getSummary();
|
||||||
|
$datetime = phabricator_datetime($commit->getEpoch(), $viewer);
|
||||||
|
|
||||||
|
$buildable = idx($buildables, $commit->getPHID());
|
||||||
|
if ($buildable) {
|
||||||
|
$status = $buildable->getBuildableStatus();
|
||||||
|
$icon = HarbormasterBuildable::getBuildableStatusIcon($status);
|
||||||
|
$color = HarbormasterBuildable::getBuildableStatusColor($status);
|
||||||
|
$name = HarbormasterBuildable::getBuildableStatusName($status);
|
||||||
|
$build_view = id(new PHUIButtonView())
|
||||||
|
->setTag('a')
|
||||||
|
->setText($name)
|
||||||
|
->setIcon($icon)
|
||||||
|
->setColor($color)
|
||||||
|
->setHref('/'.$buildable->getMonogram())
|
||||||
|
->addClass('mmr')
|
||||||
|
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$datetime = null;
|
||||||
|
$details = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($repository->supportsBranchComparison()) {
|
||||||
|
$compare_uri = $drequest->generateURI(
|
||||||
|
array(
|
||||||
|
'action' => 'compare',
|
||||||
|
'head' => $branch->getShortName(),
|
||||||
|
));
|
||||||
|
$can_compare = ($branch->getShortName() != $current_branch);
|
||||||
|
if ($can_compare) {
|
||||||
|
$button_bar->addButton(
|
||||||
|
id(new PHUIButtonView())
|
||||||
|
->setTag('a')
|
||||||
|
->setIcon('fa-balance-scale')
|
||||||
|
->setToolTip(pht('Compare'))
|
||||||
|
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
|
||||||
|
->setWorkflow(true)
|
||||||
|
->setHref($compare_uri));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$fields = $branch->getRawFields();
|
||||||
|
$closed = idx($fields, 'closed');
|
||||||
|
if ($closed) {
|
||||||
|
$status = pht('Closed');
|
||||||
|
} else {
|
||||||
|
$status = pht('Open');
|
||||||
|
}
|
||||||
|
|
||||||
|
$browse_href = $drequest->generateURI(
|
||||||
|
array(
|
||||||
|
'action' => 'browse',
|
||||||
|
'branch' => $branch->getShortName(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$button_bar->addButton(
|
||||||
|
id(new PHUIButtonView())
|
||||||
|
->setIcon('fa-code')
|
||||||
|
->setHref($browse_href)
|
||||||
|
->setTag('a')
|
||||||
|
->setTooltip(pht('Browse'))
|
||||||
|
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE));
|
||||||
|
|
||||||
|
$commit_link = $repository->getCommitURI(
|
||||||
|
$branch->getCommitIdentifier());
|
||||||
|
|
||||||
|
$commit_name = $repository->formatCommitName(
|
||||||
|
$branch->getCommitIdentifier(), $local = true);
|
||||||
|
|
||||||
|
$commit_tag = id(new PHUITagView())
|
||||||
|
->setName($commit_name)
|
||||||
|
->setHref($commit_link)
|
||||||
|
->setType(PHUITagView::TYPE_SHADE)
|
||||||
|
->setColor(PHUITagView::COLOR_INDIGO)
|
||||||
|
->setBorder(PHUITagView::BORDER_NONE)
|
||||||
|
->setSlimShady(true);
|
||||||
|
$subhead = array($commit_tag, ' ', $details);
|
||||||
|
|
||||||
|
$item = id(new PHUIObjectItemView())
|
||||||
|
->setHeader($branch->getShortName())
|
||||||
|
->setHref($drequest->generateURI(
|
||||||
|
array(
|
||||||
|
'action' => 'history',
|
||||||
|
'branch' => $branch->getShortName(),
|
||||||
|
)))
|
||||||
|
->setSubhead($subhead)
|
||||||
|
->setSideColumn(array(
|
||||||
|
$build_view,
|
||||||
|
$button_bar,
|
||||||
|
));
|
||||||
|
|
||||||
|
if ($branch->getShortName() == $repository->getDefaultBranch()) {
|
||||||
|
$item->setStatusIcon('fa-code-fork', pht('Default Branch'));
|
||||||
|
}
|
||||||
|
$item->addAttribute(array($datetime));
|
||||||
|
|
||||||
|
$list->addItem($item);
|
||||||
|
|
||||||
|
}
|
||||||
|
return $list;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -116,10 +116,10 @@ abstract class DiffusionView extends AphrontView {
|
||||||
|
|
||||||
if ($button) {
|
if ($button) {
|
||||||
return id(new PHUIButtonView())
|
return id(new PHUIButtonView())
|
||||||
->setText(pht('Browse'))
|
->setTag('a')
|
||||||
->setIcon('fa-code')
|
->setIcon('fa-code')
|
||||||
->setHref($href)
|
->setHref($href)
|
||||||
->setTag('a')
|
->setToolTip(pht('Browse'))
|
||||||
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE);
|
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,23 @@
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* - Branch Styles ----------------------------------------------------------*/
|
||||||
|
|
||||||
|
.diffusion-branch-list .phui-oi-attribute a {
|
||||||
|
color: {$darkbluetext};
|
||||||
|
}
|
||||||
|
|
||||||
|
.diffusion-branch-list .phui-oi-attribute-spacer {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.diffusion-branch-list .phui-oi-subhead {
|
||||||
|
color: {$bluetext};
|
||||||
|
}
|
||||||
|
|
||||||
|
.diffusion-branch-list .phui-oi-subhead .phui-tag-view {
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
/* - Phone Style ------------------------------------------------------------*/
|
/* - Phone Style ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue