mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Migrate Pholio to Frankenstein transactions
Summary: Begins the process of migrating Pholio to Modular Transactions by starting with the mock's description and changing the base class of PholioTransaction. Expect several more of these diffs to quickly follow. Also changes the icon for description changes to `fa-pencil`; previously it was check or ban, depending on the open/closed state. Looks like an accidental switch fallthrough. Test Plan: made new mocks, edited their descriptions, observed same UI as previously Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D17864
This commit is contained in:
parent
437a843a8e
commit
d39758ca7c
7 changed files with 64 additions and 52 deletions
|
@ -4357,6 +4357,7 @@ phutil_register_library_map(array(
|
|||
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
|
||||
'PholioDefaultEditCapability' => 'applications/pholio/capability/PholioDefaultEditCapability.php',
|
||||
'PholioDefaultViewCapability' => 'applications/pholio/capability/PholioDefaultViewCapability.php',
|
||||
'PholioDescriptionTransaction' => 'applications/pholio/xaction/PholioDescriptionTransaction.php',
|
||||
'PholioImage' => 'applications/pholio/storage/PholioImage.php',
|
||||
'PholioImagePHIDType' => 'applications/pholio/phid/PholioImagePHIDType.php',
|
||||
'PholioImageQuery' => 'applications/pholio/query/PholioImageQuery.php',
|
||||
|
@ -4393,6 +4394,7 @@ phutil_register_library_map(array(
|
|||
'PholioTransaction' => 'applications/pholio/storage/PholioTransaction.php',
|
||||
'PholioTransactionComment' => 'applications/pholio/storage/PholioTransactionComment.php',
|
||||
'PholioTransactionQuery' => 'applications/pholio/query/PholioTransactionQuery.php',
|
||||
'PholioTransactionType' => 'applications/pholio/xaction/PholioTransactionType.php',
|
||||
'PholioTransactionView' => 'applications/pholio/view/PholioTransactionView.php',
|
||||
'PholioUploadedImageView' => 'applications/pholio/view/PholioUploadedImageView.php',
|
||||
'PhortuneAccount' => 'applications/phortune/storage/PhortuneAccount.php',
|
||||
|
@ -9890,6 +9892,7 @@ phutil_register_library_map(array(
|
|||
'PholioDAO' => 'PhabricatorLiskDAO',
|
||||
'PholioDefaultEditCapability' => 'PhabricatorPolicyCapability',
|
||||
'PholioDefaultViewCapability' => 'PhabricatorPolicyCapability',
|
||||
'PholioDescriptionTransaction' => 'PholioTransactionType',
|
||||
'PholioImage' => array(
|
||||
'PholioDAO',
|
||||
'PhabricatorMarkupInterface',
|
||||
|
@ -9940,9 +9943,10 @@ phutil_register_library_map(array(
|
|||
'PholioRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'PholioReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
|
||||
'PholioSchemaSpec' => 'PhabricatorConfigSchemaSpec',
|
||||
'PholioTransaction' => 'PhabricatorApplicationTransaction',
|
||||
'PholioTransaction' => 'PhabricatorModularTransaction',
|
||||
'PholioTransactionComment' => 'PhabricatorApplicationTransactionComment',
|
||||
'PholioTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
|
||||
'PholioTransactionType' => 'PhabricatorModularTransactionType',
|
||||
'PholioTransactionView' => 'PhabricatorApplicationTransactionView',
|
||||
'PholioUploadedImageView' => 'AphrontView',
|
||||
'PhortuneAccount' => array(
|
||||
|
|
|
@ -66,7 +66,7 @@ final class PholioMockEditController extends PholioController {
|
|||
$xactions = array();
|
||||
|
||||
$type_name = PholioTransaction::TYPE_NAME;
|
||||
$type_desc = PholioTransaction::TYPE_DESCRIPTION;
|
||||
$type_desc = PholioDescriptionTransaction::TRANSACTIONTYPE;
|
||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
$type_cc = PhabricatorTransactions::TYPE_SUBSCRIBERS;
|
||||
|
|
|
@ -30,7 +30,6 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
$types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
|
||||
$types[] = PholioTransaction::TYPE_NAME;
|
||||
$types[] = PholioTransaction::TYPE_DESCRIPTION;
|
||||
$types[] = PholioTransaction::TYPE_STATUS;
|
||||
$types[] = PholioTransaction::TYPE_INLINE;
|
||||
|
||||
|
@ -50,8 +49,6 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
switch ($xaction->getTransactionType()) {
|
||||
case PholioTransaction::TYPE_NAME:
|
||||
return $object->getName();
|
||||
case PholioTransaction::TYPE_DESCRIPTION:
|
||||
return $object->getDescription();
|
||||
case PholioTransaction::TYPE_STATUS:
|
||||
return $object->getStatus();
|
||||
case PholioTransaction::TYPE_IMAGE_FILE:
|
||||
|
@ -96,7 +93,6 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
|
||||
switch ($xaction->getTransactionType()) {
|
||||
case PholioTransaction::TYPE_NAME:
|
||||
case PholioTransaction::TYPE_DESCRIPTION:
|
||||
case PholioTransaction::TYPE_STATUS:
|
||||
case PholioTransaction::TYPE_IMAGE_NAME:
|
||||
case PholioTransaction::TYPE_IMAGE_DESCRIPTION:
|
||||
|
@ -215,9 +211,6 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
$object->setOriginalName($xaction->getNewValue());
|
||||
}
|
||||
break;
|
||||
case PholioTransaction::TYPE_DESCRIPTION:
|
||||
$object->setDescription($xaction->getNewValue());
|
||||
break;
|
||||
case PholioTransaction::TYPE_STATUS:
|
||||
$object->setStatus($xaction->getNewValue());
|
||||
break;
|
||||
|
@ -311,7 +304,6 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
|
|||
$type = $u->getTransactionType();
|
||||
switch ($type) {
|
||||
case PholioTransaction::TYPE_NAME:
|
||||
case PholioTransaction::TYPE_DESCRIPTION:
|
||||
case PholioTransaction::TYPE_STATUS:
|
||||
return $v;
|
||||
case PholioTransaction::TYPE_IMAGE_REPLACE:
|
||||
|
|
|
@ -24,7 +24,7 @@ final class PhabricatorPholioMockTestDataGenerator
|
|||
$changes = array();
|
||||
$changes[PholioTransaction::TYPE_NAME] =
|
||||
$this->generateTitle();
|
||||
$changes[PholioTransaction::TYPE_DESCRIPTION] =
|
||||
$changes[PholioDescriptionTransaction::TRANSACTIONTYPE] =
|
||||
$this->generateDescription();
|
||||
$changes[PhabricatorTransactions::TYPE_VIEW_POLICY] =
|
||||
PhabricatorPolicies::POLICY_PUBLIC;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
|
||||
final class PholioTransaction extends PhabricatorApplicationTransaction {
|
||||
final class PholioTransaction extends PhabricatorModularTransaction {
|
||||
|
||||
// Edits to the high level mock
|
||||
const TYPE_NAME = 'name';
|
||||
const TYPE_DESCRIPTION = 'description';
|
||||
const TYPE_STATUS = 'status';
|
||||
|
||||
// Edits to images within the mock
|
||||
|
@ -26,6 +25,10 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
return 'pholio';
|
||||
}
|
||||
|
||||
public function getBaseTransactionClass() {
|
||||
return 'PholioTransactionType';
|
||||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PholioMockPHIDType::TYPECONST;
|
||||
}
|
||||
|
@ -67,8 +70,6 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
$old = $this->getOldValue();
|
||||
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return ($old === null);
|
||||
case self::TYPE_IMAGE_NAME:
|
||||
case self::TYPE_IMAGE_DESCRIPTION:
|
||||
return ($old === array(null => null));
|
||||
|
@ -89,7 +90,6 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
case self::TYPE_INLINE:
|
||||
return 'fa-comment';
|
||||
case self::TYPE_NAME:
|
||||
case self::TYPE_DESCRIPTION:
|
||||
case self::TYPE_STATUS:
|
||||
if ($new == PholioMock::STATUS_CLOSED) {
|
||||
return 'fa-ban';
|
||||
|
@ -119,7 +119,7 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
$tags[] = self::MAILTAG_STATUS;
|
||||
break;
|
||||
case self::TYPE_NAME:
|
||||
case self::TYPE_DESCRIPTION:
|
||||
case PholioDescriptionTransaction::TRANSACTIONTYPE:
|
||||
case self::TYPE_IMAGE_NAME:
|
||||
case self::TYPE_IMAGE_DESCRIPTION:
|
||||
case self::TYPE_IMAGE_SEQUENCE:
|
||||
|
@ -156,11 +156,6 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
$new);
|
||||
}
|
||||
break;
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return pht(
|
||||
"%s updated the mock's description.",
|
||||
$this->renderHandleLink($author_phid));
|
||||
break;
|
||||
case self::TYPE_STATUS:
|
||||
if ($new == PholioMock::STATUS_CLOSED) {
|
||||
return pht(
|
||||
|
@ -268,12 +263,6 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
$new);
|
||||
}
|
||||
break;
|
||||
case self::TYPE_DESCRIPTION:
|
||||
return pht(
|
||||
'%s updated the description for %s.',
|
||||
$this->renderHandleLink($author_phid),
|
||||
$this->renderHandleLink($object_phid));
|
||||
break;
|
||||
case self::TYPE_STATUS:
|
||||
if ($new == PholioMock::STATUS_CLOSED) {
|
||||
return pht(
|
||||
|
@ -340,30 +329,6 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
|
|||
return $text;
|
||||
}
|
||||
|
||||
public function hasChangeDetails() {
|
||||
switch ($this->getTransactionType()) {
|
||||
case self::TYPE_DESCRIPTION:
|
||||
case self::TYPE_IMAGE_DESCRIPTION:
|
||||
return true;
|
||||
}
|
||||
return parent::hasChangeDetails();
|
||||
}
|
||||
|
||||
public function renderChangeDetails(PhabricatorUser $viewer) {
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
if ($this->getTransactionType() ==
|
||||
self::TYPE_IMAGE_DESCRIPTION) {
|
||||
$old = reset($old);
|
||||
$new = reset($new);
|
||||
}
|
||||
|
||||
return $this->renderTextCorpusChangeDetails(
|
||||
$viewer,
|
||||
$old,
|
||||
$new);
|
||||
}
|
||||
|
||||
public function getColor() {
|
||||
$old = $this->getOldValue();
|
||||
$new = $this->getNewValue();
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
final class PholioDescriptionTransaction
|
||||
extends PholioTransactionType {
|
||||
|
||||
const TRANSACTIONTYPE = 'description';
|
||||
|
||||
public function generateOldValue($object) {
|
||||
return $object->getDescription();
|
||||
}
|
||||
|
||||
public function applyInternalEffects($object, $value) {
|
||||
$object->setDescription($value);
|
||||
}
|
||||
|
||||
public function getTitle() {
|
||||
return pht(
|
||||
"%s updated the mock's description.",
|
||||
$this->renderAuthor());
|
||||
}
|
||||
|
||||
public function getTitleForFeed() {
|
||||
return pht(
|
||||
'%s updated the description for %s.',
|
||||
$this->renderAuthor(),
|
||||
$this->renderObject());
|
||||
}
|
||||
|
||||
public function shouldHide() {
|
||||
$old = $this->getOldValue();
|
||||
return ($old === null);
|
||||
}
|
||||
|
||||
public function hasChangeDetailView() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function newChangeDetailView() {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
return id(new PhabricatorApplicationTransactionTextDiffDetailView())
|
||||
->setViewer($viewer)
|
||||
->setOldText($this->getOldValue())
|
||||
->setNewText($this->getNewValue());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
|
||||
abstract class PholioTransactionType
|
||||
extends PhabricatorModularTransactionType {}
|
Loading…
Reference in a new issue