@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+246 -103
+2
src/__phutil_library_map__.php
··· 892 892 'DiffusionSymbolQuery' => 'applications/diffusion/query/DiffusionSymbolQuery.php', 893 893 'DiffusionTagListController' => 'applications/diffusion/controller/DiffusionTagListController.php', 894 894 'DiffusionTagListView' => 'applications/diffusion/view/DiffusionTagListView.php', 895 + 'DiffusionTagTableView' => 'applications/diffusion/view/DiffusionTagTableView.php', 895 896 'DiffusionTaggedRepositoriesFunctionDatasource' => 'applications/diffusion/typeahead/DiffusionTaggedRepositoriesFunctionDatasource.php', 896 897 'DiffusionTagsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php', 897 898 'DiffusionURIEditConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionURIEditConduitAPIMethod.php', ··· 5866 5867 'DiffusionSymbolQuery' => 'PhabricatorOffsetPagedQuery', 5867 5868 'DiffusionTagListController' => 'DiffusionController', 5868 5869 'DiffusionTagListView' => 'DiffusionView', 5870 + 'DiffusionTagTableView' => 'DiffusionView', 5869 5871 'DiffusionTaggedRepositoriesFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource', 5870 5872 'DiffusionTagsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 5871 5873 'DiffusionURIEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
+1 -1
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 492 492 ->needCommitData(true) 493 493 ->execute(); 494 494 495 - $view = id(new DiffusionTagListView()) 495 + $view = id(new DiffusionTagTableView()) 496 496 ->setUser($viewer) 497 497 ->setDiffusionRequest($drequest) 498 498 ->setTags($tags)
+11 -14
src/applications/diffusion/controller/DiffusionTagListController.php
··· 64 64 ->needCommitData(true) 65 65 ->execute(); 66 66 67 - $view = id(new DiffusionTagListView()) 67 + $tag_list = id(new DiffusionTagListView()) 68 68 ->setTags($tags) 69 69 ->setUser($viewer) 70 70 ->setCommits($commits) 71 71 ->setDiffusionRequest($drequest); 72 72 73 - $phids = $view->getRequiredHandlePHIDs(); 73 + $phids = $tag_list->getRequiredHandlePHIDs(); 74 74 $handles = $this->loadViewerHandles($phids); 75 - $view->setHandles($handles); 75 + $tag_list->setHandles($handles); 76 76 77 - $content = $view; 77 + $content = id(new PHUIObjectBoxView()) 78 + ->setHeaderText($repository->getDisplayName()) 79 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 80 + ->setTable($tag_list) 81 + ->setPager($pager); 78 82 } 79 83 80 84 $crumbs = $this->buildCrumbs( ··· 84 88 )); 85 89 $crumbs->setBorder(true); 86 90 87 - $box = id(new PHUIObjectBoxView()) 88 - ->setHeaderText($repository->getDisplayName()) 89 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 90 - ->setTable($view) 91 - ->setPager($pager); 92 - 93 91 $view = id(new PHUITwoColumnView()) 94 92 ->setHeader($header) 95 - ->setFooter(array( 96 - $box, 97 - )); 93 + ->setFooter($content); 98 94 99 95 return $this->newPage() 100 96 ->setTitle( ··· 103 99 $repository->getDisplayName(), 104 100 )) 105 101 ->setCrumbs($crumbs) 106 - ->appendChild($view); 102 + ->appendChild($view) 103 + ->addClass('diffusion-history-view'); 107 104 } 108 105 109 106 }
+1 -12
src/applications/diffusion/view/DiffusionBranchListView.php
··· 48 48 49 49 $buildable = idx($buildables, $commit->getPHID()); 50 50 if ($buildable) { 51 - $status = $buildable->getBuildableStatus(); 52 - $icon = HarbormasterBuildable::getBuildableStatusIcon($status); 53 - $color = HarbormasterBuildable::getBuildableStatusColor($status); 54 - $name = HarbormasterBuildable::getBuildableStatusName($status); 55 - $build_view = id(new PHUIButtonView()) 56 - ->setTag('a') 57 - ->setText($name) 58 - ->setIcon($icon) 59 - ->setColor($color) 60 - ->setHref('/'.$buildable->getMonogram()) 61 - ->addClass('mmr') 62 - ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE); 51 + $build_view = $this->renderBuildable($buildable, 'button'); 63 52 } 64 53 } else { 65 54 $datetime = null;
+1 -13
src/applications/diffusion/view/DiffusionHistoryListView.php
··· 119 119 if ($show_builds) { 120 120 $buildable = idx($buildables, $commit->getPHID()); 121 121 if ($buildable !== null) { 122 - $status = $buildable->getBuildableStatus(); 123 - $icon = HarbormasterBuildable::getBuildableStatusIcon($status); 124 - $color = HarbormasterBuildable::getBuildableStatusColor($status); 125 - $name = HarbormasterBuildable::getBuildableStatusName($status); 126 - $build_view = id(new PHUIButtonView()) 127 - ->setTag('a') 128 - ->setText($name) 129 - ->setIcon($icon) 130 - ->setColor($color) 131 - ->setHref('/'.$buildable->getMonogram()) 132 - ->addClass('mmr') 133 - ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE) 134 - ->addClass('diffusion-list-build-status'); 122 + $build_view = $this->renderBuildable($buildable, 'button'); 135 123 } 136 124 } 137 125
+76 -62
src/applications/diffusion/view/DiffusionTagListView.php
··· 29 29 $drequest = $this->getDiffusionRequest(); 30 30 $repository = $drequest->getRepository(); 31 31 $viewer = $this->getViewer(); 32 + require_celerity_resource('diffusion-history-css'); 32 33 33 34 $buildables = $this->loadBuildables($this->commits); 34 - $has_builds = false; 35 35 36 - $rows = array(); 36 + $list = id(new PHUIObjectItemListView()) 37 + ->setFlush(true) 38 + ->addClass('diffusion-history-list'); 37 39 foreach ($this->tags as $tag) { 38 40 $commit = idx($this->commits, $tag->getCommitIdentifier()); 41 + $button_bar = new PHUIButtonBarView(); 39 42 40 - $tag_link = phutil_tag( 41 - 'a', 43 + $tag_href = $drequest->generateURI( 42 44 array( 43 - 'href' => $drequest->generateURI( 44 - array( 45 - 'action' => 'browse', 46 - 'commit' => $tag->getName(), 47 - )), 48 - ), 49 - $tag->getName()); 45 + 'action' => 'history', 46 + 'commit' => $tag->getName(), 47 + )); 50 48 51 - $commit_link = phutil_tag( 52 - 'a', 49 + $commit_href = $drequest->generateURI( 53 50 array( 54 - 'href' => $drequest->generateURI( 55 - array( 56 - 'action' => 'commit', 57 - 'commit' => $tag->getCommitIdentifier(), 58 - )), 59 - ), 60 - $repository->formatCommitName( 61 - $tag->getCommitIdentifier())); 51 + 'action' => 'commit', 52 + 'commit' => $tag->getCommitIdentifier(), 53 + )); 62 54 63 55 $author = null; 64 56 if ($commit && $commit->getAuthorPHID()) { ··· 69 61 $author = self::renderName($tag->getAuthor()); 70 62 } 71 63 64 + $committed = phabricator_datetime($commit->getEpoch(), $viewer); 65 + $author_name = phutil_tag( 66 + 'strong', 67 + array( 68 + 'class' => 'diffusion-history-author-name', 69 + ), 70 + $author); 71 + $authored = pht('%s on %s.', $author_name, $committed); 72 + 72 73 $description = null; 73 74 if ($tag->getType() == 'git/tag') { 74 75 // In Git, a tag may be a "real" tag, or just a reference to a commit. ··· 83 84 } 84 85 } 85 86 86 - $build = null; 87 + $build_view = null; 87 88 if ($commit) { 88 89 $buildable = idx($buildables, $commit->getPHID()); 89 90 if ($buildable) { 90 - $build = $this->renderBuildable($buildable); 91 - $has_builds = true; 91 + $build_view = $this->renderBuildable($buildable, 'button'); 92 92 } 93 93 } 94 94 95 - $history = $this->linkTagHistory($tag->getName()); 95 + if ($repository->supportsBranchComparison()) { 96 + $compare_uri = $drequest->generateURI( 97 + array( 98 + 'action' => 'compare', 99 + 'head' => $tag->getName(), 100 + )); 96 101 97 - $rows[] = array( 98 - $history, 99 - $tag_link, 100 - $commit_link, 101 - $build, 102 - $author, 103 - $description, 104 - $viewer->formatShortDateTime($tag->getEpoch()), 105 - ); 106 - } 102 + $button_bar->addButton( 103 + id(new PHUIButtonView()) 104 + ->setTag('a') 105 + ->setIcon('fa-balance-scale') 106 + ->setToolTip(pht('Compare')) 107 + ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE) 108 + ->setWorkflow(true) 109 + ->setHref($compare_uri)); 110 + } 107 111 108 - $table = id(new AphrontTableView($rows)) 109 - ->setHeaders( 112 + $commit_name = $repository->formatCommitName( 113 + $tag->getCommitIdentifier(), $local = true); 114 + 115 + $browse_href = $drequest->generateURI( 110 116 array( 111 - null, 112 - pht('Tag'), 113 - pht('Commit'), 114 - null, 115 - pht('Author'), 116 - pht('Description'), 117 - pht('Created'), 118 - )) 119 - ->setColumnClasses( 120 - array( 121 - 'nudgeright', 122 - 'pri', 123 - '', 124 - '', 125 - '', 126 - 'wide', 127 - 'right', 128 - )) 129 - ->setColumnVisibility( 130 - array( 131 - true, 132 - true, 133 - true, 134 - $has_builds, 117 + 'action' => 'browse', 118 + 'commit' => $tag->getName(), 119 + )); 120 + 121 + $button_bar->addButton( 122 + id(new PHUIButtonView()) 123 + ->setTooltip(pht('Browse')) 124 + ->setIcon('fa-code') 125 + ->setHref($browse_href) 126 + ->setTag('a') 127 + ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE)); 128 + 129 + $commit_tag = id(new PHUITagView()) 130 + ->setName($commit_name) 131 + ->setHref($commit_href) 132 + ->setType(PHUITagView::TYPE_SHADE) 133 + ->setColor(PHUITagView::COLOR_INDIGO) 134 + ->setBorder(PHUITagView::BORDER_NONE) 135 + ->setSlimShady(true); 136 + 137 + $item = id(new PHUIObjectItemView()) 138 + ->setHeader($tag->getName()) 139 + ->setHref($tag_href) 140 + ->addAttribute(array($commit_tag)) 141 + ->addAttribute($description) 142 + ->addAttribute($authored) 143 + ->setSideColumn(array( 144 + $build_view, 145 + $button_bar, 135 146 )); 136 147 137 - return $table->render(); 148 + $list->addItem($item); 149 + } 150 + 151 + return $list; 138 152 } 139 153 140 154 }
+140
src/applications/diffusion/view/DiffusionTagTableView.php
··· 1 + <?php 2 + 3 + final class DiffusionTagTableView extends DiffusionView { 4 + 5 + private $tags; 6 + private $commits = array(); 7 + private $handles = array(); 8 + 9 + public function setTags($tags) { 10 + $this->tags = $tags; 11 + return $this; 12 + } 13 + 14 + public function setCommits(array $commits) { 15 + $this->commits = mpull($commits, null, 'getCommitIdentifier'); 16 + return $this; 17 + } 18 + 19 + public function setHandles(array $handles) { 20 + $this->handles = $handles; 21 + return $this; 22 + } 23 + 24 + public function getRequiredHandlePHIDs() { 25 + return array_filter(mpull($this->commits, 'getAuthorPHID')); 26 + } 27 + 28 + public function render() { 29 + $drequest = $this->getDiffusionRequest(); 30 + $repository = $drequest->getRepository(); 31 + $viewer = $this->getViewer(); 32 + 33 + $buildables = $this->loadBuildables($this->commits); 34 + $has_builds = false; 35 + 36 + $rows = array(); 37 + foreach ($this->tags as $tag) { 38 + $commit = idx($this->commits, $tag->getCommitIdentifier()); 39 + 40 + $tag_link = phutil_tag( 41 + 'a', 42 + array( 43 + 'href' => $drequest->generateURI( 44 + array( 45 + 'action' => 'browse', 46 + 'commit' => $tag->getName(), 47 + )), 48 + ), 49 + $tag->getName()); 50 + 51 + $commit_link = phutil_tag( 52 + 'a', 53 + array( 54 + 'href' => $drequest->generateURI( 55 + array( 56 + 'action' => 'commit', 57 + 'commit' => $tag->getCommitIdentifier(), 58 + )), 59 + ), 60 + $repository->formatCommitName( 61 + $tag->getCommitIdentifier())); 62 + 63 + $author = null; 64 + if ($commit && $commit->getAuthorPHID()) { 65 + $author = $this->handles[$commit->getAuthorPHID()]->renderLink(); 66 + } else if ($commit && $commit->getCommitData()) { 67 + $author = self::renderName($commit->getCommitData()->getAuthorName()); 68 + } else { 69 + $author = self::renderName($tag->getAuthor()); 70 + } 71 + 72 + $description = null; 73 + if ($tag->getType() == 'git/tag') { 74 + // In Git, a tag may be a "real" tag, or just a reference to a commit. 75 + // If it's a real tag, use the message on the tag, since this may be 76 + // unique data which isn't otherwise available. 77 + $description = $tag->getDescription(); 78 + } else { 79 + if ($commit) { 80 + $description = $commit->getSummary(); 81 + } else { 82 + $description = $tag->getDescription(); 83 + } 84 + } 85 + 86 + $build = null; 87 + if ($commit) { 88 + $buildable = idx($buildables, $commit->getPHID()); 89 + if ($buildable) { 90 + $build = $this->renderBuildable($buildable); 91 + $has_builds = true; 92 + } 93 + } 94 + 95 + $history = $this->linkTagHistory($tag->getName()); 96 + 97 + $rows[] = array( 98 + $history, 99 + $tag_link, 100 + $commit_link, 101 + $build, 102 + $author, 103 + $description, 104 + $viewer->formatShortDateTime($tag->getEpoch()), 105 + ); 106 + } 107 + 108 + $table = id(new AphrontTableView($rows)) 109 + ->setHeaders( 110 + array( 111 + null, 112 + pht('Tag'), 113 + pht('Commit'), 114 + null, 115 + pht('Author'), 116 + pht('Description'), 117 + pht('Created'), 118 + )) 119 + ->setColumnClasses( 120 + array( 121 + 'nudgeright', 122 + 'pri', 123 + '', 124 + '', 125 + '', 126 + 'wide', 127 + 'right', 128 + )) 129 + ->setColumnVisibility( 130 + array( 131 + true, 132 + true, 133 + true, 134 + $has_builds, 135 + )); 136 + 137 + return $table->render(); 138 + } 139 + 140 + }
+14 -1
src/applications/diffusion/view/DiffusionView.php
··· 190 190 } 191 191 192 192 final protected function renderBuildable( 193 - HarbormasterBuildable $buildable) { 193 + HarbormasterBuildable $buildable, 194 + $type = null) { 194 195 $status = $buildable->getBuildableStatus(); 195 196 Javelin::initBehavior('phabricator-tooltips'); 196 197 197 198 $icon = HarbormasterBuildable::getBuildableStatusIcon($status); 198 199 $color = HarbormasterBuildable::getBuildableStatusColor($status); 199 200 $name = HarbormasterBuildable::getBuildableStatusName($status); 201 + 202 + if ($type == 'button') { 203 + return id(new PHUIButtonView()) 204 + ->setTag('a') 205 + ->setText($name) 206 + ->setIcon($icon) 207 + ->setColor($color) 208 + ->setHref('/'.$buildable->getMonogram()) 209 + ->addClass('mmr') 210 + ->setButtonType(PHUIButtonView::BUTTONTYPE_SIMPLE) 211 + ->addClass('diffusion-list-build-status'); 212 + } 200 213 201 214 return id(new PHUIIconView()) 202 215 ->setIcon($icon.' '.$color)