1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 04:50:55 +01:00

Restore "Create" transactions

Summary:
Ref T10004. This restores "alice created this task." transactions, but in a generic way so we don't have to special case one of the other edits with an old `null` value.

In most cases, creating an object now shows only an "alice created this thing." transaction, unless nonempty defaults (usually, policy or spaces) were adjusted.

Test Plan: Created pastes, tasks, blogs, packages, and forms. Saw a single "alice created this thing." transaction.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10004

Differential Revision: https://secure.phabricator.com/D14820
This commit is contained in:
epriestley 2015-12-18 10:14:37 -08:00
parent 7168d8edd9
commit 5cb0de1efc
9 changed files with 69 additions and 3 deletions

View file

@ -381,6 +381,11 @@ final class ManiphestTransaction
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this task.',
$this->renderHandleLink($author_phid));
case self::TYPE_TITLE:
if ($old === null) {
return pht(

View file

@ -47,11 +47,16 @@ final class PhabricatorOwnersPackageTransaction
switch ($this->getTransactionType()) {
case self::TYPE_DESCRIPTION:
return ($old === null);
if ($old === null) {
return true;
}
break;
case self::TYPE_PRIMARY:
// TODO: Eventually, remove these transactions entirely.
return true;
}
return parent::shouldHide();
}
public function getTitle() {
@ -60,6 +65,10 @@ final class PhabricatorOwnersPackageTransaction
$author_phid = $this->getAuthorPHID();
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this package.',
$this->renderHandleLink($author_phid));
case self::TYPE_NAME:
if ($old === null) {
return pht(

View file

@ -41,7 +41,10 @@ final class PhabricatorPasteTransaction
switch ($this->getTransactionType()) {
case self::TYPE_TITLE:
case self::TYPE_LANGUAGE:
return ($old === null);
if ($old === null) {
return true;
}
break;
}
return parent::shouldHide();
}
@ -77,6 +80,10 @@ final class PhabricatorPasteTransaction
$type = $this->getTransactionType();
switch ($type) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this paste.',
$this->renderHandleLink($author_phid));
case self::TYPE_CONTENT:
if ($old === null) {
return pht(

View file

@ -24,7 +24,9 @@ final class PhameBlogTransaction
$old = $this->getOldValue();
switch ($this->getTransactionType()) {
case self::TYPE_DESCRIPTION:
return ($old === null);
if ($old === null) {
return true;
}
}
return parent::shouldHide();
}
@ -98,6 +100,10 @@ final class PhameBlogTransaction
$type = $this->getTransactionType();
switch ($type) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this blog.',
$this->renderHandleLink($author_phid));
case self::TYPE_NAME:
if ($old === null) {
return pht(

View file

@ -13,6 +13,7 @@ final class PhabricatorTransactions extends Phobject {
const TYPE_TOKEN = 'token:give';
const TYPE_INLINESTATE = 'core:inlinestate';
const TYPE_SPACE = 'core:space';
const TYPE_CREATE = 'core:create';
const COLOR_RED = 'red';
const COLOR_ORANGE = 'orange';

View file

@ -857,6 +857,12 @@ abstract class PhabricatorEditEngine
}
$xactions = array();
if ($this->getIsCreate()) {
$xactions[] = id(clone $template)
->setTransactionType(PhabricatorTransactions::TYPE_CREATE);
}
foreach ($submit_fields as $key => $field) {
$field_value = $field->getValueForTransaction();
@ -1647,6 +1653,12 @@ abstract class PhabricatorEditEngine
}
$results = array();
if ($this->getIsCreate()) {
$results[] = id(clone $template)
->setTransactionType(PhabricatorTransactions::TYPE_CREATE);
}
foreach ($xactions as $xaction) {
$type = $types[$xaction['type']];

View file

@ -258,6 +258,8 @@ abstract class PhabricatorApplicationTransactionEditor
public function getTransactionTypes() {
$types = array();
$types[] = PhabricatorTransactions::TYPE_CREATE;
if ($this->object instanceof PhabricatorSubscribableInterface) {
$types[] = PhabricatorTransactions::TYPE_SUBSCRIBERS;
}
@ -303,6 +305,8 @@ abstract class PhabricatorApplicationTransactionEditor
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return null;
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return array_values($this->subscribers);
case PhabricatorTransactions::TYPE_VIEW_POLICY:
@ -371,6 +375,8 @@ abstract class PhabricatorApplicationTransactionEditor
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return null;
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return $this->getPHIDTransactionNewValue($xaction);
case PhabricatorTransactions::TYPE_VIEW_POLICY:
@ -422,6 +428,8 @@ abstract class PhabricatorApplicationTransactionEditor
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return true;
case PhabricatorTransactions::TYPE_COMMENT:
return $xaction->hasComment();
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
@ -484,6 +492,7 @@ abstract class PhabricatorApplicationTransactionEditor
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
$field = $this->getCustomFieldForTransaction($object, $xaction);
return $field->applyApplicationTransactionInternalEffects($xaction);
case PhabricatorTransactions::TYPE_CREATE:
case PhabricatorTransactions::TYPE_BUILDABLE:
case PhabricatorTransactions::TYPE_TOKEN:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
@ -534,6 +543,7 @@ abstract class PhabricatorApplicationTransactionEditor
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
$field = $this->getCustomFieldForTransaction($object, $xaction);
return $field->applyApplicationTransactionExternalEffects($xaction);
case PhabricatorTransactions::TYPE_CREATE:
case PhabricatorTransactions::TYPE_EDGE:
case PhabricatorTransactions::TYPE_BUILDABLE:
case PhabricatorTransactions::TYPE_TOKEN:

View file

@ -482,6 +482,7 @@ abstract class PhabricatorApplicationTransaction
// essentially never interesting.
if ($this->getIsCreateTransaction()) {
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
@ -497,6 +498,7 @@ abstract class PhabricatorApplicationTransaction
if (!strlen($old)) {
return true;
}
break;
}
}
@ -702,6 +704,10 @@ abstract class PhabricatorApplicationTransaction
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this object.',
$this->renderHandleLink($author_phid));
case PhabricatorTransactions::TYPE_COMMENT:
return pht(
'%s added a comment.',
@ -918,6 +924,11 @@ abstract class PhabricatorApplicationTransaction
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
case PhabricatorTransactions::TYPE_COMMENT:
return pht(
'%s added a comment to %s.',
@ -1119,6 +1130,7 @@ abstract class PhabricatorApplicationTransaction
// Make this weaker than TYPE_COMMENT.
return 0.25;
}
return 1.0;
}

View file

@ -34,6 +34,10 @@ final class PhabricatorEditEngineConfigurationTransaction
$type = $this->getTransactionType();
switch ($type) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this form configuration.',
$this->renderHandleLink($author_phid));
case self::TYPE_NAME:
if (strlen($old)) {
return pht(