1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

Add a DiffusionTagListView

Summary: Moves DiffusionTagsListView to uhhh, list. Separates out table view which is still in use now, implements mobile friendly UI for tags.

Test Plan:
Review KDE's Krita repository locally with lots of tags, desktop and mobile.

{F4997708}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12824

Differential Revision: https://secure.phabricator.com/D18115
This commit is contained in:
Chad Little 2017-06-13 11:16:57 -07:00
parent df6ad07566
commit 6f7b31fbf8
8 changed files with 246 additions and 103 deletions

View file

@ -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',

View file

@ -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)

View file

@ -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');
}
}

View file

@ -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;

View file

@ -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');
}
}

View file

@ -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',
'action' => 'history',
'commit' => $tag->getName(),
)),
),
$tag->getName());
));
$commit_link = phutil_tag(
'a',
array(
'href' => $drequest->generateURI(
$commit_href = $drequest->generateURI(
array(
'action' => 'commit',
'commit' => $tag->getCommitIdentifier(),
)),
),
$repository->formatCommitName(
$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());
$rows[] = array(
$history,
$tag_link,
$commit_link,
$build,
$author,
$description,
$viewer->formatShortDateTime($tag->getEpoch()),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
if ($repository->supportsBranchComparison()) {
$compare_uri = $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' => 'compare',
'head' => $tag->getName(),
));
return $table->render();
$button_bar->addButton(
id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-balance-scale')
->setToolTip(pht('Compare'))
->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
->setWorkflow(true)
->setHref($compare_uri));
}
$commit_name = $repository->formatCommitName(
$tag->getCommitIdentifier(), $local = true);
$browse_href = $drequest->generateURI(
array(
'action' => 'browse',
'commit' => $tag->getName(),
));
$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;
}
}

View file

@ -0,0 +1,140 @@
<?php
final class DiffusionTagTableView extends DiffusionView {
private $tags;
private $commits = array();
private $handles = array();
public function setTags($tags) {
$this->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();
}
}

View file

@ -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')