Skip to content

Commit e9f4a84

Browse files
author
epriestley
committed
Allow inline comments to be individually hidden
Summary: Ref T7447. Implements per-viewer comment hiding. Once a comment is obsolete or uninteresting, you can hide it completely. This is sticky per-user. My hope is that this will strike a better balance between concerns than some of the other approaches (conservative porting, summarization, hide-all). Specifically, this adds a new action here: {F435621} Clicking it completely collapses the comment into a small icon on the previous line, and saves the comment state as hidden for you: {F435626} You can click the icon to reveal all hidden comments below the line. Test Plan: - Hid comments. - Showed comments. - Created, edited, deleted and submitted comments. - Used Diffusion comments (hiding is not implemented there yet, but I'd plan to bring it there eventually if it works out in Differential). Reviewers: btrahan, chad Reviewed By: btrahan Subscribers: jparise, yelirekim, epriestley Maniphest Tasks: T7447 Differential Revision: https://secure.phabricator.com/D13009
1 parent fcac85d commit e9f4a84

26 files changed

+446
-57
lines changed

resources/celerity/map.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
'core.pkg.css' => '439658b5',
1111
'core.pkg.js' => '328799d0',
1212
'darkconsole.pkg.js' => 'e7393ebb',
13-
'differential.pkg.css' => 'bb338e4b',
14-
'differential.pkg.js' => '63a77807',
13+
'differential.pkg.css' => '30602b8c',
14+
'differential.pkg.js' => '8c98ce21',
1515
'diffusion.pkg.css' => '591664fa',
1616
'diffusion.pkg.js' => '0115b37c',
1717
'maniphest.pkg.css' => '68d4dd3d',
@@ -60,7 +60,7 @@
6060
'rsrc/css/application/differential/add-comment.css' => 'c47f8c40',
6161
'rsrc/css/application/differential/changeset-view.css' => 'e19cfd6e',
6262
'rsrc/css/application/differential/core.css' => '7ac3cabc',
63-
'rsrc/css/application/differential/phui-inline-comment.css' => '2174771a',
63+
'rsrc/css/application/differential/phui-inline-comment.css' => 'aa16f165',
6464
'rsrc/css/application/differential/results-table.css' => '181aa9d9',
6565
'rsrc/css/application/differential/revision-comment.css' => '14b8565a',
6666
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
@@ -353,7 +353,7 @@
353353
'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76',
354354
'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1',
355355
'rsrc/js/application/differential/behavior-dropdown-menus.js' => '2035b9cb',
356-
'rsrc/js/application/differential/behavior-edit-inline-comments.js' => 'e723c323',
356+
'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '037b59eb',
357357
'rsrc/js/application/differential/behavior-keyboard-nav.js' => '2c426492',
358358
'rsrc/js/application/differential/behavior-populate.js' => '8694b1df',
359359
'rsrc/js/application/differential/behavior-show-field-details.js' => 'bba9eedf',
@@ -443,7 +443,7 @@
443443
'rsrc/js/core/behavior-device.js' => 'a205cf28',
444444
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e',
445445
'rsrc/js/core/behavior-error-log.js' => '6882e80a',
446-
'rsrc/js/core/behavior-fancy-datepicker.js' => '2d4029a8',
446+
'rsrc/js/core/behavior-fancy-datepicker.js' => '5c0f680f',
447447
'rsrc/js/core/behavior-file-tree.js' => '88236f00',
448448
'rsrc/js/core/behavior-form.js' => '5c54cbf3',
449449
'rsrc/js/core/behavior-gesture.js' => '3ab51e2c',
@@ -560,7 +560,7 @@
560560
'javelin-behavior-differential-comment-jump' => '4fdb476d',
561561
'javelin-behavior-differential-diff-radios' => 'e1ff79b1',
562562
'javelin-behavior-differential-dropdown-menus' => '2035b9cb',
563-
'javelin-behavior-differential-edit-inline-comments' => 'e723c323',
563+
'javelin-behavior-differential-edit-inline-comments' => '037b59eb',
564564
'javelin-behavior-differential-feedback-preview' => 'b064af76',
565565
'javelin-behavior-differential-keyboard-navigation' => '2c426492',
566566
'javelin-behavior-differential-populate' => '8694b1df',
@@ -576,7 +576,7 @@
576576
'javelin-behavior-durable-column' => '16c695bf',
577577
'javelin-behavior-error-log' => '6882e80a',
578578
'javelin-behavior-event-all-day' => '38dcf3c8',
579-
'javelin-behavior-fancy-datepicker' => '2d4029a8',
579+
'javelin-behavior-fancy-datepicker' => '5c0f680f',
580580
'javelin-behavior-global-drag-and-drop' => 'c8e57404',
581581
'javelin-behavior-herald-rule-editor' => '7ebaeed3',
582582
'javelin-behavior-high-security-warning' => 'a464fe03',
@@ -782,7 +782,7 @@
782782
'phui-image-mask-css' => '5a8b09c8',
783783
'phui-info-panel-css' => '27ea50a1',
784784
'phui-info-view-css' => 'c6f0aef8',
785-
'phui-inline-comment-view-css' => '2174771a',
785+
'phui-inline-comment-view-css' => 'aa16f165',
786786
'phui-list-view-css' => '2e25ebfb',
787787
'phui-object-box-css' => '7d160002',
788788
'phui-object-item-list-view-css' => 'f3a22696',
@@ -830,6 +830,14 @@
830830
'029a133d' => array(
831831
'aphront-dialog-view-css',
832832
),
833+
'037b59eb' => array(
834+
'javelin-behavior',
835+
'javelin-stratcom',
836+
'javelin-dom',
837+
'javelin-util',
838+
'javelin-vector',
839+
'differential-inline-comment-editor',
840+
),
833841
'048330fa' => array(
834842
'javelin-behavior',
835843
'javelin-typeahead-ondemand-source',
@@ -1042,13 +1050,6 @@
10421050
'javelin-install',
10431051
'javelin-event',
10441052
),
1045-
'2d4029a8' => array(
1046-
'javelin-behavior',
1047-
'javelin-util',
1048-
'javelin-dom',
1049-
'javelin-stratcom',
1050-
'javelin-vector',
1051-
),
10521053
'331b1611' => array(
10531054
'javelin-install',
10541055
),
@@ -1241,6 +1242,13 @@
12411242
'javelin-uri',
12421243
'javelin-routable',
12431244
),
1245+
'5c0f680f' => array(
1246+
'javelin-behavior',
1247+
'javelin-util',
1248+
'javelin-dom',
1249+
'javelin-stratcom',
1250+
'javelin-vector',
1251+
),
12441252
'5c54cbf3' => array(
12451253
'javelin-behavior',
12461254
'javelin-stratcom',
@@ -1925,14 +1933,6 @@
19251933
'e6e25838' => array(
19261934
'javelin-install',
19271935
),
1928-
'e723c323' => array(
1929-
'javelin-behavior',
1930-
'javelin-stratcom',
1931-
'javelin-dom',
1932-
'javelin-util',
1933-
'javelin-vector',
1934-
'differential-inline-comment-editor',
1935-
),
19361936
'e9581f08' => array(
19371937
'javelin-behavior',
19381938
'javelin-stratcom',
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE {$NAMESPACE}_differential.differential_hiddencomment (
2+
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
3+
userPHID VARBINARY(64) NOT NULL,
4+
commentID INT UNSIGNED NOT NULL,
5+
UNIQUE KEY `key_user` (userPHID, commentID),
6+
KEY `key_comment` (commentID)
7+
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};

src/__phutil_library_map__.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@
374374
'DifferentialGetWorkingCopy' => 'applications/differential/DifferentialGetWorkingCopy.php',
375375
'DifferentialGitHubLandingStrategy' => 'applications/differential/landing/DifferentialGitHubLandingStrategy.php',
376376
'DifferentialGitSVNIDField' => 'applications/differential/customfield/DifferentialGitSVNIDField.php',
377+
'DifferentialHiddenComment' => 'applications/differential/storage/DifferentialHiddenComment.php',
377378
'DifferentialHostField' => 'applications/differential/customfield/DifferentialHostField.php',
378379
'DifferentialHostedGitLandingStrategy' => 'applications/differential/landing/DifferentialHostedGitLandingStrategy.php',
379380
'DifferentialHostedMercurialLandingStrategy' => 'applications/differential/landing/DifferentialHostedMercurialLandingStrategy.php',
@@ -1178,6 +1179,7 @@
11781179
'PHUIDiffInlineCommentUndoView' => 'infrastructure/diff/view/PHUIDiffInlineCommentUndoView.php',
11791180
'PHUIDiffInlineCommentView' => 'infrastructure/diff/view/PHUIDiffInlineCommentView.php',
11801181
'PHUIDiffOneUpInlineCommentRowScaffold' => 'infrastructure/diff/view/PHUIDiffOneUpInlineCommentRowScaffold.php',
1182+
'PHUIDiffRevealIconView' => 'infrastructure/diff/view/PHUIDiffRevealIconView.php',
11811183
'PHUIDiffTwoUpInlineCommentRowScaffold' => 'infrastructure/diff/view/PHUIDiffTwoUpInlineCommentRowScaffold.php',
11821184
'PHUIDocumentExample' => 'applications/uiexample/examples/PHUIDocumentExample.php',
11831185
'PHUIDocumentView' => 'view/phui/PHUIDocumentView.php',
@@ -3616,6 +3618,7 @@
36163618
'DifferentialGetRevisionConduitAPIMethod' => 'DifferentialConduitAPIMethod',
36173619
'DifferentialGitHubLandingStrategy' => 'DifferentialLandingStrategy',
36183620
'DifferentialGitSVNIDField' => 'DifferentialCustomField',
3621+
'DifferentialHiddenComment' => 'DifferentialDAO',
36193622
'DifferentialHostField' => 'DifferentialCustomField',
36203623
'DifferentialHostedGitLandingStrategy' => 'DifferentialLandingStrategy',
36213624
'DifferentialHostedMercurialLandingStrategy' => 'DifferentialLandingStrategy',
@@ -4506,6 +4509,7 @@
45064509
'PHUIDiffInlineCommentUndoView' => 'PHUIDiffInlineCommentView',
45074510
'PHUIDiffInlineCommentView' => 'AphrontView',
45084511
'PHUIDiffOneUpInlineCommentRowScaffold' => 'PHUIDiffInlineCommentRowScaffold',
4512+
'PHUIDiffRevealIconView' => 'AphrontView',
45094513
'PHUIDiffTwoUpInlineCommentRowScaffold' => 'PHUIDiffInlineCommentRowScaffold',
45104514
'PHUIDocumentExample' => 'PhabricatorUIExample',
45114515
'PHUIDocumentView' => 'AphrontTagView',

src/applications/audit/storage/PhabricatorAuditInlineComment.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public function getTransactionComment() {
2323
return $this->proxy;
2424
}
2525

26+
public function supportsHiding() {
27+
return false;
28+
}
29+
30+
public function isHidden() {
31+
return false;
32+
}
33+
2634
public function getTransactionCommentForSave() {
2735
$content_source = PhabricatorContentSource::newForSource(
2836
PhabricatorContentSource::SOURCE_LEGACY,

src/applications/differential/controller/DifferentialChangesetViewController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ public function handleRequest(AphrontRequest $request) {
191191
if ($revision) {
192192
$query = id(new DifferentialInlineCommentQuery())
193193
->setViewer($viewer)
194+
->needHidden(true)
194195
->withRevisionPHIDs(array($revision->getPHID()));
195196
$inlines = $query->execute();
196197
$inlines = $query->adjustInlinesForChangesets(

src/applications/differential/controller/DifferentialInlineCommentEditController.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ protected function loadComment($id) {
4242
->setViewer($this->getViewer())
4343
->withIDs(array($id))
4444
->withDeletedDrafts(true)
45+
->needHidden(true)
4546
->executeOne();
4647
}
4748

@@ -50,6 +51,7 @@ protected function loadCommentByPHID($phid) {
5051
->setViewer($this->getViewer())
5152
->withPHIDs(array($phid))
5253
->withDeletedDrafts(true)
54+
->needHidden(true)
5355
->executeOne();
5456
}
5557

@@ -152,4 +154,38 @@ protected function loadObjectOwnerPHID(
152154
return $this->loadRevision()->getAuthorPHID();
153155
}
154156

157+
protected function hideComments(array $ids) {
158+
$viewer = $this->getViewer();
159+
$table = new DifferentialHiddenComment();
160+
$conn_w = $table->establishConnection('w');
161+
162+
$sql = array();
163+
foreach ($ids as $id) {
164+
$sql[] = qsprintf(
165+
$conn_w,
166+
'(%s, %d)',
167+
$viewer->getPHID(),
168+
$id);
169+
}
170+
171+
queryfx(
172+
$conn_w,
173+
'INSERT IGNORE INTO %T (userPHID, commentID) VALUES %Q',
174+
$table->getTableName(),
175+
implode(', ', $sql));
176+
}
177+
178+
protected function showComments(array $ids) {
179+
$viewer = $this->getViewer();
180+
$table = new DifferentialHiddenComment();
181+
$conn_w = $table->establishConnection('w');
182+
183+
queryfx(
184+
$conn_w,
185+
'DELETE FROM %T WHERE userPHID = %s AND commentID IN (%Ld)',
186+
$table->getTableName(),
187+
$viewer->getPHID(),
188+
$ids);
189+
}
190+
155191
}

src/applications/differential/controller/DifferentialInlineCommentPreviewController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ protected function loadInlineComments() {
1919
->withDrafts(true)
2020
->withAuthorPHIDs(array($viewer->getPHID()))
2121
->withRevisionPHIDs(array($revision->getPHID()))
22+
->needHidden(true)
2223
->execute();
2324
}
2425

src/applications/differential/controller/DifferentialRevisionViewController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public function processRequest() {
175175

176176
$query = id(new DifferentialInlineCommentQuery())
177177
->setViewer($user)
178+
->needHidden(true)
178179
->withRevisionPHIDs(array($revision->getPHID()));
179180
$inlines = $query->execute();
180181
$inlines = $query->adjustInlinesForChangesets(

src/applications/differential/query/DifferentialInlineCommentQuery.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ final class DifferentialInlineCommentQuery
1515
private $authorPHIDs;
1616
private $revisionPHIDs;
1717
private $deletedDrafts;
18+
private $needHidden;
1819

1920
public function setViewer(PhabricatorUser $viewer) {
2021
$this->viewer = $viewer;
@@ -55,6 +56,11 @@ public function withDeletedDrafts($deleted_drafts) {
5556
return $this;
5657
}
5758

59+
public function needHidden($need) {
60+
$this->needHidden = $need;
61+
return $this;
62+
}
63+
5864
public function execute() {
5965
$table = new DifferentialTransactionComment();
6066
$conn_r = $table->establishConnection('r');
@@ -68,6 +74,26 @@ public function execute() {
6874

6975
$comments = $table->loadAllFromArray($data);
7076

77+
if ($this->needHidden) {
78+
$viewer_phid = $this->getViewer()->getPHID();
79+
if ($viewer_phid && $comments) {
80+
$hidden = queryfx_all(
81+
$conn_r,
82+
'SELECT commentID FROM %T WHERE userPHID = %s
83+
AND commentID IN (%Ls)',
84+
id(new DifferentialHiddenComment())->getTableName(),
85+
$viewer_phid,
86+
mpull($comments, 'getID'));
87+
$hidden = array_fuse(ipull($hidden, 'commentID'));
88+
} else {
89+
$hidden = array();
90+
}
91+
92+
foreach ($comments as $inline) {
93+
$inline->attachIsHidden(isset($hidden[$inline->getID()]));
94+
}
95+
}
96+
7197
foreach ($comments as $key => $value) {
7298
$comments[$key] = DifferentialInlineComment::newFromModernComment(
7399
$value);

src/applications/differential/render/DifferentialChangesetOneUpRenderer.php

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ protected function renderPrimitives(array $primitives, $rows) {
4141

4242
$column_width = 4;
4343

44+
$hidden = new PHUIDiffRevealIconView();
45+
4446
$out = array();
45-
foreach ($primitives as $p) {
47+
foreach ($primitives as $k => $p) {
4648
$type = $p['type'];
4749
switch ($type) {
4850
case 'old':
@@ -51,6 +53,27 @@ protected function renderPrimitives(array $primitives, $rows) {
5153
case 'new-file':
5254
$is_old = ($type == 'old' || $type == 'old-file');
5355

56+
$o_hidden = array();
57+
$n_hidden = array();
58+
59+
for ($look = $k + 1; isset($primitives[$look]); $look++) {
60+
$next = $primitives[$look];
61+
switch ($next['type']) {
62+
case 'inline':
63+
$comment = $next['comment'];
64+
if ($comment->isHidden()) {
65+
if ($next['right']) {
66+
$n_hidden[] = $comment;
67+
} else {
68+
$o_hidden[] = $comment;
69+
}
70+
}
71+
break;
72+
default:
73+
break 2;
74+
}
75+
}
76+
5477
$cells = array();
5578
if ($is_old) {
5679
if ($p['htype']) {
@@ -68,7 +91,13 @@ protected function renderPrimitives(array $primitives, $rows) {
6891
} else {
6992
$left_id = null;
7093
}
71-
$cells[] = phutil_tag('th', array('id' => $left_id), $p['line']);
94+
95+
$line = $p['line'];
96+
if ($o_hidden) {
97+
$line = array($hidden, $line);
98+
}
99+
100+
$cells[] = phutil_tag('th', array('id' => $left_id), $line);
72101

73102
$cells[] = phutil_tag('th', array());
74103
$cells[] = $no_copy;
@@ -85,7 +114,13 @@ protected function renderPrimitives(array $primitives, $rows) {
85114
} else {
86115
$left_id = null;
87116
}
88-
$cells[] = phutil_tag('th', array('id' => $left_id), $p['oline']);
117+
118+
$oline = $p['oline'];
119+
if ($o_hidden) {
120+
$oline = array($hidden, $oline);
121+
}
122+
123+
$cells[] = phutil_tag('th', array('id' => $left_id), $oline);
89124
}
90125

91126
if ($type == 'new-file') {
@@ -97,8 +132,13 @@ protected function renderPrimitives(array $primitives, $rows) {
97132
} else {
98133
$right_id = null;
99134
}
100-
$cells[] = phutil_tag('th', array('id' => $right_id), $p['line']);
101135

136+
$line = $p['line'];
137+
if ($n_hidden) {
138+
$line = array($hidden, $line);
139+
}
140+
141+
$cells[] = phutil_tag('th', array('id' => $right_id), $line);
102142

103143
$cells[] = $no_copy;
104144
$cells[] = phutil_tag('td', array('class' => $class), $p['render']);

0 commit comments

Comments
 (0)