1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Send Maniphest transaction preview through new code

Summary: Ref T2217. Get rid of this rendering pathway's internals and move them to the modern stuff.

Test Plan: See screenshot.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2217

Differential Revision: https://secure.phabricator.com/D7072
This commit is contained in:
epriestley 2013-09-23 14:29:59 -07:00
parent 781c11560f
commit e27a83960c
2 changed files with 38 additions and 20 deletions

View file

@ -33,9 +33,14 @@ final class ManiphestTransactionPreviewController extends ManiphestController {
$transaction = new ManiphestTransaction();
$transaction->setAuthorPHID($user->getPHID());
$transaction->setComments($comments);
$transaction->setTransactionType($action);
// This should really be split into a separate transaction, but it should
// all come out in the wash once we fully move to modern stuff.
$transaction->getModernTransaction()->attachComment(
id(new ManiphestTransactionComment())
->setContent($comments));
$value = $request->getStr('value');
// grab phids for handles and set transaction values based on action and
// value (empty or control-specific format) coming in from the wire
@ -56,17 +61,19 @@ final class ManiphestTransactionPreviewController extends ManiphestController {
case ManiphestTransactionType::TYPE_CCS:
if ($value) {
$value = json_decode($value);
$phids = $value;
foreach ($task->getCCPHIDs() as $cc_phid) {
$phids[] = $cc_phid;
$value[] = $cc_phid;
}
$transaction->setNewValue($value);
} else {
$phids = array();
$transaction->setNewValue(array());
}
if (!$value) {
$value = array();
}
$phids = $value;
foreach ($task->getCCPHIDs() as $cc_phid) {
$phids[] = $cc_phid;
$value[] = $cc_phid;
}
$transaction->setOldValue($task->getCCPHIDs());
$transaction->setNewValue($value);
break;
case ManiphestTransactionType::TYPE_PROJECTS:
if ($value) {
@ -92,23 +99,28 @@ final class ManiphestTransactionPreviewController extends ManiphestController {
$handles = $this->loadViewerHandles($phids);
$transactions = array();
$transactions = array();
$transactions[] = $transaction;
$engine = new PhabricatorMarkupEngine();
$engine->setViewer($user);
$engine->addObject($transaction, ManiphestTransaction::MARKUP_FIELD_BODY);
if ($transaction->getModernTransaction()->hasComment()) {
$engine->addObject(
$transaction->getModernTransaction()->getComment(),
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
}
$engine->process();
$transaction_view = new ManiphestTransactionListView();
$transaction_view->setTransactions($transactions);
$transaction_view->setHandles($handles);
$transaction_view->setUser($user);
$transaction_view->setMarkupEngine($engine);
$transaction_view->setPreview(true);
$transaction->getModernTransaction()->setHandles($handles);
$view = id(new PhabricatorApplicationTransactionView())
->setUser($user)
->setTransactions(mpull($transactions, 'getModernTransaction'))
->setIsPreview(true)
->setIsDetailView(true);
return id(new AphrontAjaxResponse())
->setContent($transaction_view->render());
->setContent((string)phutil_implode_html('', $view->buildEvents()));
}
}

View file

@ -306,12 +306,18 @@ abstract class PhabricatorApplicationTransaction
$this->renderHandleLink($author_phid),
count($add),
$this->renderHandleList($add));
} else {
} else if ($rem) {
return pht(
'%s removed %d subscriber(s): %s.',
$this->renderHandleLink($author_phid),
count($rem),
$this->renderHandleList($rem));
} else {
// This is used when rendering previews, before the user actually
// selects any CCs.
return pht(
'%s updated subscribers...',
$this->renderHandleLink($author_phid));
}
break;
case PhabricatorTransactions::TYPE_EDGE: