1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +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:
Austin McKinley 2017-05-24 12:07:04 -07:00
parent 8374ec46fd
commit eb296796aa
6 changed files with 61 additions and 35 deletions

View file

@ -3636,6 +3636,7 @@ phutil_register_library_map(array(
'PhabricatorProjectEditController' => 'applications/project/controller/PhabricatorProjectEditController.php', 'PhabricatorProjectEditController' => 'applications/project/controller/PhabricatorProjectEditController.php',
'PhabricatorProjectEditEngine' => 'applications/project/engine/PhabricatorProjectEditEngine.php', 'PhabricatorProjectEditEngine' => 'applications/project/engine/PhabricatorProjectEditEngine.php',
'PhabricatorProjectEditPictureController' => 'applications/project/controller/PhabricatorProjectEditPictureController.php', 'PhabricatorProjectEditPictureController' => 'applications/project/controller/PhabricatorProjectEditPictureController.php',
'PhabricatorProjectFilterTransaction' => 'applications/project/xaction/PhabricatorProjectFilterTransaction.php',
'PhabricatorProjectFulltextEngine' => 'applications/project/search/PhabricatorProjectFulltextEngine.php', 'PhabricatorProjectFulltextEngine' => 'applications/project/search/PhabricatorProjectFulltextEngine.php',
'PhabricatorProjectHeraldAction' => 'applications/project/herald/PhabricatorProjectHeraldAction.php', 'PhabricatorProjectHeraldAction' => 'applications/project/herald/PhabricatorProjectHeraldAction.php',
'PhabricatorProjectHeraldAdapter' => 'applications/project/herald/PhabricatorProjectHeraldAdapter.php', 'PhabricatorProjectHeraldAdapter' => 'applications/project/herald/PhabricatorProjectHeraldAdapter.php',
@ -3694,6 +3695,7 @@ phutil_register_library_map(array(
'PhabricatorProjectSilencedEdgeType' => 'applications/project/edge/PhabricatorProjectSilencedEdgeType.php', 'PhabricatorProjectSilencedEdgeType' => 'applications/project/edge/PhabricatorProjectSilencedEdgeType.php',
'PhabricatorProjectSlug' => 'applications/project/storage/PhabricatorProjectSlug.php', 'PhabricatorProjectSlug' => 'applications/project/storage/PhabricatorProjectSlug.php',
'PhabricatorProjectSlugsTransaction' => 'applications/project/xaction/PhabricatorProjectSlugsTransaction.php', 'PhabricatorProjectSlugsTransaction' => 'applications/project/xaction/PhabricatorProjectSlugsTransaction.php',
'PhabricatorProjectSortTransaction' => 'applications/project/xaction/PhabricatorProjectSortTransaction.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', 'PhabricatorProjectStatusTransaction' => 'applications/project/xaction/PhabricatorProjectStatusTransaction.php',
@ -9082,6 +9084,7 @@ phutil_register_library_map(array(
'PhabricatorProjectEditController' => 'PhabricatorProjectController', 'PhabricatorProjectEditController' => 'PhabricatorProjectController',
'PhabricatorProjectEditEngine' => 'PhabricatorEditEngine', 'PhabricatorProjectEditEngine' => 'PhabricatorEditEngine',
'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController', 'PhabricatorProjectEditPictureController' => 'PhabricatorProjectController',
'PhabricatorProjectFilterTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectFulltextEngine' => 'PhabricatorFulltextEngine', 'PhabricatorProjectFulltextEngine' => 'PhabricatorFulltextEngine',
'PhabricatorProjectHeraldAction' => 'HeraldAction', 'PhabricatorProjectHeraldAction' => 'HeraldAction',
'PhabricatorProjectHeraldAdapter' => 'HeraldAdapter', 'PhabricatorProjectHeraldAdapter' => 'HeraldAdapter',
@ -9139,6 +9142,7 @@ phutil_register_library_map(array(
'PhabricatorProjectSilencedEdgeType' => 'PhabricatorEdgeType', 'PhabricatorProjectSilencedEdgeType' => 'PhabricatorEdgeType',
'PhabricatorProjectSlug' => 'PhabricatorProjectDAO', 'PhabricatorProjectSlug' => 'PhabricatorProjectDAO',
'PhabricatorProjectSlugsTransaction' => 'PhabricatorProjectTransactionType', 'PhabricatorProjectSlugsTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectSortTransaction' => 'PhabricatorProjectTransactionType',
'PhabricatorProjectStandardCustomField' => array( 'PhabricatorProjectStandardCustomField' => array(
'PhabricatorProjectCustomField', 'PhabricatorProjectCustomField',
'PhabricatorStandardCustomFieldInterface', 'PhabricatorStandardCustomFieldInterface',

View file

@ -32,7 +32,7 @@ final class PhabricatorProjectDefaultController
$button = pht('Save Default Filter'); $button = pht('Save Default Filter');
$xaction_value = $request->getStr('filter'); $xaction_value = $request->getStr('filter');
$xaction_type = PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER; $xaction_type = PhabricatorProjectFilterTransaction::TRANSACTIONTYPE;
break; break;
case 'sort': case 'sort':
$title = pht('Set Board Default Order'); $title = pht('Set Board Default Order');
@ -43,7 +43,7 @@ final class PhabricatorProjectDefaultController
$button = pht('Save Default Order'); $button = pht('Save Default Order');
$xaction_value = $request->getStr('order'); $xaction_value = $request->getStr('order');
$xaction_type = PhabricatorProjectTransaction::TYPE_DEFAULT_SORT; $xaction_type = PhabricatorProjectSortTransaction::TRANSACTIONTYPE;
break; break;
default: default:
return new Aphront404Response(); return new Aphront404Response();

View file

@ -30,8 +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_DEFAULT_SORT;
$types[] = PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER;
$types[] = PhabricatorProjectTransaction::TYPE_BACKGROUND; $types[] = PhabricatorProjectTransaction::TYPE_BACKGROUND;
return $types; return $types;
@ -42,10 +40,6 @@ final class PhabricatorProjectTransactionEditor
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_DEFAULT_SORT:
return $object->getDefaultWorkboardSort();
case PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER:
return $object->getDefaultWorkboardFilter();
case PhabricatorProjectTransaction::TYPE_BACKGROUND: case PhabricatorProjectTransaction::TYPE_BACKGROUND:
return $object->getWorkboardBackgroundColor(); return $object->getWorkboardBackgroundColor();
} }
@ -58,9 +52,6 @@ final class PhabricatorProjectTransactionEditor
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_DEFAULT_SORT:
case PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER:
return $xaction->getNewValue();
case PhabricatorProjectTransaction::TYPE_BACKGROUND: case PhabricatorProjectTransaction::TYPE_BACKGROUND:
$value = $xaction->getNewValue(); $value = $xaction->getNewValue();
if (!strlen($value)) { if (!strlen($value)) {
@ -77,12 +68,6 @@ final class PhabricatorProjectTransactionEditor
PhabricatorApplicationTransaction $xaction) { PhabricatorApplicationTransaction $xaction) {
switch ($xaction->getTransactionType()) { 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: case PhabricatorProjectTransaction::TYPE_BACKGROUND:
$object->setWorkboardBackgroundColor($xaction->getNewValue()); $object->setWorkboardBackgroundColor($xaction->getNewValue());
return; return;
@ -99,8 +84,6 @@ final class PhabricatorProjectTransactionEditor
$new = $xaction->getNewValue(); $new = $xaction->getNewValue();
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PhabricatorProjectTransaction::TYPE_DEFAULT_SORT:
case PhabricatorProjectTransaction::TYPE_DEFAULT_FILTER:
case PhabricatorProjectTransaction::TYPE_BACKGROUND: case PhabricatorProjectTransaction::TYPE_BACKGROUND:
return; return;
} }

View file

@ -3,8 +3,6 @@
final class PhabricatorProjectTransaction final class PhabricatorProjectTransaction
extends PhabricatorModularTransaction { extends PhabricatorModularTransaction {
const TYPE_DEFAULT_SORT = 'project:sort';
const TYPE_DEFAULT_FILTER = 'project:filter';
const TYPE_BACKGROUND = 'project:background'; const TYPE_BACKGROUND = 'project:background';
// NOTE: This is deprecated, members are just a normal edge now. // NOTE: This is deprecated, members are just a normal edge now.
@ -60,8 +58,6 @@ final class PhabricatorProjectTransaction
public function shouldHideForFeed() { public function shouldHideForFeed() {
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {
case self::TYPE_DEFAULT_SORT:
case self::TYPE_DEFAULT_FILTER:
case self::TYPE_BACKGROUND: case self::TYPE_BACKGROUND:
return true; return true;
} }
@ -69,11 +65,12 @@ final class PhabricatorProjectTransaction
return parent::shouldHideForFeed(); return parent::shouldHideForFeed();
} }
public function shouldHideForMail(array $xactions) { public function shouldHideForMail(array $xactions) {
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {
case PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE: case PhabricatorProjectWorkboardTransaction::TRANSACTIONTYPE:
case self::TYPE_DEFAULT_SORT: case PhabricatorProjectSortTransaction::TRANSACTIONTYPE:
case self::TYPE_DEFAULT_FILTER: case PhabricatorProjectFilterTransaction::TRANSACTIONTYPE:
case self::TYPE_BACKGROUND: case self::TYPE_BACKGROUND:
return true; return true;
} }
@ -140,16 +137,6 @@ final class PhabricatorProjectTransaction
} }
break; 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: case self::TYPE_BACKGROUND:
return pht( return pht(
'%s changed the background color of the project workboard.', '%s changed the background color of the project workboard.',

View file

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

View file

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