1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +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:
Austin McKinley 2017-05-18 16:32:04 -07:00
parent 1bff5309e6
commit 7e46d7ab6a
6 changed files with 44 additions and 29 deletions

View file

@ -3584,6 +3584,7 @@ phutil_register_library_map(array(
'PhabricatorProjectBoardReorderController' => 'applications/project/controller/PhabricatorProjectBoardReorderController.php', 'PhabricatorProjectBoardReorderController' => 'applications/project/controller/PhabricatorProjectBoardReorderController.php',
'PhabricatorProjectBoardViewController' => 'applications/project/controller/PhabricatorProjectBoardViewController.php', 'PhabricatorProjectBoardViewController' => 'applications/project/controller/PhabricatorProjectBoardViewController.php',
'PhabricatorProjectCardView' => 'applications/project/view/PhabricatorProjectCardView.php', 'PhabricatorProjectCardView' => 'applications/project/view/PhabricatorProjectCardView.php',
'PhabricatorProjectColorTransaction' => 'applications/project/xaction/PhabricatorProjectColorTransaction.php',
'PhabricatorProjectColorsConfigOptionType' => 'applications/project/config/PhabricatorProjectColorsConfigOptionType.php', 'PhabricatorProjectColorsConfigOptionType' => 'applications/project/config/PhabricatorProjectColorsConfigOptionType.php',
'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php', 'PhabricatorProjectColumn' => 'applications/project/storage/PhabricatorProjectColumn.php',
'PhabricatorProjectColumnDetailController' => 'applications/project/controller/PhabricatorProjectColumnDetailController.php', 'PhabricatorProjectColumnDetailController' => 'applications/project/controller/PhabricatorProjectColumnDetailController.php',
@ -8987,6 +8988,7 @@ phutil_register_library_map(array(
'PhabricatorProjectBoardReorderController' => 'PhabricatorProjectBoardController', 'PhabricatorProjectBoardReorderController' => 'PhabricatorProjectBoardController',
'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController', 'PhabricatorProjectBoardViewController' => 'PhabricatorProjectBoardController',
'PhabricatorProjectCardView' => 'AphrontTagView', 'PhabricatorProjectCardView' => 'AphrontTagView',
'PhabricatorProjectColorTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectColorsConfigOptionType' => 'PhabricatorConfigJSONOptionType', 'PhabricatorProjectColorsConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorProjectColumn' => array( 'PhabricatorProjectColumn' => array(
'PhabricatorProjectDAO', 'PhabricatorProjectDAO',

View file

@ -52,13 +52,15 @@ final class ProjectCreateConduitAPIMethod extends ProjectConduitAPIMethod {
if ($request->getValue('icon')) { if ($request->getValue('icon')) {
$xactions[] = id(new PhabricatorProjectTransaction()) $xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorProjectIconTransaction::TRANSACTIONTYPE) ->setTransactionType(
PhabricatorProjectIconTransaction::TRANSACTIONTYPE)
->setNewValue($request->getValue('icon')); ->setNewValue($request->getValue('icon'));
} }
if ($request->getValue('color')) { if ($request->getValue('color')) {
$xactions[] = id(new PhabricatorProjectTransaction()) $xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorProjectTransaction::TYPE_COLOR) ->setTransactionType(
PhabricatorProjectColorTransaction::TRANSACTIONTYPE)
->setNewValue($request->getValue('color')); ->setNewValue($request->getValue('color'));
} }

View file

@ -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_COLOR;
$types[] = PhabricatorProjectTransaction::TYPE_LOCKED; $types[] = PhabricatorProjectTransaction::TYPE_LOCKED;
$types[] = PhabricatorProjectTransaction::TYPE_PARENT; $types[] = PhabricatorProjectTransaction::TYPE_PARENT;
$types[] = PhabricatorProjectTransaction::TYPE_MILESTONE; $types[] = PhabricatorProjectTransaction::TYPE_MILESTONE;
@ -47,8 +46,6 @@ final class PhabricatorProjectTransactionEditor
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_COLOR:
return $object->getColor();
case PhabricatorProjectTransaction::TYPE_LOCKED: case PhabricatorProjectTransaction::TYPE_LOCKED:
return (int)$object->getIsMembershipLocked(); return (int)$object->getIsMembershipLocked();
case PhabricatorProjectTransaction::TYPE_HASWORKBOARD: case PhabricatorProjectTransaction::TYPE_HASWORKBOARD:
@ -72,7 +69,6 @@ final class PhabricatorProjectTransactionEditor
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_COLOR:
case PhabricatorProjectTransaction::TYPE_LOCKED: case PhabricatorProjectTransaction::TYPE_LOCKED:
case PhabricatorProjectTransaction::TYPE_PARENT: case PhabricatorProjectTransaction::TYPE_PARENT:
case PhabricatorProjectTransaction::TYPE_MILESTONE: case PhabricatorProjectTransaction::TYPE_MILESTONE:
@ -97,9 +93,6 @@ final class PhabricatorProjectTransactionEditor
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_COLOR:
$object->setColor($xaction->getNewValue());
return;
case PhabricatorProjectTransaction::TYPE_LOCKED: case PhabricatorProjectTransaction::TYPE_LOCKED:
$object->setIsMembershipLocked($xaction->getNewValue()); $object->setIsMembershipLocked($xaction->getNewValue());
return; return;
@ -136,7 +129,6 @@ final class PhabricatorProjectTransactionEditor
$new = $xaction->getNewValue(); $new = $xaction->getNewValue();
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_COLOR:
case PhabricatorProjectTransaction::TYPE_LOCKED: case PhabricatorProjectTransaction::TYPE_LOCKED:
case PhabricatorProjectTransaction::TYPE_PARENT: case PhabricatorProjectTransaction::TYPE_PARENT:
case PhabricatorProjectTransaction::TYPE_MILESTONE: case PhabricatorProjectTransaction::TYPE_MILESTONE:
@ -322,7 +314,7 @@ final class PhabricatorProjectTransactionEditor
case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE: case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE:
case PhabricatorProjectImageTransaction::TRANSACTIONTYPE: case PhabricatorProjectImageTransaction::TRANSACTIONTYPE:
case PhabricatorProjectIconTransaction::TRANSACTIONTYPE: case PhabricatorProjectIconTransaction::TRANSACTIONTYPE:
case PhabricatorProjectTransaction::TYPE_COLOR: case PhabricatorProjectColorTransaction::TRANSACTIONTYPE:
PhabricatorPolicyFilter::requireCapability( PhabricatorPolicyFilter::requireCapability(
$this->requireActor(), $this->requireActor(),
$object, $object,

View file

@ -113,7 +113,7 @@ final class PhabricatorProjectEditEngine
PhabricatorTransactions::TYPE_EDIT_POLICY, PhabricatorTransactions::TYPE_EDIT_POLICY,
PhabricatorTransactions::TYPE_JOIN_POLICY, PhabricatorTransactions::TYPE_JOIN_POLICY,
PhabricatorProjectIconTransaction::TRANSACTIONTYPE, PhabricatorProjectIconTransaction::TRANSACTIONTYPE,
PhabricatorProjectTransaction::TYPE_COLOR, PhabricatorProjectColorTransaction::TRANSACTIONTYPE,
); );
$unavailable = array_fuse($unavailable); $unavailable = array_fuse($unavailable);
@ -253,7 +253,8 @@ final class PhabricatorProjectEditEngine
id(new PhabricatorSelectEditField()) id(new PhabricatorSelectEditField())
->setKey('color') ->setKey('color')
->setLabel(pht('Color')) ->setLabel(pht('Color'))
->setTransactionType(PhabricatorProjectTransaction::TYPE_COLOR) ->setTransactionType(
PhabricatorProjectColorTransaction::TRANSACTIONTYPE)
->setOptions(PhabricatorProjectIconSet::getColorMap()) ->setOptions(PhabricatorProjectIconSet::getColorMap())
->setDescription(pht('Project tag color.')) ->setDescription(pht('Project tag color.'))
->setConduitDescription(pht('Change the project tag color.')) ->setConduitDescription(pht('Change the project tag color.'))

View file

@ -3,7 +3,6 @@
final class PhabricatorProjectTransaction final class PhabricatorProjectTransaction
extends PhabricatorModularTransaction { extends PhabricatorModularTransaction {
const TYPE_COLOR = 'project:color';
const TYPE_LOCKED = 'project:locked'; const TYPE_LOCKED = 'project:locked';
const TYPE_PARENT = 'project:parent'; const TYPE_PARENT = 'project:parent';
const TYPE_MILESTONE = 'project:milestone'; const TYPE_MILESTONE = 'project:milestone';
@ -116,13 +115,6 @@ final class PhabricatorProjectTransaction
'%s created this project.', '%s created this project.',
$this->renderHandleLink($author_phid)); $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: case self::TYPE_LOCKED:
if ($new) { if ($new) {
return pht( return pht(
@ -214,13 +206,6 @@ final class PhabricatorProjectTransaction
$new = $this->getNewValue(); $new = $this->getNewValue();
switch ($this->getTransactionType()) { 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: case self::TYPE_LOCKED:
if ($new) { if ($new) {
return pht( return pht(
@ -245,7 +230,7 @@ final class PhabricatorProjectTransaction
case PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE: case PhabricatorProjectSlugsTransaction::TRANSACTIONTYPE:
case PhabricatorProjectImageTransaction::TRANSACTIONTYPE: case PhabricatorProjectImageTransaction::TRANSACTIONTYPE:
case PhabricatorProjectIconTransaction::TRANSACTIONTYPE: case PhabricatorProjectIconTransaction::TRANSACTIONTYPE:
case self::TYPE_COLOR: case PhabricatorProjectColorTransaction::TRANSACTIONTYPE:
$tags[] = self::MAILTAG_METADATA; $tags[] = self::MAILTAG_METADATA;
break; break;
case PhabricatorTransactions::TYPE_EDGE: case PhabricatorTransactions::TYPE_EDGE:

View file

@ -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)));
}
}