Skip to content

Commit 2fb1edf

Browse files
author
epriestley
committed
Restore the Differential "edit" and "reply" keyboard shortcuts
Summary: Ref T12616. This makes "edit" and "reply" work again. Test Plan: Used "e" and "r" to edit and reply. Also used them in bogus ways and got useful UI feedback. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12616 Differential Revision: https://secure.phabricator.com/D17895
1 parent 588a66c commit 2fb1edf

File tree

5 files changed

+119
-26
lines changed

5 files changed

+119
-26
lines changed

resources/celerity/map.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'core.pkg.js' => '2ff7879f',
1414
'darkconsole.pkg.js' => '1f9a31bc',
1515
'differential.pkg.css' => '58712637',
16-
'differential.pkg.js' => 'e6129b80',
16+
'differential.pkg.js' => '5ee318c2',
1717
'diffusion.pkg.css' => 'b93d9b8c',
1818
'diffusion.pkg.js' => '84c8f8fd',
1919
'favicon.ico' => '30672e08',
@@ -390,9 +390,9 @@
390390
'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => '408bf173',
391391
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375',
392392
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63',
393-
'rsrc/js/application/diff/DiffChangeset.js' => '3d4b3c5e',
394-
'rsrc/js/application/diff/DiffChangesetList.js' => 'e2c315d9',
395-
'rsrc/js/application/diff/DiffInline.js' => '98c12b2f',
393+
'rsrc/js/application/diff/DiffChangeset.js' => 'f7100923',
394+
'rsrc/js/application/diff/DiffChangesetList.js' => 'f10fd7a3',
395+
'rsrc/js/application/diff/DiffInline.js' => '00db3c3a',
396396
'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832',
397397
'rsrc/js/application/differential/behavior-comment-jump.js' => '4fdb476d',
398398
'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76',
@@ -781,9 +781,9 @@
781781
'phabricator-darklog' => 'c8e1ffe3',
782782
'phabricator-darkmessage' => 'c48cccdd',
783783
'phabricator-dashboard-css' => 'fe5b1869',
784-
'phabricator-diff-changeset' => '3d4b3c5e',
785-
'phabricator-diff-changeset-list' => 'e2c315d9',
786-
'phabricator-diff-inline' => '98c12b2f',
784+
'phabricator-diff-changeset' => 'f7100923',
785+
'phabricator-diff-changeset-list' => 'f10fd7a3',
786+
'phabricator-diff-inline' => '00db3c3a',
787787
'phabricator-drag-and-drop-file-upload' => '58dea2fa',
788788
'phabricator-draggable-list' => 'bea6e7f4',
789789
'phabricator-fatal-config-template-css' => '8f18fa41',
@@ -918,6 +918,9 @@
918918
'unhandled-exception-css' => '4c96257a',
919919
),
920920
'requires' => array(
921+
'00db3c3a' => array(
922+
'javelin-dom',
923+
),
921924
'013ffff9' => array(
922925
'javelin-install',
923926
'javelin-util',
@@ -1158,17 +1161,6 @@
11581161
'javelin-util',
11591162
'javelin-uri',
11601163
),
1161-
'3d4b3c5e' => array(
1162-
'javelin-dom',
1163-
'javelin-util',
1164-
'javelin-stratcom',
1165-
'javelin-install',
1166-
'javelin-workflow',
1167-
'javelin-router',
1168-
'javelin-behavior-device',
1169-
'javelin-vector',
1170-
'phabricator-diff-inline',
1171-
),
11721164
'3dbf94d5' => array(
11731165
'javelin-behavior',
11741166
'javelin-dom',
@@ -1666,9 +1658,6 @@
16661658
'javelin-dom',
16671659
'javelin-reactor-dom',
16681660
),
1669-
'98c12b2f' => array(
1670-
'javelin-dom',
1671-
),
16721661
'9a6dd75c' => array(
16731662
'javelin-behavior',
16741663
'javelin-stratcom',
@@ -2108,9 +2097,6 @@
21082097
'javelin-stratcom',
21092098
'javelin-dom',
21102099
),
2111-
'e2c315d9' => array(
2112-
'javelin-install',
2113-
),
21142100
'e2e0a072' => array(
21152101
'javelin-behavior',
21162102
'javelin-stratcom',
@@ -2181,6 +2167,9 @@
21812167
'javelin-workflow',
21822168
'javelin-json',
21832169
),
2170+
'f10fd7a3' => array(
2171+
'javelin-install',
2172+
),
21842173
'f12cbc9f' => array(
21852174
'phui-oi-list-view-css',
21862175
),
@@ -2199,6 +2188,17 @@
21992188
'phuix-icon-view',
22002189
'phabricator-prefab',
22012190
),
2191+
'f7100923' => array(
2192+
'javelin-dom',
2193+
'javelin-util',
2194+
'javelin-stratcom',
2195+
'javelin-install',
2196+
'javelin-workflow',
2197+
'javelin-router',
2198+
'javelin-behavior-device',
2199+
'javelin-vector',
2200+
'phabricator-diff-inline',
2201+
),
22022202
'f7fc67ec' => array(
22032203
'javelin-install',
22042204
'javelin-typeahead',

src/applications/differential/view/DifferentialChangesetListView.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,14 @@ public function render() {
244244
pht('Jump to previous inline comment.'),
245245
'Jump to the table of contents.' =>
246246
pht('Jump to the table of contents.'),
247+
'Reply to selected inline comment.' =>
248+
pht('Reply to selected inline comment.'),
249+
'Edit selected inline comment.' =>
250+
pht('Edit selected inline comment.'),
251+
'You must select a comment to reply to.' =>
252+
pht('You must select a comment to reply to.'),
253+
'You must select a comment to edit.' =>
254+
pht('You must select a comment to edit.'),
247255
),
248256
));
249257

webroot/rsrc/js/application/diff/DiffChangeset.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,19 @@ JX.install('DiffChangeset', {
367367

368368
if (block.type == 'comment') {
369369
for (var jj = 0; jj < block.items.length; jj++) {
370+
var inline = this.getInlineForRow(block.items[jj]);
371+
372+
// If this inline has been collapsed, don't select it with the
373+
// keyboard cursor.
374+
if (inline.isHidden()) {
375+
continue;
376+
}
377+
370378
items.push({
371379
type: block.type,
372380
changeset: this,
373381
target: block.items[jj],
382+
inline: inline,
374383
nodes: {
375384
begin: block.items[jj],
376385
end: block.items[jj]

webroot/rsrc/js/application/diff/DiffChangesetList.js

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ JX.install('DiffChangesetList', {
9898

9999
label = pht('Jump to the table of contents.');
100100
this._installKey('t', label, this._ontoc);
101+
102+
label = pht('Reply to selected inline comment.');
103+
this._installKey('r', label, this._onreply);
104+
105+
label = pht('Edit selected inline comment.');
106+
this._installKey('e', label, this._onedit);
101107
},
102108

103109
isAsleep: function() {
@@ -185,6 +191,52 @@ JX.install('DiffChangesetList', {
185191
manager.scrollTo(toc);
186192
},
187193

194+
_onreply: function(manager) {
195+
var cursor = this._cursorItem;
196+
197+
if (cursor) {
198+
if (cursor.type == 'comment') {
199+
var inline = cursor.inline;
200+
if (inline.canReply()) {
201+
manager.focusOn(null);
202+
203+
inline.reply();
204+
return;
205+
}
206+
}
207+
}
208+
209+
var pht = this.getTranslations();
210+
this._warnUser(pht('You must select a comment to reply to.'));
211+
},
212+
213+
_onedit: function(manager) {
214+
var cursor = this._cursorItem;
215+
216+
if (cursor) {
217+
if (cursor.type == 'comment') {
218+
var inline = cursor.inline;
219+
if (inline.canEdit()) {
220+
manager.focusOn(null);
221+
222+
inline.edit();
223+
return;
224+
}
225+
}
226+
}
227+
228+
var pht = this.getTranslations();
229+
this._warnUser(pht('You must select a comment to edit.'));
230+
},
231+
232+
_warnUser: function(message) {
233+
new JX.Notification()
234+
.setContent(message)
235+
.alterClassName('jx-notification-alert', true)
236+
.setDuration(1000)
237+
.show();
238+
},
239+
188240
_onjumpkey: function(delta, filter, manager) {
189241
var state = this._getSelectionState();
190242

@@ -534,8 +586,7 @@ JX.install('DiffChangesetList', {
534586
},
535587

536588
_onaction: function(action, e) {
537-
// TODO: This can become a kill once things fully switch over..
538-
e.prevent();
589+
e.kill();
539590

540591
var inline = this._getInlineForEvent(e);
541592
var is_ref = false;

webroot/rsrc/js/application/diff/DiffInline.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,27 @@ JX.install('DiffInline', {
114114
return this;
115115
},
116116

117+
canReply: function() {
118+
if (!this._hasAction('reply')) {
119+
return false;
120+
}
121+
122+
return true;
123+
},
124+
125+
canEdit: function() {
126+
if (!this._hasAction('edit')) {
127+
return false;
128+
}
129+
130+
return true;
131+
},
132+
133+
_hasAction: function(action) {
134+
var nodes = JX.DOM.scry(this._row, 'a', 'differential-inline-' + action);
135+
return (nodes.length > 0);
136+
},
137+
117138
_newRow: function() {
118139
var attributes = {
119140
sigil: 'inline-row'
@@ -151,6 +172,10 @@ JX.install('DiffInline', {
151172
.start();
152173
},
153174

175+
isHidden: function() {
176+
return this._hidden;
177+
},
178+
154179
toggleDone: function() {
155180
var uri = this._getInlineURI();
156181
var data = {

0 commit comments

Comments
 (0)