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

Modernize Diffusion "history" view

Summary: Fixes T903. Knock out the side nav, make it policy-aware, other minor cleanup.

Test Plan: See below.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T903

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

+103 -44
+1 -1
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 65 65 66 66 $header = id(new PHUIHeaderView()) 67 67 ->setUser($viewer) 68 - ->setHeader($this->renderPathLinks($drequest, 'browse')) 68 + ->setHeader($this->renderPathLinks($drequest, $mode = 'browse')) 69 69 ->setPolicyObject($drequest->getRepository()); 70 70 71 71 return $header;
+2 -7
src/applications/diffusion/controller/DiffusionChangeController.php
··· 73 73 'view' => 'change', 74 74 )); 75 75 76 - $links = $this->renderPathLinks($drequest); 76 + $links = $this->renderPathLinks($drequest, $mode = 'browse'); 77 77 78 78 $header = id(new PHUIHeaderView()) 79 79 ->setHeader($links) ··· 106 106 'action' => 'history', 107 107 )); 108 108 109 - $browse_uri = $drequest->generateURI( 110 - array( 111 - 'action' => 'browse', 112 - )); 113 - 114 109 $view->addAction( 115 110 id(new PhabricatorActionView()) 116 111 ->setName(pht('View History')) 117 112 ->setHref($history_uri) 118 113 ->setIcon('history')); 119 114 120 - $history_uri = $drequest->generateURI( 115 + $browse_uri = $drequest->generateURI( 121 116 array( 122 117 'action' => 'browse', 123 118 ));
+4 -4
src/applications/diffusion/controller/DiffusionController.php
··· 202 202 $crumb = id(new PhabricatorCrumbView()) 203 203 ->setName($view_name); 204 204 205 - if ($view == 'browse' || $view == 'change') { 205 + if ($view == 'browse' || $view == 'change' || $view == 'history') { 206 206 $crumb_list[] = $crumb; 207 207 return $crumb_list; 208 208 } ··· 286 286 return $this->getApplicationURI($repository->getCallsign().'/'.$path); 287 287 } 288 288 289 - protected function renderPathLinks(DiffusionRequest $drequest) { 289 + protected function renderPathLinks(DiffusionRequest $drequest, $action) { 290 290 $path = $drequest->getPath(); 291 291 $path_parts = array_filter(explode('/', trim($path, '/'))); 292 292 ··· 297 297 array( 298 298 'href' => $drequest->generateURI( 299 299 array( 300 - 'action' => 'browse', 300 + 'action' => $action, 301 301 'path' => '', 302 302 )), 303 303 ), ··· 315 315 array( 316 316 'href' => $drequest->generateURI( 317 317 array( 318 - 'action' => 'browse', 318 + 'action' => $action, 319 319 'path' => $accum, 320 320 )), 321 321 ),
+96 -32
src/applications/diffusion/controller/DiffusionHistoryController.php
··· 2 2 3 3 final class DiffusionHistoryController extends DiffusionController { 4 4 5 + public function shouldAllowPublic() { 6 + return true; 7 + } 8 + 5 9 public function processRequest() { 6 10 $drequest = $this->diffusionRequest; 7 11 $request = $this->getRequest(); 12 + $viewer = $request->getUser(); 13 + $repository = $drequest->getRepository(); 8 14 9 15 $page_size = $request->getInt('pagesize', 100); 10 - $offset = $request->getInt('page', 0); 16 + $offset = $request->getInt('offset', 0); 11 17 12 18 $params = array( 13 19 'commit' => $drequest->getCommit(), 14 20 'path' => $drequest->getPath(), 15 21 'offset' => $offset, 16 22 'limit' => $page_size + 1); 23 + 17 24 if (!$request->getBool('copies')) { 18 25 $params['needDirectChanges'] = true; 19 26 $params['needChildChanges'] = true; ··· 28 35 $pager = new AphrontPagerView(); 29 36 $pager->setPageSize($page_size); 30 37 $pager->setOffset($offset); 31 - if (count($history) == $page_size + 1) { 32 - array_pop($history); 33 - $pager->setHasMorePages(true); 34 - } else { 35 - $pager->setHasMorePages(false); 36 - } 37 - $pager->setURI($request->getRequestURI(), 'page'); 38 + $history = $pager->sliceResults($history); 39 + 40 + $pager->setURI($request->getRequestURI(), 'offset'); 38 41 39 42 $show_graph = !strlen($drequest->getPath()); 40 43 $content = array(); 41 44 42 - if ($request->getBool('copies')) { 43 - $button_title = pht('Hide Copies/Branches'); 44 - $copies_new = null; 45 - } else { 46 - $button_title = pht('Show Copies/Branches'); 47 - $copies_new = true; 48 - } 49 - 50 - $button = phutil_tag( 51 - 'a', 52 - array( 53 - 'class' => 'button small grey', 54 - 'href' => $request->getRequestURI()->alter('copies', $copies_new), 55 - ), 56 - $button_title); 57 - 58 45 $history_table = new DiffusionHistoryTableView(); 59 46 $history_table->setUser($request->getUser()); 60 47 $history_table->setDiffusionRequest($drequest); ··· 71 58 } 72 59 73 60 $history_panel = new AphrontPanelView(); 74 - $history_panel->setHeader(pht('History')); 75 - $history_panel->addButton($button); 76 61 $history_panel->appendChild($history_table); 77 62 $history_panel->appendChild($pager); 78 63 $history_panel->setNoBackground(); 79 64 80 65 $content[] = $history_panel; 81 66 82 - // TODO: Sometimes we do have a change view, we need to look at the most 83 - // recent history entry to figure it out. 67 + $header = id(new PHUIHeaderView()) 68 + ->setUser($viewer) 69 + ->setPolicyObject($repository) 70 + ->setHeader($this->renderPathLinks($drequest, $mode = 'history')); 71 + 72 + $actions = $this->buildActionView($drequest); 73 + $properties = $this->buildPropertyView($drequest); 84 74 85 - $nav = $this->buildSideNav('history', false); 86 - $nav->appendChild($content); 87 75 $crumbs = $this->buildCrumbs( 88 76 array( 89 77 'branch' => true, 90 78 'path' => true, 91 79 'view' => 'history', 92 80 )); 93 - $nav->setCrumbs($crumbs); 94 81 95 82 return $this->buildApplicationPage( 96 - $nav, 83 + array( 84 + $crumbs, 85 + $header, 86 + $actions, 87 + $properties, 88 + $content, 89 + ), 97 90 array( 98 91 'device' => true, 99 92 'title' => array( ··· 102 95 ), 103 96 )); 104 97 } 98 + 99 + private function buildActionView(DiffusionRequest $drequest) { 100 + $viewer = $this->getRequest()->getUser(); 101 + 102 + $view = id(new PhabricatorActionListView()) 103 + ->setUser($viewer); 104 + 105 + $browse_uri = $drequest->generateURI( 106 + array( 107 + 'action' => 'browse', 108 + )); 109 + 110 + $view->addAction( 111 + id(new PhabricatorActionView()) 112 + ->setName(pht('Browse Content')) 113 + ->setHref($browse_uri) 114 + ->setIcon('file')); 115 + 116 + // TODO: Sometimes we do have a change view, we need to look at the most 117 + // recent history entry to figure it out. 118 + 119 + $request = $this->getRequest(); 120 + if ($request->getBool('copies')) { 121 + $branch_name = pht('Hide Copies/Branches'); 122 + $branch_icon = 'fork-grey'; 123 + $branch_uri = $request->getRequestURI() 124 + ->alter('offset', null) 125 + ->alter('copies', null); 126 + } else { 127 + $branch_name = pht('Show Copies/Branches'); 128 + $branch_icon = 'fork'; 129 + $branch_uri = $request->getRequestURI() 130 + ->alter('offset', null) 131 + ->alter('copies', true); 132 + } 133 + 134 + $view->addAction( 135 + id(new PhabricatorActionView()) 136 + ->setName($branch_name) 137 + ->setIcon($branch_icon) 138 + ->setHref($branch_uri)); 139 + 140 + return $view; 141 + } 142 + 143 + protected function buildPropertyView(DiffusionRequest $drequest) { 144 + $viewer = $this->getRequest()->getUser(); 145 + 146 + $view = id(new PhabricatorPropertyListView()) 147 + ->setUser($viewer); 148 + 149 + $stable_commit = $drequest->getStableCommitName(); 150 + $callsign = $drequest->getRepository()->getCallsign(); 151 + 152 + $view->addProperty( 153 + pht('Commit'), 154 + phutil_tag( 155 + 'a', 156 + array( 157 + 'href' => $drequest->generateURI( 158 + array( 159 + 'action' => 'commit', 160 + 'commit' => $stable_commit, 161 + )), 162 + ), 163 + $drequest->getRepository()->formatCommitName($stable_commit))); 164 + 165 + return $view; 166 + } 167 + 168 + 105 169 106 170 }