mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 13:30:55 +01:00
Migrate Project status to modular transactions
Test Plan: Unit tests pass. Archived/activated some projects a couple times; observed expected transactions on timeline. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D17953
This commit is contained in:
parent
91eb22cb3a
commit
f92059d84c
8 changed files with 76 additions and 61 deletions
|
@ -34,7 +34,7 @@ foreach ($rows as $row) {
|
||||||
$type_map = array(
|
$type_map = array(
|
||||||
'name' => PhabricatorProjectNameTransaction::TRANSACTIONTYPE,
|
'name' => PhabricatorProjectNameTransaction::TRANSACTIONTYPE,
|
||||||
'members' => PhabricatorProjectTransaction::TYPE_MEMBERS,
|
'members' => PhabricatorProjectTransaction::TYPE_MEMBERS,
|
||||||
'status' => PhabricatorProjectTransaction::TYPE_STATUS,
|
'status' => PhabricatorProjectStatusTransaction::TRANSACTIONTYPE,
|
||||||
'canview' => PhabricatorTransactions::TYPE_VIEW_POLICY,
|
'canview' => PhabricatorTransactions::TYPE_VIEW_POLICY,
|
||||||
'canedit' => PhabricatorTransactions::TYPE_EDIT_POLICY,
|
'canedit' => PhabricatorTransactions::TYPE_EDIT_POLICY,
|
||||||
'canjoin' => PhabricatorTransactions::TYPE_JOIN_POLICY,
|
'canjoin' => PhabricatorTransactions::TYPE_JOIN_POLICY,
|
||||||
|
|
|
@ -3669,6 +3669,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorProjectSlugsTransaction' => 'applications/project/xaction/PhabricatorProjectSlugsTransaction.php',
|
'PhabricatorProjectSlugsTransaction' => 'applications/project/xaction/PhabricatorProjectSlugsTransaction.php',
|
||||||
'PhabricatorProjectStandardCustomField' => 'applications/project/customfield/PhabricatorProjectStandardCustomField.php',
|
'PhabricatorProjectStandardCustomField' => 'applications/project/customfield/PhabricatorProjectStandardCustomField.php',
|
||||||
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
|
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
|
||||||
|
'PhabricatorProjectStatusTransaction' => 'applications/project/xaction/PhabricatorProjectStatusTransaction.php',
|
||||||
'PhabricatorProjectSubprojectWarningController' => 'applications/project/controller/PhabricatorProjectSubprojectWarningController.php',
|
'PhabricatorProjectSubprojectWarningController' => 'applications/project/controller/PhabricatorProjectSubprojectWarningController.php',
|
||||||
'PhabricatorProjectSubprojectsController' => 'applications/project/controller/PhabricatorProjectSubprojectsController.php',
|
'PhabricatorProjectSubprojectsController' => 'applications/project/controller/PhabricatorProjectSubprojectsController.php',
|
||||||
'PhabricatorProjectSubprojectsProfileMenuItem' => 'applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php',
|
'PhabricatorProjectSubprojectsProfileMenuItem' => 'applications/project/menuitem/PhabricatorProjectSubprojectsProfileMenuItem.php',
|
||||||
|
@ -9084,6 +9085,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorStandardCustomFieldInterface',
|
'PhabricatorStandardCustomFieldInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorProjectStatus' => 'Phobject',
|
'PhabricatorProjectStatus' => 'Phobject',
|
||||||
|
'PhabricatorProjectStatusTransaction' => 'PhabricatorProjectTransactionType',
|
||||||
'PhabricatorProjectSubprojectWarningController' => 'PhabricatorProjectController',
|
'PhabricatorProjectSubprojectWarningController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectSubprojectsController' => 'PhabricatorProjectController',
|
'PhabricatorProjectSubprojectsController' => 'PhabricatorProjectController',
|
||||||
'PhabricatorProjectSubprojectsProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
'PhabricatorProjectSubprojectsProfileMenuItem' => 'PhabricatorProfileMenuItem',
|
||||||
|
|
|
@ -32,7 +32,8 @@ final class PhabricatorProjectArchiveController
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
|
||||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)
|
->setTransactionType(
|
||||||
|
PhabricatorProjectStatusTransaction::TRANSACTIONTYPE)
|
||||||
->setNewValue($new_status);
|
->setNewValue($new_status);
|
||||||
|
|
||||||
id(new PhabricatorProjectTransactionEditor())
|
id(new PhabricatorProjectTransactionEditor())
|
||||||
|
|
|
@ -65,7 +65,8 @@ final class PhabricatorProjectColumnHideController
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
|
||||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_STATUS)
|
->setTransactionType(
|
||||||
|
PhabricatorProjectStatusTransaction::TRANSACTIONTYPE)
|
||||||
->setNewValue($new_status);
|
->setNewValue($new_status);
|
||||||
|
|
||||||
id(new PhabricatorProjectTransactionEditor())
|
id(new PhabricatorProjectTransactionEditor())
|
||||||
|
|
|
@ -30,7 +30,6 @@ final class PhabricatorProjectTransactionEditor
|
||||||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||||
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
|
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
|
||||||
|
|
||||||
$types[] = PhabricatorProjectTransaction::TYPE_STATUS;
|
|
||||||
$types[] = PhabricatorProjectTransaction::TYPE_IMAGE;
|
$types[] = PhabricatorProjectTransaction::TYPE_IMAGE;
|
||||||
$types[] = PhabricatorProjectTransaction::TYPE_ICON;
|
$types[] = PhabricatorProjectTransaction::TYPE_ICON;
|
||||||
$types[] = PhabricatorProjectTransaction::TYPE_COLOR;
|
$types[] = PhabricatorProjectTransaction::TYPE_COLOR;
|
||||||
|
@ -50,8 +49,6 @@ final class PhabricatorProjectTransactionEditor
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
|
||||||
return $object->getStatus();
|
|
||||||
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
||||||
return $object->getProfileImagePHID();
|
return $object->getProfileImagePHID();
|
||||||
case PhabricatorProjectTransaction::TYPE_ICON:
|
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||||
|
@ -81,7 +78,6 @@ final class PhabricatorProjectTransactionEditor
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
|
||||||
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
||||||
case PhabricatorProjectTransaction::TYPE_ICON:
|
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||||
|
@ -109,9 +105,6 @@ final class PhabricatorProjectTransactionEditor
|
||||||
PhabricatorApplicationTransaction $xaction) {
|
PhabricatorApplicationTransaction $xaction) {
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
|
||||||
$object->setStatus($xaction->getNewValue());
|
|
||||||
return;
|
|
||||||
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
||||||
$object->setProfileImagePHID($xaction->getNewValue());
|
$object->setProfileImagePHID($xaction->getNewValue());
|
||||||
return;
|
return;
|
||||||
|
@ -157,7 +150,6 @@ final class PhabricatorProjectTransactionEditor
|
||||||
$new = $xaction->getNewValue();
|
$new = $xaction->getNewValue();
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
|
||||||
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
||||||
case PhabricatorProjectTransaction::TYPE_ICON:
|
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||||
|
@ -343,7 +335,7 @@ final class PhabricatorProjectTransactionEditor
|
||||||
|
|
||||||
switch ($xaction->getTransactionType()) {
|
switch ($xaction->getTransactionType()) {
|
||||||
case PhabricatorProjectNameTransaction::TRANSACTIONTYPE:
|
case PhabricatorProjectNameTransaction::TRANSACTIONTYPE:
|
||||||
case PhabricatorProjectTransaction::TYPE_STATUS:
|
case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE:
|
||||||
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
case PhabricatorProjectTransaction::TYPE_IMAGE:
|
||||||
case PhabricatorProjectTransaction::TYPE_ICON:
|
case PhabricatorProjectTransaction::TYPE_ICON:
|
||||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||||
|
|
|
@ -20,7 +20,7 @@ final class PhabricatorProjectTestDataGenerator
|
||||||
$this->newProjectTitle());
|
$this->newProjectTitle());
|
||||||
|
|
||||||
$xactions[] = $this->newTransaction(
|
$xactions[] = $this->newTransaction(
|
||||||
PhabricatorProjectTransaction::TYPE_STATUS,
|
PhabricatorProjectStatusTransaction::TRANSACTIONTYPE,
|
||||||
$this->newProjectStatus());
|
$this->newProjectStatus());
|
||||||
|
|
||||||
// Almost always make the author a member.
|
// Almost always make the author a member.
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
final class PhabricatorProjectTransaction
|
final class PhabricatorProjectTransaction
|
||||||
extends PhabricatorModularTransaction {
|
extends PhabricatorModularTransaction {
|
||||||
|
|
||||||
const TYPE_STATUS = 'project:status';
|
|
||||||
const TYPE_IMAGE = 'project:image';
|
const TYPE_IMAGE = 'project:image';
|
||||||
const TYPE_ICON = 'project:icon';
|
const TYPE_ICON = 'project:icon';
|
||||||
const TYPE_COLOR = 'project:color';
|
const TYPE_COLOR = 'project:color';
|
||||||
|
@ -55,22 +54,6 @@ final class PhabricatorProjectTransaction
|
||||||
return array_merge($req_phids, parent::getRequiredHandlePHIDs());
|
return array_merge($req_phids, parent::getRequiredHandlePHIDs());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getColor() {
|
|
||||||
|
|
||||||
$old = $this->getOldValue();
|
|
||||||
$new = $this->getNewValue();
|
|
||||||
|
|
||||||
switch ($this->getTransactionType()) {
|
|
||||||
case self::TYPE_STATUS:
|
|
||||||
if ($old == 0) {
|
|
||||||
return 'red';
|
|
||||||
} else {
|
|
||||||
return 'green';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return parent::getColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function shouldHide() {
|
public function shouldHide() {
|
||||||
switch ($this->getTransactionType()) {
|
switch ($this->getTransactionType()) {
|
||||||
case PhabricatorTransactions::TYPE_EDGE:
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
|
@ -115,12 +98,6 @@ final class PhabricatorProjectTransaction
|
||||||
$new = $this->getNewValue();
|
$new = $this->getNewValue();
|
||||||
|
|
||||||
switch ($this->getTransactionType()) {
|
switch ($this->getTransactionType()) {
|
||||||
case self::TYPE_STATUS:
|
|
||||||
if ($old == 0) {
|
|
||||||
return 'fa-ban';
|
|
||||||
} else {
|
|
||||||
return 'fa-check';
|
|
||||||
}
|
|
||||||
case self::TYPE_LOCKED:
|
case self::TYPE_LOCKED:
|
||||||
if ($new) {
|
if ($new) {
|
||||||
return 'fa-lock';
|
return 'fa-lock';
|
||||||
|
@ -149,18 +126,6 @@ final class PhabricatorProjectTransaction
|
||||||
'%s created this project.',
|
'%s created this project.',
|
||||||
$this->renderHandleLink($author_phid));
|
$this->renderHandleLink($author_phid));
|
||||||
|
|
||||||
case self::TYPE_STATUS:
|
|
||||||
if ($old == 0) {
|
|
||||||
return pht(
|
|
||||||
'%s archived this project.',
|
|
||||||
$author_handle);
|
|
||||||
} else {
|
|
||||||
return pht(
|
|
||||||
'%s activated this project.',
|
|
||||||
$author_handle);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case self::TYPE_IMAGE:
|
case self::TYPE_IMAGE:
|
||||||
// TODO: Some day, it would be nice to show the images.
|
// TODO: Some day, it would be nice to show the images.
|
||||||
if (!$old) {
|
if (!$old) {
|
||||||
|
@ -288,18 +253,6 @@ final class PhabricatorProjectTransaction
|
||||||
$new = $this->getNewValue();
|
$new = $this->getNewValue();
|
||||||
|
|
||||||
switch ($this->getTransactionType()) {
|
switch ($this->getTransactionType()) {
|
||||||
case self::TYPE_STATUS:
|
|
||||||
if ($old == 0) {
|
|
||||||
return pht(
|
|
||||||
'%s archived %s.',
|
|
||||||
$author_handle,
|
|
||||||
$object_handle);
|
|
||||||
} else {
|
|
||||||
return pht(
|
|
||||||
'%s activated %s.',
|
|
||||||
$author_handle,
|
|
||||||
$object_handle);
|
|
||||||
}
|
|
||||||
case self::TYPE_IMAGE:
|
case self::TYPE_IMAGE:
|
||||||
// TODO: Some day, it would be nice to show the images.
|
// TODO: Some day, it would be nice to show the images.
|
||||||
if (!$old) {
|
if (!$old) {
|
||||||
|
@ -378,7 +331,7 @@ final class PhabricatorProjectTransaction
|
||||||
$tags[] = self::MAILTAG_OTHER;
|
$tags[] = self::MAILTAG_OTHER;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::TYPE_STATUS:
|
case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE:
|
||||||
case self::TYPE_LOCKED:
|
case self::TYPE_LOCKED:
|
||||||
default:
|
default:
|
||||||
$tags[] = self::MAILTAG_OTHER;
|
$tags[] = self::MAILTAG_OTHER;
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorProjectStatusTransaction
|
||||||
|
extends PhabricatorProjectTransactionType {
|
||||||
|
|
||||||
|
const TRANSACTIONTYPE = 'project:status';
|
||||||
|
|
||||||
|
public function generateOldValue($object) {
|
||||||
|
return $object->getStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function applyInternalEffects($object, $value) {
|
||||||
|
$object->setStatus($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitle() {
|
||||||
|
$old = $this->getOldValue();
|
||||||
|
|
||||||
|
if ($old == 0) {
|
||||||
|
return pht(
|
||||||
|
'%s archived this project.',
|
||||||
|
$this->renderAuthor());
|
||||||
|
} else {
|
||||||
|
return pht(
|
||||||
|
'%s activated this project.',
|
||||||
|
$this->renderAuthor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTitleForFeed() {
|
||||||
|
$old = $this->getOldValue();
|
||||||
|
|
||||||
|
if ($old == 0) {
|
||||||
|
return pht(
|
||||||
|
'%s archived %s.',
|
||||||
|
$this->renderAuthor(),
|
||||||
|
$this->renderObject());
|
||||||
|
} else {
|
||||||
|
return pht(
|
||||||
|
'%s activated %s.',
|
||||||
|
$this->renderAuthor(),
|
||||||
|
$this->renderObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColor() {
|
||||||
|
$old = $this->getOldValue();
|
||||||
|
|
||||||
|
if ($old == 0) {
|
||||||
|
return 'red';
|
||||||
|
} else {
|
||||||
|
return 'green';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIcon() {
|
||||||
|
$old = $this->getOldValue();
|
||||||
|
|
||||||
|
if ($old == 0) {
|
||||||
|
return 'fa-ban';
|
||||||
|
} else {
|
||||||
|
return 'fa-check';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue