@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 tabs to Diffusion for consistent navigation

Summary:
Adds a responsive tab bar navigation to Diffusion. Working through the new design here in pieces, so keep in mind M1477 is the target. Notably:

- Removes "branches" and "tags" from RevisionView, now on tabs
- Keeps "browse", "history", "readme" on RevisionView
- Adds tabs for all main views, including Graph... unless how that feels, so let me know.

Test Plan: Browse all pages, desktop and mobile. Test hg, svn, git repositories.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+112 -248
+3
src/applications/diffusion/controller/DiffusionBranchTableController.php
··· 71 71 ->setHeader(pht('Branches')) 72 72 ->setHeaderIcon('fa-code-fork'); 73 73 74 + $tabs = $this->buildTabsView('branch'); 75 + 74 76 $view = id(new PHUITwoColumnView()) 75 77 ->setHeader($header) 78 + ->setTabs($tabs) 76 79 ->setFooter(array( 77 80 $content, 78 81 ));
+75 -5
src/applications/diffusion/controller/DiffusionController.php
··· 123 123 private function buildCrumbList(array $spec = array()) { 124 124 125 125 $spec = $spec + array( 126 - 'commit' => null, 127 - 'tags' => null, 128 - 'branches' => null, 129 - 'view' => null, 126 + 'commit' => null, 127 + 'tags' => null, 128 + 'branches' => null, 129 + 'view' => null, 130 130 ); 131 131 132 132 $crumb_list = array(); ··· 315 315 316 316 protected function renderStatusMessage($title, $body) { 317 317 return id(new PHUIInfoView()) 318 - ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 318 + ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 319 319 ->setTitle($title) 320 320 ->setFlush(true) 321 321 ->appendChild($body); ··· 408 408 ->setUser($this->getViewer()) 409 409 ->setPath($readme_path) 410 410 ->setContent($readme_corpus); 411 + } 412 + 413 + protected function buildTabsView($key) { 414 + $drequest = $this->getDiffusionRequest(); 415 + $repository = $drequest->getRepository(); 416 + 417 + $view = new PHUIListView(); 418 + 419 + $view->addMenuItem( 420 + id(new PHUIListItemView()) 421 + ->setKey('home') 422 + ->setName(pht('Home')) 423 + ->setIcon('fa-home') 424 + ->setHref($drequest->generateURI( 425 + array( 426 + 'action' => 'branch', 427 + 'path' => '/', 428 + ))) 429 + ->setSelected($key == 'home')); 430 + 431 + if (!$repository->isSVN()) { 432 + $view->addMenuItem( 433 + id(new PHUIListItemView()) 434 + ->setKey('branch') 435 + ->setName(pht('Branches')) 436 + ->setIcon('fa-code-fork') 437 + ->setHref($drequest->generateURI( 438 + array( 439 + 'action' => 'branches', 440 + ))) 441 + ->setSelected($key == 'branch')); 442 + } 443 + 444 + if (!$repository->isSVN()) { 445 + $view->addMenuItem( 446 + id(new PHUIListItemView()) 447 + ->setKey('tags') 448 + ->setName(pht('Tags')) 449 + ->setIcon('fa-tags') 450 + ->setHref($drequest->generateURI( 451 + array( 452 + 'action' => 'tags', 453 + ))) 454 + ->setSelected($key == 'tags')); 455 + } 456 + 457 + $view->addMenuItem( 458 + id(new PHUIListItemView()) 459 + ->setKey('history') 460 + ->setName(pht('History')) 461 + ->setIcon('fa-history') 462 + ->setHref($drequest->generateURI( 463 + array( 464 + 'action' => 'history', 465 + ))) 466 + ->setSelected($key == 'history')); 467 + 468 + $view->addMenuItem( 469 + id(new PHUIListItemView()) 470 + ->setKey('graph') 471 + ->setName(pht('Graph')) 472 + ->setIcon('fa-code-fork') 473 + ->setHref($drequest->generateURI( 474 + array( 475 + 'action' => 'graph', 476 + ))) 477 + ->setSelected($key == 'graph')); 478 + 479 + return $view; 480 + 411 481 } 412 482 413 483 }
+11 -16
src/applications/diffusion/controller/DiffusionGraphController.php
··· 68 68 ->setTable($graph) 69 69 ->setPager($pager); 70 70 71 + $tabs = $this->buildTabsView('graph'); 72 + 71 73 $view = id(new PHUITwoColumnView()) 72 74 ->setHeader($header) 75 + ->setTabs($tabs) 73 76 ->setFooter($graph_view); 74 77 75 78 return $this->newPage() ··· 81 84 private function buildHeader(DiffusionRequest $drequest) { 82 85 $viewer = $this->getViewer(); 83 86 84 - $tag = $this->renderCommitHashTag($drequest); 85 - $history_uri = $drequest->generateURI( 86 - array( 87 - 'action' => 'history', 88 - )); 89 - 90 - $history_button = id(new PHUIButtonView()) 91 - ->setTag('a') 92 - ->setText(pht('History')) 93 - ->setHref($history_uri) 94 - ->setIcon('fa-history'); 87 + $no_path = !strlen($drequest->getPath()); 88 + if ($no_path) { 89 + $header_text = pht('Graph'); 90 + } else { 91 + $header_text = $this->renderPathLinks($drequest, $mode = 'history'); 92 + } 95 93 96 94 $header = id(new PHUIHeaderView()) 97 95 ->setUser($viewer) 98 - ->setPolicyObject($drequest->getRepository()) 99 - ->addTag($tag) 100 - ->setHeader($this->renderPathLinks($drequest, $mode = 'history')) 101 - ->setHeaderIcon('fa-code-fork') 102 - ->addActionLink($history_button); 96 + ->setHeader($header_text) 97 + ->setHeaderIcon('fa-code-fork'); 103 98 104 99 return $header; 105 100
+10 -19
src/applications/diffusion/controller/DiffusionHistoryController.php
··· 59 59 ->addClass('mlb') 60 60 ->appendChild($pager); 61 61 62 + $tabs = $this->buildTabsView('history'); 63 + 62 64 $view = id(new PHUITwoColumnView()) 63 65 ->setHeader($header) 66 + ->setTabs($tabs) 64 67 ->setFooter(array( 65 68 $history_list, 66 69 $pager, ··· 76 79 private function buildHeader(DiffusionRequest $drequest) { 77 80 $viewer = $this->getViewer(); 78 81 79 - $tag = $this->renderCommitHashTag($drequest); 80 - $show_graph = !strlen($drequest->getPath()); 82 + $no_path = !strlen($drequest->getPath()); 83 + if ($no_path) { 84 + $header_text = pht('History'); 85 + } else { 86 + $header_text = $this->renderPathLinks($drequest, $mode = 'history'); 87 + } 81 88 82 89 $header = id(new PHUIHeaderView()) 83 90 ->setUser($viewer) 84 - ->setPolicyObject($drequest->getRepository()) 85 - ->addTag($tag) 86 - ->setHeader($this->renderPathLinks($drequest, $mode = 'history')) 91 + ->setHeader($header_text) 87 92 ->setHeaderIcon('fa-clock-o'); 88 - 89 - if ($show_graph) { 90 - $graph_uri = $drequest->generateURI( 91 - array( 92 - 'action' => 'graph', 93 - )); 94 - 95 - $graph_button = id(new PHUIButtonView()) 96 - ->setTag('a') 97 - ->setText(pht('Graph')) 98 - ->setHref($graph_uri) 99 - ->setIcon('fa-code-fork'); 100 - $header->addActionLink($graph_button); 101 - } 102 93 103 94 return $header; 104 95
+10 -208
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 84 84 ->setErrors(array($empty_message)); 85 85 } 86 86 87 + $tabs = $this->buildTabsView('home'); 88 + 87 89 $view = id(new PHUITwoColumnView()) 88 90 ->setHeader($header) 89 91 ->setCurtain($curtain) 92 + ->setTabs($tabs) 90 93 ->setMainColumn(array( 91 94 $property_table, 92 95 $description, ··· 134 137 'limit' => $browse_pager->getPageSize() + 1, 135 138 )); 136 139 137 - if ($this->needTagFuture()) { 138 - $tag_limit = $this->getTagLimit(); 139 - $this->tagFuture = $this->callConduitMethod( 140 - 'diffusion.tagsquery', 141 - array( 142 - // On the home page, we want to find tags on any branch. 143 - 'commit' => null, 144 - 'limit' => $tag_limit + 1, 145 - )); 146 - } 147 - 148 - if ($this->needBranchFuture()) { 149 - $branch_limit = $this->getBranchLimit(); 150 - $this->branchFuture = $this->callConduitMethod( 151 - 'diffusion.branchquery', 152 - array( 153 - 'closed' => false, 154 - 'limit' => $branch_limit + 1, 155 - )); 156 - } 157 - 158 140 $futures = array( 159 141 $this->historyFuture, 160 142 $this->browseFuture, 161 - $this->tagFuture, 162 - $this->branchFuture, 163 143 ); 164 144 $futures = array_filter($futures); 165 145 $futures = new FutureIterator($futures); ··· 241 221 $history, 242 222 $history_exception); 243 223 244 - try { 245 - $content[] = $this->buildTagListTable($drequest); 246 - } catch (Exception $ex) { 247 - if (!$repository->isImporting()) { 248 - $content[] = $this->renderStatusMessage( 249 - pht('Unable to Load Tags'), 250 - $ex->getMessage()); 251 - } 252 - } 253 - 254 - try { 255 - $content[] = $this->buildBranchListTable($drequest); 256 - } catch (Exception $ex) { 257 - if (!$repository->isImporting()) { 258 - $content[] = $this->renderStatusMessage( 259 - pht('Unable to Load Branches'), 260 - $ex->getMessage()); 261 - } 262 - } 263 - 264 224 if ($readme) { 265 225 $content[] = $readme; 266 226 } ··· 366 326 $this->renderCloneURI($repository, $uri)); 367 327 } 368 328 329 + if (!$view->hasAnyProperties()) { 330 + $view = id(new PHUIInfoView()) 331 + ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 332 + ->appendChild(pht('Repository has no URIs set.')); 333 + } 334 + 369 335 $box = id(new PHUIObjectBoxView()) 370 336 ->setHeaderText(pht('Details')) 371 337 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ··· 412 378 return $box; 413 379 } 414 380 415 - private function buildBranchListTable(DiffusionRequest $drequest) { 416 - $viewer = $this->getViewer(); 417 - 418 - if (!$this->needBranchFuture()) { 419 - return null; 420 - } 421 - 422 - $branches = $this->branchFuture->resolve(); 423 - if (!$branches) { 424 - return null; 425 - } 426 - 427 - $limit = $this->getBranchLimit(); 428 - $more_branches = (count($branches) > $limit); 429 - $branches = array_slice($branches, 0, $limit); 430 - 431 - $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches); 432 - 433 - $commits = id(new DiffusionCommitQuery()) 434 - ->setViewer($viewer) 435 - ->withIdentifiers(mpull($branches, 'getCommitIdentifier')) 436 - ->withRepository($drequest->getRepository()) 437 - ->execute(); 438 - 439 - $table = id(new DiffusionBranchTableView()) 440 - ->setUser($viewer) 441 - ->setDiffusionRequest($drequest) 442 - ->setBranches($branches) 443 - ->setCommits($commits); 444 - 445 - $panel = id(new PHUIObjectBoxView()) 446 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); 447 - $header = new PHUIHeaderView(); 448 - $header->setHeader(pht('Branches')); 449 - 450 - if ($more_branches) { 451 - $header->setSubheader(pht('Showing %d branches.', $limit)); 452 - } 453 - 454 - $button = id(new PHUIButtonView()) 455 - ->setText(pht('Show All')) 456 - ->setTag('a') 457 - ->setIcon('fa-code-fork') 458 - ->setHref($drequest->generateURI( 459 - array( 460 - 'action' => 'branches', 461 - ))); 462 - 463 - $header->addActionLink($button); 464 - $panel->setHeader($header); 465 - $panel->setTable($table); 466 - 467 - return $panel; 468 - } 469 - 470 - private function buildTagListTable(DiffusionRequest $drequest) { 471 - $viewer = $this->getViewer(); 472 - $repository = $drequest->getRepository(); 473 - 474 - if (!$this->needTagFuture()) { 475 - return null; 476 - } 477 - 478 - $tags = $this->tagFuture->resolve(); 479 - $tags = DiffusionRepositoryTag::newFromConduit($tags); 480 - if (!$tags) { 481 - return null; 482 - } 483 - 484 - $tag_limit = $this->getTagLimit(); 485 - $more_tags = (count($tags) > $tag_limit); 486 - $tags = array_slice($tags, 0, $tag_limit); 487 - 488 - $commits = id(new DiffusionCommitQuery()) 489 - ->setViewer($viewer) 490 - ->withIdentifiers(mpull($tags, 'getCommitIdentifier')) 491 - ->withRepository($repository) 492 - ->needCommitData(true) 493 - ->execute(); 494 - 495 - $view = id(new DiffusionTagTableView()) 496 - ->setUser($viewer) 497 - ->setDiffusionRequest($drequest) 498 - ->setTags($tags) 499 - ->setCommits($commits); 500 - 501 - $phids = $view->getRequiredHandlePHIDs(); 502 - $handles = $this->loadViewerHandles($phids); 503 - $view->setHandles($handles); 504 - 505 - $panel = new PHUIObjectBoxView(); 506 - $header = new PHUIHeaderView(); 507 - $header->setHeader(pht('Tags')); 508 - 509 - if ($more_tags) { 510 - $header->setSubheader( 511 - pht('Showing the %d most recent tags.', $tag_limit)); 512 - } 513 - 514 - $button = id(new PHUIButtonView()) 515 - ->setText(pht('Show All Tags')) 516 - ->setTag('a') 517 - ->setIcon('fa-tag') 518 - ->setHref($drequest->generateURI( 519 - array( 520 - 'action' => 'tags', 521 - ))); 522 - 523 - $header->addActionLink($button); 524 - 525 - $panel->setHeader($header); 526 - $panel->setTable($view); 527 - $panel->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); 528 - 529 - return $panel; 530 - } 531 - 532 381 private function buildHistoryTable( 533 382 $history_results, 534 383 $history, ··· 567 416 568 417 $history_table->setIsHead(true); 569 418 570 - $history = id(new PHUIButtonView()) 571 - ->setText(pht('History')) 572 - ->setHref($drequest->generateURI( 573 - array( 574 - 'action' => 'history', 575 - ))) 576 - ->setTag('a') 577 - ->setIcon('fa-history'); 578 - 579 - $graph = id(new PHUIButtonView()) 580 - ->setText(pht('Graph')) 581 - ->setHref($drequest->generateURI( 582 - array( 583 - 'action' => 'graph', 584 - ))) 585 - ->setTag('a') 586 - ->setIcon('fa-code-fork'); 587 - 588 419 $panel = id(new PHUIObjectBoxView()) 589 420 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY); 590 421 $header = id(new PHUIHeaderView()) 591 - ->setHeader(pht('Recent Commits')) 592 - ->addActionLink($graph) 593 - ->addActionLink($history); 422 + ->setHeader(pht('Recent Commits')); 594 423 $panel->setHeader($header); 595 424 $panel->setTable($history_table); 596 425 ··· 721 550 ->setDisplayURI($display); 722 551 } 723 552 724 - private function needTagFuture() { 725 - $drequest = $this->getDiffusionRequest(); 726 - $repository = $drequest->getRepository(); 727 - 728 - switch ($repository->getVersionControlSystem()) { 729 - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 730 - // No tags in SVN. 731 - return false; 732 - } 733 - 734 - return true; 735 - } 736 - 737 553 private function getTagLimit() { 738 - return 15; 739 - } 740 - 741 - private function needBranchFuture() { 742 - $drequest = $this->getDiffusionRequest(); 743 - 744 - if ($drequest->getBranch() === null) { 745 - return false; 746 - } 747 - 748 - return true; 749 - } 750 - 751 - private function getBranchLimit() { 752 554 return 15; 753 555 } 754 556
+3
src/applications/diffusion/controller/DiffusionTagListController.php
··· 88 88 )); 89 89 $crumbs->setBorder(true); 90 90 91 + $tabs = $this->buildTabsView('tags'); 92 + 91 93 $view = id(new PHUITwoColumnView()) 92 94 ->setHeader($header) 95 + ->setTabs($tabs) 93 96 ->setFooter($content); 94 97 95 98 return $this->newPage()