diff --git a/src/applications/maniphest/storage/ManiphestTransaction.php b/src/applications/maniphest/storage/ManiphestTransaction.php index e2739c1d09..6301241050 100644 --- a/src/applications/maniphest/storage/ManiphestTransaction.php +++ b/src/applications/maniphest/storage/ManiphestTransaction.php @@ -1,224 +1,240 @@ getTransactionType()) { case ManiphestTaskEdgeTransaction::TRANSACTIONTYPE: case ManiphestTaskUnblockTransaction::TRANSACTIONTYPE: return false; } return parent::shouldGenerateOldValue(); } + public function shouldHideForFeed() { + // NOTE: Modular transactions don't currently support this, and it has + // very few callsites, and it's publish-time rather than display-time. + // This should probably become a supported, display-time behavior. For + // discussion, see T12787. + + // Hide "alice created X, a task blocking Y." from feed because it + // will almost always appear adjacent to "alice created Y". + $is_new = $this->getMetadataValue('blocker.new'); + if ($is_new) { + return true; + } + + return parent::shouldHideForFeed(); + } + public function getRequiredHandlePHIDs() { $phids = parent::getRequiredHandlePHIDs(); $new = $this->getNewValue(); $old = $this->getOldValue(); switch ($this->getTransactionType()) { case ManiphestTaskOwnerTransaction::TRANSACTIONTYPE: if ($new) { $phids[] = $new; } if ($old) { $phids[] = $old; } break; case ManiphestTaskMergedIntoTransaction::TRANSACTIONTYPE: $phids[] = $new; break; case ManiphestTaskMergedFromTransaction::TRANSACTIONTYPE: $phids = array_merge($phids, $new); break; case ManiphestTaskEdgeTransaction::TRANSACTIONTYPE: $phids = array_mergev( array( $phids, array_keys(nonempty($old, array())), array_keys(nonempty($new, array())), )); break; case ManiphestTaskAttachTransaction::TRANSACTIONTYPE: $old = nonempty($old, array()); $new = nonempty($new, array()); $phids = array_mergev( array( $phids, array_keys(idx($new, 'FILE', array())), array_keys(idx($old, 'FILE', array())), )); break; case ManiphestTaskUnblockTransaction::TRANSACTIONTYPE: foreach (array_keys($new) as $phid) { $phids[] = $phid; } break; case ManiphestTaskStatusTransaction::TRANSACTIONTYPE: $commit_phid = $this->getMetadataValue('commitPHID'); if ($commit_phid) { $phids[] = $commit_phid; } break; } return $phids; } public function getActionName() { $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_COLUMNS: return pht('Changed Project Column'); } return parent::getActionName(); } public function getIcon() { switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_COLUMNS: return 'fa-columns'; } return parent::getIcon(); } public function getTitle() { $author_phid = $this->getAuthorPHID(); $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_SUBTYPE: return pht( '%s changed the subtype of this task from "%s" to "%s".', $this->renderHandleLink($author_phid), $this->renderSubtypeName($old), $this->renderSubtypeName($new)); break; } return parent::getTitle(); } public function getTitleForFeed() { $author_phid = $this->getAuthorPHID(); $object_phid = $this->getObjectPHID(); $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { case PhabricatorTransactions::TYPE_SUBTYPE: return pht( '%s changed the subtype of %s from "%s" to "%s".', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid), $this->renderSubtypeName($old), $this->renderSubtypeName($new)); } return parent::getTitleForFeed(); } public function getMailTags() { $tags = array(); switch ($this->getTransactionType()) { case ManiphestTaskMergedIntoTransaction::TRANSACTIONTYPE: case ManiphestTaskStatusTransaction::TRANSACTIONTYPE: $tags[] = self::MAILTAG_STATUS; break; case ManiphestTaskOwnerTransaction::TRANSACTIONTYPE: $tags[] = self::MAILTAG_OWNER; break; case PhabricatorTransactions::TYPE_SUBSCRIBERS: $tags[] = self::MAILTAG_CC; break; case PhabricatorTransactions::TYPE_EDGE: switch ($this->getMetadataValue('edge:type')) { case PhabricatorProjectObjectHasProjectEdgeType::EDGECONST: $tags[] = self::MAILTAG_PROJECTS; break; default: $tags[] = self::MAILTAG_OTHER; break; } break; case ManiphestTaskPriorityTransaction::TRANSACTIONTYPE: $tags[] = self::MAILTAG_PRIORITY; break; case ManiphestTaskUnblockTransaction::TRANSACTIONTYPE: $tags[] = self::MAILTAG_UNBLOCK; break; case PhabricatorTransactions::TYPE_COLUMNS: $tags[] = self::MAILTAG_COLUMN; break; case PhabricatorTransactions::TYPE_COMMENT: $tags[] = self::MAILTAG_COMMENT; break; default: $tags[] = self::MAILTAG_OTHER; break; } return $tags; } public function getNoEffectDescription() { switch ($this->getTransactionType()) { case ManiphestTaskStatusTransaction::TRANSACTIONTYPE: return pht('The task already has the selected status.'); case ManiphestTaskOwnerTransaction::TRANSACTIONTYPE: return pht('The task already has the selected owner.'); case ManiphestTaskPriorityTransaction::TRANSACTIONTYPE: return pht('The task already has the selected priority.'); } return parent::getNoEffectDescription(); } public function renderSubtypeName($value) { $object = $this->getObject(); $map = $object->newEditEngineSubtypeMap(); if (!isset($map[$value])) { return $value; } return $map[$value]->getName(); } } diff --git a/src/applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php b/src/applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php index 905554a3a3..1c7a88dec7 100644 --- a/src/applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php +++ b/src/applications/maniphest/xaction/ManiphestTaskUnblockTransaction.php @@ -1,125 +1,116 @@ getMetadataValue('blocker.new'); - if ($is_new) { - return true; - } - } - public function getActionName() { $old = $this->getOldValue(); $new = $this->getNewValue(); $old_status = head($old); $new_status = head($new); $old_closed = ManiphestTaskStatus::isClosedStatus($old_status); $new_closed = ManiphestTaskStatus::isClosedStatus($new_status); if ($old_closed && !$new_closed) { return pht('Block'); } else if (!$old_closed && $new_closed) { return pht('Unblock'); } else { return pht('Blocker'); } } public function getTitle() { $old = $this->getOldValue(); $new = $this->getNewValue(); $blocker_phid = key($new); $old_status = head($old); $new_status = head($new); $old_closed = ManiphestTaskStatus::isClosedStatus($old_status); $new_closed = ManiphestTaskStatus::isClosedStatus($new_status); $old_name = ManiphestTaskStatus::getTaskStatusName($old_status); $new_name = ManiphestTaskStatus::getTaskStatusName($new_status); if ($this->getMetadataValue('blocker.new')) { return pht( '%s created subtask %s.', $this->renderAuthor(), $this->renderHandle($blocker_phid)); } else if ($old_closed && !$new_closed) { return pht( '%s reopened subtask %s as %s.', $this->renderAuthor(), $this->renderHandle($blocker_phid), $this->renderValue($new_name)); } else if (!$old_closed && $new_closed) { return pht( '%s closed subtask %s as %s.', $this->renderAuthor(), $this->renderHandle($blocker_phid), $this->renderValue($new_name)); } else { return pht( '%s changed the status of subtask %s from %s to %s.', $this->renderAuthor(), $this->renderHandle($blocker_phid), $this->renderValue($old_name), $this->renderValue($new_name)); } } public function getTitleForFeed() { $old = $this->getOldValue(); $new = $this->getNewValue(); $blocker_phid = key($new); $old_status = head($old); $new_status = head($new); $old_closed = ManiphestTaskStatus::isClosedStatus($old_status); $new_closed = ManiphestTaskStatus::isClosedStatus($new_status); $old_name = ManiphestTaskStatus::getTaskStatusName($old_status); $new_name = ManiphestTaskStatus::getTaskStatusName($new_status); if ($old_closed && !$new_closed) { return pht( '%s reopened %s, a subtask of %s, as %s.', $this->renderAuthor(), $this->renderHandle($blocker_phid), $this->renderObject(), $this->renderValue($new_name)); } else if (!$old_closed && $new_closed) { return pht( '%s closed %s, a subtask of %s, as %s.', $this->renderAuthor(), $this->renderHandle($blocker_phid), $this->renderObject(), $this->renderValue($new_name)); } else { return pht( '%s changed the status of %s, a subtask of %s, '. 'from %s to %s.', $this->renderAuthor(), $this->renderHandle($blocker_phid), $this->renderObject(), $this->renderValue($old_name), $this->renderValue($new_name)); } } public function getIcon() { return 'fa-shield'; } }