mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 04:20:55 +01:00
Separate revision updates into two separate comments
Summary: Ref T2222. Instead of writing one comment which performs both a diff update and adds a comment, write two comments, one for each action. These will translate directly into ApplicationTransactions writes. This has a small impact on the UX: these updates now render in two rows, instead of one. After T2222, they'll automerge back together. {F111909} Test Plan: Updated a revision. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2222 Differential Revision: https://secure.phabricator.com/D8200
This commit is contained in:
parent
8e232a8bf1
commit
c65fad3fca
2 changed files with 35 additions and 24 deletions
|
@ -786,21 +786,29 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
|
|||
|
||||
|
||||
private function createComment() {
|
||||
$comment = id(new DifferentialComment())
|
||||
$template = id(new DifferentialComment())
|
||||
->setAuthorPHID($this->getActorPHID())
|
||||
->setRevision($this->revision)
|
||||
->setContent($this->getComments())
|
||||
->setRevision($this->revision);
|
||||
if ($this->contentSource) {
|
||||
$template->setContentSource($this->contentSource);
|
||||
}
|
||||
|
||||
// Write the "update active diff" transaction.
|
||||
id(clone $template)
|
||||
->setAction(DifferentialAction::ACTION_UPDATE)
|
||||
->setMetadata(
|
||||
array(
|
||||
DifferentialComment::METADATA_DIFF_ID => $this->getDiff()->getID(),
|
||||
));
|
||||
))
|
||||
->save();
|
||||
|
||||
if ($this->contentSource) {
|
||||
$comment->setContentSource($this->contentSource);
|
||||
// If we have a comment, write the "add a comment" transaction.
|
||||
if (strlen($this->getComments())) {
|
||||
id(clone $template)
|
||||
->setAction(DifferentialAction::ACTION_COMMENT)
|
||||
->setContent($this->getComments())
|
||||
->save();
|
||||
}
|
||||
|
||||
$comment->save();
|
||||
}
|
||||
|
||||
private function updateAuxiliaryFields() {
|
||||
|
|
|
@ -127,24 +127,27 @@ final class DifferentialComment extends DifferentialDAO
|
|||
$this->openTransaction();
|
||||
$result = parent::save();
|
||||
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_LEGACY,
|
||||
array());
|
||||
if (strlen($this->getContent())) {
|
||||
$content_source = PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_LEGACY,
|
||||
array());
|
||||
|
||||
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
||||
PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST,
|
||||
DifferentialPHIDTypeRevision::TYPECONST);
|
||||
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
||||
PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST,
|
||||
DifferentialPHIDTypeRevision::TYPECONST);
|
||||
|
||||
$proxy = $this->getProxyComment();
|
||||
$proxy
|
||||
->setAuthorPHID($this->getAuthorPHID())
|
||||
->setViewPolicy('public')
|
||||
->setEditPolicy($this->getAuthorPHID())
|
||||
->setContentSource($content_source)
|
||||
->setCommentVersion(1)
|
||||
->setLegacyCommentID($this->getID())
|
||||
->setTransactionPHID($xaction_phid)
|
||||
->save();
|
||||
}
|
||||
|
||||
$proxy = $this->getProxyComment();
|
||||
$proxy
|
||||
->setAuthorPHID($this->getAuthorPHID())
|
||||
->setViewPolicy('public')
|
||||
->setEditPolicy($this->getAuthorPHID())
|
||||
->setContentSource($content_source)
|
||||
->setCommentVersion(1)
|
||||
->setLegacyCommentID($this->getID())
|
||||
->setTransactionPHID($xaction_phid)
|
||||
->save();
|
||||
$this->saveTransaction();
|
||||
|
||||
return $result;
|
||||
|
|
Loading…
Reference in a new issue