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(); $new = $this->getNewValue();
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this task.',
$this->renderHandleLink($author_phid));
case self::TYPE_TITLE: case self::TYPE_TITLE:
if ($old === null) { if ($old === null) {
return pht( return pht(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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