Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14018753
D8634.id20475.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D8634.id20475.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2516,13 +2516,14 @@
'ReleephPHIDTypeRequest' => 'applications/releeph/phid/ReleephPHIDTypeRequest.php',
'ReleephProductActionController' => 'applications/releeph/controller/project/ReleephProductActionController.php',
'ReleephProductController' => 'applications/releeph/controller/project/ReleephProductController.php',
+ 'ReleephProductEditor' => 'applications/releeph/editor/ReleephProductEditor.php',
+ 'ReleephProductHistoryController' => 'applications/releeph/controller/project/ReleephProductHistoryController.php',
'ReleephProductTransaction' => 'applications/releeph/storage/ReleephProductTransaction.php',
'ReleephProductTransactionQuery' => 'applications/releeph/query/ReleephProductTransactionQuery.php',
'ReleephProject' => 'applications/releeph/storage/ReleephProject.php',
'ReleephProjectController' => 'applications/releeph/controller/ReleephProjectController.php',
'ReleephProjectCreateController' => 'applications/releeph/controller/project/ReleephProjectCreateController.php',
'ReleephProjectEditController' => 'applications/releeph/controller/project/ReleephProjectEditController.php',
- 'ReleephProjectHistoryController' => 'applications/releeph/controller/project/ReleephProjectHistoryController.php',
'ReleephProjectListController' => 'applications/releeph/controller/project/ReleephProjectListController.php',
'ReleephProjectQuery' => 'applications/releeph/query/ReleephProjectQuery.php',
'ReleephProjectSearchEngine' => 'applications/releeph/query/ReleephProjectSearchEngine.php',
@@ -5490,6 +5491,8 @@
'ReleephPHIDTypeRequest' => 'PhabricatorPHIDType',
'ReleephProductActionController' => 'ReleephProductController',
'ReleephProductController' => 'ReleephController',
+ 'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor',
+ 'ReleephProductHistoryController' => 'ReleephProductController',
'ReleephProductTransaction' => 'PhabricatorApplicationTransaction',
'ReleephProductTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'ReleephProject' =>
@@ -5500,7 +5503,6 @@
'ReleephProjectController' => 'ReleephController',
'ReleephProjectCreateController' => 'ReleephProjectController',
'ReleephProjectEditController' => 'ReleephProjectController',
- 'ReleephProjectHistoryController' => 'ReleephProjectController',
'ReleephProjectListController' =>
array(
0 => 'ReleephController',
diff --git a/src/applications/releeph/application/PhabricatorApplicationReleeph.php b/src/applications/releeph/application/PhabricatorApplicationReleeph.php
--- a/src/applications/releeph/application/PhabricatorApplicationReleeph.php
+++ b/src/applications/releeph/application/PhabricatorApplicationReleeph.php
@@ -42,7 +42,7 @@
'edit/' => 'ReleephProjectEditController',
'cutbranch/' => 'ReleephBranchCreateController',
'action/(?P<action>.+)/' => 'ReleephProductActionController',
- 'history/' => 'ReleephProjectHistoryController',
+ 'history/' => 'ReleephProductHistoryController',
),
),
'branch/' => array(
diff --git a/src/applications/releeph/controller/project/ReleephProductActionController.php b/src/applications/releeph/controller/project/ReleephProductActionController.php
--- a/src/applications/releeph/controller/project/ReleephProductActionController.php
+++ b/src/applications/releeph/controller/project/ReleephProductActionController.php
@@ -42,12 +42,27 @@
}
if ($request->isFormPost()) {
+ $type_active = ReleephProductTransaction::TYPE_ACTIVE;
+
+ $xactions = array();
if ($action == 'activate') {
- $product->setIsActive(1)->save();
+ $xactions[] = id(new ReleephProductTransaction())
+ ->setTransactionType($type_active)
+ ->setNewValue(1);
} else {
- $product->deactivate($viewer)->save();
+ $xactions[] = id(new ReleephProductTransaction())
+ ->setTransactionType($type_active)
+ ->setNewValue(0);
}
+ $editor = id(new ReleephProductEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true);
+
+ $editor->applyTransactions($product, $xactions);
+
return id(new AphrontRedirectResponse())->setURI($product_uri);
}
diff --git a/src/applications/releeph/controller/project/ReleephProjectHistoryController.php b/src/applications/releeph/controller/project/ReleephProductHistoryController.php
rename from src/applications/releeph/controller/project/ReleephProjectHistoryController.php
rename to src/applications/releeph/controller/project/ReleephProductHistoryController.php
--- a/src/applications/releeph/controller/project/ReleephProjectHistoryController.php
+++ b/src/applications/releeph/controller/project/ReleephProductHistoryController.php
@@ -1,6 +1,6 @@
<?php
-final class ReleephProjectHistoryController extends ReleephProductController {
+final class ReleephProductHistoryController extends ReleephProductController {
private $id;
@@ -29,7 +29,8 @@
$timeline = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($product->getPHID())
- ->setTransactions($xactions);
+ ->setTransactions($xactions)
+ ->setShouldTerminate(true);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('History'));
diff --git a/src/applications/releeph/editor/ReleephProductEditor.php b/src/applications/releeph/editor/ReleephProductEditor.php
new file mode 100644
--- /dev/null
+++ b/src/applications/releeph/editor/ReleephProductEditor.php
@@ -0,0 +1,53 @@
+<?php
+
+final class ReleephProductEditor
+ extends PhabricatorApplicationTransactionEditor {
+
+ public function getTransactionTypes() {
+ $types = parent::getTransactionTypes();
+
+ $types[] = ReleephProductTransaction::TYPE_ACTIVE;
+
+ return $types;
+ }
+
+ public function getCustomTransactionOldValue(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+
+ switch ($xaction->getTransactionType()) {
+ case ReleephProductTransaction::TYPE_ACTIVE:
+ return (int)$object->getIsActive();
+ }
+ }
+
+ public function getCustomTransactionNewValue(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+
+ switch ($xaction->getTransactionType()) {
+ case ReleephProductTransaction::TYPE_ACTIVE:
+ return (int)$xaction->getNewValue();
+ }
+ }
+
+ public function applyCustomInternalTransaction(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+ $new = $xaction->getNewValue();
+
+ switch ($xaction->getTransactionType()) {
+ case ReleephProductTransaction::TYPE_ACTIVE:
+ $object->setIsActive($new);
+ break;
+ }
+ }
+
+ protected function applyCustomExternalTransaction(
+ PhabricatorLiskDAO $object,
+ PhabricatorApplicationTransaction $xaction) {
+
+ return;
+ }
+
+}
diff --git a/src/applications/releeph/storage/ReleephProductTransaction.php b/src/applications/releeph/storage/ReleephProductTransaction.php
--- a/src/applications/releeph/storage/ReleephProductTransaction.php
+++ b/src/applications/releeph/storage/ReleephProductTransaction.php
@@ -3,6 +3,8 @@
final class ReleephProductTransaction
extends PhabricatorApplicationTransaction {
+ const TYPE_ACTIVE = 'releeph:product:active';
+
public function getApplicationName() {
return 'releeph';
}
@@ -11,4 +13,96 @@
return ReleephPHIDTypeProject::TYPECONST;
}
+ public function getColor() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ACTIVE:
+ if ($new) {
+ return 'green';
+ } else {
+ return 'black';
+ }
+ break;
+ }
+
+ return parent::getColor();
+ }
+
+ public function getIcon() {
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ACTIVE:
+ if ($new) {
+ return 'edit';
+ } else {
+ return 'delete';
+ }
+ break;
+ }
+
+ return parent::getIcon();
+ }
+
+ public function getTitle() {
+ $author_phid = $this->getAuthorPHID();
+
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ACTIVE:
+ if ($new) {
+ return pht(
+ '%s activated this product.',
+ $this->renderHandleLink($author_phid));
+ } else {
+ return pht(
+ '%s deactivated this product.',
+ $this->renderHandleLink($author_phid));
+ }
+ break;
+ }
+
+ return parent::getTitle();
+ }
+
+ public function getTitleForFeed(PhabricatorFeedStory $story) {
+ $author_phid = $this->getAuthorPHID();
+ $object_phid = $this->getObjectPHID();
+
+ $old = $this->getOldValue();
+ $new = $this->getNewValue();
+
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ACTIVE:
+ if ($new) {
+ return pht(
+ '%s activated release product %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
+ } else {
+ return pht(
+ '%s deactivated release product %s.',
+ $this->renderHandleLink($author_phid),
+ $this->renderHandleLink($object_phid));
+ }
+ break;
+ }
+
+ return parent::getTitleForFeed($story);
+ }
+
+ public function getNoEffectDescription() {
+ switch ($this->getTransactionType()) {
+ case self::TYPE_ACTIVE:
+ return pht('The product is already in that state.');
+ }
+
+ return parent::getNoEffectDescription();
+ }
+
}
diff --git a/src/applications/releeph/storage/ReleephProject.php b/src/applications/releeph/storage/ReleephProject.php
--- a/src/applications/releeph/storage/ReleephProject.php
+++ b/src/applications/releeph/storage/ReleephProject.php
@@ -116,21 +116,6 @@
return new ReleephDefaultFieldSelector();
}
- /**
- * Wrapper to setIsActive() that logs who deactivated a project
- */
- public function deactivate(PhabricatorUser $actor) {
- return $this
- ->setIsActive(0)
- ->setDetail('last_deactivated_user', $actor->getPHID())
- ->setDetail('last_deactivated_time', time());
- }
-
- // Hide this from the public
- private function setIsActive($v) {
- return parent::setIsActive($v);
- }
-
private function getBannedNames() {
return array(
'branch', // no one's tried this... yet!
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 6, 7:03 PM (15 h, 56 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6760955
Default Alt Text
D8634.id20475.diff (10 KB)
Attached To
Mode
D8634: Use ApplicationTransactions for Releeph product activity
Attached
Detach File
Event Timeline
Log In to Comment