diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 5d88f4665c..9ed3195e0b 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -892,6 +892,7 @@ phutil_register_library_map(array( 'DiffusionSymbolQuery' => 'applications/diffusion/query/DiffusionSymbolQuery.php', 'DiffusionTagListController' => 'applications/diffusion/controller/DiffusionTagListController.php', 'DiffusionTagListView' => 'applications/diffusion/view/DiffusionTagListView.php', + 'DiffusionTagTableView' => 'applications/diffusion/view/DiffusionTagTableView.php', 'DiffusionTaggedRepositoriesFunctionDatasource' => 'applications/diffusion/typeahead/DiffusionTaggedRepositoriesFunctionDatasource.php', 'DiffusionTagsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php', 'DiffusionURIEditConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionURIEditConduitAPIMethod.php', @@ -5866,6 +5867,7 @@ phutil_register_library_map(array( 'DiffusionSymbolQuery' => 'PhabricatorOffsetPagedQuery', 'DiffusionTagListController' => 'DiffusionController', 'DiffusionTagListView' => 'DiffusionView', + 'DiffusionTagTableView' => 'DiffusionView', 'DiffusionTaggedRepositoriesFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'DiffusionTagsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 'DiffusionURIEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php index 72b4d105d2..e341b87972 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php @@ -492,7 +492,7 @@ final class DiffusionRepositoryController extends DiffusionController { ->needCommitData(true) ->execute(); - $view = id(new DiffusionTagListView()) + $view = id(new DiffusionTagTableView()) ->setUser($viewer) ->setDiffusionRequest($drequest) ->setTags($tags) diff --git a/src/applications/diffusion/controller/DiffusionTagListController.php b/src/applications/diffusion/controller/DiffusionTagListController.php index df3b356f5d..5e765ddcb6 100644 --- a/src/applications/diffusion/controller/DiffusionTagListController.php +++ b/src/applications/diffusion/controller/DiffusionTagListController.php @@ -64,17 +64,21 @@ final class DiffusionTagListController extends DiffusionController { ->needCommitData(true) ->execute(); - $view = id(new DiffusionTagListView()) + $tag_list = id(new DiffusionTagListView()) ->setTags($tags) ->setUser($viewer) ->setCommits($commits) ->setDiffusionRequest($drequest); - $phids = $view->getRequiredHandlePHIDs(); + $phids = $tag_list->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); - $view->setHandles($handles); + $tag_list->setHandles($handles); - $content = $view; + $content = id(new PHUIObjectBoxView()) + ->setHeaderText($repository->getDisplayName()) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) + ->setTable($tag_list) + ->setPager($pager); } $crumbs = $this->buildCrumbs( @@ -84,17 +88,9 @@ final class DiffusionTagListController extends DiffusionController { )); $crumbs->setBorder(true); - $box = id(new PHUIObjectBoxView()) - ->setHeaderText($repository->getDisplayName()) - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($view) - ->setPager($pager); - $view = id(new PHUITwoColumnView()) ->setHeader($header) - ->setFooter(array( - $box, - )); + ->setFooter($content); return $this->newPage() ->setTitle( @@ -103,7 +99,8 @@ final class DiffusionTagListController extends DiffusionController { $repository->getDisplayName(), )) ->setCrumbs($crumbs) - ->appendChild($view); + ->appendChild($view) + ->addClass('diffusion-history-view'); } } diff --git a/src/applications/diffusion/view/DiffusionBranchListView.php b/src/applications/diffusion/view/DiffusionBranchListView.php index 77540bb8c3..8d1df82dc9 100644 --- a/src/applications/diffusion/view/DiffusionBranchListView.php +++ b/src/applications/diffusion/view/DiffusionBranchListView.php @@ -48,18 +48,7 @@ final class DiffusionBranchListView extends DiffusionView { $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); + $build_view = $this->renderBuildable($buildable, 'button'); } } else { $datetime = null; diff --git a/src/applications/diffusion/view/DiffusionHistoryListView.php b/src/applications/diffusion/view/DiffusionHistoryListView.php index 9d6727a357..9dfa46cbef 100644 --- a/src/applications/diffusion/view/DiffusionHistoryListView.php +++ b/src/applications/diffusion/view/DiffusionHistoryListView.php @@ -119,19 +119,7 @@ final class DiffusionHistoryListView extends DiffusionHistoryView { if ($show_builds) { $buildable = idx($buildables, $commit->getPHID()); if ($buildable !== null) { - $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) - ->addClass('diffusion-list-build-status'); + $build_view = $this->renderBuildable($buildable, 'button'); } } diff --git a/src/applications/diffusion/view/DiffusionTagListView.php b/src/applications/diffusion/view/DiffusionTagListView.php index df59925522..f9030581e3 100644 --- a/src/applications/diffusion/view/DiffusionTagListView.php +++ b/src/applications/diffusion/view/DiffusionTagListView.php @@ -29,36 +29,28 @@ final class DiffusionTagListView extends DiffusionView { $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $viewer = $this->getViewer(); + require_celerity_resource('diffusion-history-css'); $buildables = $this->loadBuildables($this->commits); - $has_builds = false; - $rows = array(); + $list = id(new PHUIObjectItemListView()) + ->setFlush(true) + ->addClass('diffusion-history-list'); foreach ($this->tags as $tag) { $commit = idx($this->commits, $tag->getCommitIdentifier()); + $button_bar = new PHUIButtonBarView(); - $tag_link = phutil_tag( - 'a', + $tag_href = $drequest->generateURI( array( - 'href' => $drequest->generateURI( - array( - 'action' => 'browse', - 'commit' => $tag->getName(), - )), - ), - $tag->getName()); + 'action' => 'history', + 'commit' => $tag->getName(), + )); - $commit_link = phutil_tag( - 'a', + $commit_href = $drequest->generateURI( array( - 'href' => $drequest->generateURI( - array( - 'action' => 'commit', - 'commit' => $tag->getCommitIdentifier(), - )), - ), - $repository->formatCommitName( - $tag->getCommitIdentifier())); + 'action' => 'commit', + 'commit' => $tag->getCommitIdentifier(), + )); $author = null; if ($commit && $commit->getAuthorPHID()) { @@ -69,6 +61,15 @@ final class DiffusionTagListView extends DiffusionView { $author = self::renderName($tag->getAuthor()); } + $committed = phabricator_datetime($commit->getEpoch(), $viewer); + $author_name = phutil_tag( + 'strong', + array( + 'class' => 'diffusion-history-author-name', + ), + $author); + $authored = pht('%s on %s.', $author_name, $committed); + $description = null; if ($tag->getType() == 'git/tag') { // In Git, a tag may be a "real" tag, or just a reference to a commit. @@ -83,58 +84,71 @@ final class DiffusionTagListView extends DiffusionView { } } - $build = null; + $build_view = null; if ($commit) { $buildable = idx($buildables, $commit->getPHID()); if ($buildable) { - $build = $this->renderBuildable($buildable); - $has_builds = true; + $build_view = $this->renderBuildable($buildable, 'button'); } } - $history = $this->linkTagHistory($tag->getName()); + if ($repository->supportsBranchComparison()) { + $compare_uri = $drequest->generateURI( + array( + 'action' => 'compare', + 'head' => $tag->getName(), + )); - $rows[] = array( - $history, - $tag_link, - $commit_link, - $build, - $author, - $description, - $viewer->formatShortDateTime($tag->getEpoch()), - ); - } + $button_bar->addButton( + id(new PHUIButtonView()) + ->setTag('a') + ->setIcon('fa-balance-scale') + ->setToolTip(pht('Compare')) + ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE) + ->setWorkflow(true) + ->setHref($compare_uri)); + } - $table = id(new AphrontTableView($rows)) - ->setHeaders( + $commit_name = $repository->formatCommitName( + $tag->getCommitIdentifier(), $local = true); + + $browse_href = $drequest->generateURI( array( - null, - pht('Tag'), - pht('Commit'), - null, - pht('Author'), - pht('Description'), - pht('Created'), - )) - ->setColumnClasses( - array( - 'nudgeright', - 'pri', - '', - '', - '', - 'wide', - 'right', - )) - ->setColumnVisibility( - array( - true, - true, - true, - $has_builds, + 'action' => 'browse', + 'commit' => $tag->getName(), )); - return $table->render(); + $button_bar->addButton( + id(new PHUIButtonView()) + ->setTooltip(pht('Browse')) + ->setIcon('fa-code') + ->setHref($browse_href) + ->setTag('a') + ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)); + + $commit_tag = id(new PHUITagView()) + ->setName($commit_name) + ->setHref($commit_href) + ->setType(PHUITagView::TYPE_SHADE) + ->setColor(PHUITagView::COLOR_INDIGO) + ->setBorder(PHUITagView::BORDER_NONE) + ->setSlimShady(true); + + $item = id(new PHUIObjectItemView()) + ->setHeader($tag->getName()) + ->setHref($tag_href) + ->addAttribute(array($commit_tag)) + ->addAttribute($description) + ->addAttribute($authored) + ->setSideColumn(array( + $build_view, + $button_bar, + )); + + $list->addItem($item); + } + + return $list; } } diff --git a/src/applications/diffusion/view/DiffusionTagTableView.php b/src/applications/diffusion/view/DiffusionTagTableView.php new file mode 100644 index 0000000000..59a06353ab --- /dev/null +++ b/src/applications/diffusion/view/DiffusionTagTableView.php @@ -0,0 +1,140 @@ +tags = $tags; + return $this; + } + + public function setCommits(array $commits) { + $this->commits = mpull($commits, null, 'getCommitIdentifier'); + return $this; + } + + public function setHandles(array $handles) { + $this->handles = $handles; + return $this; + } + + public function getRequiredHandlePHIDs() { + return array_filter(mpull($this->commits, 'getAuthorPHID')); + } + + public function render() { + $drequest = $this->getDiffusionRequest(); + $repository = $drequest->getRepository(); + $viewer = $this->getViewer(); + + $buildables = $this->loadBuildables($this->commits); + $has_builds = false; + + $rows = array(); + foreach ($this->tags as $tag) { + $commit = idx($this->commits, $tag->getCommitIdentifier()); + + $tag_link = phutil_tag( + 'a', + array( + 'href' => $drequest->generateURI( + array( + 'action' => 'browse', + 'commit' => $tag->getName(), + )), + ), + $tag->getName()); + + $commit_link = phutil_tag( + 'a', + array( + 'href' => $drequest->generateURI( + array( + 'action' => 'commit', + 'commit' => $tag->getCommitIdentifier(), + )), + ), + $repository->formatCommitName( + $tag->getCommitIdentifier())); + + $author = null; + if ($commit && $commit->getAuthorPHID()) { + $author = $this->handles[$commit->getAuthorPHID()]->renderLink(); + } else if ($commit && $commit->getCommitData()) { + $author = self::renderName($commit->getCommitData()->getAuthorName()); + } else { + $author = self::renderName($tag->getAuthor()); + } + + $description = null; + if ($tag->getType() == 'git/tag') { + // In Git, a tag may be a "real" tag, or just a reference to a commit. + // If it's a real tag, use the message on the tag, since this may be + // unique data which isn't otherwise available. + $description = $tag->getDescription(); + } else { + if ($commit) { + $description = $commit->getSummary(); + } else { + $description = $tag->getDescription(); + } + } + + $build = null; + if ($commit) { + $buildable = idx($buildables, $commit->getPHID()); + if ($buildable) { + $build = $this->renderBuildable($buildable); + $has_builds = true; + } + } + + $history = $this->linkTagHistory($tag->getName()); + + $rows[] = array( + $history, + $tag_link, + $commit_link, + $build, + $author, + $description, + $viewer->formatShortDateTime($tag->getEpoch()), + ); + } + + $table = id(new AphrontTableView($rows)) + ->setHeaders( + array( + null, + pht('Tag'), + pht('Commit'), + null, + pht('Author'), + pht('Description'), + pht('Created'), + )) + ->setColumnClasses( + array( + 'nudgeright', + 'pri', + '', + '', + '', + 'wide', + 'right', + )) + ->setColumnVisibility( + array( + true, + true, + true, + $has_builds, + )); + + return $table->render(); + } + +} diff --git a/src/applications/diffusion/view/DiffusionView.php b/src/applications/diffusion/view/DiffusionView.php index a51fbb2fd2..d058dc5cec 100644 --- a/src/applications/diffusion/view/DiffusionView.php +++ b/src/applications/diffusion/view/DiffusionView.php @@ -190,7 +190,8 @@ abstract class DiffusionView extends AphrontView { } final protected function renderBuildable( - HarbormasterBuildable $buildable) { + HarbormasterBuildable $buildable, + $type = null) { $status = $buildable->getBuildableStatus(); Javelin::initBehavior('phabricator-tooltips'); @@ -198,6 +199,18 @@ abstract class DiffusionView extends AphrontView { $color = HarbormasterBuildable::getBuildableStatusColor($status); $name = HarbormasterBuildable::getBuildableStatusName($status); + if ($type == 'button') { + return id(new PHUIButtonView()) + ->setTag('a') + ->setText($name) + ->setIcon($icon) + ->setColor($color) + ->setHref('/'.$buildable->getMonogram()) + ->addClass('mmr') + ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE) + ->addClass('diffusion-list-build-status'); + } + return id(new PHUIIconView()) ->setIcon($icon.' '.$color) ->addSigil('has-tooltip')