Page MenuHomePhabricator

D17278.diff
No OneTemporary

D17278.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2882,6 +2882,7 @@
'PhabricatorKeyring' => 'applications/files/keyring/PhabricatorKeyring.php',
'PhabricatorKeyringConfigOptionType' => 'applications/files/keyring/PhabricatorKeyringConfigOptionType.php',
'PhabricatorLDAPAuthProvider' => 'applications/auth/provider/PhabricatorLDAPAuthProvider.php',
+ 'PhabricatorLabelProfileMenuItem' => 'applications/search/menuitem/PhabricatorLabelProfileMenuItem.php',
'PhabricatorLegalpadApplication' => 'applications/legalpad/application/PhabricatorLegalpadApplication.php',
'PhabricatorLegalpadConfigOptions' => 'applications/legalpad/config/PhabricatorLegalpadConfigOptions.php',
'PhabricatorLegalpadDocumentPHIDType' => 'applications/legalpad/phid/PhabricatorLegalpadDocumentPHIDType.php',
@@ -7938,6 +7939,7 @@
'PhabricatorKeyring' => 'Phobject',
'PhabricatorKeyringConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorLDAPAuthProvider' => 'PhabricatorAuthProvider',
+ 'PhabricatorLabelProfileMenuItem' => 'PhabricatorProfileMenuItem',
'PhabricatorLegalpadApplication' => 'PhabricatorApplication',
'PhabricatorLegalpadConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorLegalpadDocumentPHIDType' => 'PhabricatorPHIDType',
diff --git a/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
new file mode 100644
--- /dev/null
+++ b/src/applications/search/menuitem/PhabricatorLabelProfileMenuItem.php
@@ -0,0 +1,75 @@
+<?php
+
+final class PhabricatorLabelProfileMenuItem
+ extends PhabricatorProfileMenuItem {
+
+ const MENUITEMKEY = 'label';
+ const FIELD_NAME = 'name';
+
+ public function getMenuItemTypeIcon() {
+ return 'fa-map-signs';
+ }
+
+ public function getMenuItemTypeName() {
+ return pht('Label');
+ }
+
+ public function canAddToObject($object) {
+ return true;
+ }
+
+ public function getDisplayName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return $this->getLabelName($config);
+ }
+
+ public function buildEditEngineFields(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return array(
+ id(new PhabricatorTextEditField())
+ ->setKey(self::FIELD_NAME)
+ ->setLabel(pht('Name'))
+ ->setIsRequired(true)
+ ->setValue($this->getLabelName($config)),
+ );
+ }
+
+ private function getLabelName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return $config->getMenuItemProperty('name');
+ }
+
+ protected function newNavigationMenuItems(
+ PhabricatorProfileMenuItemConfiguration $config) {
+
+ $name = $this->getLabelName($config);
+
+ $item = $this->newItem()
+ ->setName($name)
+ ->setType(PHUIListItemView::TYPE_LABEL);
+
+ return array(
+ $item,
+ );
+ }
+
+ public function validateTransactions(
+ PhabricatorProfileMenuItemConfiguration $config,
+ $field_key,
+ $value,
+ array $xactions) {
+
+ $viewer = $this->getViewer();
+ $errors = array();
+
+ if ($field_key == self::FIELD_NAME) {
+ if ($this->isEmptyTransaction($value, $xactions)) {
+ $errors[] = $this->newRequiredError(
+ pht('You must choose a label name.'),
+ $field_key);
+ }
+ }
+
+ return $errors;
+ }
+}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 12, 9:27 PM (21 h, 53 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6872300
Default Alt Text
D17278.diff (3 KB)

Event Timeline