mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-02 01:48:23 +01:00
Switch Maniphest to modern ApplicationTransaction rendering
Summary: Ref T2217. Route transaction rendering through modern code. This just affects the detail page. Some rough edges but nothing significant. Test Plan: See screenshot. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2217 Differential Revision: https://secure.phabricator.com/D7070
This commit is contained in:
parent
77475736a3
commit
3ba3745d67
6 changed files with 294 additions and 16 deletions
|
@ -69,11 +69,6 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
$edges = idx($query->execute(), $phid);
|
||||
$phids = array_fill_keys($query->getDestinationPHIDs(), true);
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
foreach ($transaction->extractPHIDs() as $phid) {
|
||||
$phids[$phid] = true;
|
||||
}
|
||||
}
|
||||
foreach ($task->getCCPHIDs() as $phid) {
|
||||
$phids[$phid] = true;
|
||||
}
|
||||
|
@ -140,8 +135,11 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
$engine->setViewer($user);
|
||||
$engine->addObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION);
|
||||
foreach ($transactions as $xaction) {
|
||||
if ($xaction->hasComments()) {
|
||||
$engine->addObject($xaction, ManiphestTransaction::MARKUP_FIELD_BODY);
|
||||
$modern_xaction = $xaction->getModernTransaction();
|
||||
if ($modern_xaction->getComment()) {
|
||||
$engine->addObject(
|
||||
$modern_xaction->getComment(),
|
||||
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,12 +316,11 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
</div>',
|
||||
pht('Loading preview...'));
|
||||
|
||||
$transaction_view = new ManiphestTransactionListView();
|
||||
$transaction_view->setTransactions($transactions);
|
||||
$transaction_view->setHandles($this->getLoadedHandles());
|
||||
$transaction_view->setUser($user);
|
||||
$transaction_view->setAuxiliaryFields($aux_fields);
|
||||
$transaction_view->setMarkupEngine($engine);
|
||||
$timeline = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($user)
|
||||
->setObjectPHID($task->getPHID())
|
||||
->setTransactions(mpull($transactions, 'getModernTransaction'))
|
||||
->setMarkupEngine($engine);
|
||||
|
||||
$object_name = 'T'.$task->getID();
|
||||
$actions = $this->buildActionView($task);
|
||||
|
@ -345,7 +342,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
|
|||
$header,
|
||||
$actions,
|
||||
$properties,
|
||||
$transaction_view,
|
||||
$timeline,
|
||||
$comment_header,
|
||||
$comment_form,
|
||||
$preview_panel,
|
||||
|
|
|
@ -79,6 +79,10 @@ final class ManiphestEdgeEventListener extends PhutilEventListener {
|
|||
->setOldValue($old_type)
|
||||
->setNewValue($new_type)
|
||||
->setMetadataValue('edge:type', $type)
|
||||
->setContentSource(
|
||||
PhabricatorContentSource::newForSource(
|
||||
PhabricatorContentSource::SOURCE_LEGACY,
|
||||
array()))
|
||||
->setAuthorPHID($event->getUser()->getPHID());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,10 @@ final class ManiphestTransaction
|
|||
return $obj;
|
||||
}
|
||||
|
||||
public function getModernTransaction() {
|
||||
return $this->proxy;
|
||||
}
|
||||
|
||||
public function save() {
|
||||
$this->proxy->openTransaction();
|
||||
$this->proxy
|
||||
|
|
|
@ -3,6 +3,16 @@
|
|||
final class ManiphestTransactionPro
|
||||
extends PhabricatorApplicationTransaction {
|
||||
|
||||
const TYPE_TITLE = 'title';
|
||||
const TYPE_STATUS = 'status';
|
||||
const TYPE_DESCRIPTION = 'description';
|
||||
const TYPE_OWNER = 'reassign';
|
||||
const TYPE_CCS = 'ccs';
|
||||
const TYPE_PROJECTS = 'projects';
|
||||
const TYPE_PRIORITY = 'priority';
|
||||
const TYPE_EDGE = 'edge';
|
||||
const TYPE_ATTACH = 'attach';
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'maniphest';
|
||||
}
|
||||
|
@ -15,5 +25,247 @@ final class ManiphestTransactionPro
|
|||
return new ManiphestTransactionComment();
|
||||
}
|
||||
|
||||
public function getRequiredHandlePHIDs() {
|
||||
$phids = parent::getRequiredHandlePHIDs();
|
||||
|
||||
$new = $this->getNewValue();
|
||||
$old = $this->getOldValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_OWNER:
|
||||
if ($new) {
|
||||
$phids[] = $new;
|
||||
}
|
||||
|
||||
if ($old) {
|
||||
$phids[] = $old;
|
||||
}
|
||||
break;
|
||||
case self::TYPE_CCS:
|
||||
case self::TYPE_PROJECTS:
|
||||
$phids = array_mergev(
|
||||
array(
|
||||
$phids,
|
||||
nonempty($old, array()),
|
||||
nonempty($new, array()),
|
||||
));
|
||||
break;
|
||||
case self::TYPE_EDGE:
|
||||
$phids = array_mergev(
|
||||
array(
|
||||
$phids,
|
||||
array_keys(nonempty($old, array())),
|
||||
array_keys(nonempty($new, array())),
|
||||
));
|
||||
break;
|
||||
case self::TYPE_ATTACH:
|
||||
$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;
|
||||
|
||||
}
|
||||
|
||||
return $phids;
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
$author_phid = $this->getAuthorPHID();
|
||||
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_TITLE:
|
||||
return pht(
|
||||
'%s changed the title from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$old,
|
||||
$new);
|
||||
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return pht(
|
||||
'%s edited the task description.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
|
||||
case self::TYPE_STATUS:
|
||||
if ($new == ManiphestTaskStatus::STATUS_OPEN) {
|
||||
if ($old) {
|
||||
return pht(
|
||||
'%s reopened this task.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
} else {
|
||||
return pht(
|
||||
'%s created this task.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
} else {
|
||||
switch ($new) {
|
||||
case ManiphestTaskStatus::STATUS_CLOSED_SPITE:
|
||||
return pht(
|
||||
'%s closed this task out of spite.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
case ManiphestTaskStatus::STATUS_CLOSED_DUPLICATE:
|
||||
return pht(
|
||||
'%s closed this task as a duplicate.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
default:
|
||||
$status_name = idx(
|
||||
ManiphestTaskStatus::getTaskStatusMap(),
|
||||
$new,
|
||||
'???');
|
||||
return pht(
|
||||
'%s closed this task as "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$status_name);
|
||||
}
|
||||
}
|
||||
|
||||
case self::TYPE_OWNER:
|
||||
if ($author_phid == $new) {
|
||||
return pht(
|
||||
'%s claimed this task.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
} else if (!$new) {
|
||||
return pht(
|
||||
'%s placed this task up for grabs.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
} else if (!$old) {
|
||||
return pht(
|
||||
'%s assigned this task to %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($new));
|
||||
} else {
|
||||
return pht(
|
||||
'%s reassigned this task from %s to %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($old),
|
||||
$this->renderHandleLink($new));
|
||||
}
|
||||
|
||||
case self::TYPE_PROJECTS:
|
||||
$added = array_diff($new, $old);
|
||||
$removed = array_diff($old, $new);
|
||||
if ($added && !$removed) {
|
||||
return pht(
|
||||
'%s added %d project(s): %s',
|
||||
$this->renderHandleLink($author_phid),
|
||||
count($added),
|
||||
$this->renderHandleList($added));
|
||||
} else if ($removed && !$added) {
|
||||
return pht(
|
||||
'%s removed %d project(s): %s',
|
||||
$this->renderHandleLink($author_phid),
|
||||
count($removed),
|
||||
$this->renderHandleList($removed));
|
||||
} else {
|
||||
return pht(
|
||||
'%s changed projects, added %d: %s; removed %d: %s',
|
||||
$this->renderHandleLink($author_phid),
|
||||
count($added),
|
||||
$this->renderHandleList($added),
|
||||
count($removed),
|
||||
$this->renderHandleList($removed));
|
||||
}
|
||||
|
||||
case self::TYPE_PRIORITY:
|
||||
$old_name = ManiphestTaskPriority::getTaskPriorityName($old);
|
||||
$new_name = ManiphestTaskPriority::getTaskPriorityName($new);
|
||||
|
||||
if ($old == ManiphestTaskPriority::getDefaultPriority()) {
|
||||
return pht(
|
||||
'%s triaged this task as "%s" priority.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$new_name);
|
||||
} else if ($old > $new) {
|
||||
return pht(
|
||||
'%s lowered the priority of this task from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$old_name,
|
||||
$new_name);
|
||||
} else {
|
||||
return pht(
|
||||
'%s raised the priority of this task from "%s" to "%s".',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$old_name,
|
||||
$new_name);
|
||||
}
|
||||
|
||||
case self::TYPE_CCS:
|
||||
// TODO: Remove this when we switch to subscribers. Just reuse the
|
||||
// code in the parent.
|
||||
$clone = clone $this;
|
||||
$clone->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS);
|
||||
return $clone->getTitle();
|
||||
|
||||
case self::TYPE_EDGE:
|
||||
// TODO: Remove this when we switch to real edges. Just reuse the
|
||||
// code in the parent;
|
||||
$clone = clone $this;
|
||||
$clone->setTransactionType(PhabricatorTransactions::TYPE_EDGE);
|
||||
return $clone->getTitle();
|
||||
|
||||
case self::TYPE_ATTACH:
|
||||
$old = nonempty($old, array());
|
||||
$new = nonempty($new, array());
|
||||
$new = array_keys(idx($new, 'FILE', array()));
|
||||
$old = array_keys(idx($old, 'FILE', array()));
|
||||
|
||||
$added = array_diff($new, $old);
|
||||
$removed = array_diff($old, $new);
|
||||
if ($added && !$removed) {
|
||||
return pht(
|
||||
'%s attached %d file(s): %s',
|
||||
$this->renderHandleLink($author_phid),
|
||||
count($added),
|
||||
$this->renderHandleList($added));
|
||||
} else if ($removed && !$added) {
|
||||
return pht(
|
||||
'%s detached %d file(s): %s',
|
||||
$this->renderHandleLink($author_phid),
|
||||
count($removed),
|
||||
$this->renderHandleList($removed));
|
||||
} else {
|
||||
return pht(
|
||||
'%s changed projects, attached %d: %s; detached %d: %s',
|
||||
$this->renderHandleLink($author_phid),
|
||||
count($added),
|
||||
$this->renderHandleList($added),
|
||||
count($removed),
|
||||
$this->renderHandleList($removed));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return parent::getTitle();
|
||||
}
|
||||
|
||||
public function hasChangeDetails() {
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return true;
|
||||
}
|
||||
return parent::hasChangeDetails();
|
||||
}
|
||||
|
||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
||||
$view = id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
||||
->setUser($viewer)
|
||||
->setOldText($old)
|
||||
->setNewText($new);
|
||||
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -347,6 +347,23 @@ abstract class PhabricatorApplicationTransaction
|
|||
$this->renderHandleList($rem));
|
||||
}
|
||||
|
||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
||||
$key = $this->getMetadataValue('customfield:key');
|
||||
$field = PhabricatorCustomField::getObjectField(
|
||||
// TODO: This is a giant hack, but we currently don't have a way to
|
||||
// get the contextual object and this pathway is only hit by
|
||||
// Maniphest. We should provide a way to get the actual object here.
|
||||
new ManiphestTask(),
|
||||
PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS,
|
||||
$key);
|
||||
if ($field) {
|
||||
return $field->getApplicationTransactionTitle($this);
|
||||
} else {
|
||||
return pht(
|
||||
'%s edited a custom field.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
}
|
||||
|
||||
default:
|
||||
return pht(
|
||||
'%s edited this %s.',
|
||||
|
|
|
@ -255,9 +255,11 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
case self::TYPE_PROJECT_HAS_COMMIT:
|
||||
case self::TYPE_DREV_HAS_COMMIT:
|
||||
return '%s added %d commit(s): %s.';
|
||||
case self::TYPE_COMMIT_HAS_TASK:
|
||||
case self::TYPE_TASK_DEPENDS_ON_TASK:
|
||||
return '%s added %d dependencie(s): %s.';
|
||||
case self::TYPE_TASK_DEPENDED_ON_BY_TASK:
|
||||
return '%s added %d dependent task(s): %s.';
|
||||
case self::TYPE_COMMIT_HAS_TASK:
|
||||
case self::TYPE_DREV_HAS_RELATED_TASK:
|
||||
case self::TYPE_MOCK_HAS_TASK:
|
||||
return '%s added %d task(s): %s.';
|
||||
|
@ -322,9 +324,11 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
case self::TYPE_PROJECT_HAS_COMMIT:
|
||||
case self::TYPE_DREV_HAS_COMMIT:
|
||||
return '%s removed %d commit(s): %s.';
|
||||
case self::TYPE_COMMIT_HAS_TASK:
|
||||
case self::TYPE_TASK_DEPENDS_ON_TASK:
|
||||
return '%s removed %d dependencie(s): %s.';
|
||||
case self::TYPE_TASK_DEPENDED_ON_BY_TASK:
|
||||
return '%s removed %d dependent task(s): %s.';
|
||||
case self::TYPE_COMMIT_HAS_TASK:
|
||||
case self::TYPE_DREV_HAS_RELATED_TASK:
|
||||
case self::TYPE_MOCK_HAS_TASK:
|
||||
return '%s removed %d task(s): %s.';
|
||||
|
|
Loading…
Add table
Reference in a new issue