From c9d3fb2ac5b64684d8eba7a892a4c0496486d7cc Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 31 Mar 2019 14:26:05 -0700 Subject: [PATCH] Fix the incorrect link target for "Create Revision" as a Menu Item Summary: Depends on D20359. Fixes T12098. When you add a new "Form" item and pick "Create Revision", you currently get a bad link. This is because Differential is kind of special and the form isn't usable directly, even though Differential does use EditEngine. Allow EditEngine to specify a different create URI, then specify the web UI paste-a-diff flow to fix this. Test Plan: - Added "Create Revision" to a portal, clicked it, was sensibly put on the diff flow. - Grepped for `getCreateURI()`, the only other real use case is to render the "Create X" dropdowns in the upper right. - Clicked one of those, still worked great. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T12098 Differential Revision: https://secure.phabricator.com/D20360 --- .../editor/DifferentialRevisionEditEngine.php | 4 ++++ .../editengine/PhabricatorEditEngine.php | 12 ++++++++++++ .../storage/PhabricatorEditEngineConfiguration.php | 9 +-------- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/applications/differential/editor/DifferentialRevisionEditEngine.php b/src/applications/differential/editor/DifferentialRevisionEditEngine.php index 9c399036d5..32c82629bb 100644 --- a/src/applications/differential/editor/DifferentialRevisionEditEngine.php +++ b/src/applications/differential/editor/DifferentialRevisionEditEngine.php @@ -63,6 +63,10 @@ final class DifferentialRevisionEditEngine return $object->getMonogram(); } + public function getCreateURI($form_key) { + return '/differential/diff/create/'; + } + protected function getObjectCreateShortText() { return pht('Create Revision'); } diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php index 82af45dca8..0986247454 100644 --- a/src/applications/transactions/editengine/PhabricatorEditEngine.php +++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php @@ -566,6 +566,18 @@ abstract class PhabricatorEditEngine return $this->getObjectViewURI($object); } + /** + * @task uri + */ + public function getCreateURI($form_key) { + try { + $create_uri = $this->getEditURI(null, "form/{$form_key}/"); + } catch (Exception $ex) { + $create_uri = null; + } + + return $create_uri; + } /** * @task uri diff --git a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php index 6c9f3a50a6..b1919a0ee0 100644 --- a/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php +++ b/src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php @@ -227,14 +227,7 @@ final class PhabricatorEditEngineConfiguration 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; + return $engine->getCreateURI($form_key); } public function getIdentifier() {