mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 14:30:56 +01:00
Add new-style transaction editor to Maniphest and switch priority edits to it
Summary: Ref T2217. All the reads route through new code already, start swapping writes over. This is the simplest writer, used when the user drag-and-drops stuff on the task list. Test Plan: Dragged and dropped stuff across priorities. Got a transaction and some email. Verified the email and transaction looked OK, threaded properly, etc. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2217 Differential Revision: https://secure.phabricator.com/D7080
This commit is contained in:
parent
28e66090fd
commit
69523d30cc
4 changed files with 136 additions and 16 deletions
|
@ -734,6 +734,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTransaction' => 'applications/maniphest/storage/ManiphestTransaction.php',
|
||||
'ManiphestTransactionComment' => 'applications/maniphest/storage/ManiphestTransactionComment.php',
|
||||
'ManiphestTransactionEditor' => 'applications/maniphest/editor/ManiphestTransactionEditor.php',
|
||||
'ManiphestTransactionEditorPro' => 'applications/maniphest/editor/ManiphestTransactionEditorPro.php',
|
||||
'ManiphestTransactionPreviewController' => 'applications/maniphest/controller/ManiphestTransactionPreviewController.php',
|
||||
'ManiphestTransactionPro' => 'applications/maniphest/storage/ManiphestTransactionPro.php',
|
||||
'ManiphestTransactionQuery' => 'applications/maniphest/query/ManiphestTransactionQuery.php',
|
||||
|
@ -2824,6 +2825,7 @@ phutil_register_library_map(array(
|
|||
'ManiphestTaskSubscriber' => 'ManiphestDAO',
|
||||
'ManiphestTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||
'ManiphestTransactionEditor' => 'PhabricatorEditor',
|
||||
'ManiphestTransactionEditorPro' => 'PhabricatorApplicationTransactionEditor',
|
||||
'ManiphestTransactionPreviewController' => 'ManiphestController',
|
||||
'ManiphestTransactionPro' => 'PhabricatorApplicationTransaction',
|
||||
'ManiphestTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
|
|
|
@ -34,22 +34,23 @@ final class ManiphestSubpriorityController extends ManiphestController {
|
|||
$after_pri,
|
||||
$after_sub);
|
||||
|
||||
if ($after_pri != $task->getPriority()) {
|
||||
$xaction = new ManiphestTransaction();
|
||||
$xaction->setAuthorPHID($request->getUser()->getPHID());
|
||||
|
||||
// TODO: Content source?
|
||||
|
||||
$xaction->setTransactionType(ManiphestTransactionType::TYPE_PRIORITY);
|
||||
$xaction->setNewValue($after_pri);
|
||||
|
||||
$editor = new ManiphestTransactionEditor();
|
||||
$editor->setActor($request->getUser());
|
||||
$editor->applyTransactions($task, array($xaction));
|
||||
}
|
||||
|
||||
$task->setSubpriority($new_sub);
|
||||
$task->save();
|
||||
|
||||
if ($after_pri != $task->getPriority()) {
|
||||
$xactions = array();
|
||||
$xactions[] = id(new ManiphestTransactionPro())
|
||||
->setTransactionType(ManiphestTransactionPro::TYPE_PRIORITY)
|
||||
->setNewValue($after_pri);
|
||||
|
||||
$editor = id(new ManiphestTransactionEditorPro())
|
||||
->setActor($user)
|
||||
->setContinueOnNoEffect($request->isContinueRequest())
|
||||
->setContentSourceFromRequest($request);
|
||||
|
||||
$editor->applyTransactions($task, $xactions);
|
||||
} else {
|
||||
$task->save();
|
||||
}
|
||||
|
||||
return id(new AphrontAjaxResponse())->setContent(
|
||||
array(
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
<?php
|
||||
|
||||
final class ManiphestTransactionEditorPro
|
||||
extends PhabricatorApplicationTransactionEditor {
|
||||
|
||||
public function getTransactionTypes() {
|
||||
$types = parent::getTransactionTypes();
|
||||
|
||||
$types[] = PhabricatorTransactions::TYPE_COMMENT;
|
||||
$types[] = ManiphestTransactionPro::TYPE_PRIORITY;
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
protected function getCustomTransactionOldValue(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case ManiphestTransactionPro::TYPE_PRIORITY:
|
||||
return $object->getPriority();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function getCustomTransactionNewValue(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case ManiphestTransactionPro::TYPE_PRIORITY:
|
||||
return $xaction->getNewValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function applyCustomInternalTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case ManiphestTransactionPro::TYPE_PRIORITY:
|
||||
return $object->setPriority($xaction->getNewValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function applyCustomExternalTransaction(
|
||||
PhabricatorLiskDAO $object,
|
||||
PhabricatorApplicationTransaction $xaction) {
|
||||
}
|
||||
|
||||
protected function shouldSendMail(
|
||||
PhabricatorLiskDAO $object,
|
||||
array $xactions) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function getMailSubjectPrefix() {
|
||||
return PhabricatorEnv::getEnvConfig('metamta.maniphest.subject-prefix');
|
||||
}
|
||||
|
||||
protected function getMailThreadID(PhabricatorLiskDAO $object) {
|
||||
return 'maniphest-task-'.$object->getPHID();
|
||||
}
|
||||
|
||||
protected function getMailTo(PhabricatorLiskDAO $object) {
|
||||
return array(
|
||||
$object->getOwnerPHID(),
|
||||
$this->requireActor()->getPHID(),
|
||||
);
|
||||
}
|
||||
|
||||
protected function getMailCC(PhabricatorLiskDAO $object) {
|
||||
return $object->getCCPHIDs();
|
||||
}
|
||||
|
||||
protected function buildReplyHandler(PhabricatorLiskDAO $object) {
|
||||
return id(new ManiphestReplyHandler())
|
||||
->setMailReceiver($object);
|
||||
}
|
||||
|
||||
protected function buildMailTemplate(PhabricatorLiskDAO $object) {
|
||||
$id = $object->getID();
|
||||
$title = $object->getTitle();
|
||||
|
||||
return id(new PhabricatorMetaMTAMail())
|
||||
->setSubject("T{$id}: {$title}")
|
||||
->addHeader('Thread-Topic', "T{$id}: ".$object->getOriginalTitle());
|
||||
}
|
||||
|
||||
protected function buildMailBody(
|
||||
PhabricatorLiskDAO $object,
|
||||
array $xactions) {
|
||||
|
||||
$body = parent::buildMailBody($object, $xactions);
|
||||
|
||||
$body->addTextSection(
|
||||
pht('TASK DETAIL'),
|
||||
PhabricatorEnv::getProductionURI('/T'.$object->getID()));
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
protected function supportsFeed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function supportsSearch() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1176,7 +1176,7 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
->setFrom($this->requireActor()->getPHID())
|
||||
->setSubjectPrefix($this->getMailSubjectPrefix())
|
||||
->setVarySubjectPrefix('['.$action.']')
|
||||
->setThreadID($object->getPHID(), $this->getIsNewObject())
|
||||
->setThreadID($this->getMailThreadID($object), $this->getIsNewObject())
|
||||
->setRelatedPHID($object->getPHID())
|
||||
->setExcludeMailRecipientPHIDs($this->getExcludeMailRecipientPHIDs())
|
||||
->setMailTags($mail_tags)
|
||||
|
@ -1204,6 +1204,10 @@ abstract class PhabricatorApplicationTransactionEditor
|
|||
return $template;
|
||||
}
|
||||
|
||||
protected function getMailThreadID(PhabricatorLiskDAO $object) {
|
||||
return $object->getPHID();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @task mail
|
||||
|
|
Loading…
Reference in a new issue