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

Migrate Project workboard background color to modular transactions

Summary: Removes now-unused method as well. Fixes T12673.

Test Plan: UI fiddling.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: epriestley

Maniphest Tasks: T12673

Differential Revision: https://secure.phabricator.com/D18014
This commit is contained in:
Austin McKinley 2017-05-24 12:46:49 -07:00
parent eb296796aa
commit 88466addee
5 changed files with 31 additions and 77 deletions

View file

@ -3716,6 +3716,7 @@ phutil_register_library_map(array(
'PhabricatorProjectWatchController' => 'applications/project/controller/PhabricatorProjectWatchController.php',
'PhabricatorProjectWatcherListView' => 'applications/project/view/PhabricatorProjectWatcherListView.php',
'PhabricatorProjectWorkboardBackgroundColor' => 'applications/project/constants/PhabricatorProjectWorkboardBackgroundColor.php',
'PhabricatorProjectWorkboardBackgroundTransaction' => 'applications/project/xaction/PhabricatorProjectWorkboardBackgroundTransaction.php',
'PhabricatorProjectWorkboardProfileMenuItem' => 'applications/project/menuitem/PhabricatorProjectWorkboardProfileMenuItem.php',
'PhabricatorProjectWorkboardTransaction' => 'applications/project/xaction/PhabricatorProjectWorkboardTransaction.php',
'PhabricatorProjectsAncestorsSearchEngineAttachment' => 'applications/project/engineextension/PhabricatorProjectsAncestorsSearchEngineAttachment.php',
@ -9166,6 +9167,7 @@ phutil_register_library_map(array(
'PhabricatorProjectWatchController' => 'PhabricatorProjectController',
'PhabricatorProjectWatcherListView' => 'PhabricatorProjectUserListView',
'PhabricatorProjectWorkboardBackgroundColor' => 'Phobject',
'PhabricatorProjectWorkboardBackgroundTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectWorkboardProfileMenuItem' => 'PhabricatorProfileMenuItem',
'PhabricatorProjectWorkboardTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectsAncestorsSearchEngineAttachment' => 'PhabricatorSearchEngineAttachment',

View file

@ -37,7 +37,8 @@ final class PhabricatorProjectBoardBackgroundController
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorProjectTransaction::TYPE_BACKGROUND)
->setTransactionType(
PhabricatorProjectWorkboardBackgroundTransaction::TRANSACTIONTYPE)
->setNewValue($background_key);
id(new PhabricatorProjectTransactionEditor())

View file

@ -30,67 +30,9 @@ final class PhabricatorProjectTransactionEditor
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
$types[] = PhabricatorProjectTransaction::TYPE_BACKGROUND;
return $types;
}
protected function getCustomTransactionOldValue(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_BACKGROUND:
return $object->getWorkboardBackgroundColor();
}
return parent::getCustomTransactionOldValue($object, $xaction);
}
protected function getCustomTransactionNewValue(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_BACKGROUND:
$value = $xaction->getNewValue();
if (!strlen($value)) {
return null;
}
return $value;
}
return parent::getCustomTransactionNewValue($object, $xaction);
}
protected function applyCustomInternalTransaction(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_BACKGROUND:
$object->setWorkboardBackgroundColor($xaction->getNewValue());
return;
}
return parent::applyCustomInternalTransaction($object, $xaction);
}
protected function applyCustomExternalTransaction(
PhabricatorLiskDAO $object,
PhabricatorApplicationTransaction $xaction) {
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_BACKGROUND:
return;
}
return parent::applyCustomExternalTransaction($object, $xaction);
}
protected function validateAllTransactions(
PhabricatorLiskDAO $object,
array $xactions) {

View file

@ -3,8 +3,6 @@
final class PhabricatorProjectTransaction
extends PhabricatorModularTransaction {
const TYPE_BACKGROUND = 'project:background';
// NOTE: This is deprecated, members are just a normal edge now.
const TYPE_MEMBERS = 'project:members';
@ -56,22 +54,12 @@ final class PhabricatorProjectTransaction
return parent::shouldHide();
}
public function shouldHideForFeed() {
switch ($this->getTransactionType()) {
case self::TYPE_BACKGROUND:
return true;
}
return parent::shouldHideForFeed();
}
public function shouldHideForMail(array $xactions) {
switch ($this->getTransactionType()) {
case PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE:
case PhabricatorProjectSortTransaction::TRANSACTIONTYPE:
case PhabricatorProjectFilterTransaction::TRANSACTIONTYPE:
case self::TYPE_BACKGROUND:
case PhabricatorProjectWorkboardBackgroundTransaction::TRANSACTIONTYPE:
return true;
}
@ -136,11 +124,6 @@ final class PhabricatorProjectTransaction
}
}
break;
case self::TYPE_BACKGROUND:
return pht(
'%s changed the background color of the project workboard.',
$author_handle);
}
return parent::getTitle();

View file

@ -0,0 +1,26 @@
<?php
final class PhabricatorProjectWorkboardBackgroundTransaction
extends PhabricatorProjectTransactionType {
const TRANSACTIONTYPE = 'project:background';
public function generateOldValue($object) {
return $object->getWorkboardBackgroundColor();
}
public function applyInternalEffects($object, $value) {
$object->setWorkboardBackgroundColor($value);
}
public function getTitle() {
return pht(
'%s changed the background color of the project workboard.',
$this->renderAuthor());
}
public function shouldHide() {
return true;
}
}