mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Migrate Project sort and filter defaults to modular transactions
Test Plan: Unit tests pass, manually changed the default sort and filter on a workboard and observed expected transactions in the DB. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D18013
This commit is contained in:
parent
8374ec46fd
commit
eb296796aa
6 changed files with 61 additions and 35 deletions
|
@ -3636,6 +3636,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectEditController' => 'applications/project/controller/PhabricatorProjectEditController.php',
|
||||
'PhabricatorProjectEditEngine' => 'applications/project/engine/PhabricatorProjectEditEngine.php',
|
||||
'PhabricatorProjectEditPictureController' => 'applications/project/controller/PhabricatorProjectEditPictureController.php',
|
||||
'PhabricatorProjectFilterTransaction' => 'applications/project/xaction/PhabricatorProjectFilterTransaction.php',
|
||||
'PhabricatorProjectFulltextEngine' => 'applications/project/search/PhabricatorProjectFulltextEngine.php',
|
||||
'PhabricatorProjectHeraldAction' => 'applications/project/herald/PhabricatorProjectHeraldAction.php',
|
||||
'PhabricatorProjectHeraldAdapter' => 'applications/project/herald/PhabricatorProjectHeraldAdapter.php',
|
||||
|
@ -3694,6 +3695,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectSilencedEdgeType' => 'applications/project/edge/PhabricatorProjectSilencedEdgeType.php',
|
||||
'PhabricatorProjectSlug' => 'applications/project/storage/PhabricatorProjectSlug.php',
|
||||
'PhabricatorProjectSlugsTransaction' => 'applications/project/xaction/PhabricatorProjectSlugsTransaction.php',
|
||||
'PhabricatorProjectSortTransaction' => 'applications/project/xaction/PhabricatorProjectSortTransaction.php',
|
||||
'PhabricatorProjectStandardCustomField' => 'applications/project/customfield/PhabricatorProjectStandardCustomField.php',
|
||||
'PhabricatorProjectStatus' => 'applications/project/constants/PhabricatorProjectStatus.php',
|
||||
'PhabricatorProjectStatusTransaction' => 'applications/project/xaction/PhabricatorProjectStatusTransaction.php',
|
||||
|
@ -9082,6 +9084,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectEditController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectEditEngine' => 'PhabricatorEditEngine',
|
||||
'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectFilterTransaction' => 'PhabricatorProjectTransactionType',
|
||||
'PhabricatorProjectFulltextEngine' => 'PhabricatorFulltextEngine',
|
||||
'PhabricatorProjectHeraldAction' => 'HeraldAction',
|
||||
'PhabricatorProjectHeraldAdapter' => 'HeraldAdapter',
|
||||
|
@ -9139,6 +9142,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectSilencedEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorProjectSlug' => 'PhabricatorProjectDAO',
|
||||
'PhabricatorProjectSlugsTransaction' => 'PhabricatorProjectTransactionType',
|
||||
'PhabricatorProjectSortTransaction' => 'PhabricatorProjectTransactionType',
|
||||
'PhabricatorProjectStandardCustomField' => array(
|
||||
'PhabricatorProjectCustomField',
|
||||
'PhabricatorStandardCustomFieldInterface',
|
||||
|
|
|
@ -32,7 +32,7 @@ final class PhabricatorProjectDefaultController
|
|||
$button = pht('Save Default Filter');
|
||||
|
||||
$xaction_value = $request->getStr('filter');
|
||||
$xaction_type = PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER;
|
||||
$xaction_type = PhabricatorProjectFilterTransaction::TRANSACTIONTYPE;
|
||||
break;
|
||||
case 'sort':
|
||||
$title = pht('Set Board Default Order');
|
||||
|
@ -43,7 +43,7 @@ final class PhabricatorProjectDefaultController
|
|||
$button = pht('Save Default Order');
|
||||
|
||||
$xaction_value = $request->getStr('order');
|
||||
$xaction_type = PhabricatorProjectTransaction::TYPE_DEFAULT_SORT;
|
||||
$xaction_type = PhabricatorProjectSortTransaction::TRANSACTIONTYPE;
|
||||
break;
|
||||
default:
|
||||
return new Aphront404Response();
|
||||
|
|
|
@ -30,8 +30,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
|
||||
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_DEFAULT_SORT;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_BACKGROUND;
|
||||
|
||||
return $types;
|
||||
|
@ -42,10 +40,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_SORT:
|
||||
return $object->getDefaultWorkboardSort();
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER:
|
||||
return $object->getDefaultWorkboardFilter();
|
||||
case PhabricatorProjectTransaction::TYPE_BACKGROUND:
|
||||
return $object->getWorkboardBackgroundColor();
|
||||
}
|
||||
|
@ -58,9 +52,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_SORT:
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER:
|
||||
return $xaction->getNewValue();
|
||||
case PhabricatorProjectTransaction::TYPE_BACKGROUND:
|
||||
$value = $xaction->getNewValue();
|
||||
if (!strlen($value)) {
|
||||
|
@ -77,12 +68,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_SORT:
|
||||
$object->setDefaultWorkboardSort($xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER:
|
||||
$object->setDefaultWorkboardFilter($xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorProjectTransaction::TYPE_BACKGROUND:
|
||||
$object->setWorkboardBackgroundColor($xaction->getNewValue());
|
||||
return;
|
||||
|
@ -99,8 +84,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
$new = $xaction->getNewValue();
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_SORT:
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER:
|
||||
case PhabricatorProjectTransaction::TYPE_BACKGROUND:
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
final class PhabricatorProjectTransaction
|
||||
extends PhabricatorModularTransaction {
|
||||
|
||||
const TYPE_DEFAULT_SORT = 'project:sort';
|
||||
const TYPE_DEFAULT_FILTER = 'project:filter';
|
||||
const TYPE_BACKGROUND = 'project:background';
|
||||
|
||||
// NOTE: This is deprecated, members are just a normal edge now.
|
||||
|
@ -60,8 +58,6 @@ final class PhabricatorProjectTransaction
|
|||
|
||||
public function shouldHideForFeed() {
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_DEFAULT_SORT:
|
||||
case self::TYPE_DEFAULT_FILTER:
|
||||
case self::TYPE_BACKGROUND:
|
||||
return true;
|
||||
}
|
||||
|
@ -69,11 +65,12 @@ final class PhabricatorProjectTransaction
|
|||
return parent::shouldHideForFeed();
|
||||
}
|
||||
|
||||
|
||||
public function shouldHideForMail(array $xactions) {
|
||||
switch ($this->getTransactionType()) {
|
||||
case PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE:
|
||||
case self::TYPE_DEFAULT_SORT:
|
||||
case self::TYPE_DEFAULT_FILTER:
|
||||
case PhabricatorProjectSortTransaction::TRANSACTIONTYPE:
|
||||
case PhabricatorProjectFilterTransaction::TRANSACTIONTYPE:
|
||||
case self::TYPE_BACKGROUND:
|
||||
return true;
|
||||
}
|
||||
|
@ -140,16 +137,6 @@ final class PhabricatorProjectTransaction
|
|||
}
|
||||
break;
|
||||
|
||||
case self::TYPE_DEFAULT_SORT:
|
||||
return pht(
|
||||
'%s changed the default sort order for the project workboard.',
|
||||
$author_handle);
|
||||
|
||||
case self::TYPE_DEFAULT_FILTER:
|
||||
return pht(
|
||||
'%s changed the default filter for the project workboard.',
|
||||
$author_handle);
|
||||
|
||||
case self::TYPE_BACKGROUND:
|
||||
return pht(
|
||||
'%s changed the background color of the project workboard.',
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectFilterTransaction
|
||||
extends PhabricatorProjectTransactionType {
|
||||
|
||||
const TRANSACTIONTYPE = 'project:filter';
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return $object->getDefaultWorkboardFilter();
|
||||
}
|
||||
|
||||
public function applyInternalEffects($object, $value) {
|
||||
$object->setDefaultWorkboardFilter($value);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
return pht(
|
||||
'%s changed the default filter for the project workboard.',
|
||||
$this->renderAuthor());
|
||||
}
|
||||
|
||||
public function shouldHide() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectSortTransaction
|
||||
extends PhabricatorProjectTransactionType {
|
||||
|
||||
const TRANSACTIONTYPE = 'project:sort';
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return $object->getDefaultWorkboardSort();
|
||||
}
|
||||
|
||||
public function applyInternalEffects($object, $value) {
|
||||
$object->setDefaultWorkboardSort($value);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
return pht(
|
||||
'%s changed the default sort order for the project workboard.',
|
||||
$this->renderAuthor());
|
||||
}
|
||||
|
||||
public function shouldHide() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue