From e7aa874f5eba4757bf007dfab010b9fbcf375e5c Mon Sep 17 00:00:00 2001 From: Chad Little Date: Fri, 19 Aug 2016 09:29:57 -0700 Subject: [PATCH] Fix getIcon calls in PHUIObjectListItem Summary: Fixes T11501. Let's you pass in a full PHUIIconView or just the icon name to give ObjectListItem a large icon. Test Plan: Alamanac, Applications, Drydock, Settings, Search Typeahead, Config page... Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T11501 Differential Revision: https://secure.phabricator.com/D16421 --- .../controller/AlmanacConsoleController.php | 10 +++++----- .../controller/PhabricatorConfigListController.php | 2 +- .../controller/DrydockConsoleController.php | 8 ++++---- .../meta/query/PhabricatorAppSearchEngine.php | 14 +------------- .../PhabricatorUserPreferencesSearchEngine.php | 4 ++-- src/view/phui/PHUIObjectItemView.php | 9 ++++----- 6 files changed, 17 insertions(+), 30 deletions(-) diff --git a/src/applications/almanac/controller/AlmanacConsoleController.php b/src/applications/almanac/controller/AlmanacConsoleController.php index cd9ebf610a..74c57c384f 100644 --- a/src/applications/almanac/controller/AlmanacConsoleController.php +++ b/src/applications/almanac/controller/AlmanacConsoleController.php @@ -16,7 +16,7 @@ final class AlmanacConsoleController extends AlmanacController { id(new PHUIObjectItemView()) ->setHeader(pht('Devices')) ->setHref($this->getApplicationURI('device/')) - ->setIcon('fa-server') + ->setImageIcon('fa-server') ->addAttribute( pht( 'Create an inventory of physical and virtual hosts and '. @@ -26,7 +26,7 @@ final class AlmanacConsoleController extends AlmanacController { id(new PHUIObjectItemView()) ->setHeader(pht('Services')) ->setHref($this->getApplicationURI('service/')) - ->setIcon('fa-plug') + ->setImageIcon('fa-plug') ->addAttribute( pht( 'Create and update services, and map them to interfaces on '. @@ -36,7 +36,7 @@ final class AlmanacConsoleController extends AlmanacController { id(new PHUIObjectItemView()) ->setHeader(pht('Networks')) ->setHref($this->getApplicationURI('network/')) - ->setIcon('fa-globe') + ->setImageIcon('fa-globe') ->addAttribute( pht( 'Manage public and private networks.'))); @@ -45,7 +45,7 @@ final class AlmanacConsoleController extends AlmanacController { id(new PHUIObjectItemView()) ->setHeader(pht('Namespaces')) ->setHref($this->getApplicationURI('namespace/')) - ->setIcon('fa-asterisk') + ->setImageIcon('fa-asterisk') ->addAttribute( pht('Control who can create new named services and devices.'))); @@ -56,7 +56,7 @@ final class AlmanacConsoleController extends AlmanacController { id(new PHUIObjectItemView()) ->setHeader(pht('Documentation')) ->setHref($docs_uri) - ->setIcon('fa-book') + ->setImageIcon('fa-book') ->addAttribute(pht('Browse documentation for Almanac.'))); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/config/controller/PhabricatorConfigListController.php b/src/applications/config/controller/PhabricatorConfigListController.php index 8b0ff42e50..e6af666931 100644 --- a/src/applications/config/controller/PhabricatorConfigListController.php +++ b/src/applications/config/controller/PhabricatorConfigListController.php @@ -51,7 +51,7 @@ final class PhabricatorConfigListController ->setHeader($group->getName()) ->setHref('/config/group/'.$group->getKey().'/') ->addAttribute($group->getDescription()) - ->setIcon($group->getIcon()); + ->setImageIcon($group->getIcon()); $list->addItem($item); } } diff --git a/src/applications/drydock/controller/DrydockConsoleController.php b/src/applications/drydock/controller/DrydockConsoleController.php index 1d79f52c14..ac524cb8a5 100644 --- a/src/applications/drydock/controller/DrydockConsoleController.php +++ b/src/applications/drydock/controller/DrydockConsoleController.php @@ -31,7 +31,7 @@ final class DrydockConsoleController extends DrydockController { $menu->addItem( id(new PHUIObjectItemView()) ->setHeader(pht('Blueprints')) - ->setIcon('fa-map-o') + ->setImageIcon('fa-map-o') ->setHref($this->getApplicationURI('blueprint/')) ->addAttribute( pht( @@ -41,7 +41,7 @@ final class DrydockConsoleController extends DrydockController { $menu->addItem( id(new PHUIObjectItemView()) ->setHeader(pht('Resources')) - ->setIcon('fa-map') + ->setImageIcon('fa-map') ->setHref($this->getApplicationURI('resource/')) ->addAttribute( pht('View and manage resources Drydock has built, like hosts.'))); @@ -49,14 +49,14 @@ final class DrydockConsoleController extends DrydockController { $menu->addItem( id(new PHUIObjectItemView()) ->setHeader(pht('Leases')) - ->setIcon('fa-link') + ->setImageIcon('fa-link') ->setHref($this->getApplicationURI('lease/')) ->addAttribute(pht('Manage leases on resources.'))); $menu->addItem( id(new PHUIObjectItemView()) ->setHeader(pht('Repository Operations')) - ->setIcon('fa-fighter-jet') + ->setImageIcon('fa-fighter-jet') ->setHref($this->getApplicationURI('operation/')) ->addAttribute(pht('Review the repository operation queue.'))); diff --git a/src/applications/meta/query/PhabricatorAppSearchEngine.php b/src/applications/meta/query/PhabricatorAppSearchEngine.php index 98a9495fa0..62e1c1020e 100644 --- a/src/applications/meta/query/PhabricatorAppSearchEngine.php +++ b/src/applications/meta/query/PhabricatorAppSearchEngine.php @@ -214,18 +214,6 @@ final class PhabricatorAppSearchEngine $icon = 'application'; } - // TODO: This sheet doesn't work the same way other sheets do so it - // ends up with the wrong classes if we try to use PHUIIconView. This - // is probably all changing in the redesign anyway. - - $icon_view = javelin_tag( - 'span', - array( - 'class' => 'phui-icon-view phui-font-fa '.$icon, - 'aural' => false, - ), - ''); - $description = $application->getShortDescription(); $configure = id(new PHUIButtonView()) @@ -241,7 +229,7 @@ final class PhabricatorAppSearchEngine $item = id(new PHUIObjectItemView()) ->setHeader($name) - ->setImageIcon($icon_view) + ->setImageIcon($icon) ->setSubhead($description) ->setLaunchButton($configure); diff --git a/src/applications/settings/query/PhabricatorUserPreferencesSearchEngine.php b/src/applications/settings/query/PhabricatorUserPreferencesSearchEngine.php index 4b1f135c6a..dc01a5191b 100644 --- a/src/applications/settings/query/PhabricatorUserPreferencesSearchEngine.php +++ b/src/applications/settings/query/PhabricatorUserPreferencesSearchEngine.php @@ -65,8 +65,8 @@ final class PhabricatorUserPreferencesSearchEngine $item = id(new PHUIObjectItemView()) ->setHeader($setting->getDisplayName()) ->setHref($setting->getEditURI()) - ->setImageURI(PhabricatorUser::getDefaultProfileImageURI()) - ->setIcon('fa-globe') + // TODO: Replace this with NUX Style bg / white icon when built + ->setImageIcon('fa-globe') ->addAttribute(pht('Edit global default settings for all users.')); $list->addItem($item); diff --git a/src/view/phui/PHUIObjectItemView.php b/src/view/phui/PHUIObjectItemView.php index 73f4ff7824..28d683e4d3 100644 --- a/src/view/phui/PHUIObjectItemView.php +++ b/src/view/phui/PHUIObjectItemView.php @@ -131,6 +131,10 @@ final class PHUIObjectItemView extends AphrontTagView { } public function setImageIcon($image_icon) { + if (!$image_icon instanceof PHUIIconView) { + $image_icon = id(new PHUIIconView()) + ->setIcon($image_icon); + } $this->imageIcon = $image_icon; return $this; } @@ -167,11 +171,6 @@ final class PHUIObjectItemView extends AphrontTagView { return $this; } - public function setIcon($icon) { - // TODO: Remove this in favor of setStatusIcon()? - return $this->setStatusIcon($icon); - } - public function setStatusIcon($icon, $label = null) { $this->statusIcon = array( 'icon' => $icon,