Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14023293
D12128.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D12128.diff
View Options
diff --git a/src/applications/audit/editor/PhabricatorAuditEditor.php b/src/applications/audit/editor/PhabricatorAuditEditor.php
--- a/src/applications/audit/editor/PhabricatorAuditEditor.php
+++ b/src/applications/audit/editor/PhabricatorAuditEditor.php
@@ -9,6 +9,7 @@
private $heraldEmailPHIDs = array();
private $affectedFiles;
private $rawPatch;
+ private $expandedDone;
public function addAuditReason($phid, $reason) {
if (!isset($this->auditReasonMap[$phid])) {
@@ -54,6 +55,7 @@
$types[] = PhabricatorTransactions::TYPE_EDGE;
$types[] = PhabricatorAuditTransaction::TYPE_COMMIT;
+ $types[] = PhabricatorAuditTransaction::TYPE_INLINEDONE;
// TODO: These will get modernized eventually, but that can happen one
// at a time later on.
@@ -102,6 +104,7 @@
case PhabricatorAuditActionConstants::INLINE:
case PhabricatorAuditActionConstants::ADD_AUDITORS:
case PhabricatorAuditTransaction::TYPE_COMMIT:
+ case PhabricatorAuditTransaction::TYPE_INLINEDONE:
return $xaction->getNewValue();
}
@@ -120,6 +123,7 @@
case PhabricatorAuditActionConstants::INLINE:
case PhabricatorAuditActionConstants::ADD_AUDITORS:
case PhabricatorAuditTransaction::TYPE_COMMIT:
+ case PhabricatorAuditTransaction::TYPE_INLINEDONE:
return;
}
@@ -143,6 +147,18 @@
$reply->setHasReplies(1)->save();
}
return;
+ case PhabricatorAuditTransaction::TYPE_INLINEDONE:
+ $table = new PhabricatorAuditTransactionComment();
+ $conn_w = $table->establishConnection('w');
+ foreach ($xaction->getNewValue() as $phid => $state) {
+ queryfx(
+ $conn_w,
+ 'UPDATE %T SET fixedState = %s WHERE phid = %s',
+ $table->getTableName(),
+ $state,
+ $phid);
+ }
+ return;
case PhabricatorAuditActionConstants::ADD_AUDITORS:
$new = $xaction->getNewValue();
if (!is_array($new)) {
@@ -344,6 +360,52 @@
default:
break;
}
+
+ if (!$this->expandedDone) {
+
+ switch ($xaction->getTransactionType()) {
+ case PhabricatorTransactions::TYPE_COMMENT:
+ case PhabricatorAuditActionConstants::ACTION:
+ $this->expandedDone = true;
+
+ $actor_phid = $this->getActingAsPHID();
+ $actor_is_author = ($object->getAuthorPHID() == $actor_phid);
+ if (!$actor_is_author) {
+ break;
+ }
+
+ $state_map = array(
+ PhabricatorInlineCommentInterface::STATE_DRAFT =>
+ PhabricatorInlineCommentInterface::STATE_DONE,
+ PhabricatorInlineCommentInterface::STATE_UNDRAFT =>
+ PhabricatorInlineCommentInterface::STATE_UNDONE,
+ );
+
+ $inlines = id(new DiffusionDiffInlineCommentQuery())
+ ->setViewer($this->getActor())
+ ->withCommitPHIDs(array($object->getPHID()))
+ ->withFixedStates(array_keys($state_map))
+ ->execute();
+
+ if (!$inlines) {
+ break;
+ }
+
+ $old_value = mpull($inlines, 'getFixedState', 'getPHID');
+ $new_value = array();
+ foreach ($old_value as $key => $state) {
+ $new_value[$key] = $state_map[$state];
+ }
+
+ $xactions[] = id(new PhabricatorAuditTransaction())
+ ->setTransactionType(PhabricatorAuditTransaction::TYPE_INLINEDONE)
+ ->setIgnoreOnNoEffect(true)
+ ->setOldValue($old_value)
+ ->setNewValue($new_value);
+ break;
+ }
+ }
+
return $xactions;
}
diff --git a/src/applications/audit/storage/PhabricatorAuditTransaction.php b/src/applications/audit/storage/PhabricatorAuditTransaction.php
--- a/src/applications/audit/storage/PhabricatorAuditTransaction.php
+++ b/src/applications/audit/storage/PhabricatorAuditTransaction.php
@@ -4,6 +4,7 @@
extends PhabricatorApplicationTransaction {
const TYPE_COMMIT = 'audit:commit';
+ const TYPE_INLINEDONE = 'audit:inlinedone';
const MAILTAG_ACTION_CONCERN = 'audit-action-concern';
const MAILTAG_ACTION_ACCEPT = 'audit-action-accept';
@@ -182,6 +183,36 @@
}
return $title;
+ case self::TYPE_INLINEDONE:
+ $done = 0;
+ $undone = 0;
+ foreach ($new as $phid => $state) {
+ if ($state == PhabricatorInlineCommentInterface::STATE_DONE) {
+ $done++;
+ } else {
+ $undone++;
+ }
+ }
+ if ($done && $undone) {
+ return pht(
+ '%s marked %s inline comment(s) as done and %s inline comment(s) '.
+ 'as not done.',
+ $author_handle,
+ new PhutilNumber($done),
+ new PhutilNumber($undone));
+ } else if ($done) {
+ return pht(
+ '%s marked %s inline comment(s) as done.',
+ $author_handle,
+ new PhutilNumber($done));
+ } else {
+ return pht(
+ '%s marked %s inline comment(s) as not done.',
+ $author_handle,
+ new PhutilNumber($undone));
+ }
+ break;
+
case PhabricatorAuditActionConstants::INLINE:
return pht(
'%s added inline comments.',
@@ -388,6 +419,16 @@
}
+ public function shouldGenerateOldValue() {
+ switch ($this->getTransactionType()) {
+ case self::TYPE_INLINEDONE:
+ return false;
+ }
+
+ return parent::shouldGenerateOldValue();
+ }
+
+
// TODO: These two mail methods can likely be abstracted by introducing a
// formal concept of "inline comment" transactions.
diff --git a/src/applications/diffusion/controller/DiffusionInlineCommentController.php b/src/applications/diffusion/controller/DiffusionInlineCommentController.php
--- a/src/applications/diffusion/controller/DiffusionInlineCommentController.php
+++ b/src/applications/diffusion/controller/DiffusionInlineCommentController.php
@@ -70,7 +70,7 @@
$commit = id(new DiffusionCommitQuery())
->setViewer($viewer)
->withPHIDs(array($inline->getCommitPHID()))
- ->exeucteOne();
+ ->executeOne();
if (!$commit) {
throw new Exception(pht('Failed to load commit.'));
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 8, 12:50 AM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6739308
Default Alt Text
D12128.diff (6 KB)
Attached To
Mode
D12128: Publish "done" inline comment checkbox state in Diffusion
Attached
Detach File
Event Timeline
Log In to Comment