mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-30 02:32:42 +01:00
Migrate Project lock to modular transactions
Summary: See T12673 Test Plan: Unit tests pass. Locked and unlocked a project and saw timeline changes. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D17986
This commit is contained in:
parent
11578bfc90
commit
179d80dd57
5 changed files with 62 additions and 60 deletions
|
@ -3630,6 +3630,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectListController' => 'applications/project/controller/PhabricatorProjectListController.php',
|
||||
'PhabricatorProjectListView' => 'applications/project/view/PhabricatorProjectListView.php',
|
||||
'PhabricatorProjectLockController' => 'applications/project/controller/PhabricatorProjectLockController.php',
|
||||
'PhabricatorProjectLockTransaction' => 'applications/project/xaction/PhabricatorProjectLockTransaction.php',
|
||||
'PhabricatorProjectLogicalAncestorDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalAncestorDatasource.php',
|
||||
'PhabricatorProjectLogicalDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalDatasource.php',
|
||||
'PhabricatorProjectLogicalOrNotDatasource' => 'applications/project/typeahead/PhabricatorProjectLogicalOrNotDatasource.php',
|
||||
|
@ -9048,6 +9049,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectListController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectListView' => 'AphrontView',
|
||||
'PhabricatorProjectLockController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectLockTransaction' => 'PhabricatorProjectTransactionType',
|
||||
'PhabricatorProjectLogicalAncestorDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'PhabricatorProjectLogicalDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
'PhabricatorProjectLogicalOrNotDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
|
||||
|
|
|
@ -49,7 +49,8 @@ final class PhabricatorProjectLockController
|
|||
}
|
||||
|
||||
$xactions[] = id(new PhabricatorProjectTransaction())
|
||||
->setTransactionType(PhabricatorProjectTransaction::TYPE_LOCKED)
|
||||
->setTransactionType(
|
||||
PhabricatorProjectLockTransaction::TRANSACTIONTYPE)
|
||||
->setNewValue($new_value);
|
||||
|
||||
$editor = id(new PhabricatorProjectTransactionEditor())
|
||||
|
|
|
@ -30,7 +30,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
$types[] = PhabricatorTransactions::TYPE_JOIN_POLICY;
|
||||
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_LOCKED;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_PARENT;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_MILESTONE;
|
||||
$types[] = PhabricatorProjectTransaction::TYPE_HASWORKBOARD;
|
||||
|
@ -46,8 +45,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
return (int)$object->getIsMembershipLocked();
|
||||
case PhabricatorProjectTransaction::TYPE_HASWORKBOARD:
|
||||
return (int)$object->getHasWorkboard();
|
||||
case PhabricatorProjectTransaction::TYPE_PARENT:
|
||||
|
@ -69,7 +66,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
case PhabricatorProjectTransaction::TYPE_PARENT:
|
||||
case PhabricatorProjectTransaction::TYPE_MILESTONE:
|
||||
case PhabricatorProjectTransaction::TYPE_DEFAULT_SORT:
|
||||
|
@ -93,9 +89,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
PhabricatorApplicationTransaction $xaction) {
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
$object->setIsMembershipLocked($xaction->getNewValue());
|
||||
return;
|
||||
case PhabricatorProjectTransaction::TYPE_PARENT:
|
||||
$object->setParentProjectPHID($xaction->getNewValue());
|
||||
return;
|
||||
|
@ -129,7 +122,6 @@ final class PhabricatorProjectTransactionEditor
|
|||
$new = $xaction->getNewValue();
|
||||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
case PhabricatorProjectTransaction::TYPE_PARENT:
|
||||
case PhabricatorProjectTransaction::TYPE_MILESTONE:
|
||||
case PhabricatorProjectTransaction::TYPE_HASWORKBOARD:
|
||||
|
@ -320,7 +312,7 @@ final class PhabricatorProjectTransactionEditor
|
|||
$object,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
return;
|
||||
case PhabricatorProjectTransaction::TYPE_LOCKED:
|
||||
case PhabricatorProjectLockTransaction::TRANSACTIONTYPE:
|
||||
PhabricatorPolicyFilter::requireCapability(
|
||||
$this->requireActor(),
|
||||
newv($this->getEditorApplicationClass(), array()),
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
final class PhabricatorProjectTransaction
|
||||
extends PhabricatorModularTransaction {
|
||||
|
||||
const TYPE_LOCKED = 'project:locked';
|
||||
const TYPE_PARENT = 'project:parent';
|
||||
const TYPE_MILESTONE = 'project:milestone';
|
||||
const TYPE_HASWORKBOARD = 'project:hasworkboard';
|
||||
|
@ -87,16 +86,7 @@ final class PhabricatorProjectTransaction
|
|||
}
|
||||
|
||||
public function getIcon() {
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_LOCKED:
|
||||
if ($new) {
|
||||
return 'fa-lock';
|
||||
} else {
|
||||
return 'fa-unlock';
|
||||
}
|
||||
case self::TYPE_MEMBERS:
|
||||
return 'fa-user';
|
||||
}
|
||||
|
@ -115,18 +105,6 @@ final class PhabricatorProjectTransaction
|
|||
'%s created this project.',
|
||||
$this->renderHandleLink($author_phid));
|
||||
|
||||
case self::TYPE_LOCKED:
|
||||
if ($new) {
|
||||
return pht(
|
||||
"%s locked this project's membership.",
|
||||
$author_handle);
|
||||
} else {
|
||||
return pht(
|
||||
"%s unlocked this project's membership.",
|
||||
$author_handle);
|
||||
}
|
||||
break;
|
||||
|
||||
case self::TYPE_MEMBERS:
|
||||
$add = array_diff($new, $old);
|
||||
$rem = array_diff($old, $new);
|
||||
|
@ -196,33 +174,6 @@ final class PhabricatorProjectTransaction
|
|||
return parent::getTitle();
|
||||
}
|
||||
|
||||
public function getTitleForFeed() {
|
||||
$author_phid = $this->getAuthorPHID();
|
||||
$object_phid = $this->getObjectPHID();
|
||||
$author_handle = $this->renderHandleLink($author_phid);
|
||||
$object_handle = $this->renderHandleLink($object_phid);
|
||||
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_LOCKED:
|
||||
if ($new) {
|
||||
return pht(
|
||||
'%s locked membership for %s.',
|
||||
$author_handle,
|
||||
$object_handle);
|
||||
} else {
|
||||
return pht(
|
||||
'%s unlocked membership for %s.',
|
||||
$author_handle,
|
||||
$object_handle);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::getTitleForFeed();
|
||||
}
|
||||
|
||||
public function getMailTags() {
|
||||
$tags = array();
|
||||
switch ($this->getTransactionType()) {
|
||||
|
@ -247,7 +198,7 @@ final class PhabricatorProjectTransaction
|
|||
}
|
||||
break;
|
||||
case PhabricatorProjectStatusTransaction::TRANSACTIONTYPE:
|
||||
case self::TYPE_LOCKED:
|
||||
case PhabricatorProjectLockTransaction::TRANSACTIONTYPE:
|
||||
default:
|
||||
$tags[] = self::MAILTAG_OTHER;
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectLockTransaction
|
||||
extends PhabricatorProjectTransactionType {
|
||||
|
||||
const TRANSACTIONTYPE = 'project:locked';
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return (int)$object->getIsMembershipLocked();
|
||||
}
|
||||
|
||||
public function applyInternalEffects($object, $value) {
|
||||
$object->setIsMembershipLocked($value);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
$new = $this->getNewValue();
|
||||
|
||||
if ($new) {
|
||||
return pht(
|
||||
"%s locked this project's membership.",
|
||||
$this->renderAuthor());
|
||||
} else {
|
||||
return pht(
|
||||
"%s unlocked this project's membership.",
|
||||
$this->renderAuthor());
|
||||
}
|
||||
}
|
||||
|
||||
public function getTitleForFeed() {
|
||||
$new = $this->getNewValue();
|
||||
|
||||
if ($new) {
|
||||
return pht(
|
||||
'%s locked %s membership.',
|
||||
$this->renderAuthor(),
|
||||
$this->renderObject());
|
||||
} else {
|
||||
return pht(
|
||||
'%s unlocked %s membership.',
|
||||
$this->renderAuthor(),
|
||||
$this->renderObject());
|
||||
}
|
||||
}
|
||||
|
||||
public function getIcon() {
|
||||
$new = $this->getNewValue();
|
||||
|
||||
if ($new) {
|
||||
return 'fa-lock';
|
||||
} else {
|
||||
return 'fa-unlock';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue