mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Migrate Project color to modular transactions
Test Plan: Unit tests + changing project colors. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D17958
This commit is contained in:
parent
1bff5309e6
commit
7e46d7ab6a
6 changed files with 44 additions and 29 deletions
|
@ -3584,6 +3584,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectBoardReorderController' => 'applications/project/controller/PhabricatorProjectBoardReorderController.php',
|
||||
'PhabricatorProjectBoardViewController' => 'applications/project/controller/PhabricatorProjectBoardViewController.php',
|
||||
'PhabricatorProjectCardView' => 'applications/project/view/PhabricatorProjectCardView.php',
|
||||
'PhabricatorProjectColorTransaction' => 'applications/project/xaction/PhabricatorProjectColorTransaction.php',
|
||||
'PhabricatorProjectColorsConfigOptionType' => 'applications/project/config/PhabricatorProjectColorsConfigOptionType.php',
|
||||
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
|
||||
'PhabricatorProjectColumnDetailController' => 'applications/project/controller/PhabricatorProjectColumnDetailController.php',
|
||||
|
@ -8987,6 +8988,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectBoardReorderController' => 'PhabricatorProjectBoardController',
|
||||
'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController',
|
||||
'PhabricatorProjectCardView' => 'AphrontTagView',
|
||||
'PhabricatorProjectColorTransaction' => 'PhabricatorProjectTransactionType',
|
||||
'PhabricatorProjectColorsConfigOptionType' => 'PhabricatorConfigJSONOptionType',
|
||||
'PhabricatorProjectColumn' => array(
|
||||
'PhabricatorProjectDAO',
|
||||
|
|
|
@ -52,13 +52,15 @@ final class ProjectCreateConduitAPIMethod extends ProjectConduitAPIMethod {
|
|||
|
||||
if ($request->getValue('icon')) {
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType(PhabricatorProjectIconTransaction::TRANSACTIONTYPE)
|
||||
->setTransactionType(
|
||||
PhabricatorProjectIconTransaction::TRANSACTIONTYPE)
|
||||
->setNewValue($request->getValue('icon'));
|
||||
}
|
||||
|
||||
if ($request->getValue('color')) {
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_COLOR)
|
||||
->setTransactionType(
|
||||
PhabricatorProjectColorTransaction::TRANSACTIONTYPE)
|
||||
->setNewValue($request->getValue('color'));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
|
||||
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_COLOR;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_LOCKED;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_PARENT;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_MILESTONE;
|
||||
|
@ -47,8 +46,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
return $object->getColor();
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
return (int)$object->getIsMembershipLocked();
|
||||
case PhabricatorProjectTransaction::TYPE_HASWORKBOARD:
|
||||
|
@ -72,7 +69,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
case PhabricatorProjectTransaction::TYPE_PARENT:
|
||||
case PhabricatorProjectTransaction::TYPE_MILESTONE:
|
||||
|
@ -97,9 +93,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
$object->setColor($xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
$object->setIsMembershipLocked($xaction->getNewValue());
|
||||
return;
|
||||
|
@ -136,7 +129,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
$new = $xaction->getNewValue();
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
case PhabricatorProjectTransaction::TYPE_PARENT:
|
||||
case PhabricatorProjectTransaction::TYPE_MILESTONE:
|
||||
|
@ -322,7 +314,7 @@ final class PhabricatorProjectTransactionEditor
|
|||
case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE:
|
||||
case PhabricatorProjectImageTransaction::TRANSACTIONTYPE:
|
||||
case PhabricatorProjectIconTransaction::TRANSACTIONTYPE:
|
||||
case PhabricatorProjectTransaction::TYPE_COLOR:
|
||||
case PhabricatorProjectColorTransaction::TRANSACTIONTYPE:
|
||||
PhabricatorPolicyFilter::requireCapability(
|
||||
$this->requireActor(),
|
||||
$object,
|
||||
|
|
|
@ -113,7 +113,7 @@ final class PhabricatorProjectEditEngine
|
|||
PhabricatorTransactions::TYPE_EDIT_POLICY,
|
||||
PhabricatorTransactions::TYPE_JOIN_POLICY,
|
||||
PhabricatorProjectIconTransaction::TRANSACTIONTYPE,
|
||||
PhabricatorProjectTransaction::TYPE_COLOR,
|
||||
PhabricatorProjectColorTransaction::TRANSACTIONTYPE,
|
||||
);
|
||||
$unavailable = array_fuse($unavailable);
|
||||
|
||||
|
@ -253,7 +253,8 @@ final class PhabricatorProjectEditEngine
|
|||
id(new PhabricatorSelectEditField())
|
||||
->setKey('color')
|
||||
->setLabel(pht('Color'))
|
||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_COLOR)
|
||||
->setTransactionType(
|
||||
PhabricatorProjectColorTransaction::TRANSACTIONTYPE)
|
||||
->setOptions(PhabricatorProjectIconSet::getColorMap())
|
||||
->setDescription(pht('Project tag color.'))
|
||||
->setConduitDescription(pht('Change the project tag color.'))
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
final class PhabricatorProjectTransaction
|
||||
extends PhabricatorModularTransaction {
|
||||
|
||||
const TYPE_COLOR = 'project:color';
|
||||
const TYPE_LOCKED = 'project:locked';
|
||||
const TYPE_PARENT = 'project:parent';
|
||||
const TYPE_MILESTONE = 'project:milestone';
|
||||
|
@ -116,13 +115,6 @@ final class PhabricatorProjectTransaction
|
|||
'%s created this project.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
|
||||
case self::TYPE_COLOR:
|
||||
return pht(
|
||||
"%s set this project's color to %s.",
|
||||
$author_handle,
|
||||
PHUITagView::getShadeName($new));
|
||||
break;
|
||||
|
||||
case self::TYPE_LOCKED:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
@ -214,13 +206,6 @@ final class PhabricatorProjectTransaction
|
|||
$new = $this->getNewValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_COLOR:
|
||||
return pht(
|
||||
'%s set the color for %s to %s.',
|
||||
$author_handle,
|
||||
$object_handle,
|
||||
PHUITagView::getShadeName($new));
|
||||
|
||||
case self::TYPE_LOCKED:
|
||||
if ($new) {
|
||||
return pht(
|
||||
|
@ -245,7 +230,7 @@ final class PhabricatorProjectTransaction
|
|||
case PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE:
|
||||
case PhabricatorProjectImageTransaction::TRANSACTIONTYPE:
|
||||
case PhabricatorProjectIconTransaction::TRANSACTIONTYPE:
|
||||
case self::TYPE_COLOR:
|
||||
case PhabricatorProjectColorTransaction::TRANSACTIONTYPE:
|
||||
$tags[] = self::MAILTAG_METADATA;
|
||||
break;
|
||||
case PhabricatorTransactions::TYPE_EDGE:
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectColorTransaction
|
||||
extends PhabricatorProjectTransactionType {
|
||||
|
||||
const TRANSACTIONTYPE = 'project:color';
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return $object->getColor();
|
||||
}
|
||||
|
||||
public function applyInternalEffects($object, $value) {
|
||||
$object->setColor($value);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
$new = $this->getNewValue();
|
||||
return pht(
|
||||
"%s set this project's color to %s.",
|
||||
$this->renderAuthor(),
|
||||
$this->renderValue(PHUITagView::getShadeName($new)));
|
||||
}
|
||||
|
||||
public function getTitleForFeed() {
|
||||
$new = $this->getNewValue();
|
||||
return pht(
|
||||
'%s set the color for %s to %s.',
|
||||
$this->renderAuthor(),
|
||||
$this->renderObject(),
|
||||
$this->renderValue(PHUITagView::getShadeName($new)));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue