Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit fbd57ad

Browse files
author
epriestley
committed
Give selected inline comments are more obvious selected state
Summary: Ref T13513. Give selected inlines a selection state and visual cues which are similar to the changeset selection state. Also fix a couple of minor issues with select interactions and offset comments. Test Plan: Selected inlines, saw obvious visual cues. Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21256
1 parent b021da7 commit fbd57ad

File tree

7 files changed

+129
-56
lines changed

7 files changed

+129
-56
lines changed

resources/celerity/map.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
'core.pkg.css' => 'a560707d',
1313
'core.pkg.js' => '845355f4',
1414
'dark-console.pkg.js' => '187792c2',
15-
'differential.pkg.css' => 'b042ee8b',
16-
'differential.pkg.js' => 'e0600220',
15+
'differential.pkg.css' => '319dca29',
16+
'differential.pkg.js' => 'ccf7bdca',
1717
'diffusion.pkg.css' => '42c75c37',
1818
'diffusion.pkg.js' => 'a98c0bf7',
1919
'maniphest.pkg.css' => '35995d6d',
@@ -65,7 +65,7 @@
6565
'rsrc/css/application/differential/add-comment.css' => '7e5900d9',
6666
'rsrc/css/application/differential/changeset-view.css' => 'df3afa61',
6767
'rsrc/css/application/differential/core.css' => '7300a73e',
68-
'rsrc/css/application/differential/phui-inline-comment.css' => '48acce5b',
68+
'rsrc/css/application/differential/phui-inline-comment.css' => 'd5749acc',
6969
'rsrc/css/application/differential/revision-comment.css' => '7dbc8d1d',
7070
'rsrc/css/application/differential/revision-history.css' => '8aa3eac5',
7171
'rsrc/css/application/differential/revision-list.css' => '93d2df7d',
@@ -379,9 +379,9 @@
379379
'rsrc/js/application/dashboard/behavior-dashboard-move-panels.js' => 'a2ab19be',
380380
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9',
381381
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
382-
'rsrc/js/application/diff/DiffChangeset.js' => 'd721533b',
383-
'rsrc/js/application/diff/DiffChangesetList.js' => '8b0eab21',
384-
'rsrc/js/application/diff/DiffInline.js' => '734d3c33',
382+
'rsrc/js/application/diff/DiffChangeset.js' => 'bfdae878',
383+
'rsrc/js/application/diff/DiffChangesetList.js' => 'a00bf62d',
384+
'rsrc/js/application/diff/DiffInline.js' => 'b00168c1',
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',
@@ -774,9 +774,9 @@
774774
'phabricator-darklog' => '3b869402',
775775
'phabricator-darkmessage' => '26cd4b73',
776776
'phabricator-dashboard-css' => '5a205b9d',
777-
'phabricator-diff-changeset' => 'd721533b',
778-
'phabricator-diff-changeset-list' => '8b0eab21',
779-
'phabricator-diff-inline' => '734d3c33',
777+
'phabricator-diff-changeset' => 'bfdae878',
778+
'phabricator-diff-changeset-list' => 'a00bf62d',
779+
'phabricator-diff-inline' => 'b00168c1',
780780
'phabricator-diff-path-view' => '8207abf9',
781781
'phabricator-diff-tree-view' => '5d83623b',
782782
'phabricator-drag-and-drop-file-upload' => '4370900d',
@@ -854,7 +854,7 @@
854854
'phui-icon-view-css' => '4cbc684a',
855855
'phui-image-mask-css' => '62c7f4d2',
856856
'phui-info-view-css' => 'a10a909b',
857-
'phui-inline-comment-view-css' => '48acce5b',
857+
'phui-inline-comment-view-css' => 'd5749acc',
858858
'phui-invisible-character-view-css' => 'c694c4a4',
859859
'phui-left-right-css' => '68513c34',
860860
'phui-lightbox-css' => '4ebf22da',
@@ -1560,9 +1560,6 @@
15601560
'javelin-util',
15611561
'javelin-reactor-node-calmer',
15621562
),
1563-
'734d3c33' => array(
1564-
'javelin-dom',
1565-
),
15661563
'73ecc1f8' => array(
15671564
'javelin-behavior',
15681565
'javelin-behavior-device',
@@ -1670,11 +1667,6 @@
16701667
'javelin-dom',
16711668
'phabricator-draggable-list',
16721669
),
1673-
'8b0eab21' => array(
1674-
'javelin-install',
1675-
'phuix-button-view',
1676-
'phabricator-diff-tree-view',
1677-
),
16781670
'8b5c7d65' => array(
16791671
'javelin-behavior',
16801672
'javelin-stratcom',
@@ -1816,6 +1808,11 @@
18161808
'javelin-util',
18171809
'phabricator-keyboard-shortcut',
18181810
),
1811+
'a00bf62d' => array(
1812+
'javelin-install',
1813+
'phuix-button-view',
1814+
'phabricator-diff-tree-view',
1815+
),
18191816
'a17b84f1' => array(
18201817
'javelin-behavior',
18211818
'javelin-dom',
@@ -1927,6 +1924,9 @@
19271924
'javelin-behavior-device',
19281925
'javelin-vector',
19291926
),
1927+
'b00168c1' => array(
1928+
'javelin-dom',
1929+
),
19301930
'b105a3a6' => array(
19311931
'javelin-behavior',
19321932
'javelin-stratcom',
@@ -2019,6 +2019,19 @@
20192019
'bcec20f0' => array(
20202020
'phui-theme-css',
20212021
),
2022+
'bfdae878' => array(
2023+
'javelin-dom',
2024+
'javelin-util',
2025+
'javelin-stratcom',
2026+
'javelin-install',
2027+
'javelin-workflow',
2028+
'javelin-router',
2029+
'javelin-behavior-device',
2030+
'javelin-vector',
2031+
'phabricator-diff-inline',
2032+
'phabricator-diff-path-view',
2033+
'phuix-button-view',
2034+
),
20222035
'c03f2fb4' => array(
20232036
'javelin-install',
20242037
),
@@ -2090,19 +2103,6 @@
20902103
'd4cc2d2a' => array(
20912104
'javelin-install',
20922105
),
2093-
'd721533b' => array(
2094-
'javelin-dom',
2095-
'javelin-util',
2096-
'javelin-stratcom',
2097-
'javelin-install',
2098-
'javelin-workflow',
2099-
'javelin-router',
2100-
'javelin-behavior-device',
2101-
'javelin-vector',
2102-
'phabricator-diff-inline',
2103-
'phabricator-diff-path-view',
2104-
'phuix-button-view',
2105-
),
21062106
'd8a86cfb' => array(
21072107
'javelin-behavior',
21082108
'javelin-dom',

src/applications/celerity/postprocessor/CelerityDefaultPostprocessor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ public function buildVariables() {
8282
'alphablack' => '0,0,0',
8383

8484
// Base Greys
85+
'thingreyborder' => '#dadee8',
8586
'lightgreyborder' => '#C7CCD9',
8687
'greyborder' => '#A1A6B0',
8788
'darkgreyborder' => '#676A70',
@@ -207,6 +208,7 @@ public function buildVariables() {
207208
// Usually light yellow
208209
'gentle.highlight' => '#fdf3da',
209210
'gentle.highlight.border' => '#c9b8a8',
211+
'gentle.highlight.background' => '#fffdf6',
210212

211213
'highlight.bright' => '#fdf320',
212214

src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ public function render() {
7979
require_celerity_resource('phui-inline-comment-view-css');
8080
$inline = $this->getInlineComment();
8181

82-
$classes = array(
83-
'differential-inline-comment',
84-
);
85-
8682
$is_synthetic = false;
8783
if ($inline->getSyntheticAuthor()) {
8884
$is_synthetic = true;
@@ -92,14 +88,18 @@ public function render() {
9288

9389
$metadata = $this->getInlineCommentMetadata();
9490

91+
$classes = array(
92+
'differential-inline-comment',
93+
);
94+
9595
$sigil = 'differential-inline-comment';
9696
if ($is_preview) {
9797
$sigil = $sigil.' differential-inline-comment-preview';
98-
}
9998

100-
$classes = array(
101-
'differential-inline-comment',
102-
);
99+
$classes[] = 'inline-comment-preview';
100+
} else {
101+
$classes[] = 'inline-comment-element';
102+
}
103103

104104
$content = $inline->getContent();
105105
$handles = $this->handles;

webroot/rsrc/css/application/differential/phui-inline-comment.css

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
.differential-inline-comment,
2727
.differential-inline-comment-edit {
28-
background: {$page.content};
29-
border: 1px solid {$gentle.highlight.border};
3028
font: {$basefont};
3129
-moz-box-sizing: border-box;
3230
-webkit-box-sizing: border-box;
@@ -35,6 +33,8 @@
3533
white-space: normal;
3634
border-radius: 3px;
3735
margin: 8px 12px;
36+
background: {$page.content};
37+
border: 1px solid {$blueborder};
3838
}
3939

4040
.device .differential-inline-comment {
@@ -48,9 +48,10 @@
4848
.differential-inline-comment-head {
4949
font-weight: bold;
5050
color: {$darkbluetext};
51-
border-bottom: 1px solid {$gentle.highlight.border};
5251
padding: 4px 5px 4px 8px;
53-
background-color: {$gentle.highlight};
52+
53+
background: {$lightbluebackground};
54+
border-bottom: 1px solid {$blueborder};
5455
}
5556

5657
.differential-inline-comment-content {
@@ -261,21 +262,14 @@
261262
color: {$sky};
262263
}
263264

264-
265-
/* - Inline Is Done -----------------------------------------------------------
266-
267-
Is Done for Diff Author = grey, for Diff Viewer = yellow.
268-
269-
*/
270-
271265
.differential-inline-comment.inline-is-done {
272-
border-color: {$lightgreyborder};
266+
border-color: {$thingreyborder};
273267
}
274268

275269
.differential-inline-comment.inline-is-done
276270
.differential-inline-comment-head {
277271
background-color: {$lightgreybackground};
278-
border-bottom-color: {$lightgreyborder};
272+
border-bottom-color: {$thingreyborder};
279273
}
280274

281275
.differential-inline-comment.inline-is-done .differential-inline-comment-head
@@ -427,3 +421,18 @@
427421
.differential-inline-comment-synthetic .inline-button-divider {
428422
border: none;
429423
}
424+
425+
.inline-comment-element .differential-inline-comment-head {
426+
cursor: pointer;
427+
}
428+
429+
.inline-comment-selected .inline-comment-element {
430+
border-color: {$yellow};
431+
background: {$gentle.highlight.background};
432+
}
433+
434+
.inline-comment-selected .inline-comment-element
435+
.differential-inline-comment-head {
436+
background: {$lightyellow};
437+
border-color: {$yellow};
438+
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@ JX.install('DiffChangeset', {
5050
this._loadChangesetState(data.changesetState);
5151
}
5252

53+
JX.enableDispatch(window, 'selectstart');
54+
5355
var onselect = JX.bind(this, this._onClickHeader);
54-
JX.DOM.listen(this._node, 'mousedown', 'changeset-header', onselect);
56+
JX.DOM.listen(
57+
this._node,
58+
['mousedown', 'selectstart'],
59+
'changeset-header',
60+
onselect);
5561
},
5662

5763
members: {
@@ -907,6 +913,13 @@ JX.install('DiffChangeset', {
907913
return;
908914
}
909915

916+
// Don't allow repeatedly clicking a header to begin a "select word" or
917+
// "select line" operation.
918+
if (e.getType() === 'selectstart') {
919+
e.kill();
920+
return;
921+
}
922+
910923
// NOTE: Don't prevent or kill the event. If the user has text selected,
911924
// clicking a header should clear the selection (and dismiss any inline
912925
// context menu, if one exists) as clicking elsewhere in the document

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@ JX.install('DiffChangesetList', {
2929
var onscroll = JX.bind(this, this._ifawake, this._onscroll);
3030
JX.Stratcom.listen('scroll', null, onscroll);
3131

32+
JX.enableDispatch(window, 'selectstart');
33+
3234
var onselect = JX.bind(this, this._ifawake, this._onselect);
3335
JX.Stratcom.listen(
34-
'mousedown',
36+
['mousedown', 'selectstart'],
3537
['differential-inline-comment', 'differential-inline-header'],
3638
onselect);
3739

@@ -717,7 +719,22 @@ JX.install('DiffChangesetList', {
717719
},
718720

719721
_setSelectionState: function(item, scroll) {
722+
var old = this._cursorItem;
723+
724+
if (old) {
725+
if (old.type === 'comment') {
726+
old.target.setIsSelected(false);
727+
}
728+
}
729+
720730
this._cursorItem = item;
731+
732+
if (item) {
733+
if (item.type === 'comment') {
734+
item.target.setIsSelected(true);
735+
}
736+
}
737+
721738
this._redrawSelection(scroll);
722739

723740
return this;
@@ -1126,6 +1143,14 @@ JX.install('DiffChangesetList', {
11261143
return;
11271144
}
11281145

1146+
// If the user has double-clicked or triple-clicked a header, we want to
1147+
// toggle the inline selection mode, not select text. Kill select events
1148+
// originating with this element as the target.
1149+
if (e.getType() === 'selectstart') {
1150+
e.kill();
1151+
return;
1152+
}
1153+
11291154
var inline = this._getInlineForEvent(e);
11301155
if (!inline) {
11311156
return;

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ JX.install('DiffInline', {
5050

5151
_startOffset: null,
5252
_endOffset: null,
53+
_isSelected: false,
5354

5455
bindToRow: function(row) {
5556
this._row = row;
@@ -161,15 +162,38 @@ JX.install('DiffInline', {
161162
return this._endOffset;
162163
},
163164

165+
setIsSelected: function(is_selected) {
166+
this._isSelected = is_selected;
167+
168+
if (this._row) {
169+
JX.DOM.alterClass(
170+
this._row,
171+
'inline-comment-selected',
172+
this._isSelected);
173+
}
174+
175+
return this;
176+
},
177+
164178
bindToRange: function(data) {
165179
this._displaySide = data.displaySide;
166180
this._number = parseInt(data.number, 10);
167181
this._length = parseInt(data.length, 10);
168182
this._isNewFile = data.isNewFile;
169183
this._changesetID = data.changesetID;
170184
this._isNew = true;
171-
this._startOffset = null;
172-
this._endOffset = null;
185+
186+
if (data.hasOwnProperty('startOffset')) {
187+
this._startOffset = data.startOffset;
188+
} else {
189+
this._startOffset = null;
190+
}
191+
192+
if (data.hasOwnProperty('endOffset')) {
193+
this._endOffset = data.endOffset;
194+
} else {
195+
this._endOffset = null;
196+
}
173197

174198
// Insert the comment after any other comments which already appear on
175199
// the same row.

0 commit comments

Comments
 (0)