Route Maniphest comments/detail edits through new code
Summary: Ref T2217. When you add comments (or use that interface to make updates), ship it through the new code. Test Plan: Added comments, made other changes to Maniphest tasks. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2217 Differential Revision: https://secure.phabricator.com/D7088
This commit is contained in:
parent
2a78767a4a
commit
bf14bb45f1
|
@ -78,17 +78,19 @@ final class ManiphestTransactionPreviewController extends ManiphestController {
|
||||||
case ManiphestTransactionType::TYPE_PROJECTS:
|
case ManiphestTransactionType::TYPE_PROJECTS:
|
||||||
if ($value) {
|
if ($value) {
|
||||||
$value = json_decode($value);
|
$value = json_decode($value);
|
||||||
$phids = $value;
|
|
||||||
foreach ($task->getProjectPHIDs() as $project_phid) {
|
|
||||||
$phids[] = $project_phid;
|
|
||||||
$value[] = $project_phid;
|
|
||||||
}
|
|
||||||
$transaction->setNewValue($value);
|
|
||||||
} else {
|
|
||||||
$phids = array();
|
|
||||||
$transaction->setNewValue(array());
|
|
||||||
}
|
}
|
||||||
|
if (!$value) {
|
||||||
|
$value = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$phids = $value;
|
||||||
|
foreach ($task->getProjectPHIDs() as $project_phid) {
|
||||||
|
$phids[] = $project_phid;
|
||||||
|
$value[] = $project_phid;
|
||||||
|
}
|
||||||
|
|
||||||
$transaction->setOldValue($task->getProjectPHIDs());
|
$transaction->setOldValue($task->getProjectPHIDs());
|
||||||
|
$transaction->setNewValue($value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$phids = array();
|
$phids = array();
|
||||||
|
|
|
@ -59,9 +59,8 @@ final class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
}
|
}
|
||||||
$new[PhabricatorFilePHIDTypeFile::TYPECONST][$phid] = array();
|
$new[PhabricatorFilePHIDTypeFile::TYPECONST][$phid] = array();
|
||||||
}
|
}
|
||||||
$transaction = new ManiphestTransaction();
|
$transaction = new ManiphestTransactionPro();
|
||||||
$transaction
|
$transaction
|
||||||
->setAuthorPHID($user->getPHID())
|
|
||||||
->setTransactionType(ManiphestTransactionType::TYPE_ATTACH);
|
->setTransactionType(ManiphestTransactionType::TYPE_ATTACH);
|
||||||
$transaction->setNewValue($new);
|
$transaction->setNewValue($new);
|
||||||
$transactions[] = $transaction;
|
$transactions[] = $transaction;
|
||||||
|
@ -77,15 +76,13 @@ final class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
$request->getStr('comments'),
|
$request->getStr('comments'),
|
||||||
));
|
));
|
||||||
|
|
||||||
$cc_transaction = new ManiphestTransaction();
|
$cc_transaction = new ManiphestTransactionPro();
|
||||||
$cc_transaction
|
$cc_transaction
|
||||||
->setAuthorPHID($user->getPHID())
|
|
||||||
->setTransactionType(ManiphestTransactionType::TYPE_CCS);
|
->setTransactionType(ManiphestTransactionType::TYPE_CCS);
|
||||||
$force_cc_transaction = false;
|
$force_cc_transaction = false;
|
||||||
|
|
||||||
$transaction = new ManiphestTransaction();
|
$transaction = new ManiphestTransactionPro();
|
||||||
$transaction
|
$transaction
|
||||||
->setAuthorPHID($user->getPHID())
|
|
||||||
->setTransactionType($action);
|
->setTransactionType($action);
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
@ -139,10 +136,11 @@ final class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->getStr('comments')) {
|
if ($request->getStr('comments')) {
|
||||||
$transactions[] = id(new ManiphestTransaction())
|
$transactions[] = id(new ManiphestTransactionPro())
|
||||||
->setAuthorPHID($user->getPHID())
|
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
|
||||||
->setComments($request->getStr('comments'));
|
->attachComment(
|
||||||
|
id(new ManiphestTransactionComment())
|
||||||
|
->setContent($request->getStr('comments')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// When you interact with a task, we add you to the CC list so you get
|
// When you interact with a task, we add you to the CC list so you get
|
||||||
|
@ -168,7 +166,6 @@ final class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
// Closing an unassigned task. Assign the user as the owner of
|
// Closing an unassigned task. Assign the user as the owner of
|
||||||
// this task.
|
// this task.
|
||||||
$assign = new ManiphestTransaction();
|
$assign = new ManiphestTransaction();
|
||||||
$assign->setAuthorPHID($user->getPHID());
|
|
||||||
$assign->setTransactionType(ManiphestTransactionType::TYPE_OWNER);
|
$assign->setTransactionType(ManiphestTransactionType::TYPE_OWNER);
|
||||||
$assign->setNewValue($user->getPHID());
|
$assign->setNewValue($user->getPHID());
|
||||||
$transactions[] = $assign;
|
$transactions[] = $assign;
|
||||||
|
@ -194,8 +191,10 @@ final class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
|
|
||||||
if (!$user_owns_task) {
|
if (!$user_owns_task) {
|
||||||
// If we aren't making the user the new task owner and they aren't the
|
// If we aren't making the user the new task owner and they aren't the
|
||||||
// existing task owner, add them to CC.
|
// existing task owner, add them to CC unless they're aleady CC'd.
|
||||||
$added_ccs[] = $user->getPHID();
|
if (!in_array($user->getPHID(), $task->getCCPHIDs())) {
|
||||||
|
$added_ccs[] = $user->getPHID();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($added_ccs || $force_cc_transaction) {
|
if ($added_ccs || $force_cc_transaction) {
|
||||||
|
@ -207,16 +206,6 @@ final class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
$transactions[] = $cc_transaction;
|
$transactions[] = $cc_transaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
$content_source = PhabricatorContentSource::newForSource(
|
|
||||||
PhabricatorContentSource::SOURCE_WEB,
|
|
||||||
array(
|
|
||||||
'ip' => $request->getRemoteAddr(),
|
|
||||||
));
|
|
||||||
|
|
||||||
foreach ($transactions as $transaction) {
|
|
||||||
$transaction->setContentSource($content_source);
|
|
||||||
}
|
|
||||||
|
|
||||||
$event = new PhabricatorEvent(
|
$event = new PhabricatorEvent(
|
||||||
PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK,
|
PhabricatorEventType::TYPE_MANIPHEST_WILLEDITTASK,
|
||||||
array(
|
array(
|
||||||
|
@ -231,9 +220,11 @@ final class ManiphestTransactionSaveController extends ManiphestController {
|
||||||
$task = $event->getValue('task');
|
$task = $event->getValue('task');
|
||||||
$transactions = $event->getValue('transactions');
|
$transactions = $event->getValue('transactions');
|
||||||
|
|
||||||
$editor = new ManiphestTransactionEditor();
|
$editor = id(new ManiphestTransactionEditorPro())
|
||||||
$editor->setActor($user);
|
->setActor($user)
|
||||||
$editor->applyTransactions($task, $transactions);
|
->setContentSourceFromRequest($request)
|
||||||
|
->setContinueOnMissingFields(true)
|
||||||
|
->applyTransactions($task, $transactions);
|
||||||
|
|
||||||
$draft = id(new PhabricatorDraft())->loadOneWhere(
|
$draft = id(new PhabricatorDraft())->loadOneWhere(
|
||||||
'authorPHID = %s AND draftKey = %s',
|
'authorPHID = %s AND draftKey = %s',
|
||||||
|
|
|
@ -36,7 +36,7 @@ final class ManiphestTransactionEditorPro
|
||||||
case ManiphestTransactionPro::TYPE_OWNER:
|
case ManiphestTransactionPro::TYPE_OWNER:
|
||||||
return $object->getOwnerPHID();
|
return $object->getOwnerPHID();
|
||||||
case ManiphestTransactionPro::TYPE_CCS:
|
case ManiphestTransactionPro::TYPE_CCS:
|
||||||
return $object->getCCPHIDs();
|
return array_values(array_unique($object->getCCPHIDs()));
|
||||||
case ManiphestTransactionPro::TYPE_PROJECTS:
|
case ManiphestTransactionPro::TYPE_PROJECTS:
|
||||||
return $object->getProjectPHIDs();
|
return $object->getProjectPHIDs();
|
||||||
case ManiphestTransactionPro::TYPE_ATTACH:
|
case ManiphestTransactionPro::TYPE_ATTACH:
|
||||||
|
@ -56,10 +56,11 @@ final class ManiphestTransactionEditorPro
|
||||||
case ManiphestTransactionPro::TYPE_PRIORITY:
|
case ManiphestTransactionPro::TYPE_PRIORITY:
|
||||||
case ManiphestTransactionPro::TYPE_STATUS:
|
case ManiphestTransactionPro::TYPE_STATUS:
|
||||||
return (int)$xaction->getNewValue();
|
return (int)$xaction->getNewValue();
|
||||||
|
case ManiphestTransactionPro::TYPE_CCS:
|
||||||
|
return array_values(array_unique($xaction->getNewValue()));
|
||||||
case ManiphestTransactionPro::TYPE_TITLE:
|
case ManiphestTransactionPro::TYPE_TITLE:
|
||||||
case ManiphestTransactionPro::TYPE_DESCRIPTION:
|
case ManiphestTransactionPro::TYPE_DESCRIPTION:
|
||||||
case ManiphestTransactionPro::TYPE_OWNER:
|
case ManiphestTransactionPro::TYPE_OWNER:
|
||||||
case ManiphestTransactionPro::TYPE_CCS:
|
|
||||||
case ManiphestTransactionPro::TYPE_PROJECTS:
|
case ManiphestTransactionPro::TYPE_PROJECTS:
|
||||||
case ManiphestTransactionPro::TYPE_ATTACH:
|
case ManiphestTransactionPro::TYPE_ATTACH:
|
||||||
case ManiphestTransactionPro::TYPE_EDGE:
|
case ManiphestTransactionPro::TYPE_EDGE:
|
||||||
|
|
|
@ -306,7 +306,7 @@ final class ManiphestTransactionPro
|
||||||
$this->renderHandleLink($author_phid),
|
$this->renderHandleLink($author_phid),
|
||||||
count($removed),
|
count($removed),
|
||||||
$this->renderHandleList($removed));
|
$this->renderHandleList($removed));
|
||||||
} else {
|
} else if ($removed && $added) {
|
||||||
return pht(
|
return pht(
|
||||||
'%s changed projects, added %d: %s; removed %d: %s',
|
'%s changed projects, added %d: %s; removed %d: %s',
|
||||||
$this->renderHandleLink($author_phid),
|
$this->renderHandleLink($author_phid),
|
||||||
|
@ -314,6 +314,11 @@ final class ManiphestTransactionPro
|
||||||
$this->renderHandleList($added),
|
$this->renderHandleList($added),
|
||||||
count($removed),
|
count($removed),
|
||||||
$this->renderHandleList($removed));
|
$this->renderHandleList($removed));
|
||||||
|
} else {
|
||||||
|
// This is hit when rendering previews.
|
||||||
|
return pht(
|
||||||
|
'%s changed projects...',
|
||||||
|
$this->renderHandleLink($author_phid));
|
||||||
}
|
}
|
||||||
|
|
||||||
case self::TYPE_PRIORITY:
|
case self::TYPE_PRIORITY:
|
||||||
|
|
Loading…
Reference in a new issue