Build separate comments for each inline comment in Audit
Summary: Ref T4896. Moves us closer to migrating comments to transactions by building a transaction per inline. This makes the UI a little wonky, and it will get slightly worse until we swap to the new UI and grouping/collapsing starts working. It's still usable, there's just a box per inline. Test Plan: - Added a comment. - Added an inline comment. - Added a comment and an inline comment. Reviewers: btrahan, joshuaspence Reviewed By: joshuaspence Subscribers: epriestley Maniphest Tasks: T4896 Differential Revision: https://secure.phabricator.com/D10023
This commit is contained in:
		@@ -9,6 +9,7 @@ final class PhabricatorAuditActionConstants {
 | 
			
		||||
  const CLOSE     = 'close';
 | 
			
		||||
  const ADD_CCS = 'add_ccs';
 | 
			
		||||
  const ADD_AUDITORS = 'add_auditors';
 | 
			
		||||
  const INLINE = 'audit:inline';
 | 
			
		||||
 | 
			
		||||
  public static function getActionNameMap() {
 | 
			
		||||
    $map = array(
 | 
			
		||||
 
 | 
			
		||||
@@ -57,13 +57,8 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
 | 
			
		||||
      ->save();
 | 
			
		||||
 | 
			
		||||
    $content_blocks = array($comment->getContent());
 | 
			
		||||
 | 
			
		||||
    if ($inline_comments) {
 | 
			
		||||
      foreach ($inline_comments as $inline) {
 | 
			
		||||
        $inline->setAuditCommentID($comment->getID());
 | 
			
		||||
        $inline->save();
 | 
			
		||||
        $content_blocks[] = $inline->getContent();
 | 
			
		||||
      }
 | 
			
		||||
    foreach ($inline_comments as $inline) {
 | 
			
		||||
      $content_blocks[] = $inline->getContent();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $ccs = $this->ccs;
 | 
			
		||||
@@ -280,6 +275,20 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
 | 
			
		||||
    $commit->updateAuditStatus($requests);
 | 
			
		||||
    $commit->save();
 | 
			
		||||
 | 
			
		||||
    $comments = array($comment);
 | 
			
		||||
    foreach ($inline_comments as $inline) {
 | 
			
		||||
      $xaction = id(new PhabricatorAuditComment())
 | 
			
		||||
        ->setAction(PhabricatorAuditActionConstants::INLINE)
 | 
			
		||||
        ->setActorPHID($actor->getPHID())
 | 
			
		||||
        ->setTargetPHID($commit->getPHID())
 | 
			
		||||
        ->save();
 | 
			
		||||
 | 
			
		||||
      $inline->setAuditCommentID($xaction->getID());
 | 
			
		||||
      $inline->save();
 | 
			
		||||
 | 
			
		||||
      $comments[] = $xaction;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $feed_dont_publish_phids = array();
 | 
			
		||||
    foreach ($requests as $request) {
 | 
			
		||||
      $status = $request->getAuditStatus();
 | 
			
		||||
@@ -305,7 +314,7 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
 | 
			
		||||
 | 
			
		||||
    if (!$this->noEmail) {
 | 
			
		||||
      $this->sendMail(
 | 
			
		||||
        array($comment),
 | 
			
		||||
        $comments,
 | 
			
		||||
        $other_comments,
 | 
			
		||||
        $inline_comments,
 | 
			
		||||
        $requests);
 | 
			
		||||
@@ -530,6 +539,10 @@ final class PhabricatorAuditCommentEditor extends PhabricatorEditor {
 | 
			
		||||
 | 
			
		||||
    $body = new PhabricatorMetaMTAMailBody();
 | 
			
		||||
    foreach ($comments as $comment) {
 | 
			
		||||
      if ($comment->getAction() == PhabricatorAuditActionConstants::INLINE) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      $verb = PhabricatorAuditActionConstants::getActionPastTenseVerb(
 | 
			
		||||
        $comment->getAction());
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user