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
This commit is contained in:
epriestley
2015-05-27 10:28:38 -07:00
parent fcac85d807
commit e9f4a84a89
26 changed files with 454 additions and 65 deletions

View File

@@ -191,6 +191,7 @@ final class DifferentialChangesetViewController extends DifferentialController {
if ($revision) {
$query = id(new DifferentialInlineCommentQuery())
->setViewer($viewer)
->needHidden(true)
->withRevisionPHIDs(array($revision->getPHID()));
$inlines = $query->execute();
$inlines = $query->adjustInlinesForChangesets(

View File

@@ -42,6 +42,7 @@ final class DifferentialInlineCommentEditController
->setViewer($this->getViewer())
->withIDs(array($id))
->withDeletedDrafts(true)
->needHidden(true)
->executeOne();
}
@@ -50,6 +51,7 @@ final class DifferentialInlineCommentEditController
->setViewer($this->getViewer())
->withPHIDs(array($phid))
->withDeletedDrafts(true)
->needHidden(true)
->executeOne();
}
@@ -152,4 +154,38 @@ final class DifferentialInlineCommentEditController
return $this->loadRevision()->getAuthorPHID();
}
protected function hideComments(array $ids) {
$viewer = $this->getViewer();
$table = new DifferentialHiddenComment();
$conn_w = $table->establishConnection('w');
$sql = array();
foreach ($ids as $id) {
$sql[] = qsprintf(
$conn_w,
'(%s, %d)',
$viewer->getPHID(),
$id);
}
queryfx(
$conn_w,
'INSERT IGNORE INTO %T (userPHID, commentID) VALUES %Q',
$table->getTableName(),
implode(', ', $sql));
}
protected function showComments(array $ids) {
$viewer = $this->getViewer();
$table = new DifferentialHiddenComment();
$conn_w = $table->establishConnection('w');
queryfx(
$conn_w,
'DELETE FROM %T WHERE userPHID = %s AND commentID IN (%Ld)',
$table->getTableName(),
$viewer->getPHID(),
$ids);
}
}

View File

@@ -19,6 +19,7 @@ extends PhabricatorInlineCommentPreviewController {
->withDrafts(true)
->withAuthorPHIDs(array($viewer->getPHID()))
->withRevisionPHIDs(array($revision->getPHID()))
->needHidden(true)
->execute();
}

View File

@@ -175,6 +175,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
$query = id(new DifferentialInlineCommentQuery())
->setViewer($user)
->needHidden(true)
->withRevisionPHIDs(array($revision->getPHID()));
$inlines = $query->execute();
$inlines = $query->adjustInlinesForChangesets(