mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +01:00
Publish draft "done" status when submitting comments/updates/actions/inlines
Summary: Ref T1460. When a revision author updates/comments/etc on a revision, publish all their checkmarks. This doesn't handle Diffusion/audits yet. Test Plan: {F346870} Reviewers: btrahan Reviewed By: btrahan Subscribers: yelirekim, epriestley Maniphest Tasks: T1460 Differential Revision: https://secure.phabricator.com/D12126
This commit is contained in:
parent
4310c4ed53
commit
9f3210c883
4 changed files with 152 additions and 0 deletions
|
@ -7,6 +7,7 @@ final class DifferentialTransactionEditor
|
||||||
private $changedPriorToCommitURI;
|
private $changedPriorToCommitURI;
|
||||||
private $isCloseByCommit;
|
private $isCloseByCommit;
|
||||||
private $repositoryPHIDOverride = false;
|
private $repositoryPHIDOverride = false;
|
||||||
|
private $expandedDone = false;
|
||||||
|
|
||||||
public function getEditorApplicationClass() {
|
public function getEditorApplicationClass() {
|
||||||
return 'PhabricatorDifferentialApplication';
|
return 'PhabricatorDifferentialApplication';
|
||||||
|
@ -99,6 +100,7 @@ final class DifferentialTransactionEditor
|
||||||
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
||||||
case DifferentialTransaction::TYPE_ACTION:
|
case DifferentialTransaction::TYPE_ACTION:
|
||||||
case DifferentialTransaction::TYPE_UPDATE:
|
case DifferentialTransaction::TYPE_UPDATE:
|
||||||
|
case DifferentialTransaction::TYPE_INLINEDONE:
|
||||||
return $xaction->getNewValue();
|
return $xaction->getNewValue();
|
||||||
case DifferentialTransaction::TYPE_INLINE:
|
case DifferentialTransaction::TYPE_INLINE:
|
||||||
return null;
|
return null;
|
||||||
|
@ -197,6 +199,7 @@ final class DifferentialTransactionEditor
|
||||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||||
case PhabricatorTransactions::TYPE_COMMENT:
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
case DifferentialTransaction::TYPE_INLINE:
|
case DifferentialTransaction::TYPE_INLINE:
|
||||||
|
case DifferentialTransaction::TYPE_INLINEDONE:
|
||||||
return;
|
return;
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
return;
|
return;
|
||||||
|
@ -524,6 +527,52 @@ final class DifferentialTransactionEditor
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->expandedDone) {
|
||||||
|
switch ($xaction->getTransactionType()) {
|
||||||
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
|
case DifferentialTransaction::TYPE_ACTION:
|
||||||
|
case DifferentialTransaction::TYPE_UPDATE:
|
||||||
|
case DifferentialTransaction::TYPE_INLINE:
|
||||||
|
$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 DifferentialDiffInlineCommentQuery())
|
||||||
|
->setViewer($this->getActor())
|
||||||
|
->withRevisionPHIDs(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];
|
||||||
|
}
|
||||||
|
|
||||||
|
$results[] = id(new DifferentialTransaction())
|
||||||
|
->setTransactionType(DifferentialTransaction::TYPE_INLINEDONE)
|
||||||
|
->setIgnoreOnNoEffect(true)
|
||||||
|
->setOldValue($old_value)
|
||||||
|
->setNewValue($new_value);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,6 +595,18 @@ final class DifferentialTransactionEditor
|
||||||
$reply->setHasReplies(1)->save();
|
$reply->setHasReplies(1)->save();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
case DifferentialTransaction::TYPE_INLINEDONE:
|
||||||
|
$table = new DifferentialTransactionComment();
|
||||||
|
$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 DifferentialTransaction::TYPE_UPDATE:
|
case DifferentialTransaction::TYPE_UPDATE:
|
||||||
// Now that we're inside the transaction, do a final check.
|
// Now that we're inside the transaction, do a final check.
|
||||||
$diff = $this->requireDiff($xaction->getNewValue());
|
$diff = $this->requireDiff($xaction->getNewValue());
|
||||||
|
|
|
@ -18,6 +18,7 @@ final class DifferentialTransaction extends PhabricatorApplicationTransaction {
|
||||||
const TYPE_UPDATE = 'differential:update';
|
const TYPE_UPDATE = 'differential:update';
|
||||||
const TYPE_ACTION = 'differential:action';
|
const TYPE_ACTION = 'differential:action';
|
||||||
const TYPE_STATUS = 'differential:status';
|
const TYPE_STATUS = 'differential:status';
|
||||||
|
const TYPE_INLINEDONE = 'differential:inlinedone';
|
||||||
|
|
||||||
public function getApplicationName() {
|
public function getApplicationName() {
|
||||||
return 'differential';
|
return 'differential';
|
||||||
|
@ -35,6 +36,15 @@ final class DifferentialTransaction extends PhabricatorApplicationTransaction {
|
||||||
return new DifferentialTransactionView();
|
return new DifferentialTransactionView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldGenerateOldValue() {
|
||||||
|
switch ($this->getTransactionType()) {
|
||||||
|
case DifferentialTransaction::TYPE_INLINEDONE:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::shouldGenerateOldValue();
|
||||||
|
}
|
||||||
|
|
||||||
public function shouldHide() {
|
public function shouldHide() {
|
||||||
$old = $this->getOldValue();
|
$old = $this->getOldValue();
|
||||||
$new = $this->getNewValue();
|
$new = $this->getNewValue();
|
||||||
|
@ -231,6 +241,35 @@ final class DifferentialTransaction extends PhabricatorApplicationTransaction {
|
||||||
return pht(
|
return pht(
|
||||||
'%s added inline comments.',
|
'%s added inline comments.',
|
||||||
$author_handle);
|
$author_handle);
|
||||||
|
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 self::TYPE_UPDATE:
|
case self::TYPE_UPDATE:
|
||||||
if ($this->getMetadataValue('isCommitUpdate')) {
|
if ($this->getMetadataValue('isCommitUpdate')) {
|
||||||
return pht(
|
return pht(
|
||||||
|
|
|
@ -3,13 +3,33 @@
|
||||||
abstract class PhabricatorDiffInlineCommentQuery
|
abstract class PhabricatorDiffInlineCommentQuery
|
||||||
extends PhabricatorApplicationTransactionCommentQuery {
|
extends PhabricatorApplicationTransactionCommentQuery {
|
||||||
|
|
||||||
|
private $fixedStates;
|
||||||
private $needReplyToComments;
|
private $needReplyToComments;
|
||||||
|
|
||||||
|
public function withFixedStates(array $states) {
|
||||||
|
$this->fixedStates = $states;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function needReplyToComments($need_reply_to) {
|
public function needReplyToComments($need_reply_to) {
|
||||||
$this->needReplyToComments = $need_reply_to;
|
$this->needReplyToComments = $need_reply_to;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function buildWhereClauseComponents(
|
||||||
|
AphrontDatabaseConnection $conn_r) {
|
||||||
|
$where = parent::buildWhereClauseComponents($conn_r);
|
||||||
|
|
||||||
|
if ($this->fixedStates !== null) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn_r,
|
||||||
|
'fixedState IN (%Ls)',
|
||||||
|
$this->fixedStates);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $where;
|
||||||
|
}
|
||||||
|
|
||||||
protected function willFilterPage(array $comments) {
|
protected function willFilterPage(array $comments) {
|
||||||
if ($this->needReplyToComments) {
|
if ($this->needReplyToComments) {
|
||||||
$reply_phids = array();
|
$reply_phids = array();
|
||||||
|
|
|
@ -967,6 +967,38 @@ final class PhabricatorUSEnglishTranslation
|
||||||
'Show Last %d Lines',
|
'Show Last %d Lines',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'%s marked %s inline comment(s) as done and %s inline comment(s) as '.
|
||||||
|
'not done.' => array(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'%s marked an inline comment as done and an inline comment '.
|
||||||
|
'as not done.',
|
||||||
|
'%s marked an inline comment as done and %3$s inline comments '.
|
||||||
|
'as not done.',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'%s marked %s inline comments as done and an inline comment '.
|
||||||
|
'as not done.',
|
||||||
|
'%s marked %s inline comments as done and %s inline comments '.
|
||||||
|
'as done.',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
'%s marked %s inline comment(s) as done.' => array(
|
||||||
|
array(
|
||||||
|
'%s marked an inline comment as done.',
|
||||||
|
'%s marked %s inline comments as done.',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
'%s marked %s inline comment(s) as not done.' => array(
|
||||||
|
array(
|
||||||
|
'%s marked an inline comment as not done.',
|
||||||
|
'%s marked %s inline comments as not done.',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue