@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 browse views

Summary: Broadly, I'm trying to modernize these views and fix UI and at least mitigate mobile problems. See discussion.

Test Plan: See screenshots.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

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

+195 -54
+2 -1
src/applications/diffusion/conduit/ConduitAPI_diffusion_tagsquery_Method.php
··· 26 26 protected function getGitResult(ConduitAPIRequest $request) { 27 27 $drequest = $this->getDiffusionRequest(); 28 28 $repository = $drequest->getRepository(); 29 - $commit = $drequest->getCommit(); 29 + $commit = $drequest->getRawCommit(); 30 + 30 31 $offset = $request->getValue('offset'); 31 32 $limit = $request->getValue('limit'); 32 33
+156 -22
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 29 29 30 30 $content = array(); 31 31 32 - if ($drequest->getTagContent()) { 33 - $title = pht('Tag: %s', $drequest->getSymbolicCommit()); 34 - 35 - $tag_view = new AphrontPanelView(); 36 - $tag_view->setHeader($title); 37 - $tag_view->appendChild( 38 - $this->markupText($drequest->getTagContent())); 39 - 40 - $content[] = $tag_view; 41 - } 32 + $content[] = $this->buildHeaderView($drequest); 33 + $content[] = $this->buildActionView($drequest); 34 + $content[] = $this->buildPropertyView($drequest); 42 35 43 36 $content[] = $this->renderSearchForm(); 44 37 45 38 if ($this->getRequest()->getStr('grep') != '') { 46 39 $content[] = $this->renderSearchResults(); 47 - 48 40 } else { 49 41 if (!$results->isValidResults()) { 50 42 $empty_result = new DiffusionEmptyResultView(); ··· 52 44 $empty_result->setDiffusionBrowseResultSet($results); 53 45 $empty_result->setView($this->getRequest()->getStr('view')); 54 46 $content[] = $empty_result; 55 - 56 47 } else { 57 - 58 48 $phids = array(); 59 49 foreach ($results->getPaths() as $result) { 60 50 $data = $result->getLastCommitData(); ··· 103 93 $box, 104 94 ); 105 95 } 106 - 107 96 } 108 - 109 - $nav = $this->buildSideNav('browse', false); 110 - $nav->appendChild($content); 111 97 112 98 $crumbs = $this->buildCrumbs( 113 99 array( ··· 115 101 'path' => true, 116 102 'view' => 'browse', 117 103 )); 118 - $nav->setCrumbs($crumbs); 104 + 119 105 return $this->buildApplicationPage( 120 - $nav, 106 + array( 107 + $crumbs, 108 + $content, 109 + ), 121 110 array( 122 111 'device' => true, 123 112 'title' => array( ··· 146 135 ->setLabel(pht('Search Here')) 147 136 ->setName('grep') 148 137 ->setValue($this->getRequest()->getStr('grep')) 149 - ->setCaption(pht('Regular expression'))) 138 + ->setCaption(pht('Enter a regular expression.'))) 150 139 ->appendChild( 151 140 id(new AphrontFormSubmitControl()) 152 - ->setValue(pht('Grep'))); 141 + ->setValue(pht('Search File Content'))); 153 142 break; 154 143 } 155 144 156 145 $filter = new AphrontListFilterView(); 157 146 $filter->appendChild($form); 147 + 148 + if (!strlen($this->getRequest()->getStr('grep'))) { 149 + $filter->setCollapsed( 150 + pht('Show Search'), 151 + pht('Hide Search'), 152 + pht('Search for file content in this directory.'), 153 + '#'); 154 + } 158 155 159 156 return $filter; 160 157 } ··· 249 246 ->setNoDataString($no_data); 250 247 251 248 return id(new AphrontPanelView()) 252 - ->setHeader(pht('Search Results')) 249 + ->setNoBackground(true) 253 250 ->appendChild($table) 254 251 ->appendChild($pager); 255 252 } ··· 268 265 $text); 269 266 270 267 return $text; 268 + } 269 + 270 + private function buildHeaderView(DiffusionRequest $drequest) { 271 + $viewer = $this->getRequest()->getUser(); 272 + 273 + $header = id(new PHUIHeaderView()) 274 + ->setUser($viewer) 275 + ->setHeader($this->renderPathLinks($drequest)) 276 + ->setPolicyObject($drequest->getRepository()); 277 + 278 + return $header; 279 + } 280 + 281 + private function buildActionView(DiffusionRequest $drequest) { 282 + $viewer = $this->getRequest()->getUser(); 283 + 284 + $view = id(new PhabricatorActionListView()) 285 + ->setUser($viewer); 286 + 287 + $history_uri = $drequest->generateURI( 288 + array( 289 + 'action' => 'history', 290 + )); 291 + 292 + $view->addAction( 293 + id(new PhabricatorActionView()) 294 + ->setName(pht('View History')) 295 + ->setHref($history_uri) 296 + ->setIcon('perflab')); 297 + 298 + $behind_head = $drequest->getRawCommit(); 299 + $head_uri = $drequest->generateURI( 300 + array( 301 + 'commit' => '', 302 + 'action' => 'browse', 303 + )); 304 + $view->addAction( 305 + id(new PhabricatorActionView()) 306 + ->setName(pht('Jump to HEAD')) 307 + ->setHref($head_uri) 308 + ->setIcon('home') 309 + ->setDisabled(!$behind_head)); 310 + 311 + // TODO: Ideally, this should live in Owners and be event-triggered, but 312 + // there's no reasonable object for it to react to right now. 313 + 314 + $owners_uri = id(new PhutilURI('/owners/view/search/')) 315 + ->setQueryParams( 316 + array( 317 + 'repository' => $drequest->getCallsign(), 318 + 'path' => '/'.$drequest->getPath(), 319 + )); 320 + 321 + $view->addAction( 322 + id(new PhabricatorActionView()) 323 + ->setName(pht('Find Owners')) 324 + ->setHref((string)$owners_uri) 325 + ->setIcon('preview')); 326 + 327 + return $view; 328 + } 329 + 330 + private function buildPropertyView(DiffusionRequest $drequest) { 331 + $viewer = $this->getRequest()->getUser(); 332 + 333 + $view = id(new PhabricatorPropertyListView()) 334 + ->setUser($viewer); 335 + 336 + $stable_commit = $drequest->getStableCommitName(); 337 + $callsign = $drequest->getRepository()->getCallsign(); 338 + 339 + $view->addProperty( 340 + pht('Commit'), 341 + phutil_tag( 342 + 'a', 343 + array( 344 + 'href' => $drequest->generateURI( 345 + array( 346 + 'action' => 'commit', 347 + 'commit' => $stable_commit, 348 + )), 349 + ), 350 + $drequest->getRepository()->formatCommitName($stable_commit))); 351 + 352 + if ($drequest->getTagContent()) { 353 + $view->addProperty( 354 + pht('Tag'), 355 + $drequest->getSymbolicCommit()); 356 + 357 + $view->addSectionHeader(pht('Tag Content')); 358 + $view->addTextContent($this->markupText($drequest->getTagContent())); 359 + } 360 + 361 + return $view; 362 + } 363 + 364 + private function renderPathLinks(DiffusionRequest $drequest) { 365 + $path = $drequest->getPath(); 366 + $path_parts = array_filter(explode('/', trim($path, '/'))); 367 + 368 + $links = array(); 369 + if ($path_parts) { 370 + $links[] = phutil_tag( 371 + 'a', 372 + array( 373 + 'href' => $drequest->generateURI( 374 + array( 375 + 'action' => 'browse', 376 + 'path' => '', 377 + )), 378 + ), 379 + 'r'.$drequest->getRepository()->getCallsign().'/'); 380 + $accum = ''; 381 + $last_key = last_key($path_parts); 382 + foreach ($path_parts as $key => $part) { 383 + $links[] = ' '; 384 + $accum .= '/'.$part; 385 + if ($key === $last_key) { 386 + $links[] = $part; 387 + } else { 388 + $links[] = phutil_tag( 389 + 'a', 390 + array( 391 + 'href' => $drequest->generateURI( 392 + array( 393 + 'action' => 'browse', 394 + 'path' => $accum, 395 + )), 396 + ), 397 + $part.'/'); 398 + } 399 + } 400 + } else { 401 + $links[] = 'r'.$drequest->getRepository()->getCallsign().'/'; 402 + } 403 + 404 + return $links; 271 405 } 272 406 273 407 }
+31 -30
src/applications/diffusion/controller/DiffusionController.php
··· 259 259 260 260 $crumb = id(new PhabricatorCrumbView()) 261 261 ->setName($view_name); 262 - if (!strlen($path)) { 263 - $crumb_list[] = $crumb; 264 - } else { 265 262 266 - $crumb->setHref($drequest->generateURI( 267 - array( 268 - 'path' => '', 269 - ) + $uri_params)); 263 + if ($view == 'browse') { 270 264 $crumb_list[] = $crumb; 265 + return $crumb_list; 266 + } 267 + 268 + $crumb->setHref($drequest->generateURI( 269 + array( 270 + 'path' => '', 271 + ) + $uri_params)); 272 + $crumb_list[] = $crumb; 271 273 272 - $path_parts = explode('/', $path); 273 - do { 274 - $last = array_pop($path_parts); 275 - } while ($last == ''); 274 + $path_parts = explode('/', $path); 275 + do { 276 + $last = array_pop($path_parts); 277 + } while (count($path_parts) && $last == ''); 276 278 277 - $path_sections = array(); 278 - $thus_far = ''; 279 - foreach ($path_parts as $path_part) { 280 - $thus_far .= $path_part.'/'; 281 - $path_sections[] = '/'; 282 - $path_sections[] = phutil_tag( 283 - 'a', 284 - array( 285 - 'href' => $drequest->generateURI( 286 - array( 287 - 'path' => $thus_far, 288 - ) + $uri_params), 289 - ), 290 - $path_part); 291 - } 279 + $path_sections = array(); 280 + $thus_far = ''; 281 + foreach ($path_parts as $path_part) { 282 + $thus_far .= $path_part.'/'; 283 + $path_sections[] = '/'; 284 + $path_sections[] = phutil_tag( 285 + 'a', 286 + array( 287 + 'href' => $drequest->generateURI( 288 + array( 289 + 'path' => $thus_far, 290 + ) + $uri_params), 291 + ), 292 + $path_part); 293 + } 292 294 293 - $path_sections[] = '/'.$last; 295 + $path_sections[] = '/'.$last; 294 296 295 - $crumb_list[] = id(new PhabricatorCrumbView()) 296 - ->setName($path_sections); 297 - } 297 + $crumb_list[] = id(new PhabricatorCrumbView()) 298 + ->setName($path_sections); 298 299 299 300 $last_crumb = array_pop($crumb_list); 300 301
+6 -1
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 238 238 $tags = DiffusionRepositoryTag::newFromConduit( 239 239 $this->callConduitWithDiffusionRequest( 240 240 'diffusion.tagsquery', 241 - array('limit' => $tag_limit + 1))); 241 + array( 242 + // On the home page, we want to find tags on any branch. 243 + 'commit' => null, 244 + 'limit' => $tag_limit + 1, 245 + ))); 242 246 } catch (ConduitException $e) { 243 247 if ($e->getMessage() != 'ERR-UNSUPPORTED-VCS') { 244 248 throw $e; ··· 271 275 272 276 $panel = new AphrontPanelView(); 273 277 $panel->setHeader(pht('Tags')); 278 + $panel->setNoBackground(true); 274 279 275 280 if ($more_tags) { 276 281 $panel->setCaption(pht('Showing the %d most recent tags.', $tag_limit));