diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 2209dffea7..e5903df96e 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -71,7 +71,7 @@ return array( 'rsrc/css/application/differential/revision-history.css' => '0e8eb855', 'rsrc/css/application/differential/revision-list.css' => 'f3c47d33', '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-readme.css' => '419dd5b6', 'rsrc/css/application/diffusion/diffusion-source.css' => '750add59', @@ -569,7 +569,7 @@ return array( 'differential-revision-history-css' => '0e8eb855', 'differential-revision-list-css' => 'f3c47d33', 'differential-table-of-contents-css' => 'ae4b7a55', - 'diffusion-history-css' => '6870e8c1', + 'diffusion-history-css' => '4540f568', 'diffusion-icons-css' => 'a6a1e2ba', 'diffusion-readme-css' => '419dd5b6', 'diffusion-source-css' => '750add59', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 5d917db2c0..5d88f4665c 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -613,6 +613,7 @@ phutil_register_library_map(array( 'DiffusionBlameConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionBlameConduitAPIMethod.php', 'DiffusionBlameQuery' => 'applications/diffusion/query/blame/DiffusionBlameQuery.php', 'DiffusionBlockHeraldAction' => 'applications/diffusion/herald/DiffusionBlockHeraldAction.php', + 'DiffusionBranchListView' => 'applications/diffusion/view/DiffusionBranchListView.php', 'DiffusionBranchQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php', 'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php', 'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php', @@ -5584,6 +5585,7 @@ phutil_register_library_map(array( 'DiffusionBlameConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 'DiffusionBlameQuery' => 'DiffusionQuery', 'DiffusionBlockHeraldAction' => 'HeraldAction', + 'DiffusionBranchListView' => 'DiffusionView', 'DiffusionBranchQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 'DiffusionBranchTableController' => 'DiffusionController', 'DiffusionBranchTableView' => 'DiffusionView', diff --git a/src/applications/diffusion/controller/DiffusionBranchTableController.php b/src/applications/diffusion/controller/DiffusionBranchTableController.php index e5e033f416..7f8ae11f57 100644 --- a/src/applications/diffusion/controller/DiffusionBranchTableController.php +++ b/src/applications/diffusion/controller/DiffusionBranchTableController.php @@ -48,7 +48,7 @@ final class DiffusionBranchTableController extends DiffusionController { ->withRepository($repository) ->execute(); - $table = id(new DiffusionBranchTableView()) + $list = id(new DiffusionBranchListView()) ->setUser($viewer) ->setBranches($branches) ->setCommits($commits) @@ -57,7 +57,7 @@ final class DiffusionBranchTableController extends DiffusionController { $content = id(new PHUIObjectBoxView()) ->setHeaderText($repository->getName()) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($table) + ->setTable($list) ->setPager($pager); } @@ -84,10 +84,7 @@ final class DiffusionBranchTableController extends DiffusionController { $repository->getDisplayName(), )) ->setCrumbs($crumbs) - ->appendChild( - array( - $view, - )); + ->appendChild($view); } } diff --git a/src/applications/diffusion/view/DiffusionBranchListView.php b/src/applications/diffusion/view/DiffusionBranchListView.php new file mode 100644 index 0000000000..77540bb8c3 --- /dev/null +++ b/src/applications/diffusion/view/DiffusionBranchListView.php @@ -0,0 +1,149 @@ +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; + + } +} diff --git a/src/applications/diffusion/view/DiffusionView.php b/src/applications/diffusion/view/DiffusionView.php index 1d89a9dbd7..a51fbb2fd2 100644 --- a/src/applications/diffusion/view/DiffusionView.php +++ b/src/applications/diffusion/view/DiffusionView.php @@ -116,10 +116,10 @@ abstract class DiffusionView extends AphrontView { if ($button) { return id(new PHUIButtonView()) - ->setText(pht('Browse')) + ->setTag('a') ->setIcon('fa-code') ->setHref($href) - ->setTag('a') + ->setToolTip(pht('Browse')) ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE); } diff --git a/webroot/rsrc/css/application/diffusion/diffusion-history.css b/webroot/rsrc/css/application/diffusion/diffusion-history.css index 2d0aea3b10..f4a51f7b56 100644 --- a/webroot/rsrc/css/application/diffusion/diffusion-history.css +++ b/webroot/rsrc/css/application/diffusion/diffusion-history.css @@ -30,6 +30,23 @@ 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 ------------------------------------------------------------*/