2013-06-21 21:54:29 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DifferentialTransactionComment
|
|
|
|
extends PhabricatorApplicationTransactionComment {
|
|
|
|
|
|
|
|
protected $revisionPHID;
|
|
|
|
protected $changesetID;
|
Migrate all Differential inline comments to ApplicationTransactions
Summary:
Ref T2222. This implements step (1) described there, which is moving over all the inline comments.
The old and new tables are simliar. The only real trick here is that `transactionPHID` and `legacyCommentID` mean roughly the same thing (`null` if the inline is a draft, non-null if it has been submitted) but we don't have real `transactionPHID`s yet. We just make some up -- we'll backfill them later.
Two risks here:
- I need to take a second look at the keys on this table. I think we need to tweak them a bit, and it will be less disruptive to do that before this migration than after.
- This will take a while for Facebook, and other large installs with tens of thousands of revisions. I'll communicate this.
I'm otherwise pretty satisfied with this, seems to work well and is pretty low risk / non-disruptive.
Test Plan:
- Before migrating, then after migrating:
- Made a bunch of inlines (drafts, submitted).
- Edited and deleted inlines.
- Verified inlines showed up in preview.
- Verified that inlines aren't indexed when they're drafts (`bin/search index D935`).
- Verified that inlines ARE indexed when they're not drafts.
- Verified that drafts inlines make revisions appear as "with draft" in the revision list.
- Made left, right, and draft inlines.
- Migrated (`bin/storage upgrade`).
- Verified that my inlines from before the migration still showed up.
- (Repeated all the stuff above.)
- Manually inspected the inline comment table.
Reviewers: btrahan
Reviewed By: btrahan
CC: FacebookPOC, aran
Maniphest Tasks: T2222
Differential Revision: https://secure.phabricator.com/D7139
2013-10-19 14:03:25 +02:00
|
|
|
protected $isNewFile = 0;
|
|
|
|
protected $lineNumber = 0;
|
|
|
|
protected $lineLength = 0;
|
2013-06-21 21:54:29 +02:00
|
|
|
protected $fixedState;
|
|
|
|
protected $hasReplies = 0;
|
|
|
|
protected $replyToCommentPHID;
|
|
|
|
|
2015-03-09 19:51:26 +01:00
|
|
|
private $replyToComment = self::ATTACHABLE;
|
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
2015-05-27 19:28:38 +02:00
|
|
|
private $isHidden = self::ATTACHABLE;
|
2015-03-09 19:51:26 +01:00
|
|
|
|
2013-06-21 21:54:29 +02:00
|
|
|
public function getApplicationTransactionObject() {
|
|
|
|
return new DifferentialTransaction();
|
|
|
|
}
|
|
|
|
|
2015-03-09 19:51:26 +01:00
|
|
|
public function attachReplyToComment(
|
|
|
|
DifferentialTransactionComment $comment = null) {
|
|
|
|
$this->replyToComment = $comment;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getReplyToComment() {
|
|
|
|
return $this->assertAttached($this->replyToComment);
|
|
|
|
}
|
|
|
|
|
2015-01-13 20:47:05 +01:00
|
|
|
protected function getConfiguration() {
|
2014-09-29 00:12:58 +02:00
|
|
|
$config = parent::getConfiguration();
|
|
|
|
$config[self::CONFIG_COLUMN_SCHEMA] = array(
|
|
|
|
'revisionPHID' => 'phid?',
|
|
|
|
'changesetID' => 'id?',
|
|
|
|
'isNewFile' => 'bool',
|
|
|
|
'lineNumber' => 'uint32',
|
|
|
|
'lineLength' => 'uint32',
|
|
|
|
'fixedState' => 'text12?',
|
|
|
|
'hasReplies' => 'bool',
|
|
|
|
'replyToCommentPHID' => 'phid?',
|
|
|
|
) + $config[self::CONFIG_COLUMN_SCHEMA];
|
|
|
|
$config[self::CONFIG_KEY_SCHEMA] = array(
|
|
|
|
'key_draft' => array(
|
|
|
|
'columns' => array('authorPHID', 'transactionPHID'),
|
|
|
|
),
|
|
|
|
'key_changeset' => array(
|
|
|
|
'columns' => array('changesetID'),
|
|
|
|
),
|
|
|
|
'key_revision' => array(
|
|
|
|
'columns' => array('revisionPHID'),
|
|
|
|
),
|
|
|
|
) + $config[self::CONFIG_KEY_SCHEMA];
|
|
|
|
return $config;
|
|
|
|
}
|
|
|
|
|
2013-06-21 21:54:29 +02:00
|
|
|
public function shouldUseMarkupCache($field) {
|
|
|
|
// Only cache submitted comments.
|
|
|
|
return ($this->getTransactionPHID() != null);
|
|
|
|
}
|
2014-02-21 20:52:03 +01:00
|
|
|
|
|
|
|
public static function sortAndGroupInlines(
|
|
|
|
array $inlines,
|
|
|
|
array $changesets) {
|
|
|
|
assert_instances_of($inlines, 'DifferentialTransaction');
|
|
|
|
assert_instances_of($changesets, 'DifferentialChangeset');
|
|
|
|
|
|
|
|
$changesets = mpull($changesets, null, 'getID');
|
|
|
|
$changesets = msort($changesets, 'getFilename');
|
|
|
|
|
|
|
|
// Group the changesets by file and reorder them by display order.
|
|
|
|
$inline_groups = array();
|
|
|
|
foreach ($inlines as $inline) {
|
|
|
|
$changeset_id = $inline->getComment()->getChangesetID();
|
|
|
|
$inline_groups[$changeset_id][] = $inline;
|
|
|
|
}
|
|
|
|
$inline_groups = array_select_keys($inline_groups, array_keys($changesets));
|
|
|
|
|
|
|
|
foreach ($inline_groups as $changeset_id => $group) {
|
|
|
|
// Sort the group of inlines by line number.
|
|
|
|
$items = array();
|
|
|
|
foreach ($group as $inline) {
|
|
|
|
$comment = $inline->getComment();
|
2014-04-04 03:41:49 +02:00
|
|
|
$num = $comment->getLineNumber();
|
|
|
|
$len = $comment->getLineLength();
|
|
|
|
$id = $comment->getID();
|
2014-02-21 20:52:03 +01:00
|
|
|
|
|
|
|
$items[] = array(
|
|
|
|
'inline' => $inline,
|
2014-04-04 03:41:49 +02:00
|
|
|
'sort' => sprintf('~%010d%010d%010d', $num, $len, $id),
|
2014-02-21 20:52:03 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$items = isort($items, 'sort');
|
|
|
|
$items = ipull($items, 'inline');
|
|
|
|
$inline_groups[$changeset_id] = $items;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $inline_groups;
|
|
|
|
}
|
|
|
|
|
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
2015-05-27 19:28:38 +02:00
|
|
|
public function getIsHidden() {
|
|
|
|
return $this->assertAttached($this->isHidden);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function attachIsHidden($hidden) {
|
|
|
|
$this->isHidden = $hidden;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-06-21 21:54:29 +02:00
|
|
|
}
|