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

Improve consistency and Harbormaster integration of Diffusion

Summary:
Ref T9123. Two major Harbormaster-related UI changes in Diffusion:

- Tags table now shows tag build status.
- Branches table now shows branch build status.

Then some minor consistency / qualtiy of life changes:

- Picked a nicer looking "history" icon?
- Branches table now uses the same "history" icon as other tables.
- Tags table now has a "history" link.
- Browse table now has a "history" link.
- Dates now use more consistent formatting.
- Column order is now more consistent.
- Use of style is now more consistent.

Test Plan:
{F865056}

{F865057}

{F865058}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9123

Differential Revision: https://secure.phabricator.com/D14242

+173 -114
+1 -4
src/applications/diffusion/controller/DiffusionLastModifiedController.php
··· 98 98 $modified = DiffusionView::linkCommit( 99 99 $drequest->getRepository(), 100 100 $commit->getCommitIdentifier()); 101 - $date = phabricator_date($epoch, $viewer); 102 - $time = phabricator_time($epoch, $viewer); 101 + $date = phabricator_datetime($epoch, $viewer); 103 102 } else { 104 103 $modified = ''; 105 104 $date = ''; 106 - $time = ''; 107 105 } 108 106 109 107 $data = $commit->getCommitData(); ··· 137 135 $return = array( 138 136 'commit' => $modified, 139 137 'date' => $date, 140 - 'time' => $time, 141 138 'author' => $author, 142 139 'details' => $details, 143 140 );
+26 -17
src/applications/diffusion/view/DiffusionBranchTableView.php
··· 21 21 $drequest = $this->getDiffusionRequest(); 22 22 $current_branch = $drequest->getBranch(); 23 23 $repository = $drequest->getRepository(); 24 + $commits = $this->commits; 25 + $viewer = $this->getUser(); 26 + 27 + $buildables = $this->loadBuildables($commits); 28 + $have_builds = false; 24 29 25 30 $can_close_branches = ($repository->isHg()); 26 31 ··· 31 36 $rows = array(); 32 37 $rowc = array(); 33 38 foreach ($this->branches as $branch) { 34 - $commit = idx($this->commits, $branch->getCommitIdentifier()); 39 + $commit = idx($commits, $branch->getCommitIdentifier()); 35 40 if ($commit) { 36 41 $details = $commit->getSummary(); 37 - $datetime = phabricator_datetime($commit->getEpoch(), $this->user); 42 + $datetime = phabricator_datetime($commit->getEpoch(), $viewer); 43 + $buildable = idx($buildables, $commit->getPHID()); 44 + if ($buildable) { 45 + $build_status = $this->renderBuildable($buildable); 46 + $have_builds = true; 47 + } else { 48 + $build_status = null; 49 + } 38 50 } else { 39 51 $datetime = null; 40 52 $details = null; 53 + $build_status = null; 41 54 } 42 55 43 56 switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) { ··· 86 99 } 87 100 88 101 $rows[] = array( 89 - phutil_tag( 90 - 'a', 91 - array( 92 - 'href' => $drequest->generateURI( 93 - array( 94 - 'action' => 'history', 95 - 'branch' => $branch->getShortName(), 96 - )), 97 - ), 98 - pht('History')), 102 + $this->linkBranchHistory($branch->getShortName()), 99 103 phutil_tag( 100 104 'a', 101 105 array( ··· 109 113 self::linkCommit( 110 114 $drequest->getRepository(), 111 115 $branch->getCommitIdentifier()), 116 + $build_status, 112 117 $status, 118 + AphrontTableView::renderSingleDisplayLine($details), 113 119 $status_icon, 114 120 $datetime, 115 - AphrontTableView::renderSingleDisplayLine($details), 116 121 ); 117 122 if ($branch->getShortName() == $current_branch) { 118 123 $rowc[] = 'highlighted'; ··· 124 129 $view = new AphrontTableView($rows); 125 130 $view->setHeaders( 126 131 array( 127 - pht('History'), 132 + null, 128 133 pht('Branch'), 129 134 pht('Head'), 135 + null, 130 136 pht('State'), 131 - pht(''), 132 - pht('Modified'), 133 137 pht('Details'), 138 + null, 139 + pht('Committed'), 134 140 )); 135 141 $view->setColumnClasses( 136 142 array( 137 143 '', 138 144 'pri', 139 145 '', 146 + 'icon', 140 147 '', 148 + 'wide', 141 149 '', 142 150 '', 143 - 'wide', 144 151 )); 145 152 $view->setColumnVisibility( 146 153 array( 147 154 true, 148 155 true, 149 156 true, 157 + $have_builds, 150 158 $can_close_branches, 151 159 )); 152 160 $view->setRowClasses($rowc); 153 161 return $view->render(); 154 162 } 163 + 155 164 156 165 }
+10 -9
src/applications/diffusion/view/DiffusionBrowseTableView.php
··· 31 31 $show_edit = false; 32 32 foreach ($this->paths as $path) { 33 33 34 + $history_link = $this->linkHistory($path->getPath()); 35 + 34 36 $dir_slash = null; 35 37 $file_type = $path->getFileType(); 36 38 if ($file_type == DifferentialChangeType::FILE_DIRECTORY) { ··· 67 69 'lint' => celerity_generate_unique_node_id(), 68 70 'commit' => celerity_generate_unique_node_id(), 69 71 'date' => celerity_generate_unique_node_id(), 70 - 'time' => celerity_generate_unique_node_id(), 71 72 'author' => celerity_generate_unique_node_id(), 72 73 'details' => celerity_generate_unique_node_id(), 73 74 ); ··· 78 79 } 79 80 80 81 $rows[] = array( 82 + $history_link, 81 83 $browse_link, 82 84 idx($dict, 'lint'), 83 85 $dict['commit'], 84 86 $dict['author'], 85 87 $dict['details'], 86 88 $dict['date'], 87 - $dict['time'], 88 89 ); 89 90 } 90 91 ··· 108 109 $view = new AphrontTableView($rows); 109 110 $view->setHeaders( 110 111 array( 112 + null, 111 113 pht('Path'), 112 114 ($lint ? $lint : pht('Lint')), 113 115 pht('Modified'), 114 116 pht('Author/Committer'), 115 117 pht('Details'), 116 - pht('Date'), 117 - pht('Time'), 118 + pht('Committed'), 118 119 )); 119 120 $view->setColumnClasses( 120 121 array( 122 + 'nudgeright', 121 123 '', 122 - 'n', 123 - 'n', 124 + '', 125 + '', 124 126 '', 125 127 'wide', 126 128 '', 127 - 'right', 128 129 )); 129 130 $view->setColumnVisibility( 130 131 array( 131 132 true, 132 - $show_lint, 133 133 true, 134 + $show_lint, 134 135 true, 135 136 true, 136 137 true, ··· 140 141 $view->setDeviceVisibility( 141 142 array( 142 143 true, 144 + true, 143 145 false, 144 146 true, 145 147 false, 146 148 true, 147 - false, 148 149 false, 149 150 )); 150 151
+13 -67
src/applications/diffusion/view/DiffusionHistoryTableView.php
··· 7 7 private $handles = array(); 8 8 private $isHead; 9 9 private $parents; 10 - private $buildCache; 11 10 12 11 public function setHistory(array $history) { 13 12 assert_instances_of($history, 'DiffusionPathChange'); 14 13 $this->history = $history; 15 - $this->buildCache = null; 16 14 return $this; 17 15 } 18 16 ··· 62 60 return $this; 63 61 } 64 62 65 - public function loadBuildablesOnDemand() { 66 - if ($this->buildCache !== null) { 67 - return $this->buildCache; 68 - } 69 - 70 - $commits_to_builds = array(); 71 - 72 - $commits = mpull($this->history, 'getCommit'); 73 - 74 - $commit_phids = mpull($commits, 'getPHID'); 75 - 76 - $buildables = id(new HarbormasterBuildableQuery()) 77 - ->setViewer($this->getUser()) 78 - ->withBuildablePHIDs($commit_phids) 79 - ->withManualBuildables(false) 80 - ->execute(); 81 - 82 - $this->buildCache = mpull($buildables, null, 'getBuildablePHID'); 83 - 84 - return $this->buildCache; 85 - } 86 - 87 63 public function render() { 88 64 $drequest = $this->getDiffusionRequest(); 89 65 90 66 $viewer = $this->getUser(); 67 + 68 + $buildables = $this->loadBuildables(mpull($this->history, 'getCommit')); 69 + $has_any_build = false; 91 70 92 71 $show_revisions = PhabricatorApplication::isClassInstalledForViewer( 93 72 'PhabricatorDifferentialApplication', ··· 110 89 $epoch = $history->getEpoch(); 111 90 112 91 if ($epoch) { 113 - $date = phabricator_date($epoch, $this->user); 114 - $time = phabricator_time($epoch, $this->user); 92 + $committed = phabricator_datetime($epoch, $viewer); 115 93 } else { 116 - $date = null; 117 - $time = null; 94 + $committed = null; 118 95 } 119 96 120 97 $data = $history->getCommitData(); ··· 160 137 161 138 $build = null; 162 139 if ($show_builds) { 163 - $buildable_lookup = $this->loadBuildablesOnDemand(); 164 - $buildable = idx($buildable_lookup, $commit->getPHID()); 140 + $buildable = idx($buildables, $commit->getPHID()); 165 141 if ($buildable !== null) { 166 - $icon = HarbormasterBuildable::getBuildableStatusIcon( 167 - $buildable->getBuildableStatus()); 168 - $color = HarbormasterBuildable::getBuildableStatusColor( 169 - $buildable->getBuildableStatus()); 170 - $name = HarbormasterBuildable::getBuildableStatusName( 171 - $buildable->getBuildableStatus()); 172 - 173 - $icon_view = id(new PHUIIconView()) 174 - ->setIconFont($icon.' '.$color); 175 - 176 - $tooltip_view = javelin_tag( 177 - 'span', 178 - array( 179 - 'sigil' => 'has-tooltip', 180 - 'meta' => array('tip' => $name), 181 - ), 182 - $icon_view); 183 - 184 - Javelin::initBehavior('phabricator-tooltips'); 185 - 186 - $href_view = phutil_tag( 187 - 'a', 188 - array('href' => '/'.$buildable->getMonogram()), 189 - $tooltip_view); 190 - 191 - $build = $href_view; 192 - 142 + $build = $this->renderBuildable($buildable); 193 143 $has_any_build = true; 194 144 } 195 145 } ··· 214 164 null), 215 165 $author, 216 166 $summary, 217 - $date, 218 - $time, 167 + $committed, 219 168 ); 220 169 } 221 170 ··· 226 175 null, 227 176 pht('Commit'), 228 177 null, 229 - pht('Revision'), 178 + null, 230 179 pht('Author/Committer'), 231 180 pht('Details'), 232 - pht('Date'), 233 - pht('Time'), 181 + pht('Committed'), 234 182 )); 235 183 $view->setColumnClasses( 236 184 array( 237 185 'threads', 238 186 'nudgeright', 239 - 'n', 187 + '', 240 188 'icon', 241 - 'n', 189 + '', 242 190 '', 243 191 'wide', 244 192 '', 245 - 'right', 246 193 )); 247 194 $view->setColumnVisibility( 248 195 array( 249 196 $graph ? true : false, 250 197 true, 251 198 true, 252 - true, 199 + $has_any_build, 253 200 $show_revisions, 254 201 )); 255 202 $view->setDeviceVisibility( ··· 261 208 true, 262 209 false, 263 210 true, 264 - false, 265 211 false, 266 212 )); 267 213 return $view->render();
+44 -16
src/applications/diffusion/view/DiffusionTagListView.php
··· 29 29 $drequest = $this->getDiffusionRequest(); 30 30 $repository = $drequest->getRepository(); 31 31 32 + $buildables = $this->loadBuildables($this->commits); 33 + $has_builds = false; 32 34 33 35 $rows = array(); 34 36 foreach ($this->tags as $tag) { ··· 80 82 } 81 83 } 82 84 85 + $build = null; 86 + if ($commit) { 87 + $buildable = idx($buildables, $commit->getPHID()); 88 + if ($buildable) { 89 + $build = $this->renderBuildable($buildable); 90 + $has_builds = true; 91 + } 92 + } 93 + 94 + $history = $this->linkTagHistory($tag->getName()); 95 + 83 96 $rows[] = array( 97 + $history, 84 98 $tag_link, 85 99 $commit_link, 86 - $description, 100 + $build, 87 101 $author, 102 + $description, 88 103 phabricator_datetime($tag->getEpoch(), $this->user), 89 104 ); 90 105 } 91 106 92 - $table = new AphrontTableView($rows); 93 - $table->setHeaders( 94 - array( 95 - pht('Tag'), 96 - pht('Commit'), 97 - pht('Description'), 98 - pht('Author'), 99 - pht('Created'), 100 - )); 101 - $table->setColumnClasses( 102 - array( 103 - 'pri', 104 - '', 105 - 'wide', 106 - )); 107 + $table = id(new AphrontTableView($rows)) 108 + ->setHeaders( 109 + array( 110 + null, 111 + pht('Tag'), 112 + pht('Commit'), 113 + null, 114 + pht('Author'), 115 + pht('Description'), 116 + pht('Created'), 117 + )) 118 + ->setColumnClasses( 119 + array( 120 + 'nudgeright', 121 + 'pri', 122 + '', 123 + '', 124 + '', 125 + 'wide', 126 + )) 127 + ->setColumnVisibility( 128 + array( 129 + true, 130 + true, 131 + true, 132 + $has_builds, 133 + )); 134 + 107 135 return $table->render(); 108 136 } 109 137
+79 -1
src/applications/diffusion/view/DiffusionView.php
··· 20 20 'path' => $path, 21 21 )); 22 22 23 + return $this->renderHistoryLink($href); 24 + } 25 + 26 + final public function linkBranchHistory($branch) { 27 + $href = $this->getDiffusionRequest()->generateURI( 28 + array( 29 + 'action' => 'history', 30 + 'branch' => $branch, 31 + )); 32 + 33 + return $this->renderHistoryLink($href); 34 + } 35 + 36 + final public function linkTagHistory($tag) { 37 + $href = $this->getDiffusionRequest()->generateURI( 38 + array( 39 + 'action' => 'history', 40 + 'commit' => $tag, 41 + )); 42 + 43 + return $this->renderHistoryLink($href); 44 + } 45 + 46 + private function renderHistoryLink($href) { 23 47 return javelin_tag( 24 48 'a', 25 49 array( ··· 31 55 'align' => 'E', 32 56 ), 33 57 ), 34 - id(new PHUIIconView())->setIconFont('fa-list-ul blue')); 58 + id(new PHUIIconView())->setIconFont('fa-history bluegrey')); 35 59 } 36 60 37 61 final public function linkBrowse($path, array $details = array()) { ··· 168 192 $email->getDisplayName()); 169 193 } 170 194 return hsprintf('%s', $name); 195 + } 196 + 197 + final protected function renderBuildable(HarbormasterBuildable $buildable) { 198 + $status = $buildable->getBuildableStatus(); 199 + 200 + $icon = HarbormasterBuildable::getBuildableStatusIcon($status); 201 + $color = HarbormasterBuildable::getBuildableStatusColor($status); 202 + $name = HarbormasterBuildable::getBuildableStatusName($status); 203 + 204 + $icon_view = id(new PHUIIconView()) 205 + ->setIconFont($icon.' '.$color); 206 + 207 + $tooltip_view = javelin_tag( 208 + 'span', 209 + array( 210 + 'sigil' => 'has-tooltip', 211 + 'meta' => array('tip' => $name), 212 + ), 213 + $icon_view); 214 + 215 + Javelin::initBehavior('phabricator-tooltips'); 216 + 217 + return phutil_tag( 218 + 'a', 219 + array('href' => '/'.$buildable->getMonogram()), 220 + $tooltip_view); 221 + } 222 + 223 + final protected function loadBuildables(array $commits) { 224 + assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 225 + 226 + if (!$commits) { 227 + return array(); 228 + } 229 + 230 + $viewer = $this->getUser(); 231 + 232 + $harbormaster_app = 'PhabricatorHarbormasterApplication'; 233 + $have_harbormaster = PhabricatorApplication::isClassInstalledForViewer( 234 + $harbormaster_app, 235 + $viewer); 236 + 237 + if ($have_harbormaster) { 238 + $buildables = id(new HarbormasterBuildableQuery()) 239 + ->setViewer($viewer) 240 + ->withBuildablePHIDs(mpull($commits, 'getPHID')) 241 + ->withManualBuildables(false) 242 + ->execute(); 243 + $buildables = mpull($buildables, null, 'getBuildablePHID'); 244 + } else { 245 + $buildables = array(); 246 + } 247 + 248 + return $buildables; 171 249 } 172 250 173 251 }