From d24739ee3cfa9b18594a2298620e0a3cb12f87fb Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 20 Jan 2017 11:42:29 -0800 Subject: [PATCH] Minor consistency/order updates for menu items which reference other objects Summary: See T11957#208140. - Let Applications have a custom name, like other object items (for example, so you can call Maniphest "Tasks" if you prefer). - Put the optional name field after the required typeahead field for these items. - (I left "Link" in "Name, URI" order since both are required, but there's maybe an argument for swapping them?) Test Plan: - Created each type of item, saw "thing, name" order. - Created an application with a cusotm name, saw custom name. - Removed custom name, saw original name. Reviewers: chad Reviewed By: chad Differential Revision: https://secure.phabricator.com/D17236 --- .../PhabricatorApplicationProfileMenuItem.php | 27 ++++++++++++++----- .../PhabricatorDashboardProfileMenuItem.php | 8 +++--- .../PhabricatorEditEngineProfileMenuItem.php | 8 +++--- .../PhabricatorProjectProfileMenuItem.php | 8 +++--- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php index 2cd6440cf5..1c4c8410f3 100644 --- a/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php +++ b/src/applications/search/menuitem/PhabricatorApplicationProfileMenuItem.php @@ -21,13 +21,17 @@ final class PhabricatorApplicationProfileMenuItem public function getDisplayName( PhabricatorProfileMenuItemConfiguration $config) { - $app = $this->getApplication($config); - if ($app) { - return $app->getName(); - } else { - return pht('(Uninstalled Application)'); + $application = $this->getApplication($config); + if (!$application) { + return pht('(Restricted/Invalid Application)'); } - return $app->getName(); + + $name = $this->getName($config); + if (strlen($name)) { + return $name; + } + + return $application->getName(); } public function buildEditEngineFields( @@ -40,9 +44,18 @@ final class PhabricatorApplicationProfileMenuItem ->setDatasource(new PhabricatorApplicationDatasource()) ->setIsRequired(true) ->setSingleValue($config->getMenuItemProperty('application')), + id(new PhabricatorTextEditField()) + ->setKey('name') + ->setLabel(pht('Name')) + ->setValue($this->getName($config)), ); } + private function getName( + PhabricatorProfileMenuItemConfiguration $config) { + return $config->getMenuItemProperty('name'); + } + private function getApplication( PhabricatorProfileMenuItemConfiguration $config) { $viewer = $this->getViewer(); @@ -73,7 +86,7 @@ final class PhabricatorApplicationProfileMenuItem $item = $this->newItem() ->setHref($app->getApplicationURI()) - ->setName($app->getName()) + ->setName($this->getDisplayName($config)) ->setIcon($app->getIcon()); return array( diff --git a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php index 2aab6eee34..c9a13bd4ab 100644 --- a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php +++ b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php @@ -72,16 +72,16 @@ final class PhabricatorDashboardProfileMenuItem public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( - id(new PhabricatorTextEditField()) - ->setKey('name') - ->setLabel(pht('Name')) - ->setValue($this->getName($config)), id(new PhabricatorDatasourceEditField()) ->setKey(self::FIELD_DASHBOARD) ->setLabel(pht('Dashboard')) ->setIsRequired(true) ->setDatasource(new PhabricatorDashboardDatasource()) ->setSingleValue($config->getMenuItemProperty('dashboardPHID')), + id(new PhabricatorTextEditField()) + ->setKey('name') + ->setLabel(pht('Name')) + ->setValue($this->getName($config)), ); } diff --git a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php index db4804996a..4b840d39e3 100644 --- a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php +++ b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php @@ -81,16 +81,16 @@ final class PhabricatorEditEngineProfileMenuItem public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( - id(new PhabricatorTextEditField()) - ->setKey('name') - ->setLabel(pht('Name')) - ->setValue($this->getName($config)), id(new PhabricatorDatasourceEditField()) ->setKey(self::FIELD_FORM) ->setLabel(pht('Form')) ->setIsRequired(true) ->setDatasource(new PhabricatorEditEngineDatasource()) ->setSingleValue($config->getMenuItemProperty('formKey')), + id(new PhabricatorTextEditField()) + ->setKey('name') + ->setLabel(pht('Name')) + ->setValue($this->getName($config)), ); } diff --git a/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php index 364a68e4b8..aadabd179a 100644 --- a/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php +++ b/src/applications/search/menuitem/PhabricatorProjectProfileMenuItem.php @@ -72,16 +72,16 @@ final class PhabricatorProjectProfileMenuItem public function buildEditEngineFields( PhabricatorProfileMenuItemConfiguration $config) { return array( - id(new PhabricatorTextEditField()) - ->setKey('name') - ->setLabel(pht('Name')) - ->setValue($this->getName($config)), id(new PhabricatorDatasourceEditField()) ->setKey(self::FIELD_PROJECT) ->setLabel(pht('Project')) ->setIsRequired(true) ->setDatasource(new PhabricatorProjectDatasource()) ->setSingleValue($config->getMenuItemProperty('project')), + id(new PhabricatorTextEditField()) + ->setKey('name') + ->setLabel(pht('Name')) + ->setValue($this->getName($config)), ); }