mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Don't allow forms which can't create objects to be added to profile menus
Summary: Fixes T12281. Some forms (like Settings) can't actually create new objects. Currently, though, you can select them and add them to profile menus; if you do, they fail when building an item. Kick them out of the typeahead, and decline to render them in menus. Test Plan: Added "Create Settings" to a menu, no longer fatals after patch (item vanished from menu, still editable normally to get rid of it). Tried to add another "Create Settings", no longer available in typehaead. Added some normal stuff. Viewed a choose-among-forms dropdown in Maniphest, which still worked normally. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12281 Differential Revision: https://secure.phabricator.com/D17372
This commit is contained in:
parent
b11138a16b
commit
b2739710ba
4 changed files with 25 additions and 5 deletions
|
@ -106,12 +106,14 @@ final class PhabricatorEditEngineProfileMenuItem
|
|||
if (!$form) {
|
||||
return array();
|
||||
}
|
||||
$engine = $form->getEngine();
|
||||
$form_key = $form->getIdentifier();
|
||||
|
||||
$icon = $form->getIcon();
|
||||
$name = $this->getDisplayName($config);
|
||||
$href = $engine->getEditURI(null, "form/{$form_key}/");
|
||||
|
||||
$href = $form->getCreateURI();
|
||||
if ($href === null) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$item = $this->newItem()
|
||||
->setHref($href)
|
||||
|
|
|
@ -1489,8 +1489,7 @@ abstract class PhabricatorEditEngine
|
|||
);
|
||||
} else {
|
||||
foreach ($configs as $config) {
|
||||
$form_key = $config->getIdentifier();
|
||||
$config_uri = $this->getEditURI(null, "form/{$form_key}/");
|
||||
$config_uri = $config->getCreateURI();
|
||||
|
||||
if ($parameters) {
|
||||
$config_uri = (string)id(new PhutilURI($config_uri))
|
||||
|
|
|
@ -216,6 +216,19 @@ final class PhabricatorEditEngineConfiguration
|
|||
return "/transactions/editengine/{$engine_key}/view/{$key}/";
|
||||
}
|
||||
|
||||
public function getCreateURI() {
|
||||
$form_key = $this->getIdentifier();
|
||||
$engine = $this->getEngine();
|
||||
|
||||
try {
|
||||
$create_uri = $engine->getEditURI(null, "form/{$form_key}/");
|
||||
} catch (Exception $ex) {
|
||||
$create_uri = null;
|
||||
}
|
||||
|
||||
return $create_uri;
|
||||
}
|
||||
|
||||
public function getIdentifier() {
|
||||
$key = $this->getID();
|
||||
if (!$key) {
|
||||
|
|
|
@ -30,11 +30,17 @@ final class PhabricatorEditEngineDatasource
|
|||
$forms = $this->executeQuery($query);
|
||||
$results = array();
|
||||
foreach ($forms as $form) {
|
||||
$create_uri = $form->getCreateURI();
|
||||
if (!$create_uri) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($form->getID()) {
|
||||
$key = $form->getEngineKey().'/'.$form->getID();
|
||||
} else {
|
||||
$key = $form->getEngineKey().'/'.$form->getBuiltinKey();
|
||||
}
|
||||
|
||||
$result = id(new PhabricatorTypeaheadResult())
|
||||
->setName($form->getName())
|
||||
->setPHID($key)
|
||||
|
|
Loading…
Reference in a new issue