From c3644216bf222f97a011b449663a95435c6da6eb Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 20 Oct 2016 09:09:34 -0700 Subject: [PATCH] Add developer UI for accessing NUX and "Overheated" query states Summary: Ref T11773. Not committed to this implementation, but adds some "Developer" query actions to jump to the nux/overheated states without needing to know secret magic URL variables. Test Plan: {F1878984} Reviewers: chad Reviewed By: chad Maniphest Tasks: T11773 Differential Revision: https://secure.phabricator.com/D16736 --- ...PhabricatorApplicationSearchController.php | 48 +++++++++++++++++-- .../PhabricatorApplicationSearchEngine.php | 4 ++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index 386be2ca8a..b7bef9a623 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -111,6 +111,7 @@ final class PhabricatorApplicationSearchController 'before' => true, 'after' => true, 'nux' => true, + 'overheated' => true, ); foreach ($pt_data as $pt_key => $pt_value) { @@ -238,7 +239,8 @@ final class PhabricatorApplicationSearchController $nux_view = null; } - $is_overheated = $query->getIsOverheated(); + $force_overheated = $request->getBool('overheated'); + $is_overheated = $query->getIsOverheated() || $force_overheated; if ($nux_view) { $box->appendChild($nux_view); @@ -277,13 +279,23 @@ final class PhabricatorApplicationSearchController $header = $result_header; } - if ($list->getActions()) { - foreach ($list->getActions() as $action) { + $actions = $list->getActions(); + if ($actions) { + foreach ($actions as $action) { $header->addActionLink($action); } } $use_actions = $engine->newUseResultsActions($saved_query); + + // TODO: Eventually, modularize all this stuff. + $builtin_use_actions = $this->newBuiltinUseActions(); + if ($builtin_use_actions) { + foreach ($builtin_use_actions as $builtin_use_action) { + $use_actions[] = $builtin_use_action; + } + } + if ($use_actions) { $use_dropdown = $this->newUseResultsDropdown( $saved_query, @@ -554,4 +566,34 @@ final class PhabricatorApplicationSearchController )); } + private function newBuiltinUseActions() { + $actions = array(); + + $is_dev = PhabricatorEnv::getEnvConfig('phabricator.developer-mode'); + + if ($is_dev) { + $engine = $this->getSearchEngine(); + $nux_uri = $engine->getQueryBaseURI(); + $nux_uri = id(new PhutilURI($nux_uri)) + ->setQueryParam('nux', true); + + $actions[] = id(new PhabricatorActionView()) + ->setIcon('fa-bug') + ->setName(pht('Developer: Show New User State')) + ->setHref($nux_uri); + } + + if ($is_dev) { + $overheated_uri = $this->getRequest()->getRequestURI() + ->setQueryParam('overheated', true); + + $actions[] = id(new PhabricatorActionView()) + ->setIcon('fa-bug') + ->setName(pht('Developer: Show Overheated State')) + ->setHref($overheated_uri); + } + + return $actions; + } + } diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index 221703b7fd..26a9e0f8e4 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -406,6 +406,10 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject { return $this->getURI('query/edit/'); } + public function getQueryBaseURI() { + return $this->getURI(''); + } + /** * Return the URI to a path within the application. Used to construct default