Skip to content

Commit 419b7ce

Browse files
author
epriestley
committedMay 14, 2020
Move inline comment actions into a dropdown menu
Summary: Ref T11401. Ref T13513. This paves the way for more comment actions, particularly an edit-after-submit action. Test Plan: Took all actions from menus, via mouse and via keyboard (where applicable). Maniphest Tasks: T13513, T11401 Differential Revision: https://secure.phabricator.com/D21244
1 parent 1da5483 commit 419b7ce

File tree

4 files changed

+207
-121
lines changed

4 files changed

+207
-121
lines changed
 

‎resources/celerity/map.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'core.pkg.js' => '1e667bcb',
1414
'dark-console.pkg.js' => '187792c2',
1515
'differential.pkg.css' => 'd71d4531',
16-
'differential.pkg.js' => '39781f05',
16+
'differential.pkg.js' => '21616a78',
1717
'diffusion.pkg.css' => '42c75c37',
1818
'diffusion.pkg.js' => 'a98c0bf7',
1919
'maniphest.pkg.css' => '35995d6d',
@@ -380,8 +380,8 @@
380380
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9',
381381
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
382382
'rsrc/js/application/diff/DiffChangeset.js' => '20715b98',
383-
'rsrc/js/application/diff/DiffChangesetList.js' => '564cbd20',
384-
'rsrc/js/application/diff/DiffInline.js' => 'a0ef0b54',
383+
'rsrc/js/application/diff/DiffChangesetList.js' => '40d6c41c',
384+
'rsrc/js/application/diff/DiffInline.js' => '15de2478',
385385
'rsrc/js/application/diff/DiffPathView.js' => '8207abf9',
386386
'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b',
387387
'rsrc/js/application/differential/behavior-diff-radios.js' => '925fe8cd',
@@ -775,8 +775,8 @@
775775
'phabricator-darkmessage' => '26cd4b73',
776776
'phabricator-dashboard-css' => '5a205b9d',
777777
'phabricator-diff-changeset' => '20715b98',
778-
'phabricator-diff-changeset-list' => '564cbd20',
779-
'phabricator-diff-inline' => 'a0ef0b54',
778+
'phabricator-diff-changeset-list' => '40d6c41c',
779+
'phabricator-diff-inline' => '15de2478',
780780
'phabricator-diff-path-view' => '8207abf9',
781781
'phabricator-diff-tree-view' => '5d83623b',
782782
'phabricator-drag-and-drop-file-upload' => '4370900d',
@@ -1034,6 +1034,9 @@
10341034
'javelin-stratcom',
10351035
'javelin-util',
10361036
),
1037+
'15de2478' => array(
1038+
'javelin-dom',
1039+
),
10371040
'1a844c06' => array(
10381041
'javelin-install',
10391042
'javelin-util',
@@ -1259,6 +1262,11 @@
12591262
'javelin-behavior',
12601263
'javelin-uri',
12611264
),
1265+
'40d6c41c' => array(
1266+
'javelin-install',
1267+
'phuix-button-view',
1268+
'phabricator-diff-tree-view',
1269+
),
12621270
'42c44e8b' => array(
12631271
'javelin-behavior',
12641272
'javelin-workflow',
@@ -1418,11 +1426,6 @@
14181426
'javelin-stratcom',
14191427
'javelin-dom',
14201428
),
1421-
'564cbd20' => array(
1422-
'javelin-install',
1423-
'phuix-button-view',
1424-
'phabricator-diff-tree-view',
1425-
),
14261429
'5793d835' => array(
14271430
'javelin-install',
14281431
'javelin-util',
@@ -1833,9 +1836,6 @@
18331836
'javelin-util',
18341837
'phabricator-keyboard-shortcut',
18351838
),
1836-
'a0ef0b54' => array(
1837-
'javelin-dom',
1838-
),
18391839
'a17b84f1' => array(
18401840
'javelin-behavior',
18411841
'javelin-dom',

‎src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php

+69-58
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,12 @@ public function render() {
8888
$is_synthetic = true;
8989
}
9090

91+
$is_preview = $this->preview;
92+
9193
$metadata = $this->getInlineCommentMetadata();
9294

9395
$sigil = 'differential-inline-comment';
94-
if ($this->preview) {
96+
if ($is_preview) {
9597
$sigil = $sigil.' differential-inline-comment-preview';
9698
}
9799

@@ -146,11 +148,6 @@ public function render() {
146148
$classes[] = 'inline-comment-ghost';
147149
}
148150

149-
// I think this is unused
150-
if ($inline->getHasReplies()) {
151-
$classes[] = 'inline-comment-has-reply';
152-
}
153-
154151
if ($inline->getReplyToCommentPHID()) {
155152
$classes[] = 'inline-comment-is-reply';
156153
}
@@ -167,47 +164,22 @@ public function render() {
167164
$anchor_name = $this->getAnchorName();
168165

169166
$action_buttons = array();
170-
171-
$can_reply =
172-
(!$this->editable) &&
173-
(!$this->preview) &&
174-
($this->allowReply) &&
175-
176-
// NOTE: No product reason why you can't reply to synthetic comments,
177-
// but the reply mechanism currently sends the inline comment ID to the
178-
// server, not file/line information, and synthetic comments don't have
179-
// an inline comment ID.
180-
(!$is_synthetic);
181-
182-
183-
if ($can_reply) {
184-
$action_buttons[] = id(new PHUIButtonView())
185-
->setTag('a')
186-
->setIcon('fa-reply')
187-
->setTooltip(pht('Reply'))
188-
->addSigil('differential-inline-reply')
189-
->setMustCapture(true)
190-
->setAuralLabel(pht('Reply'));
191-
}
192-
193-
if ($this->editable && !$this->preview) {
194-
$action_buttons[] = id(new PHUIButtonView())
195-
->setTag('a')
196-
->setIcon('fa-pencil')
197-
->setTooltip(pht('Edit'))
198-
->addSigil('differential-inline-edit')
199-
->setMustCapture(true)
200-
->setAuralLabel(pht('Edit'));
201-
202-
$action_buttons[] = id(new PHUIButtonView())
203-
->setTag('a')
204-
->setIcon('fa-trash-o')
205-
->setTooltip(pht('Delete'))
206-
->addSigil('differential-inline-delete')
207-
->setMustCapture(true)
208-
->setAuralLabel(pht('Delete'));
209-
210-
} else if ($this->preview) {
167+
$menu_items = array();
168+
169+
if ($this->editable && !$is_preview) {
170+
$menu_items[] = array(
171+
'label' => pht('Edit Comment'),
172+
'icon' => 'fa-pencil',
173+
'action' => 'edit',
174+
'key' => 'e',
175+
);
176+
177+
$menu_items[] = array(
178+
'label' => pht('Delete Comment'),
179+
'icon' => 'fa-trash-o',
180+
'action' => 'delete',
181+
);
182+
} else if ($is_preview) {
211183
$links[] = javelin_tag(
212184
'a',
213185
array(
@@ -228,14 +200,40 @@ public function render() {
228200
->setAuralLabel(pht('Delete'));
229201
}
230202

231-
if (!$this->preview && $this->canHide()) {
232-
$action_buttons[] = id(new PHUIButtonView())
233-
->setTag('a')
234-
->setTooltip(pht('Collapse'))
235-
->setIcon('fa-times')
236-
->addSigil('hide-inline')
237-
->setMustCapture(true)
238-
->setAuralLabel(pht('Collapse'));
203+
if (!$is_preview && $this->canHide()) {
204+
$menu_items[] = array(
205+
'label' => pht('Collapse'),
206+
'icon' => 'fa-times',
207+
'action' => 'collapse',
208+
'key' => 'q',
209+
);
210+
}
211+
212+
$can_reply =
213+
(!$this->editable) &&
214+
(!$is_preview) &&
215+
($this->allowReply) &&
216+
217+
// NOTE: No product reason why you can't reply to synthetic comments,
218+
// but the reply mechanism currently sends the inline comment ID to the
219+
// server, not file/line information, and synthetic comments don't have
220+
// an inline comment ID.
221+
(!$is_synthetic);
222+
223+
if ($can_reply) {
224+
$menu_items[] = array(
225+
'label' => pht('Reply to Comment'),
226+
'icon' => 'fa-reply',
227+
'action' => 'reply',
228+
'key' => 'r',
229+
);
230+
231+
$menu_items[] = array(
232+
'label' => pht('Quote Comment'),
233+
'icon' => 'fa-quote-left',
234+
'action' => 'quote',
235+
'key' => 'R',
236+
);
239237
}
240238

241239
$done_button = null;
@@ -283,7 +281,7 @@ public function render() {
283281
$classes[] = 'inline-state-is-draft';
284282
}
285283

286-
if ($mark_done && !$this->preview) {
284+
if ($mark_done && !$is_preview) {
287285
$done_input = javelin_tag(
288286
'input',
289287
array(
@@ -327,7 +325,7 @@ public function render() {
327325
$inline,
328326
PhabricatorInlineComment::MARKUP_FIELD_BODY);
329327

330-
if ($this->preview) {
328+
if ($is_preview) {
331329
$anchor = null;
332330
} else {
333331
$anchor = phutil_tag(
@@ -364,13 +362,24 @@ public function render() {
364362
}
365363

366364
$actions = null;
367-
if ($action_buttons) {
365+
if ($action_buttons || $menu_items) {
368366
$actions = new PHUIButtonBarView();
369367
$actions->setBorderless(true);
370368
$actions->addClass('inline-button-divider');
371369
foreach ($action_buttons as $button) {
372370
$actions->addButton($button);
373371
}
372+
373+
if (!$is_preview) {
374+
$menu_button = id(new PHUIButtonView())
375+
->setTag('a')
376+
->setColor(PHUIButtonView::GREY)
377+
->setDropdown(true)
378+
->setAuralLabel(pht('Inline Actions'))
379+
->addSigil('inline-action-dropdown');
380+
381+
$actions->addButton($menu_button);
382+
}
374383
}
375384

376385
$group_left = phutil_tag(
@@ -401,6 +410,8 @@ public function render() {
401410
->truncateString($inline->getContent());
402411
$metadata['snippet'] = pht('%s: %s', $author, $snippet);
403412

413+
$metadata['menuItems'] = $menu_items;
414+
404415
$markup = javelin_tag(
405416
'div',
406417
array(

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

+9-29
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ JX.install('DiffChangesetList', {
2020
var onmenu = JX.bind(this, this._ifawake, this._onmenu);
2121
JX.Stratcom.listen('click', 'differential-view-options', onmenu);
2222

23-
var oncollapse = JX.bind(this, this._ifawake, this._oncollapse, true);
24-
JX.Stratcom.listen('click', 'hide-inline', oncollapse);
25-
2623
var onexpand = JX.bind(this, this._ifawake, this._oncollapse, false);
2724
JX.Stratcom.listen('click', 'reveal-inline', onexpand);
2825

@@ -336,16 +333,7 @@ JX.install('DiffChangesetList', {
336333
var inline = cursor.target;
337334
if (inline.canReply()) {
338335
this.setFocus(null);
339-
340-
var text;
341-
if (is_quote) {
342-
text = inline.getRawText();
343-
text = '> ' + text.replace(/\n/g, '\n> ') + '\n\n';
344-
} else {
345-
text = '';
346-
}
347-
348-
inline.reply(text);
336+
inline.reply(true);
349337
return;
350338
}
351339
}
@@ -2094,12 +2082,6 @@ JX.install('DiffChangesetList', {
20942082
'differential-inline-comment-undo',
20952083
onundo);
20962084

2097-
var onedit = JX.bind(this, this._onInlineEvent, 'edit');
2098-
JX.Stratcom.listen(
2099-
'click',
2100-
['differential-inline-comment', 'differential-inline-edit'],
2101-
onedit);
2102-
21032085
var ondone = JX.bind(this, this._onInlineEvent, 'done');
21042086
JX.Stratcom.listen(
21052087
'click',
@@ -2112,11 +2094,11 @@ JX.install('DiffChangesetList', {
21122094
['differential-inline-comment', 'differential-inline-delete'],
21132095
ondelete);
21142096

2115-
var onreply = JX.bind(this, this._onInlineEvent, 'reply');
2097+
var onmenu = JX.bind(this, this._onInlineEvent, 'menu');
21162098
JX.Stratcom.listen(
21172099
'click',
2118-
['differential-inline-comment', 'differential-inline-reply'],
2119-
onreply);
2100+
['differential-inline-comment', 'inline-action-dropdown'],
2101+
onmenu);
21202102

21212103
var ondraft = JX.bind(this, this._onInlineEvent, 'draft');
21222104
JX.Stratcom.listen(
@@ -2156,7 +2138,7 @@ JX.install('DiffChangesetList', {
21562138
return;
21572139
}
21582140

2159-
if (action !== 'draft') {
2141+
if (action !== 'draft' && action !== 'menu') {
21602142
e.kill();
21612143
}
21622144

@@ -2201,21 +2183,19 @@ JX.install('DiffChangesetList', {
22012183
case 'undo':
22022184
inline.undo();
22032185
break;
2204-
case 'edit':
2205-
inline.edit();
2206-
break;
22072186
case 'done':
22082187
inline.toggleDone();
22092188
break;
22102189
case 'delete':
22112190
inline.delete(is_ref);
22122191
break;
2213-
case 'reply':
2214-
inline.reply();
2215-
break;
22162192
case 'draft':
22172193
inline.triggerDraft();
22182194
break;
2195+
case 'menu':
2196+
var node = e.getNode('inline-action-dropdown');
2197+
inline.activateMenu(node, e);
2198+
break;
22192199
}
22202200
}
22212201

0 commit comments

Comments
 (0)
Failed to load comments.