Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F18773109
D17098.id41127.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D17098.id41127.diff
View Options
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
@@ -2570,6 +2570,7 @@
'PhabricatorEditEngineExtensionModule' => 'applications/transactions/engineextension/PhabricatorEditEngineExtensionModule.php',
'PhabricatorEditEngineListController' => 'applications/transactions/controller/PhabricatorEditEngineListController.php',
'PhabricatorEditEnginePointsCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEnginePointsCommentAction.php',
+ 'PhabricatorEditEngineProfileMenuItem' => 'applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php',
'PhabricatorEditEngineQuery' => 'applications/transactions/query/PhabricatorEditEngineQuery.php',
'PhabricatorEditEngineSearchEngine' => 'applications/transactions/query/PhabricatorEditEngineSearchEngine.php',
'PhabricatorEditEngineSelectCommentAction' => 'applications/transactions/commentaction/PhabricatorEditEngineSelectCommentAction.php',
@@ -7545,6 +7546,7 @@
'PhabricatorEditEngineExtensionModule' => 'PhabricatorConfigModule',
'PhabricatorEditEngineListController' => 'PhabricatorEditEngineController',
'PhabricatorEditEnginePointsCommentAction' => 'PhabricatorEditEngineCommentAction',
+ 'PhabricatorEditEngineProfileMenuItem' => 'PhabricatorProfileMenuItem',
'PhabricatorEditEngineQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorEditEngineSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorEditEngineSelectCommentAction' => 'PhabricatorEditEngineCommentAction',
diff --git a/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
new file mode 100644
--- /dev/null
+++ b/src/applications/search/menuitem/PhabricatorEditEngineProfileMenuItem.php
@@ -0,0 +1,132 @@
+<?php
+
+final class PhabricatorEditEngineProfileMenuItem
+ extends PhabricatorProfileMenuItem {
+
+ const MENUITEMKEY = 'editengine';
+
+ private $form;
+
+ public function getMenuItemTypeIcon() {
+ return 'fa-plus';
+ }
+
+ public function getMenuItemTypeName() {
+ return pht('Forms');
+ }
+
+ public function canAddToObject($object) {
+ return true;
+ }
+
+ public function attachForm($form) {
+ $this->form = $form;
+ return $this;
+ }
+
+ public function getForm() {
+ $form = $this->form;
+ if (!$form) {
+ return null;
+ }
+ return $form;
+ }
+
+ public function willBuildNavigationItems(array $items) {
+ $viewer = $this->getViewer();
+ $engines = PhabricatorEditEngine::getAllEditEngines();
+ $engine_keys = array_keys($engines);
+ $forms = id(new PhabricatorEditEngineConfigurationQuery())
+ ->setViewer($viewer)
+ ->withEngineKeys($engine_keys)
+ ->withIsDisabled(false)
+ ->execute();
+ $form_engines = mgroup($forms, 'getEngineKey');
+ $form_ids = $forms;
+
+ foreach ($items as $item) {
+ $key = $item->getMenuItemProperty('formKey');
+ list($engine_key, $form_key) = explode('/', $key);
+ if (is_numeric($form_key)) {
+ $form = idx($form_ids, $form_key, null);
+ $item->getMenuItem()->attachForm($form);
+ } else {
+ foreach ($form_engines as $form_engine) {
+ $forms = mpull($form_engine, null, 'getBuiltinKey');
+ foreach ($forms as $form) {
+ if ($engine_key == $form->getEngineKey()) {
+ $form = idx($forms, $form_key, null);
+ $item->getMenuItem()->attachForm($form);
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ public function getDisplayName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $form = $this->getForm();
+ if (!$form) {
+ return pht('(Restricted/Invalid Form)');
+ }
+ if (strlen($this->getName($config))) {
+ return $this->getName($config);
+ } else {
+ return $form->getName();
+ }
+ }
+
+ public function buildEditEngineFields(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return array(
+ id(new PhabricatorTextEditField())
+ ->setKey('name')
+ ->setLabel(pht('Name'))
+ ->setValue($this->getName($config)),
+ id(new PhabricatorDatasourceEditField())
+ ->setKey('formKey')
+ ->setLabel(pht('Form'))
+ ->setDatasource(new PhabricatorEditEngineDatasource())
+ ->setSingleValue($config->getMenuItemProperty('formKey')),
+ );
+ }
+
+ private function getName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return $config->getMenuItemProperty('name');
+ }
+
+ protected function newNavigationMenuItems(
+ PhabricatorProfileMenuItemConfiguration $config) {
+
+ $form = $this->getForm();
+ if (!$form) {
+ return array();
+ }
+ $engine = $form->getEngine();
+ $form_key = $form->getIdentifier();
+
+ $id = $form->getID();
+ if ($id) {
+ $key = $id;
+ } else {
+ $key = $form->getBuiltinKey();
+ }
+
+ $icon = $form->getIcon();
+ $name = $this->getDisplayName($config);
+ $href = $engine->getEditURI(null, "form/{$form_key}/");
+
+ $item = $this->newItem()
+ ->setHref($href)
+ ->setName($name)
+ ->setIcon($icon);
+
+ return array(
+ $item,
+ );
+ }
+
+}
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -49,7 +49,14 @@
}
final public function getEngineKey() {
- return $this->getPhobjectClassConstant('ENGINECONST', 64);
+ $key = $this->getPhobjectClassConstant('ENGINECONST', 64);
+ if (strpos('/', $key)) {
+ throw new Exception(
+ pht(
+ 'EditEngine ("%s") contains an invalid key character "/".',
+ get_class($this)));
+ }
+ return $key;
}
final public function getApplication() {
diff --git a/src/applications/transactions/typeahead/PhabricatorEditEngineDatasource.php b/src/applications/transactions/typeahead/PhabricatorEditEngineDatasource.php
--- a/src/applications/transactions/typeahead/PhabricatorEditEngineDatasource.php
+++ b/src/applications/transactions/typeahead/PhabricatorEditEngineDatasource.php
@@ -21,10 +21,14 @@
$forms = $this->executeQuery($query);
$results = array();
foreach ($forms as $form) {
-
+ if ($form->getID()) {
+ $key = $form->getEngineKey().'/'.$form->getID();
+ } else {
+ $key = $form->getEngineKey().'/'.$form->getBuiltinKey();
+ }
$result = id(new PhabricatorTypeaheadResult())
->setName($form->getName())
- ->setPHID($form->getPHID());
+ ->setPHID($key);
if ($form->getIsDisabled()) {
$result->setClosed(pht('Archived'));
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 10 2025, 7:12 AM (13 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
9187966
Default Alt Text
D17098.id41127.diff (6 KB)
Attached To
Mode
D17098: Add Form MenuItem, Fix EditEngine Typeahead
Attached
Detach File
Event Timeline
Log In to Comment