1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 18:22:41 +01:00

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
This commit is contained in:
epriestley 2017-01-20 11:42:29 -08:00
parent 8113b76910
commit d24739ee3c
4 changed files with 32 additions and 19 deletions

View file

@ -21,13 +21,17 @@ final class PhabricatorApplicationProfileMenuItem
public function getDisplayName( public function getDisplayName(
PhabricatorProfileMenuItemConfiguration $config) { PhabricatorProfileMenuItemConfiguration $config) {
$app = $this->getApplication($config); $application = $this->getApplication($config);
if ($app) { if (!$application) {
return $app->getName(); return pht('(Restricted/Invalid Application)');
} else {
return pht('(Uninstalled Application)');
} }
return $app->getName();
$name = $this->getName($config);
if (strlen($name)) {
return $name;
}
return $application->getName();
} }
public function buildEditEngineFields( public function buildEditEngineFields(
@ -40,9 +44,18 @@ final class PhabricatorApplicationProfileMenuItem
->setDatasource(new PhabricatorApplicationDatasource()) ->setDatasource(new PhabricatorApplicationDatasource())
->setIsRequired(true) ->setIsRequired(true)
->setSingleValue($config->getMenuItemProperty('application')), ->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( private function getApplication(
PhabricatorProfileMenuItemConfiguration $config) { PhabricatorProfileMenuItemConfiguration $config) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
@ -73,7 +86,7 @@ final class PhabricatorApplicationProfileMenuItem
$item = $this->newItem() $item = $this->newItem()
->setHref($app->getApplicationURI()) ->setHref($app->getApplicationURI())
->setName($app->getName()) ->setName($this->getDisplayName($config))
->setIcon($app->getIcon()); ->setIcon($app->getIcon());
return array( return array(

View file

@ -72,16 +72,16 @@ final class PhabricatorDashboardProfileMenuItem
public function buildEditEngineFields( public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) { PhabricatorProfileMenuItemConfiguration $config) {
return array( return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
id(new PhabricatorDatasourceEditField()) id(new PhabricatorDatasourceEditField())
->setKey(self::FIELD_DASHBOARD) ->setKey(self::FIELD_DASHBOARD)
->setLabel(pht('Dashboard')) ->setLabel(pht('Dashboard'))
->setIsRequired(true) ->setIsRequired(true)
->setDatasource(new PhabricatorDashboardDatasource()) ->setDatasource(new PhabricatorDashboardDatasource())
->setSingleValue($config->getMenuItemProperty('dashboardPHID')), ->setSingleValue($config->getMenuItemProperty('dashboardPHID')),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
); );
} }

View file

@ -81,16 +81,16 @@ final class PhabricatorEditEngineProfileMenuItem
public function buildEditEngineFields( public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) { PhabricatorProfileMenuItemConfiguration $config) {
return array( return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
id(new PhabricatorDatasourceEditField()) id(new PhabricatorDatasourceEditField())
->setKey(self::FIELD_FORM) ->setKey(self::FIELD_FORM)
->setLabel(pht('Form')) ->setLabel(pht('Form'))
->setIsRequired(true) ->setIsRequired(true)
->setDatasource(new PhabricatorEditEngineDatasource()) ->setDatasource(new PhabricatorEditEngineDatasource())
->setSingleValue($config->getMenuItemProperty('formKey')), ->setSingleValue($config->getMenuItemProperty('formKey')),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
); );
} }

View file

@ -72,16 +72,16 @@ final class PhabricatorProjectProfileMenuItem
public function buildEditEngineFields( public function buildEditEngineFields(
PhabricatorProfileMenuItemConfiguration $config) { PhabricatorProfileMenuItemConfiguration $config) {
return array( return array(
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
id(new PhabricatorDatasourceEditField()) id(new PhabricatorDatasourceEditField())
->setKey(self::FIELD_PROJECT) ->setKey(self::FIELD_PROJECT)
->setLabel(pht('Project')) ->setLabel(pht('Project'))
->setIsRequired(true) ->setIsRequired(true)
->setDatasource(new PhabricatorProjectDatasource()) ->setDatasource(new PhabricatorProjectDatasource())
->setSingleValue($config->getMenuItemProperty('project')), ->setSingleValue($config->getMenuItemProperty('project')),
id(new PhabricatorTextEditField())
->setKey('name')
->setLabel(pht('Name'))
->setValue($this->getName($config)),
); );
} }