Changeset View
Changeset View
Standalone View
Standalone View
src/applications/releeph/storage/ReleephRequestTransaction.php
| Show All 32 Lines | final class ReleephRequestTransaction | ||||
| public function getRequiredHandlePHIDs() { | public function getRequiredHandlePHIDs() { | ||||
| $phids = parent::getRequiredHandlePHIDs(); | $phids = parent::getRequiredHandlePHIDs(); | ||||
| $phids[] = $this->getObjectPHID(); | $phids[] = $this->getObjectPHID(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case ReleephRequestTransaction::TYPE_REQUEST: | case self::TYPE_REQUEST: | ||||
| case ReleephRequestTransaction::TYPE_DISCOVERY: | case self::TYPE_DISCOVERY: | ||||
| $phids[] = $new; | $phids[] = $new; | ||||
| break; | break; | ||||
| case ReleephRequestTransaction::TYPE_EDIT_FIELD: | case self::TYPE_EDIT_FIELD: | ||||
| self::searchForPHIDs($this->getOldValue(), $phids); | self::searchForPHIDs($this->getOldValue(), $phids); | ||||
| self::searchForPHIDs($this->getNewValue(), $phids); | self::searchForPHIDs($this->getNewValue(), $phids); | ||||
| break; | break; | ||||
| } | } | ||||
| return $phids; | return $phids; | ||||
| } | } | ||||
| public function getTitle() { | public function getTitle() { | ||||
| $author_phid = $this->getAuthorPHID(); | $author_phid = $this->getAuthorPHID(); | ||||
| $object_phid = $this->getObjectPHID(); | $object_phid = $this->getObjectPHID(); | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case ReleephRequestTransaction::TYPE_REQUEST: | case self::TYPE_REQUEST: | ||||
| return pht( | return pht( | ||||
| '%s requested %s', | '%s requested %s', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($new)); | $this->renderHandleLink($new)); | ||||
| break; | break; | ||||
| case ReleephRequestTransaction::TYPE_USER_INTENT: | case self::TYPE_USER_INTENT: | ||||
| return $this->getIntentTitle(); | return $this->getIntentTitle(); | ||||
| break; | break; | ||||
| case ReleephRequestTransaction::TYPE_EDIT_FIELD: | case self::TYPE_EDIT_FIELD: | ||||
| $field = newv($this->getMetadataValue('fieldClass'), array()); | $field = newv($this->getMetadataValue('fieldClass'), array()); | ||||
| $name = $field->getName(); | $name = $field->getName(); | ||||
| $markup = $name; | $markup = $name; | ||||
| if ($this->getRenderingTarget() === | if ($this->getRenderingTarget() === | ||||
| PhabricatorApplicationTransaction::TARGET_HTML) { | PhabricatorApplicationTransaction::TARGET_HTML) { | ||||
| $markup = hsprintf('<em>%s</em>', $name); | $markup = hsprintf('<em>%s</em>', $name); | ||||
| } | } | ||||
| return pht( | return pht( | ||||
| '%s changed the %s to "%s"', | '%s changed the %s to "%s"', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $markup, | $markup, | ||||
| $field->normalizeForTransactionView($this, $new)); | $field->normalizeForTransactionView($this, $new)); | ||||
| break; | break; | ||||
| case ReleephRequestTransaction::TYPE_PICK_STATUS: | case self::TYPE_PICK_STATUS: | ||||
| switch ($new) { | switch ($new) { | ||||
| case ReleephRequest::PICK_OK: | case ReleephRequest::PICK_OK: | ||||
| return pht('%s found this request picks without error', | return pht('%s found this request picks without error', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| case ReleephRequest::REVERT_OK: | case ReleephRequest::REVERT_OK: | ||||
| return pht('%s found this request reverts without error', | return pht('%s found this request reverts without error', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| case ReleephRequest::PICK_FAILED: | case ReleephRequest::PICK_FAILED: | ||||
| return pht("%s couldn't pick this request", | return pht("%s couldn't pick this request", | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| case ReleephRequest::REVERT_FAILED: | case ReleephRequest::REVERT_FAILED: | ||||
| return pht("%s couldn't revert this request", | return pht("%s couldn't revert this request", | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } | } | ||||
| break; | break; | ||||
| case ReleephRequestTransaction::TYPE_COMMIT: | case self::TYPE_COMMIT: | ||||
| $action_type = $this->getMetadataValue('action'); | $action_type = $this->getMetadataValue('action'); | ||||
| switch ($action_type) { | switch ($action_type) { | ||||
| case 'pick': | case 'pick': | ||||
| return pht( | return pht( | ||||
| '%s picked this request and committed the result upstream', | '%s picked this request and committed the result upstream', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| break; | break; | ||||
| case 'revert': | case 'revert': | ||||
| return pht( | return pht( | ||||
| '%s reverted this request and committed the result upstream', | '%s reverted this request and committed the result upstream', | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| break; | break; | ||||
| } | } | ||||
| break; | break; | ||||
| case ReleephRequestTransaction::TYPE_MANUAL_IN_BRANCH: | case self::TYPE_MANUAL_IN_BRANCH: | ||||
| $action = $new ? pht('picked') : pht('reverted'); | $action = $new ? pht('picked') : pht('reverted'); | ||||
| return pht( | return pht( | ||||
| '%s marked this request as manually %s', | '%s marked this request as manually %s', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $action); | $action); | ||||
| break; | break; | ||||
| case ReleephRequestTransaction::TYPE_DISCOVERY: | case self::TYPE_DISCOVERY: | ||||
| return pht('%s discovered this commit as %s', | return pht('%s discovered this commit as %s', | ||||
| $this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
| $this->renderHandleLink($new)); | $this->renderHandleLink($new)); | ||||
| break; | break; | ||||
| default: | default: | ||||
| return parent::getTitle(); | return parent::getTitle(); | ||||
| break; | break; | ||||
| Show All 22 Lines | public function getActionName() { | ||||
| return parent::getActionName(); | return parent::getActionName(); | ||||
| } | } | ||||
| public function getColor() { | public function getColor() { | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case ReleephRequestTransaction::TYPE_USER_INTENT: | case self::TYPE_USER_INTENT: | ||||
| switch ($new) { | switch ($new) { | ||||
| case ReleephRequest::INTENT_WANT: | case ReleephRequest::INTENT_WANT: | ||||
| return PhabricatorTransactions::COLOR_GREEN; | return PhabricatorTransactions::COLOR_GREEN; | ||||
| case ReleephRequest::INTENT_PASS: | case ReleephRequest::INTENT_PASS: | ||||
| return PhabricatorTransactions::COLOR_RED; | return PhabricatorTransactions::COLOR_RED; | ||||
| } | } | ||||
| } | } | ||||
| return parent::getColor(); | return parent::getColor(); | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | switch ($new) { | ||||
| $this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public function shouldHide() { | public function shouldHide() { | ||||
| $type = $this->getTransactionType(); | $type = $this->getTransactionType(); | ||||
| if ($type === ReleephRequestTransaction::TYPE_USER_INTENT && | if ($type === self::TYPE_USER_INTENT && | ||||
| $this->getMetadataValue('isRQCreate')) { | $this->getMetadataValue('isRQCreate')) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| if ($this->isBoringPickStatus()) { | if ($this->isBoringPickStatus()) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| // ReleephSummaryFieldSpecification is usually blank when an RQ is created, | // ReleephSummaryFieldSpecification is usually blank when an RQ is created, | ||||
| // creating a transaction change from null to "". Hide these! | // creating a transaction change from null to "". Hide these! | ||||
| if ($type === ReleephRequestTransaction::TYPE_EDIT_FIELD) { | if ($type === self::TYPE_EDIT_FIELD) { | ||||
| if ($this->getOldValue() === null && $this->getNewValue() === '') { | if ($this->getOldValue() === null && $this->getNewValue() === '') { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return parent::shouldHide(); | return parent::shouldHide(); | ||||
| } | } | ||||
| public function isBoringPickStatus() { | public function isBoringPickStatus() { | ||||
| $type = $this->getTransactionType(); | $type = $this->getTransactionType(); | ||||
| if ($type === ReleephRequestTransaction::TYPE_PICK_STATUS) { | if ($type === self::TYPE_PICK_STATUS) { | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| if ($new === ReleephRequest::PICK_OK || | if ($new === ReleephRequest::PICK_OK || | ||||
| $new === ReleephRequest::REVERT_OK) { | $new === ReleephRequest::REVERT_OK) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||