1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 22:40:55 +01:00

Style tweaks for Conduit API console

Summary:
  - Use pretty JSON formatter for human-readable Conduit output
  - Fix some whitespace issues with format/layout.

Test Plan:
  - Looked at conduit console.
  - Looked at human-readable output of several calls.

Reviewed By: codeblock
Reviewers: codeblock, jungejason, tuomaspelkonen, aran
CC: aran, codeblock
Differential Revision: 740
This commit is contained in:
epriestley 2011-07-28 21:32:11 -07:00
parent 879431fb50
commit ab0f09d115
3 changed files with 20 additions and 7 deletions

View file

@ -236,12 +236,12 @@ class PhabricatorConduitAPIController
$result = null) { $result = null) {
$param_rows = array(); $param_rows = array();
$param_rows[] = array('Method', phutil_escape_html($method)); $param_rows[] = array('Method', $this->renderAPIValue($method));
if ($request) { if ($request) {
foreach ($request->getAllParameters() as $key => $value) { foreach ($request->getAllParameters() as $key => $value) {
$param_rows[] = array( $param_rows[] = array(
phutil_escape_html($key), phutil_escape_html($key),
phutil_escape_html(json_encode($value)), $this->renderAPIValue($value),
); );
} }
} }
@ -257,7 +257,7 @@ class PhabricatorConduitAPIController
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
$result_rows[] = array( $result_rows[] = array(
phutil_escape_html($key), phutil_escape_html($key),
phutil_escape_html(json_encode($value)), $this->renderAPIValue($value),
); );
} }
@ -286,4 +286,18 @@ class PhabricatorConduitAPIController
)); ));
} }
private function renderAPIValue($value) {
$json = new PhutilJSON();
if (is_array($value)) {
$value = $json->encodeFormatted($value);
$value = phutil_escape_html($value);
} else {
$value = phutil_escape_html($value);
}
$value = '<pre style="white-space: pre-wrap;">'.$value.'</pre>';
return $value;
}
} }

View file

@ -17,6 +17,7 @@ phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel'); phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'parser/json');
phutil_require_module('phutil', 'utils'); phutil_require_module('phutil', 'utils');

View file

@ -106,7 +106,7 @@ class PhabricatorConduitConsoleController
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Conduit API: '.phutil_escape_html($this->method)); $panel->setHeader('Conduit API: '.phutil_escape_html($this->method));
$panel->appendChild($form); $panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_WIDE); $panel->setWidth(AphrontPanelView::WIDTH_FULL);
$view = new AphrontSideNavView(); $view = new AphrontSideNavView();
foreach ($this->buildNavItems() as $item) { foreach ($this->buildNavItems() as $item) {
@ -154,9 +154,7 @@ class PhabricatorConduitConsoleController
'class' => $selected ? 'aphront-side-nav-selected' : null, 'class' => $selected ? 'aphront-side-nav-selected' : null,
'href' => '/conduit/method/'.$method_name, 'href' => '/conduit/method/'.$method_name,
), ),
'<span style="padding-left: 1em;">'. phutil_escape_html($method_name));
phutil_escape_html($method_name).
'</span>');
} }
$items[] = '<hr />'; $items[] = '<hr />';
} }