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', 'DiffusionSymbolQuery' => 'applications/diffusion/query/DiffusionSymbolQuery.php',
'DiffusionTagListController' => 'applications/diffusion/controller/DiffusionTagListController.php', 'DiffusionTagListController' => 'applications/diffusion/controller/DiffusionTagListController.php',
'DiffusionTagListView' => 'applications/diffusion/view/DiffusionTagListView.php', 'DiffusionTagListView' => 'applications/diffusion/view/DiffusionTagListView.php',
'DiffusionTagTableView' => 'applications/diffusion/view/DiffusionTagTableView.php',
'DiffusionTaggedRepositoriesFunctionDatasource' => 'applications/diffusion/typeahead/DiffusionTaggedRepositoriesFunctionDatasource.php', 'DiffusionTaggedRepositoriesFunctionDatasource' => 'applications/diffusion/typeahead/DiffusionTaggedRepositoriesFunctionDatasource.php',
'DiffusionTagsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php', 'DiffusionTagsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php',
'DiffusionURIEditConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionURIEditConduitAPIMethod.php', 'DiffusionURIEditConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionURIEditConduitAPIMethod.php',
@ -5866,6 +5867,7 @@ phutil_register_library_map(array(
'DiffusionSymbolQuery' => 'PhabricatorOffsetPagedQuery', 'DiffusionSymbolQuery' => 'PhabricatorOffsetPagedQuery',
'DiffusionTagListController' => 'DiffusionController', 'DiffusionTagListController' => 'DiffusionController',
'DiffusionTagListView' => 'DiffusionView', 'DiffusionTagListView' => 'DiffusionView',
'DiffusionTagTableView' => 'DiffusionView',
'DiffusionTaggedRepositoriesFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 'DiffusionTaggedRepositoriesFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'DiffusionTagsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 'DiffusionTagsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
'DiffusionURIEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 'DiffusionURIEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',

View file

@ -492,7 +492,7 @@ final class DiffusionRepositoryController extends DiffusionController {
->needCommitData(true) ->needCommitData(true)
->execute(); ->execute();
$view = id(new DiffusionTagListView()) $view = id(new DiffusionTagTableView())
->setUser($viewer) ->setUser($viewer)
->setDiffusionRequest($drequest) ->setDiffusionRequest($drequest)
->setTags($tags) ->setTags($tags)

View file

@ -64,17 +64,21 @@ final class DiffusionTagListController extends DiffusionController {
->needCommitData(true) ->needCommitData(true)
->execute(); ->execute();
$view = id(new DiffusionTagListView()) $tag_list = id(new DiffusionTagListView())
->setTags($tags) ->setTags($tags)
->setUser($viewer) ->setUser($viewer)
->setCommits($commits) ->setCommits($commits)
->setDiffusionRequest($drequest); ->setDiffusionRequest($drequest);
$phids = $view->getRequiredHandlePHIDs(); $phids = $tag_list->getRequiredHandlePHIDs();
$handles = $this->loadViewerHandles($phids); $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( $crumbs = $this->buildCrumbs(
@ -84,17 +88,9 @@ final class DiffusionTagListController extends DiffusionController {
)); ));
$crumbs->setBorder(true); $crumbs->setBorder(true);
$box = id(new PHUIObjectBoxView())
->setHeaderText($repository->getDisplayName())
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($view)
->setPager($pager);
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setFooter(array( ->setFooter($content);
$box,
));
return $this->newPage() return $this->newPage()
->setTitle( ->setTitle(
@ -103,7 +99,8 @@ final class DiffusionTagListController extends DiffusionController {
$repository->getDisplayName(), $repository->getDisplayName(),
)) ))
->setCrumbs($crumbs) ->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()); $buildable = idx($buildables, $commit->getPHID());
if ($buildable) { if ($buildable) {
$status = $buildable->getBuildableStatus(); $build_view = $this->renderBuildable($buildable, 'button');
$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 { } else {
$datetime = null; $datetime = null;

View file

@ -119,19 +119,7 @@ final class DiffusionHistoryListView extends DiffusionHistoryView {
if ($show_builds) { if ($show_builds) {
$buildable = idx($buildables, $commit->getPHID()); $buildable = idx($buildables, $commit->getPHID());
if ($buildable !== null) { if ($buildable !== null) {
$status = $buildable->getBuildableStatus(); $build_view = $this->renderBuildable($buildable, 'button');
$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');
} }
} }

View file

@ -29,36 +29,28 @@ final class DiffusionTagListView extends DiffusionView {
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository(); $repository = $drequest->getRepository();
$viewer = $this->getViewer(); $viewer = $this->getViewer();
require_celerity_resource('diffusion-history-css');
$buildables = $this->loadBuildables($this->commits); $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) { foreach ($this->tags as $tag) {
$commit = idx($this->commits, $tag->getCommitIdentifier()); $commit = idx($this->commits, $tag->getCommitIdentifier());
$button_bar = new PHUIButtonBarView();
$tag_link = phutil_tag( $tag_href = $drequest->generateURI(
'a',
array( array(
'href' => $drequest->generateURI( 'action' => 'history',
array( 'commit' => $tag->getName(),
'action' => 'browse', ));
'commit' => $tag->getName(),
)),
),
$tag->getName());
$commit_link = phutil_tag( $commit_href = $drequest->generateURI(
'a',
array( array(
'href' => $drequest->generateURI( 'action' => 'commit',
array( 'commit' => $tag->getCommitIdentifier(),
'action' => 'commit', ));
'commit' => $tag->getCommitIdentifier(),
)),
),
$repository->formatCommitName(
$tag->getCommitIdentifier()));
$author = null; $author = null;
if ($commit && $commit->getAuthorPHID()) { if ($commit && $commit->getAuthorPHID()) {
@ -69,6 +61,15 @@ final class DiffusionTagListView extends DiffusionView {
$author = self::renderName($tag->getAuthor()); $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; $description = null;
if ($tag->getType() == 'git/tag') { if ($tag->getType() == 'git/tag') {
// In Git, a tag may be a "real" tag, or just a reference to a commit. // 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) { if ($commit) {
$buildable = idx($buildables, $commit->getPHID()); $buildable = idx($buildables, $commit->getPHID());
if ($buildable) { if ($buildable) {
$build = $this->renderBuildable($buildable); $build_view = $this->renderBuildable($buildable, 'button');
$has_builds = true;
} }
} }
$history = $this->linkTagHistory($tag->getName()); if ($repository->supportsBranchComparison()) {
$compare_uri = $drequest->generateURI(
array(
'action' => 'compare',
'head' => $tag->getName(),
));
$rows[] = array( $button_bar->addButton(
$history, id(new PHUIButtonView())
$tag_link, ->setTag('a')
$commit_link, ->setIcon('fa-balance-scale')
$build, ->setToolTip(pht('Compare'))
$author, ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)
$description, ->setWorkflow(true)
$viewer->formatShortDateTime($tag->getEpoch()), ->setHref($compare_uri));
); }
}
$table = id(new AphrontTableView($rows)) $commit_name = $repository->formatCommitName(
->setHeaders( $tag->getCommitIdentifier(), $local = true);
$browse_href = $drequest->generateURI(
array( array(
null, 'action' => 'browse',
pht('Tag'), 'commit' => $tag->getName(),
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(); $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( final protected function renderBuildable(
HarbormasterBuildable $buildable) { HarbormasterBuildable $buildable,
$type = null) {
$status = $buildable->getBuildableStatus(); $status = $buildable->getBuildableStatus();
Javelin::initBehavior('phabricator-tooltips'); Javelin::initBehavior('phabricator-tooltips');
@ -198,6 +199,18 @@ abstract class DiffusionView extends AphrontView {
$color = HarbormasterBuildable::getBuildableStatusColor($status); $color = HarbormasterBuildable::getBuildableStatusColor($status);
$name = HarbormasterBuildable::getBuildableStatusName($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()) return id(new PHUIIconView())
->setIcon($icon.' '.$color) ->setIcon($icon.' '.$color)
->addSigil('has-tooltip') ->addSigil('has-tooltip')