From 7c61ace086fa634a67c822c2b35208f15a417834 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Fri, 21 Apr 2017 11:22:06 -0700 Subject: [PATCH] Attach Diffusion Pagers to their ObjectBoxView Summary: Adds the ability to set a pager onto an object box directly and pick up appropriate styles. Test Plan: grep for renderTablePagerBox, test layouts with and without a pager. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T12604 Differential Revision: https://secure.phabricator.com/D17754 --- resources/celerity/map.php | 12 ++++++------ .../DiffusionBranchTableController.php | 6 ++---- .../controller/DiffusionBrowseController.php | 18 +++++++----------- .../controller/DiffusionCompareController.php | 12 ++++-------- .../controller/DiffusionController.php | 6 ------ .../controller/DiffusionHistoryController.php | 6 ++---- .../controller/DiffusionLintController.php | 5 ++--- .../DiffusionRepositoryController.php | 13 ++++--------- .../controller/DiffusionTagListController.php | 6 ++---- src/view/phui/PHUIObjectBoxView.php | 11 +++++++++++ .../application/diffusion/diffusion-icons.css | 5 +++++ webroot/rsrc/css/phui/phui-object-box.css | 12 ++++++++++++ 12 files changed, 57 insertions(+), 55 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 2a4b7ee272..9774488c4b 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -9,12 +9,12 @@ return array( 'names' => array( 'conpherence.pkg.css' => 'ff161f2d', 'conpherence.pkg.js' => 'b5b51108', - 'core.pkg.css' => '959330a2', + 'core.pkg.css' => 'd23d18e6', 'core.pkg.js' => '47a69358', 'darkconsole.pkg.js' => '1f9a31bc', 'differential.pkg.css' => '90b30783', 'differential.pkg.js' => 'ddfeb49b', - 'diffusion.pkg.css' => '30dd8a58', + 'diffusion.pkg.css' => 'b93d9b8c', 'diffusion.pkg.js' => '84c8f8fd', 'favicon.ico' => '30672e08', 'maniphest.pkg.css' => '4845691a', @@ -71,7 +71,7 @@ return array( 'rsrc/css/application/differential/revision-history.css' => '0e8eb855', 'rsrc/css/application/differential/revision-list.css' => 'f3c47d33', 'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55', - 'rsrc/css/application/diffusion/diffusion-icons.css' => '60c21c3b', + 'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba', 'rsrc/css/application/diffusion/diffusion-readme.css' => '297373eb', 'rsrc/css/application/diffusion/diffusion-source.css' => '750add59', 'rsrc/css/application/feed/feed.css' => 'ecd4ec57', @@ -164,7 +164,7 @@ return array( 'rsrc/css/phui/phui-invisible-character-view.css' => '6993d9f0', 'rsrc/css/phui/phui-lightbox.css' => '0a035e40', 'rsrc/css/phui/phui-list.css' => '12eb8ce6', - 'rsrc/css/phui/phui-object-box.css' => '8b289e3d', + 'rsrc/css/phui/phui-object-box.css' => '9cff003c', 'rsrc/css/phui/phui-pager.css' => '77d8a794', 'rsrc/css/phui/phui-pinboard-view.css' => '2495140e', 'rsrc/css/phui/phui-property-list-view.css' => '2dc7993f', @@ -578,7 +578,7 @@ return array( 'differential-revision-history-css' => '0e8eb855', 'differential-revision-list-css' => 'f3c47d33', 'differential-table-of-contents-css' => 'ae4b7a55', - 'diffusion-icons-css' => '60c21c3b', + 'diffusion-icons-css' => 'a6a1e2ba', 'diffusion-readme-css' => '297373eb', 'diffusion-source-css' => '750add59', 'diviner-shared-css' => '896f1d43', @@ -872,7 +872,7 @@ return array( 'phui-invisible-character-view-css' => '6993d9f0', 'phui-lightbox-css' => '0a035e40', 'phui-list-view-css' => '12eb8ce6', - 'phui-object-box-css' => '8b289e3d', + 'phui-object-box-css' => '9cff003c', 'phui-oi-big-ui-css' => '19f9369b', 'phui-oi-color-css' => 'cd2b9b77', 'phui-oi-drag-ui-css' => 'f12cbc9f', diff --git a/src/applications/diffusion/controller/DiffusionBranchTableController.php b/src/applications/diffusion/controller/DiffusionBranchTableController.php index 5c76469b5e..e5e033f416 100644 --- a/src/applications/diffusion/controller/DiffusionBranchTableController.php +++ b/src/applications/diffusion/controller/DiffusionBranchTableController.php @@ -57,7 +57,8 @@ final class DiffusionBranchTableController extends DiffusionController { $content = id(new PHUIObjectBoxView()) ->setHeaderText($repository->getName()) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($table); + ->setTable($table) + ->setPager($pager); } $crumbs = $this->buildCrumbs( @@ -66,8 +67,6 @@ final class DiffusionBranchTableController extends DiffusionController { )); $crumbs->setBorder(true); - $pager_box = $this->renderTablePagerBox($pager); - $header = id(new PHUIHeaderView()) ->setHeader(pht('Branches')) ->setHeaderIcon('fa-code-fork'); @@ -76,7 +75,6 @@ final class DiffusionBranchTableController extends DiffusionController { ->setHeader($header) ->setFooter(array( $content, - $pager_box, )); return $this->newPage() diff --git a/src/applications/diffusion/controller/DiffusionBrowseController.php b/src/applications/diffusion/controller/DiffusionBrowseController.php index b29dcf3d1e..4eb6144ede 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseController.php @@ -370,7 +370,8 @@ final class DiffusionBrowseController extends DiffusionController { $browse_panel = id(new PHUIObjectBoxView()) ->setHeader($browse_header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($browse_table); + ->setTable($browse_table) + ->setPager($pager); $browse_panel->setShowHide( array(pht('Show Search')), @@ -395,7 +396,6 @@ final class DiffusionBrowseController extends DiffusionController { 'view' => 'browse', )); - $pager_box = $this->renderTablePagerBox($pager); $crumbs->setBorder(true); $view = id(new PHUITwoColumnView()) @@ -411,7 +411,6 @@ final class DiffusionBrowseController extends DiffusionController { array( $open_revisions, $readme, - $pager_box, )); if ($details) { @@ -489,14 +488,12 @@ final class DiffusionBrowseController extends DiffusionController { nonempty($drequest->getPath(), '/')); } - $box = id(new PHUIObjectBoxView()) + return id(new PHUIObjectBoxView()) ->setHeaderText($header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($table); + ->setTable($table) + ->setPager($pager); - $pager_box = $this->renderTablePagerBox($pager); - - return array($box, $pager_box); } private function renderGrepResults(array $results, $pattern) { @@ -1775,9 +1772,8 @@ final class DiffusionBrowseController extends DiffusionController { } $header = id(new PHUIHeaderView()) - ->setHeader(pht('Open Revisions')) - ->setSubheader( - pht('Recently updated open revisions affecting this file.')); + ->setHeader(pht('Recently Open Revisions')) + ->setHeaderIcon('fa-gear'); $view = id(new DifferentialRevisionListView()) ->setHeader($header) diff --git a/src/applications/diffusion/controller/DiffusionCompareController.php b/src/applications/diffusion/controller/DiffusionCompareController.php index 884e740309..a3104e6da4 100644 --- a/src/applications/diffusion/controller/DiffusionCompareController.php +++ b/src/applications/diffusion/controller/DiffusionCompareController.php @@ -92,6 +92,7 @@ final class DiffusionCompareController extends DiffusionController { array( 'view' => 'compare', )); + $crumbs->setBorder(true); $pager = id(new PHUIPagerView()) ->readFromRequest($request); @@ -310,16 +311,11 @@ final class DiffusionCompareController extends DiffusionController { $header = id(new PHUIHeaderView()) ->setHeader(pht('Commits')); - $object_box = id(new PHUIObjectBoxView()) + return id(new PHUIObjectBoxView()) ->setHeader($header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($history_table); + ->setTable($history_table) + ->setPager($pager); - $pager_box = $this->renderTablePagerBox($pager); - - return array( - $object_box, - $pager_box, - ); } } diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php index eb46211d99..a018eb3dbb 100644 --- a/src/applications/diffusion/controller/DiffusionController.php +++ b/src/applications/diffusion/controller/DiffusionController.php @@ -317,12 +317,6 @@ abstract class DiffusionController extends PhabricatorController { ->appendChild($body); } - protected function renderTablePagerBox(PHUIPagerView $pager) { - return id(new PHUIBoxView()) - ->addMargin(PHUI::MARGIN_LARGE) - ->appendChild($pager); - } - protected function renderCommitHashTag(DiffusionRequest $drequest) { $stable_commit = $drequest->getStableCommit(); $commit = phutil_tag( diff --git a/src/applications/diffusion/controller/DiffusionHistoryController.php b/src/applications/diffusion/controller/DiffusionHistoryController.php index c9df551c43..1a29a4263a 100644 --- a/src/applications/diffusion/controller/DiffusionHistoryController.php +++ b/src/applications/diffusion/controller/DiffusionHistoryController.php @@ -57,7 +57,8 @@ final class DiffusionHistoryController extends DiffusionController { $history_panel = id(new PHUIObjectBoxView()) ->setHeader($history_header) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($history_table); + ->setTable($history_table) + ->setPager($pager); $header = $this->buildHeader($drequest); @@ -69,13 +70,10 @@ final class DiffusionHistoryController extends DiffusionController { )); $crumbs->setBorder(true); - $pager_box = $this->renderTablePagerBox($pager); - $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setFooter(array( $history_panel, - $pager_box, )); return $this->newPage() diff --git a/src/applications/diffusion/controller/DiffusionLintController.php b/src/applications/diffusion/controller/DiffusionLintController.php index fbd059796a..980dc8d27c 100644 --- a/src/applications/diffusion/controller/DiffusionLintController.php +++ b/src/applications/diffusion/controller/DiffusionLintController.php @@ -456,7 +456,8 @@ final class DiffusionLintController extends DiffusionController { $content[] = id(new PHUIObjectBoxView()) ->setHeaderText(pht('Lint Details')) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($table); + ->setTable($table) + ->setPager($pager); $crumbs = $this->buildCrumbs( array( @@ -465,7 +466,6 @@ final class DiffusionLintController extends DiffusionController { 'view' => 'lint', )); - $pager_box = $this->renderTablePagerBox($pager); $header = id(new PHUIHeaderView()) ->setHeader(pht('Lint: %s', $drequest->getRepository()->getDisplayName())) ->setHeaderIcon('fa-code'); @@ -474,7 +474,6 @@ final class DiffusionLintController extends DiffusionController { ->setHeader($header) ->setFooter(array( $content, - $pager_box, )); return $this->newPage() diff --git a/src/applications/diffusion/controller/DiffusionRepositoryController.php b/src/applications/diffusion/controller/DiffusionRepositoryController.php index a18f2da1d7..91b33bcaaa 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryController.php @@ -354,9 +354,9 @@ final class DiffusionRepositoryController extends DiffusionController { } if ($repository->isSVN()) { - $label = pht('Checkout'); + $label = phutil_tag_div('diffusion-clone-label', pht('Checkout')); } else { - $label = pht('Clone'); + $label = phutil_tag_div('diffusion-clone-label', pht('Clone')); } $view->addProperty( @@ -686,15 +686,10 @@ final class DiffusionRepositoryController extends DiffusionController { $pager->setURI($browse_uri, 'offset'); if ($pager->willShowPagingControls()) { - $pager_box = $this->renderTablePagerBox($pager); - } else { - $pager_box = null; + $browse_panel->setPager($pager); } - return array( - $browse_panel, - $pager_box, - ); + return $browse_panel; } private function renderCloneURI( diff --git a/src/applications/diffusion/controller/DiffusionTagListController.php b/src/applications/diffusion/controller/DiffusionTagListController.php index 5abd93c37d..df3b356f5d 100644 --- a/src/applications/diffusion/controller/DiffusionTagListController.php +++ b/src/applications/diffusion/controller/DiffusionTagListController.php @@ -87,15 +87,13 @@ final class DiffusionTagListController extends DiffusionController { $box = id(new PHUIObjectBoxView()) ->setHeaderText($repository->getDisplayName()) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->setTable($view); - - $pager_box = $this->renderTablePagerBox($pager); + ->setTable($view) + ->setPager($pager); $view = id(new PHUITwoColumnView()) ->setHeader($header) ->setFooter(array( $box, - $pager_box, )); return $this->newPage() diff --git a/src/view/phui/PHUIObjectBoxView.php b/src/view/phui/PHUIObjectBoxView.php index 1e1d9898ec..26044ef3a0 100644 --- a/src/view/phui/PHUIObjectBoxView.php +++ b/src/view/phui/PHUIObjectBoxView.php @@ -18,6 +18,7 @@ final class PHUIObjectBoxView extends AphrontTagView { private $table; private $collapsed = false; private $anchor; + private $pager; private $showAction; private $hideAction; @@ -126,6 +127,11 @@ final class PHUIObjectBoxView extends AphrontTagView { return $this; } + public function setPager(PHUIPagerView $pager) { + $this->pager = $pager; + return $this; + } + public function setAnchor(PhabricatorAnchorView $anchor) { $this->anchor = $anchor; return $this; @@ -294,6 +300,10 @@ final class PHUIObjectBoxView extends AphrontTagView { $lists = null; } + $pager = null; + if ($this->pager) { + $pager = phutil_tag_div('phui-object-box-pager', $this->pager); + } $content = array( ($this->showHideOpen == false ? $this->anchor : null), @@ -308,6 +318,7 @@ final class PHUIObjectBoxView extends AphrontTagView { ($this->showHideOpen == true ? $this->anchor : null), $lists, $this->table, + $pager, $this->renderChildren(), ); diff --git a/webroot/rsrc/css/application/diffusion/diffusion-icons.css b/webroot/rsrc/css/application/diffusion/diffusion-icons.css index a645f5cb84..8edc034975 100644 --- a/webroot/rsrc/css/application/diffusion/diffusion-icons.css +++ b/webroot/rsrc/css/application/diffusion/diffusion-icons.css @@ -13,6 +13,11 @@ input.diffusion-clone-uri { color: {$lightgreytext}; } +.diffusion-clone-label { + height: 30px; + line-height: 28px; +} + .diffusion-browse-name { margin-left: 8px; } diff --git a/webroot/rsrc/css/phui/phui-object-box.css b/webroot/rsrc/css/phui/phui-object-box.css index dee0525944..4999a4c2c2 100644 --- a/webroot/rsrc/css/phui/phui-object-box.css +++ b/webroot/rsrc/css/phui/phui-object-box.css @@ -146,3 +146,15 @@ div.phui-object-box.phui-object-box-flush { padding: 4px 8px; background-color: {$lightgreybackground}; } + +/* - Pager at the bottom ---------------------------------------------------- */ + +.phui-object-box-pager { + background-color: {$bluebackground}; + border-top: 1px solid {$lightblueborder}; +} + +.phui-object-box-pager a.button { + margin-top: 8px; + margin-bottom: 8px; +}