1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 15:21:03 +01:00

Add a tooltip option to Link menu items

Summary: Ref T12174. Let's users add a tooltip to LinkProfileMenuItem

Test Plan: Add a tooltip, remove tooltip. Menu appears as expected

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12174

Differential Revision: https://secure.phabricator.com/D17437
This commit is contained in:
Chad Little 2017-03-01 11:05:49 -08:00
parent bf0a7cbec6
commit 3f1ee67972

View file

@ -7,6 +7,7 @@ final class PhabricatorLinkProfileMenuItem
const FIELD_URI = 'uri'; const FIELD_URI = 'uri';
const FIELD_NAME = 'name'; const FIELD_NAME = 'name';
const FIELD_TOOLTIP = 'tooltip';
public function getMenuItemTypeIcon() { public function getMenuItemTypeIcon() {
return 'fa-link'; return 'fa-link';
@ -38,6 +39,10 @@ final class PhabricatorLinkProfileMenuItem
->setLabel(pht('URI')) ->setLabel(pht('URI'))
->setIsRequired(true) ->setIsRequired(true)
->setValue($this->getLinkURI($config)), ->setValue($this->getLinkURI($config)),
id(new PhabricatorTextEditField())
->setKey(self::FIELD_TOOLTIP)
->setLabel(pht('Tooltip'))
->setValue($this->getLinkTooltip($config)),
id(new PhabricatorIconSetEditField()) id(new PhabricatorIconSetEditField())
->setKey('icon') ->setKey('icon')
->setLabel(pht('Icon')) ->setLabel(pht('Icon'))
@ -61,6 +66,11 @@ final class PhabricatorLinkProfileMenuItem
return $config->getMenuItemProperty('uri'); return $config->getMenuItemProperty('uri');
} }
private function getLinkTooltip(
PhabricatorProfileMenuItemConfiguration $config) {
return $config->getMenuItemProperty('tooltip');
}
private function isValidLinkURI($uri) { private function isValidLinkURI($uri) {
return PhabricatorEnv::isValidURIForLink($uri); return PhabricatorEnv::isValidURIForLink($uri);
} }
@ -71,6 +81,7 @@ final class PhabricatorLinkProfileMenuItem
$icon = $this->getLinkIcon($config); $icon = $this->getLinkIcon($config);
$name = $this->getLinkName($config); $name = $this->getLinkName($config);
$href = $this->getLinkURI($config); $href = $this->getLinkURI($config);
$tooltip = $this->getLinkTooltip($config);
if (!$this->isValidLinkURI($href)) { if (!$this->isValidLinkURI($href)) {
$href = '#'; $href = '#';
@ -87,7 +98,8 @@ final class PhabricatorLinkProfileMenuItem
$item = $this->newItem() $item = $this->newItem()
->setHref($href) ->setHref($href)
->setName($name) ->setName($name)
->setIcon($icon_class); ->setIcon($icon_class)
->setTooltip($tooltip);
return array( return array(
$item, $item,