diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php b/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php index ac830a0d2b..8e912dde6a 100644 --- a/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php +++ b/src/applications/maniphest/editor/ManiphestTransactionEditorPro.php @@ -30,10 +30,19 @@ final class ManiphestTransactionEditorPro case ManiphestTransaction::TYPE_PRIORITY: return (int)$object->getPriority(); case ManiphestTransaction::TYPE_STATUS: + if ($this->getIsNewObject()) { + return null; + } return (int)$object->getStatus(); case ManiphestTransaction::TYPE_TITLE: + if ($this->getIsNewObject()) { + return null; + } return $object->getTitle(); case ManiphestTransaction::TYPE_DESCRIPTION: + if ($this->getIsNewObject()) { + return null; + } return $object->getDescription(); case ManiphestTransaction::TYPE_OWNER: return nonempty($object->getOwnerPHID(), null); diff --git a/src/applications/maniphest/storage/ManiphestTransaction.php b/src/applications/maniphest/storage/ManiphestTransaction.php index 8514c7cbd3..ee84f99f78 100644 --- a/src/applications/maniphest/storage/ManiphestTransaction.php +++ b/src/applications/maniphest/storage/ManiphestTransaction.php @@ -74,17 +74,40 @@ final class ManiphestTransaction return $phids; } + public function shouldHide() { + switch ($this->getTransactionType()) { + case self::TYPE_TITLE: + case self::TYPE_DESCRIPTION: + if ($this->getOldValue() === null) { + return true; + } else { + return false; + } + break; + } + + return false; + } + + public function getActionStrength() { + switch ($this->getTransactionType()) { + case self::TYPE_STATUS: + return 1.3; + case self::TYPE_OWNER: + return 1.2; + case self::TYPE_PRIORITY: + return 1.1; + } + + return parent::getActionStrength(); + } + public function getColor() { $old = $this->getOldValue(); $new = $this->getNewValue(); switch ($this->getTransactionType()) { - case self::TYPE_TITLE: - if (!strlen($old)) { - return 'green'; - } - case self::TYPE_STATUS: if ($new == ManiphestTaskStatus::STATUS_OPEN) { return 'green'; @@ -112,16 +135,16 @@ final class ManiphestTransaction switch ($this->getTransactionType()) { case self::TYPE_TITLE: - if (!strlen($old)) { - return pht('Created'); - } else { - return pht('Retitled'); - } + return pht('Retitled'); case self::TYPE_STATUS: switch ($new) { case ManiphestTaskStatus::STATUS_OPEN: - return pht('Reopened'); + if ($old === null) { + return pht('Created'); + } else { + return pht('Reopened'); + } case ManiphestTaskStatus::STATUS_CLOSED_SPITE: return pht('Spited'); case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: @@ -173,11 +196,7 @@ final class ManiphestTransaction switch ($this->getTransactionType()) { case self::TYPE_TITLE: - if (!strlen($old)) { - return 'create'; - } else { - return 'edit'; - } + return 'edit'; case self::TYPE_STATUS: switch ($new) { @@ -226,19 +245,11 @@ final class ManiphestTransaction switch ($this->getTransactionType()) { case self::TYPE_TITLE: - if (!strlen($old)) { - return pht( - '%s created this task.', - $this->renderHandleLink($author_phid), - $old, - $new); - } else { - return pht( - '%s changed the title from "%s" to "%s".', - $this->renderHandleLink($author_phid), - $old, - $new); - } + return pht( + '%s changed the title from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $old, + $new); case self::TYPE_DESCRIPTION: return pht( @@ -248,9 +259,15 @@ final class ManiphestTransaction case self::TYPE_STATUS: switch ($new) { case ManiphestTaskStatus::STATUS_OPEN: - return pht( - '%s reopened this task.', - $this->renderHandleLink($author_phid)); + if ($old === null) { + return pht( + '%s created this task.', + $this->renderHandleLink($author_phid)); + } else { + return pht( + '%s reopened this task.', + $this->renderHandleLink($author_phid)); + } case ManiphestTaskStatus::STATUS_CLOSED_SPITE: return pht( @@ -405,19 +422,12 @@ final class ManiphestTransaction switch ($this->getTransactionType()) { case self::TYPE_TITLE: - if (!strlen($old)) { - return pht( - '%s created %s.', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid)); - } else { - return pht( - '%s renamed %s from "%s" to "%s".', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid), - $old, - $new); - } + return pht( + '%s renamed %s from "%s" to "%s".', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid), + $old, + $new); case self::TYPE_DESCRIPTION: return pht( @@ -426,34 +436,40 @@ final class ManiphestTransaction $this->renderHandleLink($object_phid)); case self::TYPE_STATUS: - if ($new == ManiphestTaskStatus::STATUS_OPEN) { - return pht( - '%s reopened %s.', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid)); - } else { - switch ($new) { - case ManiphestTaskStatus::STATUS_CLOSED_SPITE: + switch ($new) { + case ManiphestTaskStatus::STATUS_OPEN: + if ($old === null) { return pht( - '%s closed %s out of spite.', + '%s created %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); - case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: + } else { return pht( - '%s closed %s as a duplicate.', + '%s reopened %s.', $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); - default: - $status_name = idx( - ManiphestTaskStatus::getTaskStatusMap(), - $new, - '???'); - return pht( - '%s closed %s as "%s".', - $this->renderHandleLink($author_phid), - $this->renderHandleLink($object_phid), - $status_name); - } + } + + case ManiphestTaskStatus::STATUS_CLOSED_SPITE: + return pht( + '%s closed %s out of spite.', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid)); + case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE: + return pht( + '%s closed %s as a duplicate.', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid)); + default: + $status_name = idx( + ManiphestTaskStatus::getTaskStatusMap(), + $new, + '???'); + return pht( + '%s closed %s as "%s".', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid), + $status_name); } case self::TYPE_OWNER: