mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Publish "done" inline comment checkbox state in Diffusion
Summary: Ref T1460. See D12126. This is essentially the same change, but for Diffusion. This is a bit copy/pastey. I'm going to make an effort to lift inline handling into the core before pushing this in, so hopefully that will clean things up a bit. Test Plan: Submitted stuff in Diffusion and got checkmarks to publish. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T1460 Differential Revision: https://secure.phabricator.com/D12128
This commit is contained in:
parent
9f3210c883
commit
cbb5a297d5
3 changed files with 104 additions and 1 deletions
|
@ -9,6 +9,7 @@ final class PhabricatorAuditEditor
|
||||||
private $heraldEmailPHIDs = array();
|
private $heraldEmailPHIDs = array();
|
||||||
private $affectedFiles;
|
private $affectedFiles;
|
||||||
private $rawPatch;
|
private $rawPatch;
|
||||||
|
private $expandedDone;
|
||||||
|
|
||||||
public function addAuditReason($phid, $reason) {
|
public function addAuditReason($phid, $reason) {
|
||||||
if (!isset($this->auditReasonMap[$phid])) {
|
if (!isset($this->auditReasonMap[$phid])) {
|
||||||
|
@ -54,6 +55,7 @@ final class PhabricatorAuditEditor
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
$types[] = PhabricatorTransactions::TYPE_EDGE;
|
||||||
|
|
||||||
$types[] = PhabricatorAuditTransaction::TYPE_COMMIT;
|
$types[] = PhabricatorAuditTransaction::TYPE_COMMIT;
|
||||||
|
$types[] = PhabricatorAuditTransaction::TYPE_INLINEDONE;
|
||||||
|
|
||||||
// TODO: These will get modernized eventually, but that can happen one
|
// TODO: These will get modernized eventually, but that can happen one
|
||||||
// at a time later on.
|
// at a time later on.
|
||||||
|
@ -102,6 +104,7 @@ final class PhabricatorAuditEditor
|
||||||
case PhabricatorAuditActionConstants::INLINE:
|
case PhabricatorAuditActionConstants::INLINE:
|
||||||
case PhabricatorAuditActionConstants::ADD_AUDITORS:
|
case PhabricatorAuditActionConstants::ADD_AUDITORS:
|
||||||
case PhabricatorAuditTransaction::TYPE_COMMIT:
|
case PhabricatorAuditTransaction::TYPE_COMMIT:
|
||||||
|
case PhabricatorAuditTransaction::TYPE_INLINEDONE:
|
||||||
return $xaction->getNewValue();
|
return $xaction->getNewValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +123,7 @@ final class PhabricatorAuditEditor
|
||||||
case PhabricatorAuditActionConstants::INLINE:
|
case PhabricatorAuditActionConstants::INLINE:
|
||||||
case PhabricatorAuditActionConstants::ADD_AUDITORS:
|
case PhabricatorAuditActionConstants::ADD_AUDITORS:
|
||||||
case PhabricatorAuditTransaction::TYPE_COMMIT:
|
case PhabricatorAuditTransaction::TYPE_COMMIT:
|
||||||
|
case PhabricatorAuditTransaction::TYPE_INLINEDONE:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +147,18 @@ final class PhabricatorAuditEditor
|
||||||
$reply->setHasReplies(1)->save();
|
$reply->setHasReplies(1)->save();
|
||||||
}
|
}
|
||||||
return;
|
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:
|
case PhabricatorAuditActionConstants::ADD_AUDITORS:
|
||||||
$new = $xaction->getNewValue();
|
$new = $xaction->getNewValue();
|
||||||
if (!is_array($new)) {
|
if (!is_array($new)) {
|
||||||
|
@ -344,6 +360,52 @@ final class PhabricatorAuditEditor
|
||||||
default:
|
default:
|
||||||
break;
|
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;
|
return $xactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ final class PhabricatorAuditTransaction
|
||||||
extends PhabricatorApplicationTransaction {
|
extends PhabricatorApplicationTransaction {
|
||||||
|
|
||||||
const TYPE_COMMIT = 'audit:commit';
|
const TYPE_COMMIT = 'audit:commit';
|
||||||
|
const TYPE_INLINEDONE = 'audit:inlinedone';
|
||||||
|
|
||||||
const MAILTAG_ACTION_CONCERN = 'audit-action-concern';
|
const MAILTAG_ACTION_CONCERN = 'audit-action-concern';
|
||||||
const MAILTAG_ACTION_ACCEPT = 'audit-action-accept';
|
const MAILTAG_ACTION_ACCEPT = 'audit-action-accept';
|
||||||
|
@ -182,6 +183,36 @@ final class PhabricatorAuditTransaction
|
||||||
}
|
}
|
||||||
return $title;
|
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:
|
case PhabricatorAuditActionConstants::INLINE:
|
||||||
return pht(
|
return pht(
|
||||||
'%s added inline comments.',
|
'%s added inline comments.',
|
||||||
|
@ -388,6 +419,16 @@ final class PhabricatorAuditTransaction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
// TODO: These two mail methods can likely be abstracted by introducing a
|
||||||
// formal concept of "inline comment" transactions.
|
// formal concept of "inline comment" transactions.
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ final class DiffusionInlineCommentController
|
||||||
$commit = id(new DiffusionCommitQuery())
|
$commit = id(new DiffusionCommitQuery())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer)
|
||||||
->withPHIDs(array($inline->getCommitPHID()))
|
->withPHIDs(array($inline->getCommitPHID()))
|
||||||
->exeucteOne();
|
->executeOne();
|
||||||
if (!$commit) {
|
if (!$commit) {
|
||||||
throw new Exception(pht('Failed to load commit.'));
|
throw new Exception(pht('Failed to load commit.'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue