mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +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:
parent
bf0a7cbec6
commit
3f1ee67972
1 changed files with 13 additions and 1 deletions
|
@ -7,6 +7,7 @@ final class PhabricatorLinkProfileMenuItem
|
|||
|
||||
const FIELD_URI = 'uri';
|
||||
const FIELD_NAME = 'name';
|
||||
const FIELD_TOOLTIP = 'tooltip';
|
||||
|
||||
public function getMenuItemTypeIcon() {
|
||||
return 'fa-link';
|
||||
|
@ -38,6 +39,10 @@ final class PhabricatorLinkProfileMenuItem
|
|||
->setLabel(pht('URI'))
|
||||
->setIsRequired(true)
|
||||
->setValue($this->getLinkURI($config)),
|
||||
id(new PhabricatorTextEditField())
|
||||
->setKey(self::FIELD_TOOLTIP)
|
||||
->setLabel(pht('Tooltip'))
|
||||
->setValue($this->getLinkTooltip($config)),
|
||||
id(new PhabricatorIconSetEditField())
|
||||
->setKey('icon')
|
||||
->setLabel(pht('Icon'))
|
||||
|
@ -61,6 +66,11 @@ final class PhabricatorLinkProfileMenuItem
|
|||
return $config->getMenuItemProperty('uri');
|
||||
}
|
||||
|
||||
private function getLinkTooltip(
|
||||
PhabricatorProfileMenuItemConfiguration $config) {
|
||||
return $config->getMenuItemProperty('tooltip');
|
||||
}
|
||||
|
||||
private function isValidLinkURI($uri) {
|
||||
return PhabricatorEnv::isValidURIForLink($uri);
|
||||
}
|
||||
|
@ -71,6 +81,7 @@ final class PhabricatorLinkProfileMenuItem
|
|||
$icon = $this->getLinkIcon($config);
|
||||
$name = $this->getLinkName($config);
|
||||
$href = $this->getLinkURI($config);
|
||||
$tooltip = $this->getLinkTooltip($config);
|
||||
|
||||
if (!$this->isValidLinkURI($href)) {
|
||||
$href = '#';
|
||||
|
@ -87,7 +98,8 @@ final class PhabricatorLinkProfileMenuItem
|
|||
$item = $this->newItem()
|
||||
->setHref($href)
|
||||
->setName($name)
|
||||
->setIcon($icon_class);
|
||||
->setIcon($icon_class)
|
||||
->setTooltip($tooltip);
|
||||
|
||||
return array(
|
||||
$item,
|
||||
|
|
Loading…
Reference in a new issue