Skip to content

Commit 0c85a8d

Browse files
committed
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
1 parent 889958e commit 0c85a8d

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

src/__celerity_resource_map__.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@
13481348
),
13491349
'javelin-behavior-dark-console' =>
13501350
array(
1351-
'uri' => '/res/635a9422/rsrc/js/core/behavior-dark-console.js',
1351+
'uri' => '/res/1e2c7a5e/rsrc/js/core/behavior-dark-console.js',
13521352
'type' => 'js',
13531353
'requires' =>
13541354
array(
@@ -4050,15 +4050,15 @@
40504050
'uri' => '/res/pkg/26980a1c/core.pkg.js',
40514051
'type' => 'js',
40524052
),
4053-
'6d1d1e99' =>
4053+
'4ccfeb47' =>
40544054
array(
40554055
'name' => 'darkconsole.pkg.js',
40564056
'symbols' =>
40574057
array(
40584058
0 => 'javelin-behavior-dark-console',
40594059
1 => 'javelin-behavior-error-log',
40604060
),
4061-
'uri' => '/res/pkg/6d1d1e99/darkconsole.pkg.js',
4061+
'uri' => '/res/pkg/4ccfeb47/darkconsole.pkg.js',
40624062
'type' => 'js',
40634063
),
40644064
'8aaacd1b' =>
@@ -4228,7 +4228,7 @@
42284228
'javelin-behavior-aphront-drag-and-drop-textarea' => '27c55b30',
42294229
'javelin-behavior-aphront-form-disable-on-submit' => '26980a1c',
42304230
'javelin-behavior-audit-preview' => 'f96657b8',
4231-
'javelin-behavior-dark-console' => '6d1d1e99',
4231+
'javelin-behavior-dark-console' => '4ccfeb47',
42324232
'javelin-behavior-device' => '26980a1c',
42334233
'javelin-behavior-differential-accept-with-errors' => '27c55b30',
42344234
'javelin-behavior-differential-add-reviewers-and-ccs' => '27c55b30',
@@ -4244,7 +4244,7 @@
42444244
'javelin-behavior-differential-user-select' => '27c55b30',
42454245
'javelin-behavior-diffusion-commit-graph' => 'f96657b8',
42464246
'javelin-behavior-diffusion-pull-lastmodified' => 'f96657b8',
4247-
'javelin-behavior-error-log' => '6d1d1e99',
4247+
'javelin-behavior-error-log' => '4ccfeb47',
42484248
'javelin-behavior-global-drag-and-drop' => '26980a1c',
42494249
'javelin-behavior-history-install' => '26980a1c',
42504250
'javelin-behavior-konami' => '26980a1c',

src/aphront/console/DarkConsoleCore.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ public function getKey(AphrontRequest $request) {
8383
return $key;
8484
}
8585

86+
public function getColor() {
87+
foreach ($this->getPlugins() as $plugin) {
88+
if ($plugin->getColor()) {
89+
return $plugin->getColor();
90+
}
91+
}
92+
}
93+
8694
public function render(AphrontRequest $request) {
8795
$user = $request->getUser();
8896
$visible = $user ? $user->getConsoleVisible() : true;
@@ -94,6 +102,7 @@ public function render(AphrontRequest $request) {
94102
'class' => 'dark-console',
95103
'style' => $visible ? '' : 'display: none;',
96104
'data-console-key' => $this->getKey($request),
105+
'data-console-color' => $this->getColor(),
97106
),
98107
'');
99108
}

src/aphront/console/DarkConsoleDataController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public function processRequest() {
5151
$panel = $obj->renderPanel();
5252

5353
if (!empty($_COOKIE['phsid'])) {
54-
$panel = str_replace(
54+
$panel = PhutilSafeHTML::applyFunction(
55+
'str_replace',
5556
$_COOKIE['phsid'],
5657
'(session-key)',
5758
$panel);

src/aphront/response/AphrontAjaxResponse.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public function buildResponseString() {
4242
array(
4343
'uri' => (string)$this->getRequest()->getRequestURI(),
4444
'key' => $console->getKey($this->getRequest()),
45+
'color' => $console->getColor(),
4546
));
4647
}
4748

webroot/rsrc/js/core/behavior-dark-console.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ JX.behavior('dark-console', function(config, statics) {
1212
var root = statics.root || setup_console();
1313

1414
config.key = config.key || root.getAttribute('data-console-key');
15+
16+
if (!('color' in config)) {
17+
config.color = root.getAttribute('data-console-color');
18+
}
19+
1520
add_request(config);
1621

1722
// Do first-time setup.
@@ -71,7 +76,7 @@ JX.behavior('dark-console', function(config, statics) {
7176
href: '#'
7277
};
7378

74-
var link = JX.$N('a', attr, config.uri);
79+
var link = JX.$N('a', attr, [get_bullet(config.color), ' ', config.uri]);
7580
statics.el.reqs.appendChild(link);
7681
statics.req.all[config.key] = link;
7782

@@ -81,6 +86,14 @@ JX.behavior('dark-console', function(config, statics) {
8186
}
8287

8388

89+
function get_bullet(color) {
90+
if (!color) {
91+
return null;
92+
}
93+
return JX.$N('span', {style: {color: color}}, "\u2022");
94+
}
95+
96+
8497
// Select a request (on load, or when the user clicks one).
8598
function select_request(key) {
8699
var req = statics.req;
@@ -155,12 +168,7 @@ JX.behavior('dark-console', function(config, statics) {
155168
href: '#'
156169
};
157170

158-
var bullet = null;
159-
if (tab.color) {
160-
bullet = JX.$N('span', {style: {color: tab.color}}, "\u2022");
161-
}
162-
163-
var link = JX.$N('a', attr, [bullet, ' ', tab.name]);
171+
var link = JX.$N('a', attr, [get_bullet(tab.color), ' ', tab.name]);
164172
links.push(link);
165173
statics.tab.all[tab['class']] = link;
166174
first = first || tab['class'];

0 commit comments

Comments
 (0)