mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-27 01:02:42 +01:00
Make marking comments as "Done" work cleanly on EditEngine
Summary: Ref T11114. Fixes T10323. Test Plan: - Marked comments as done only: no warning about not leaving a comment. - Did nothing: warning about posting an empty comment. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11114, T10323 Differential Revision: https://secure.phabricator.com/D17120
This commit is contained in:
parent
a4ba7daf90
commit
69194fdaf5
2 changed files with 43 additions and 0 deletions
|
@ -262,6 +262,31 @@ final class DifferentialRevisionEditEngine
|
||||||
->attachComment($inline);
|
->attachComment($inline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$viewer_phid = $viewer->getPHID();
|
||||||
|
$viewer_is_author = ($object->getAuthorPHID() == $viewer_phid);
|
||||||
|
if ($viewer_is_author) {
|
||||||
|
$state_map = PhabricatorTransactions::getInlineStateMap();
|
||||||
|
|
||||||
|
$inlines = id(new DifferentialDiffInlineCommentQuery())
|
||||||
|
->setViewer($viewer)
|
||||||
|
->withRevisionPHIDs(array($object->getPHID()))
|
||||||
|
->withFixedStates(array_keys($state_map))
|
||||||
|
->execute();
|
||||||
|
if ($inlines) {
|
||||||
|
$old_value = mpull($inlines, 'getFixedState', 'getPHID');
|
||||||
|
$new_value = array();
|
||||||
|
foreach ($old_value as $key => $state) {
|
||||||
|
$new_value[$key] = $state_map[$state];
|
||||||
|
}
|
||||||
|
|
||||||
|
$xactions[] = id(new DifferentialTransaction())
|
||||||
|
->setTransactionType(PhabricatorTransactions::TYPE_INLINESTATE)
|
||||||
|
->setIgnoreOnNoEffect(true)
|
||||||
|
->setOldValue($old_value)
|
||||||
|
->setNewValue($new_value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $xactions;
|
return $xactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ final class DifferentialTransactionEditor
|
||||||
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
||||||
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
|
$types[] = PhabricatorTransactions::TYPE_INLINESTATE;
|
||||||
|
|
||||||
$types[] = DifferentialTransaction::TYPE_ACTION;
|
$types[] = DifferentialTransaction::TYPE_ACTION;
|
||||||
$types[] = DifferentialTransaction::TYPE_INLINE;
|
$types[] = DifferentialTransaction::TYPE_INLINE;
|
||||||
|
@ -256,6 +257,23 @@ final class DifferentialTransactionEditor
|
||||||
return parent::applyCustomInternalTransaction($object, $xaction);
|
return parent::applyCustomInternalTransaction($object, $xaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function expandTransactions(
|
||||||
|
PhabricatorLiskDAO $object,
|
||||||
|
array $xactions) {
|
||||||
|
|
||||||
|
// If we have an "Inline State" transaction already, the caller built it
|
||||||
|
// for us so we don't need to expand it again.
|
||||||
|
foreach ($xactions as $xaction) {
|
||||||
|
switch ($xaction->getTransactionType()) {
|
||||||
|
case PhabricatorTransactions::TYPE_INLINESTATE:
|
||||||
|
$this->didExpandInlineState = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::expandTransactions($object, $xactions);
|
||||||
|
}
|
||||||
|
|
||||||
protected function expandTransaction(
|
protected function expandTransaction(
|
||||||
PhabricatorLiskDAO $object,
|
PhabricatorLiskDAO $object,
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
|
Loading…
Reference in a new issue