From 1a001ca033794706d032d376918d3408a961de96 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 7 Jul 2015 11:52:06 -0700 Subject: [PATCH] Render ApplicationSearch errors correctly Summary: Fixes T8774. When an ApplicationSearch page returned an error (e.g., using a "viewer()" query while logged out), we would try to add action links to a box without a header. Instead: - If a box has no header, but has show/hide actions, just create an empty header so the view renders. This is a little silly looking but does what the caller asks. - Always set the title on the result box, so we get a header. Test Plan: Did an invalid (logged out, with viewer()) search. Did a valid search. Reviewers: btrahan, chad Reviewed By: chad Subscribers: epriestley Maniphest Tasks: T8774 Differential Revision: https://secure.phabricator.com/D13576 --- .../PhabricatorApplicationSearchController.php | 12 +++++------- src/view/phui/PHUIObjectBoxView.php | 6 +++++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/applications/search/controller/PhabricatorApplicationSearchController.php b/src/applications/search/controller/PhabricatorApplicationSearchController.php index a2b2b9e034..fb82bbc705 100644 --- a/src/applications/search/controller/PhabricatorApplicationSearchController.php +++ b/src/applications/search/controller/PhabricatorApplicationSearchController.php @@ -185,7 +185,11 @@ final class PhabricatorApplicationSearchController $title = pht('Advanced Search'); } - $box = new PHUIObjectBoxView(); + $header = id(new PHUIHeaderView()) + ->setHeader($title); + + $box = id(new PHUIObjectBoxView()) + ->setHeader($header); if ($run_query || $named_query) { $box->setShowHide( @@ -227,16 +231,12 @@ final class PhabricatorApplicationSearchController $saved_query); } - $header = id(new PHUIHeaderView()) - ->setHeader($title); if ($list->getActions()) { foreach ($list->getActions() as $action) { $header->addActionLink($action); } } - $box->setHeader($header); - if ($list->getObjectList()) { $box->setObjectList($list->getObjectList()); } @@ -267,8 +267,6 @@ final class PhabricatorApplicationSearchController 'This query specifies an invalid parameter. Review the '. 'query parameters and correct errors.'); } - } else { - $box->setHeaderText($title); } if ($errors) { diff --git a/src/view/phui/PHUIObjectBoxView.php b/src/view/phui/PHUIObjectBoxView.php index 9648ab88fe..49c55769b4 100644 --- a/src/view/phui/PHUIObjectBoxView.php +++ b/src/view/phui/PHUIObjectBoxView.php @@ -190,10 +190,10 @@ final class PHUIObjectBoxView extends AphrontView { } public function render() { - require_celerity_resource('phui-object-box-css'); $header = $this->header; + if ($this->headerText) { $header = id(new PHUIHeaderView()) ->setHeader($this->headerText); @@ -201,6 +201,10 @@ final class PHUIObjectBoxView extends AphrontView { $showhide = null; if ($this->showAction !== null) { + if (!$header) { + $header = id(new PHUIHeaderView()); + } + Javelin::initBehavior('phabricator-reveal-content'); $hide_action_id = celerity_generate_unique_node_id();