mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-20 20:40:56 +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() {
|
private function createComment() {
|
||||||
$comment = id(new DifferentialComment())
|
$template = id(new DifferentialComment())
|
||||||
->setAuthorPHID($this->getActorPHID())
|
->setAuthorPHID($this->getActorPHID())
|
||||||
->setRevision($this->revision)
|
->setRevision($this->revision);
|
||||||
->setContent($this->getComments())
|
if ($this->contentSource) {
|
||||||
|
$template->setContentSource($this->contentSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the "update active diff" transaction.
|
||||||
|
id(clone $template)
|
||||||
->setAction(DifferentialAction::ACTION_UPDATE)
|
->setAction(DifferentialAction::ACTION_UPDATE)
|
||||||
->setMetadata(
|
->setMetadata(
|
||||||
array(
|
array(
|
||||||
DifferentialComment::METADATA_DIFF_ID => $this->getDiff()->getID(),
|
DifferentialComment::METADATA_DIFF_ID => $this->getDiff()->getID(),
|
||||||
));
|
))
|
||||||
|
->save();
|
||||||
|
|
||||||
if ($this->contentSource) {
|
// If we have a comment, write the "add a comment" transaction.
|
||||||
$comment->setContentSource($this->contentSource);
|
if (strlen($this->getComments())) {
|
||||||
|
id(clone $template)
|
||||||
|
->setAction(DifferentialAction::ACTION_COMMENT)
|
||||||
|
->setContent($this->getComments())
|
||||||
|
->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$comment->save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateAuxiliaryFields() {
|
private function updateAuxiliaryFields() {
|
||||||
|
|
|
@ -127,24 +127,27 @@ final class DifferentialComment extends DifferentialDAO
|
||||||
$this->openTransaction();
|
$this->openTransaction();
|
||||||
$result = parent::save();
|
$result = parent::save();
|
||||||
|
|
||||||
$content_source = PhabricatorContentSource::newForSource(
|
if (strlen($this->getContent())) {
|
||||||
PhabricatorContentSource::SOURCE_LEGACY,
|
$content_source = PhabricatorContentSource::newForSource(
|
||||||
array());
|
PhabricatorContentSource::SOURCE_LEGACY,
|
||||||
|
array());
|
||||||
|
|
||||||
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
$xaction_phid = PhabricatorPHID::generateNewPHID(
|
||||||
PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST,
|
PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST,
|
||||||
DifferentialPHIDTypeRevision::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();
|
$this->saveTransaction();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|
Loading…
Reference in a new issue