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

Update Diffusion File UI for single column

Summary: Moves browseFile to single column, implements Owners as a list under the file (and now directory as well), improved information listed in Owners, and moves actions into the Diffusion action bar instead of the header.

Test Plan:
Test browsing directories, files, text, images, binaries, enabling blame. Mobile and desktop.

{F5111045}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+183 -110
+4 -4
resources/celerity/map.php
··· 75 75 'rsrc/css/application/diffusion/diffusion-readme.css' => '419dd5b6', 76 76 'rsrc/css/application/diffusion/diffusion-repository.css' => 'ee6f20ec', 77 77 'rsrc/css/application/diffusion/diffusion-source.css' => '750add59', 78 - 'rsrc/css/application/diffusion/diffusion.css' => '58e0704b', 78 + 'rsrc/css/application/diffusion/diffusion.css' => 'ceacf994', 79 79 'rsrc/css/application/feed/feed.css' => 'ecd4ec57', 80 80 'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948', 81 81 'rsrc/css/application/flag/flag.css' => 'bba8f811', ··· 165 165 'rsrc/css/phui/phui-image-mask.css' => 'a8498f9c', 166 166 'rsrc/css/phui/phui-info-view.css' => 'e1b4ec37', 167 167 'rsrc/css/phui/phui-invisible-character-view.css' => '6993d9f0', 168 - 'rsrc/css/phui/phui-left-right.css' => 'f60c67e7', 168 + 'rsrc/css/phui/phui-left-right.css' => '75227a4d', 169 169 'rsrc/css/phui/phui-lightbox.css' => '0a035e40', 170 170 'rsrc/css/phui/phui-list.css' => '38f8c9bd', 171 171 'rsrc/css/phui/phui-object-box.css' => '9cff003c', ··· 570 570 'differential-revision-history-css' => '0e8eb855', 571 571 'differential-revision-list-css' => 'f3c47d33', 572 572 'differential-table-of-contents-css' => 'ae4b7a55', 573 - 'diffusion-css' => '58e0704b', 573 + 'diffusion-css' => 'ceacf994', 574 574 'diffusion-icons-css' => '0c15255e', 575 575 'diffusion-readme-css' => '419dd5b6', 576 576 'diffusion-repository-css' => 'ee6f20ec', ··· 854 854 'phui-info-view-css' => 'e1b4ec37', 855 855 'phui-inline-comment-view-css' => '65ae3bc2', 856 856 'phui-invisible-character-view-css' => '6993d9f0', 857 - 'phui-left-right-css' => 'f60c67e7', 857 + 'phui-left-right-css' => '75227a4d', 858 858 'phui-lightbox-css' => '0a035e40', 859 859 'phui-list-view-css' => '38f8c9bd', 860 860 'phui-object-box-css' => '9cff003c',
+161 -106
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 5 5 private $lintCommit; 6 6 private $lintMessages; 7 7 private $coverage; 8 + private $corpusButtons = array(); 8 9 9 10 public function shouldAllowPublic() { 10 11 return true; ··· 240 241 require_celerity_resource('diffusion-source-css'); 241 242 242 243 // Render the page. 243 - $curtain = $this->buildCurtain($drequest, $show_blame, $show_editor); 244 - $properties = $this->buildPropertyView($drequest); 244 + $bar = $this->buildButtonBar($drequest, $show_blame, $show_editor); 245 245 $header = $this->buildHeaderView($drequest); 246 246 $header->setHeaderIcon('fa-file-code-o'); 247 - 248 - $content = array(); 249 247 250 248 $follow = $request->getStr('follow'); 249 + $follow_notice = null; 251 250 if ($follow) { 252 - $notice = new PHUIInfoView(); 253 - $notice->setSeverity(PHUIInfoView::SEVERITY_WARNING); 254 - $notice->setTitle(pht('Unable to Continue')); 251 + $follow_notice = id(new PHUIInfoView()) 252 + ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 253 + ->setTitle(pht('Unable to Continue')); 255 254 switch ($follow) { 256 255 case 'first': 257 - $notice->appendChild( 256 + $follow_notice->appendChild( 258 257 pht( 259 258 'Unable to continue tracing the history of this file because '. 260 259 'this commit is the first commit in the repository.')); 261 260 break; 262 261 case 'created': 263 - $notice->appendChild( 262 + $follow_notice->appendChild( 264 263 pht( 265 264 'Unable to continue tracing the history of this file because '. 266 265 'this commit created the file.')); 267 266 break; 268 267 } 269 - $content[] = $notice; 270 268 } 271 269 272 270 $renamed = $request->getStr('renamed'); 271 + $renamed_notice = null; 273 272 if ($renamed) { 274 - $notice = new PHUIInfoView(); 275 - $notice->setSeverity(PHUIInfoView::SEVERITY_NOTICE); 276 - $notice->setTitle(pht('File Renamed')); 277 - $notice->appendChild( 278 - pht( 279 - 'File history passes through a rename from "%s" to "%s".', 280 - $drequest->getPath(), 281 - $renamed)); 282 - $content[] = $notice; 273 + $renamed_notice = id(new PHUIInfoView()) 274 + ->setSeverity(PHUIInfoView::SEVERITY_NOTICE) 275 + ->setTitle(pht('File Renamed')) 276 + ->appendChild( 277 + pht( 278 + 'File history passes through a rename from "%s" to "%s".', 279 + $drequest->getPath(), 280 + $renamed)); 283 281 } 284 282 285 - $content[] = $corpus; 286 - $content[] = $this->buildOpenRevisions(); 283 + $open_revisions = $this->buildOpenRevisions(); 284 + $owners_list = $this->buildOwnersList($drequest); 287 285 288 286 $crumbs = $this->buildCrumbs( 289 287 array( ··· 295 293 296 294 $basename = basename($this->getDiffusionRequest()->getPath()); 297 295 $tabs = $this->buildTabsView('code'); 296 + $bar->setRight($this->corpusButtons); 298 297 299 298 $view = id(new PHUITwoColumnView()) 300 299 ->setHeader($header) 301 300 ->setTabs($tabs) 302 - ->setCurtain($curtain) 303 - ->setMainColumn(array( 304 - $content, 305 - )); 306 - 307 - if ($properties) { 308 - $view->addPropertySection(pht('Details'), $properties); 309 - } 301 + ->setFooter(array( 302 + $bar, 303 + $follow_notice, 304 + $renamed_notice, 305 + $corpus, 306 + $open_revisions, 307 + $owners_list, 308 + )); 310 309 311 310 $title = array($basename, $repository->getDisplayName()); 312 311 ··· 330 329 331 330 $reason = $results->getReasonForEmptyResultSet(); 332 331 333 - $actions = $this->getActions($drequest); 332 + $this->buildActionButtons($drequest, true); 334 333 $details = $this->buildPropertyView($drequest); 335 334 336 335 $header = $this->buildHeaderView($drequest); ··· 366 365 367 366 $title = nonempty(basename($drequest->getPath()), '/'); 368 367 $icon = 'fa-folder-open'; 369 - $browse_header = $this->buildPanelHeaderView($title, $icon, $actions); 368 + $browse_header = $this->buildPanelHeaderView($title, $icon); 370 369 371 370 $browse_panel = id(new PHUIObjectBoxView()) 372 371 ->setHeader($browse_header) ··· 393 392 394 393 $crumbs->setBorder(true); 395 394 $tabs = $this->buildTabsView('code'); 395 + $owners_list = $this->buildOwnersList($drequest); 396 + $bar = id(new PHUILeftRightView()) 397 + ->setRight($this->corpusButtons) 398 + ->addClass('diffusion-action-bar'); 396 399 397 400 $view = id(new PHUITwoColumnView()) 398 401 ->setHeader($header) 399 402 ->setTabs($tabs) 400 403 ->setFooter( 401 404 array( 405 + $bar, 402 406 $branch_panel, 403 407 $empty_result, 404 408 $browse_panel, 405 409 $open_revisions, 410 + $owners_list, 406 411 $readme, 407 412 )); 408 413 ··· 637 642 638 643 Javelin::initBehavior('load-blame', array('id' => $id)); 639 644 640 - $file = $this->renderFileButton(); 645 + $this->corpusButtons[] = $this->renderFileButton(); 641 646 $title = basename($this->getDiffusionRequest()->getPath()); 642 647 $icon = 'fa-file-code-o'; 643 648 $drequest = $this->getDiffusionRequest(); 644 - $actions = $this->getActions($drequest); 649 + $this->buildActionButtons($drequest); 645 650 646 - $header = $this->buildPanelHeaderView($title, $icon, $actions); 647 - $header->addActionLink($file); 651 + $header = $this->buildPanelHeaderView($title, $icon); 648 652 649 653 $corpus = id(new PHUIObjectBoxView()) 650 654 ->setHeader($header) ··· 683 687 return $corpus; 684 688 } 685 689 686 - private function buildCurtain( 690 + private function buildButtonBar( 687 691 DiffusionRequest $drequest, 688 692 $show_blame, 689 693 $show_editor) { 690 694 691 - $curtain = $this->newCurtainView($drequest); 692 695 $viewer = $this->getViewer(); 693 696 $base_uri = $this->getRequest()->getRequestURI(); 694 697 ··· 696 699 $repository = $drequest->getRepository(); 697 700 $path = $drequest->getPath(); 698 701 $line = nonempty((int)$drequest->getLine(), 1); 702 + $buttons = array(); 699 703 700 704 $editor_link = $user->loadEditorLink($path, $line, $repository); 701 705 $template = $user->loadEditorLink($path, '%l', $repository); 702 706 703 - $curtain->addAction( 704 - id(new PhabricatorActionView()) 705 - ->setName(pht('Show Last Change')) 707 + $buttons[] = 708 + id(new PHUIButtonView()) 709 + ->setText(pht('Last Change')) 710 + ->setColor(PHUIButtonView::GREY) 706 711 ->setHref( 707 712 $drequest->generateURI( 708 713 array( 709 714 'action' => 'change', 710 715 ))) 711 - ->setIcon('fa-backward')); 716 + ->setIcon('fa-backward'); 712 717 713 718 if ($show_blame) { 714 719 $blame_text = pht('Disable Blame'); ··· 720 725 $blame_value = 1; 721 726 } 722 727 723 - $curtain->addAction( 724 - id(new PhabricatorActionView()) 725 - ->setName($blame_text) 726 - ->setHref($base_uri->alter('blame', $blame_value)) 727 - ->setIcon($blame_icon) 728 - ->setUser($viewer) 729 - ->setRenderAsForm($viewer->isLoggedIn())); 728 + $blame = id(new PHUIButtonView()) 729 + ->setText($blame_text) 730 + ->setIcon($blame_icon) 731 + ->setUser($viewer) 732 + ->setColor(PHUIButtonView::GREY); 733 + 734 + if ($viewer->isLoggedIn()) { 735 + $blame = phabricator_form( 736 + $viewer, 737 + array( 738 + 'action' => $base_uri->alter('blame', $blame_value), 739 + 'method' => 'POST', 740 + 'style' => 'display: inline-block;', 741 + ), 742 + $blame); 743 + } else { 744 + $blame->setTag('a'); 745 + $blame->setHref($base_uri->alter('blame', $blame_value)); 746 + } 747 + $buttons[] = $blame; 730 748 731 - $curtain->addAction( 732 - id(new PhabricatorActionView()) 733 - ->setName(pht('Open in Editor')) 734 - ->setHref($editor_link) 735 - ->setIcon('fa-pencil') 736 - ->setID('editor_link') 737 - ->setMetadata(array('link_template' => $template)) 738 - ->setDisabled(!$editor_link)); 749 + if ($editor_link) { 750 + $buttons[] = 751 + id(new PHUIButtonView()) 752 + ->setTag('a') 753 + ->setText(pht('Open File')) 754 + ->setHref($editor_link) 755 + ->setIcon('fa-pencil') 756 + ->setID('editor_link') 757 + ->setMetadata(array('link_template' => $template)) 758 + ->setDisabled(!$editor_link) 759 + ->setColor(PHUIButtonView::GREY); 760 + } 739 761 740 762 $href = null; 763 + $show_lint = true; 741 764 if ($this->getRequest()->getStr('lint') !== null) { 742 - $lint_text = pht('Hide %d Lint Message(s)', count($this->lintMessages)); 765 + $lint_text = pht('Hide Lint'); 743 766 $href = $base_uri->alter('lint', null); 744 767 745 768 } else if ($this->lintCommit === null) { 746 - $lint_text = pht('Lint not Available'); 769 + $show_lint = false; 747 770 } else { 748 - $lint_text = pht( 749 - 'Show %d Lint Message(s)', 750 - count($this->lintMessages)); 771 + $lint_text = pht('Show Lint'); 751 772 $href = $this->getDiffusionRequest()->generateURI(array( 752 773 'action' => 'browse', 753 774 'commit' => $this->lintCommit, 754 775 ))->alter('lint', ''); 755 776 } 756 777 757 - $curtain->addAction( 758 - id(new PhabricatorActionView()) 759 - ->setName($lint_text) 760 - ->setHref($href) 761 - ->setIcon('fa-exclamation-triangle') 762 - ->setDisabled(!$href)); 778 + if ($show_lint) { 779 + $buttons[] = 780 + id(new PHUIButtonView()) 781 + ->setTag('a') 782 + ->setText($lint_text) 783 + ->setHref($href) 784 + ->setIcon('fa-exclamation-triangle') 785 + ->setDisabled(!$href) 786 + ->setColor(PHUIButtonView::GREY); 787 + } 763 788 789 + $bar = id(new PHUILeftRightView()) 790 + ->setLeft($buttons) 791 + ->addClass('diffusion-action-bar full-mobile-buttons'); 792 + return $bar; 793 + } 764 794 795 + private function buildOwnersList(DiffusionRequest $drequest) { 796 + 797 + $viewer = $this->getViewer(); 765 798 $repository = $drequest->getRepository(); 766 799 767 800 $owners = 'PhabricatorOwnersApplication'; ··· 781 814 $repository->getPHID(), 782 815 $drequest->getPath()); 783 816 817 + $ownership = id(new PHUIObjectItemListView()) 818 + ->setUser($viewer) 819 + ->setNoDataString(pht('No Owners')); 820 + 784 821 if ($packages) { 785 - $ownership = id(new PHUIStatusListView()) 786 - ->setUser($viewer); 822 + foreach ($packages as $package) { 823 + $item = id(new PHUIObjectItemView()) 824 + ->setObject($package) 825 + ->setObjectName($package->getMonogram()) 826 + ->setHeader($package->getName()) 827 + ->setHref($package->getURI()); 828 + 829 + $owners = $package->getOwners(); 830 + if ($owners) { 831 + $owner_list = $viewer->renderHandleList( 832 + mpull($owners, 'getUserPHID')); 833 + } else { 834 + $owner_list = phutil_tag('em', array(), pht('None')); 835 + } 836 + $item->addAttribute(pht('Owners: %s', $owner_list)); 787 837 788 - foreach ($packages as $package) { 789 - $icon = 'fa-list-alt'; 790 - $color = 'grey'; 838 + $auto = $package->getAutoReview(); 839 + $autoreview_map = PhabricatorOwnersPackage::getAutoreviewOptionsMap(); 840 + $spec = idx($autoreview_map, $auto, array()); 841 + $name = idx($spec, 'name', $auto); 842 + $item->addIcon('fa-code', $name); 843 + 844 + if ($package->getAuditingEnabled()) { 845 + $item->addIcon('fa-check', pht('Auditing Enabled')); 846 + } else { 847 + $item->addIcon('fa-ban', pht('No Auditing')); 848 + } 791 849 792 - $item = id(new PHUIStatusItemView()) 793 - ->setIcon($icon, $color) 794 - ->setTarget($viewer->renderHandle($package->getPHID())); 850 + if ($package->isArchived()) { 851 + $item->setDisabled(true); 852 + } 795 853 796 854 $ownership->addItem($item); 797 855 } 798 - } else { 799 - $ownership = phutil_tag('em', array(), pht('None')); 800 856 } 801 857 802 - $curtain->newPanel() 803 - ->setHeaderText(pht('Owners')) 804 - ->appendChild($ownership); 858 + $view = id(new PHUIObjectBoxView()) 859 + ->setHeaderText(pht('Owner Packages')) 860 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 861 + ->setObjectList($ownership); 805 862 } 806 863 807 - return $curtain; 864 + return $view; 808 865 } 809 866 810 867 private function renderFileButton($file_uri = null, $label = null) { ··· 812 869 $base_uri = $this->getRequest()->getRequestURI(); 813 870 814 871 if ($file_uri) { 815 - $text = pht('Download Raw'); 872 + $text = pht('Download File'); 816 873 $href = $file_uri; 817 874 $icon = 'fa-download'; 818 875 } else { 819 - $text = pht('View Raw'); 876 + $text = pht('Raw File'); 820 877 $href = $base_uri->alter('view', 'raw'); 821 878 $icon = 'fa-file-text'; 822 879 } ··· 829 886 ->setTag('a') 830 887 ->setText($text) 831 888 ->setHref($href) 832 - ->setIcon($icon); 889 + ->setIcon($icon) 890 + ->setColor(PHUIButtonView::GREY); 833 891 834 892 return $button; 835 893 } ··· 1258 1316 'src' => $file_uri, 1259 1317 ))); 1260 1318 1261 - $file = $this->renderFileButton($file_uri); 1319 + $this->corpusButtons[] = $this->renderFileButton($file_uri); 1262 1320 $title = basename($this->getDiffusionRequest()->getPath()); 1263 1321 $icon = 'fa-file-image-o'; 1264 1322 $drequest = $this->getDiffusionRequest(); 1265 - $actions = $this->getActions($drequest); 1266 - $header = $this->buildPanelHeaderView($title, $icon, $actions); 1267 - $header->addActionLink($file); 1323 + $this->buildActionButtons($drequest); 1324 + $header = $this->buildPanelHeaderView($title, $icon); 1268 1325 1269 1326 return id(new PHUIObjectBoxView()) 1270 1327 ->setHeader($header) ··· 1279 1336 ->addPadding(PHUI::PADDING_LARGE) 1280 1337 ->appendChild($text); 1281 1338 1282 - $file = $this->renderFileButton($file_uri); 1339 + $this->corpusButtons[] = $this->renderFileButton($file_uri); 1283 1340 $title = basename($this->getDiffusionRequest()->getPath()); 1284 1341 $icon = 'fa-file'; 1285 1342 $drequest = $this->getDiffusionRequest(); 1286 - $actions = $this->getActions($drequest); 1287 - $header = $this->buildPanelHeaderView($title, $icon, $actions); 1288 - $header->addActionLink($file); 1343 + $this->buildActionButtons($drequest); 1344 + $header = $this->buildPanelHeaderView($title, $icon); 1289 1345 1290 1346 $box = id(new PHUIObjectBoxView()) 1291 1347 ->setHeader($header) ··· 1520 1576 return $header; 1521 1577 } 1522 1578 1523 - protected function buildPanelHeaderView($title, $icon, array $actions) { 1579 + protected function buildPanelHeaderView($title, $icon) { 1524 1580 1525 1581 $header = id(new PHUIHeaderView()) 1526 1582 ->setHeader($title) 1527 1583 ->setHeaderIcon($icon) 1528 1584 ->addClass('diffusion-panel-header-view'); 1529 1585 1530 - foreach ($actions as $action_link) { 1531 - if ($action_link) { 1532 - $header->addActionLink($action_link); 1533 - } 1534 - } 1535 1586 return $header; 1536 1587 1537 1588 } 1538 1589 1539 - protected function getActions(DiffusionRequest $drequest) { 1590 + protected function buildActionButtons( 1591 + DiffusionRequest $drequest, 1592 + $is_directory = false) { 1593 + 1540 1594 $viewer = $this->getViewer(); 1541 1595 $repository = $drequest->getRepository(); 1542 1596 $history_uri = $drequest->generateURI(array('action' => 'history')); ··· 1548 1602 'action' => 'browse', 1549 1603 )); 1550 1604 1551 - if ($repository->supportsBranchComparison()) { 1605 + if ($repository->supportsBranchComparison() && $is_directory) { 1552 1606 $compare_uri = $drequest->generateURI(array('action' => 'compare')); 1553 1607 $compare = id(new PHUIButtonView()) 1554 1608 ->setText(pht('Compare')) ··· 1557 1611 ->setTag('a') 1558 1612 ->setHref($compare_uri) 1559 1613 ->setColor(PHUIButtonView::GREY); 1614 + $this->corpusButtons[] = $compare; 1560 1615 } 1561 1616 1562 1617 $head = null; ··· 1566 1621 ->setHref($head_uri) 1567 1622 ->setIcon('fa-home') 1568 1623 ->setColor(PHUIButtonView::GREY); 1624 + $this->corpusButtons[] = $head; 1569 1625 } 1570 1626 1571 1627 $history = id(new PHUIButtonView()) ··· 1574 1630 ->setTag('a') 1575 1631 ->setIcon('fa-history') 1576 1632 ->setColor(PHUIButtonView::GREY); 1633 + $this->corpusButtons[] = $history; 1577 1634 1578 - return array($history, $compare, $head); 1579 1635 } 1580 1636 1581 1637 protected function buildPropertyView( ··· 1779 1835 $title = basename($this->getDiffusionRequest()->getPath()); 1780 1836 $icon = 'fa-archive'; 1781 1837 $drequest = $this->getDiffusionRequest(); 1782 - $actions = $this->getActions($drequest); 1783 - $header = $this->buildPanelHeaderView($title, $icon, $actions); 1838 + $this->buildActionButtons($drequest); 1839 + $header = $this->buildPanelHeaderView($title, $icon); 1784 1840 1785 1841 $severity = PHUIInfoView::SEVERITY_NOTICE; 1786 1842 ··· 1792 1848 try { 1793 1849 $file = $this->loadGitLFSFile($ref); 1794 1850 $data = $this->renderGitLFSButton(); 1795 - $header->addActionLink($data); 1796 1851 } catch (Exception $ex) { 1797 1852 $severity = PHUIInfoView::SEVERITY_ERROR; 1798 1853 $messages[] = pht('The data for this file could not be loaded.'); 1799 1854 } 1800 1855 1801 - $raw = $this->renderFileButton(null, pht('View Raw LFS Pointer')); 1802 - $header->addActionLink($raw); 1856 + $this->corpusButtons[] = $this->renderFileButton( 1857 + null, pht('View Raw LFS Pointer')); 1803 1858 1804 1859 $corpus = id(new PHUIObjectBoxView()) 1805 1860 ->setHeader($header)
+10
webroot/rsrc/css/application/diffusion/diffusion.css
··· 43 43 margin-left: 8px; 44 44 } 45 45 46 + .device-phone .full-mobile-buttons.diffusion-action-bar .phui-lr-container 47 + .phui-left-view { 48 + display: inline-block; 49 + } 50 + 51 + .device-phone .full-mobile-buttons.diffusion-action-bar .phui-lr-container 52 + .phui-right-view { 53 + display: inline-block; 54 + } 55 + 46 56 .diffusion-profile-locate .phui-form-view { 47 57 margin: 0; 48 58 padding: 0;
+8
webroot/rsrc/css/phui/phui-left-right.css
··· 21 21 text-align: right; 22 22 } 23 23 24 + .phui-left-view .button { 25 + margin-right: 8px; 26 + } 27 + 28 + .phui-right-view .button { 29 + margin-left: 8px; 30 + } 31 + 24 32 .phui-lr-view-top .phui-left-view, 25 33 .phui-lr-view-top .phui-right-view { 26 34 vertical-align: top;