1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-07 12:28:28 +01:00

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
This commit is contained in:
epriestley 2015-07-07 11:52:06 -07:00
parent 9618ab6426
commit 1a001ca033
2 changed files with 10 additions and 8 deletions

View file

@ -185,7 +185,11 @@ final class PhabricatorApplicationSearchController
$title = pht('Advanced Search'); $title = pht('Advanced Search');
} }
$box = new PHUIObjectBoxView(); $header = id(new PHUIHeaderView())
->setHeader($title);
$box = id(new PHUIObjectBoxView())
->setHeader($header);
if ($run_query || $named_query) { if ($run_query || $named_query) {
$box->setShowHide( $box->setShowHide(
@ -227,16 +231,12 @@ final class PhabricatorApplicationSearchController
$saved_query); $saved_query);
} }
$header = id(new PHUIHeaderView())
->setHeader($title);
if ($list->getActions()) { if ($list->getActions()) {
foreach ($list->getActions() as $action) { foreach ($list->getActions() as $action) {
$header->addActionLink($action); $header->addActionLink($action);
} }
} }
$box->setHeader($header);
if ($list->getObjectList()) { if ($list->getObjectList()) {
$box->setObjectList($list->getObjectList()); $box->setObjectList($list->getObjectList());
} }
@ -267,8 +267,6 @@ final class PhabricatorApplicationSearchController
'This query specifies an invalid parameter. Review the '. 'This query specifies an invalid parameter. Review the '.
'query parameters and correct errors.'); 'query parameters and correct errors.');
} }
} else {
$box->setHeaderText($title);
} }
if ($errors) { if ($errors) {

View file

@ -190,10 +190,10 @@ final class PHUIObjectBoxView extends AphrontView {
} }
public function render() { public function render() {
require_celerity_resource('phui-object-box-css'); require_celerity_resource('phui-object-box-css');
$header = $this->header; $header = $this->header;
if ($this->headerText) { if ($this->headerText) {
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setHeader($this->headerText); ->setHeader($this->headerText);
@ -201,6 +201,10 @@ final class PHUIObjectBoxView extends AphrontView {
$showhide = null; $showhide = null;
if ($this->showAction !== null) { if ($this->showAction !== null) {
if (!$header) {
$header = id(new PHUIHeaderView());
}
Javelin::initBehavior('phabricator-reveal-content'); Javelin::initBehavior('phabricator-reveal-content');
$hide_action_id = celerity_generate_unique_node_id(); $hide_action_id = celerity_generate_unique_node_id();