1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-03 07:59:15 +01:00

Display bullet next to request with errors in DarkConsole.

Summary:
I always put a `phlog()` somewhere or something fails and I have hard times figuring out which request it was.

Also fix safe HTML in panel.

Test Plan: Looked at DarkConsole with error on main page, AJAX request and both.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5784
This commit is contained in:
Jakub Vrana 2013-04-25 18:30:13 -07:00
parent 889958e876
commit 0c85a8de87
5 changed files with 32 additions and 13 deletions

View file

@ -1348,7 +1348,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-dark-console' =>
array(
'uri' => '/res/635a9422/rsrc/js/core/behavior-dark-console.js',
'uri' => '/res/1e2c7a5e/rsrc/js/core/behavior-dark-console.js',
'type' => 'js',
'requires' =>
array(
@ -4050,7 +4050,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/26980a1c/core.pkg.js',
'type' => 'js',
),
'6d1d1e99' =>
'4ccfeb47' =>
array(
'name' => 'darkconsole.pkg.js',
'symbols' =>
@ -4058,7 +4058,7 @@ celerity_register_resource_map(array(
0 => 'javelin-behavior-dark-console',
1 => 'javelin-behavior-error-log',
),
'uri' => '/res/pkg/6d1d1e99/darkconsole.pkg.js',
'uri' => '/res/pkg/4ccfeb47/darkconsole.pkg.js',
'type' => 'js',
),
'8aaacd1b' =>
@ -4228,7 +4228,7 @@ celerity_register_resource_map(array(
'javelin-behavior-aphront-drag-and-drop-textarea' => '27c55b30',
'javelin-behavior-aphront-form-disable-on-submit' => '26980a1c',
'javelin-behavior-audit-preview' => 'f96657b8',
'javelin-behavior-dark-console' => '6d1d1e99',
'javelin-behavior-dark-console' => '4ccfeb47',
'javelin-behavior-device' => '26980a1c',
'javelin-behavior-differential-accept-with-errors' => '27c55b30',
'javelin-behavior-differential-add-reviewers-and-ccs' => '27c55b30',
@ -4244,7 +4244,7 @@ celerity_register_resource_map(array(
'javelin-behavior-differential-user-select' => '27c55b30',
'javelin-behavior-diffusion-commit-graph' => 'f96657b8',
'javelin-behavior-diffusion-pull-lastmodified' => 'f96657b8',
'javelin-behavior-error-log' => '6d1d1e99',
'javelin-behavior-error-log' => '4ccfeb47',
'javelin-behavior-global-drag-and-drop' => '26980a1c',
'javelin-behavior-history-install' => '26980a1c',
'javelin-behavior-konami' => '26980a1c',

View file

@ -83,6 +83,14 @@ final class DarkConsoleCore {
return $key;
}
public function getColor() {
foreach ($this->getPlugins() as $plugin) {
if ($plugin->getColor()) {
return $plugin->getColor();
}
}
}
public function render(AphrontRequest $request) {
$user = $request->getUser();
$visible = $user ? $user->getConsoleVisible() : true;
@ -94,6 +102,7 @@ final class DarkConsoleCore {
'class' => 'dark-console',
'style' => $visible ? '' : 'display: none;',
'data-console-key' => $this->getKey($request),
'data-console-color' => $this->getColor(),
),
'');
}

View file

@ -51,7 +51,8 @@ final class DarkConsoleDataController extends PhabricatorController {
$panel = $obj->renderPanel();
if (!empty($_COOKIE['phsid'])) {
$panel = str_replace(
$panel = PhutilSafeHTML::applyFunction(
'str_replace',
$_COOKIE['phsid'],
'(session-key)',
$panel);

View file

@ -42,6 +42,7 @@ final class AphrontAjaxResponse extends AphrontResponse {
array(
'uri' => (string)$this->getRequest()->getRequestURI(),
'key' => $console->getKey($this->getRequest()),
'color' => $console->getColor(),
));
}

View file

@ -12,6 +12,11 @@ JX.behavior('dark-console', function(config, statics) {
var root = statics.root || setup_console();
config.key = config.key || root.getAttribute('data-console-key');
if (!('color' in config)) {
config.color = root.getAttribute('data-console-color');
}
add_request(config);
// Do first-time setup.
@ -71,7 +76,7 @@ JX.behavior('dark-console', function(config, statics) {
href: '#'
};
var link = JX.$N('a', attr, config.uri);
var link = JX.$N('a', attr, [get_bullet(config.color), ' ', config.uri]);
statics.el.reqs.appendChild(link);
statics.req.all[config.key] = link;
@ -81,6 +86,14 @@ JX.behavior('dark-console', function(config, statics) {
}
function get_bullet(color) {
if (!color) {
return null;
}
return JX.$N('span', {style: {color: color}}, "\u2022");
}
// Select a request (on load, or when the user clicks one).
function select_request(key) {
var req = statics.req;
@ -155,12 +168,7 @@ JX.behavior('dark-console', function(config, statics) {
href: '#'
};
var bullet = null;
if (tab.color) {
bullet = JX.$N('span', {style: {color: tab.color}}, "\u2022");
}
var link = JX.$N('a', attr, [bullet, ' ', tab.name]);
var link = JX.$N('a', attr, [get_bullet(tab.color), ' ', tab.name]);
links.push(link);
statics.tab.all[tab['class']] = link;
first = first || tab['class'];