mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Transactions - deploy buildTransactionTimeline against a few more applications
Summary: Ref T4712. Thus far, it seems that most "non-standard" things can be done pretty easily in the controller. Aside from deploying, this diff had to fix a few bugs / missing implementations of stuff. (Notably, PhabricatorAuthProviderConfig, HeraldRule, PhabricatorSlowvotePoll, and AlmanacNetwork needed to implement PhabricatorApplicationTransactionInterface, PhabricatorAuthAuthProviderPHIDType had to be added, and a rendering bug in transactions of type PhabricatorOAuth2AuthProvider had to be fixed.) Test Plan: Almanac - looked at binding, device, network, and service view controllers and verified timeline displayed properly. Herald - looked at a rule and verified timeline. Slowvote - looked at a vote and verified timeline. Auth - looked at an auth provider (Facebook) and verified proper display of transactions within timeline. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4712 Differential Revision: https://secure.phabricator.com/D10921
This commit is contained in:
parent
f88b8a4520
commit
69cc5df645
17 changed files with 152 additions and 122 deletions
|
@ -1288,6 +1288,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthAccountView' => 'applications/auth/view/PhabricatorAuthAccountView.php',
|
||||
'PhabricatorAuthApplication' => 'applications/auth/application/PhabricatorAuthApplication.php',
|
||||
'PhabricatorAuthAuthFactorPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthFactorPHIDType.php',
|
||||
'PhabricatorAuthAuthProviderPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthProviderPHIDType.php',
|
||||
'PhabricatorAuthConfirmLinkController' => 'applications/auth/controller/PhabricatorAuthConfirmLinkController.php',
|
||||
'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php',
|
||||
'PhabricatorAuthDAO' => 'applications/auth/storage/PhabricatorAuthDAO.php',
|
||||
|
@ -3054,6 +3055,7 @@ phutil_register_library_map(array(
|
|||
'AlmanacNamesTestCase' => 'PhabricatorTestCase',
|
||||
'AlmanacNetwork' => array(
|
||||
'AlmanacDAO',
|
||||
'PhabricatorApplicationTransactionInterface',
|
||||
'PhabricatorPolicyInterface',
|
||||
),
|
||||
'AlmanacNetworkController' => 'AlmanacController',
|
||||
|
@ -3927,6 +3929,7 @@ phutil_register_library_map(array(
|
|||
'HeraldRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
'HeraldRule' => array(
|
||||
'HeraldDAO',
|
||||
'PhabricatorApplicationTransactionInterface',
|
||||
'PhabricatorFlaggableInterface',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorDestructibleInterface',
|
||||
|
@ -4372,6 +4375,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthAccountView' => 'AphrontView',
|
||||
'PhabricatorAuthApplication' => 'PhabricatorApplication',
|
||||
'PhabricatorAuthAuthFactorPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorAuthAuthProviderPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorAuthConfirmLinkController' => 'PhabricatorAuthController',
|
||||
'PhabricatorAuthController' => 'PhabricatorController',
|
||||
'PhabricatorAuthDAO' => 'PhabricatorLiskDAO',
|
||||
|
@ -4400,6 +4404,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorAuthOneTimeLoginController' => 'PhabricatorAuthController',
|
||||
'PhabricatorAuthProviderConfig' => array(
|
||||
'PhabricatorAuthDAO',
|
||||
'PhabricatorApplicationTransactionInterface',
|
||||
'PhabricatorPolicyInterface',
|
||||
),
|
||||
'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthController',
|
||||
|
@ -5516,6 +5521,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSlowvoteOption' => 'PhabricatorSlowvoteDAO',
|
||||
'PhabricatorSlowvotePoll' => array(
|
||||
'PhabricatorSlowvoteDAO',
|
||||
'PhabricatorApplicationTransactionInterface',
|
||||
'PhabricatorPolicyInterface',
|
||||
'PhabricatorSubscribableInterface',
|
||||
'PhabricatorFlaggableInterface',
|
||||
|
|
|
@ -42,23 +42,17 @@ final class AlmanacBindingViewController
|
|||
$crumbs->addTextCrumb($service->getName(), $service_uri);
|
||||
$crumbs->addTextCrumb($title);
|
||||
|
||||
$xactions = id(new AlmanacBindingTransactionQuery())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($binding->getPHID()))
|
||||
->execute();
|
||||
|
||||
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($binding->getPHID())
|
||||
->setTransactions($xactions)
|
||||
->setShouldTerminate(true);
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$binding,
|
||||
new AlmanacBindingTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$box,
|
||||
$this->buildAlmanacPropertiesTable($binding),
|
||||
$xaction_view,
|
||||
$timeline,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
|
|
|
@ -40,16 +40,10 @@ final class AlmanacDeviceViewController
|
|||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($device->getName());
|
||||
|
||||
$xactions = id(new AlmanacDeviceTransactionQuery())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($device->getPHID()))
|
||||
->execute();
|
||||
|
||||
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($device->getPHID())
|
||||
->setTransactions($xactions)
|
||||
->setShouldTerminate(true);
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$device,
|
||||
new AlmanacDeviceTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
|
@ -58,7 +52,7 @@ final class AlmanacDeviceViewController
|
|||
$interfaces,
|
||||
$this->buildAlmanacPropertiesTable($device),
|
||||
$this->buildSSHKeysTable($device),
|
||||
$xaction_view,
|
||||
$timeline,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
|
|
|
@ -38,22 +38,16 @@ final class AlmanacNetworkViewController
|
|||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($network->getName());
|
||||
|
||||
$xactions = id(new AlmanacNetworkTransactionQuery())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($network->getPHID()))
|
||||
->execute();
|
||||
|
||||
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($network->getPHID())
|
||||
->setTransactions($xactions)
|
||||
->setShouldTerminate(true);
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$network,
|
||||
new AlmanacNetworkTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$crumbs,
|
||||
$box,
|
||||
$xaction_view,
|
||||
$timeline,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
|
|
|
@ -40,16 +40,10 @@ final class AlmanacServiceViewController
|
|||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($service->getName());
|
||||
|
||||
$xactions = id(new AlmanacServiceTransactionQuery())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($service->getPHID()))
|
||||
->execute();
|
||||
|
||||
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($service->getPHID())
|
||||
->setTransactions($xactions)
|
||||
->setShouldTerminate(true);
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$service,
|
||||
new AlmanacServiceTransactionQuery());
|
||||
$timeline->setShouldTerminate(true);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
|
@ -57,7 +51,7 @@ final class AlmanacServiceViewController
|
|||
$box,
|
||||
$bindings,
|
||||
$this->buildAlmanacPropertiesTable($service),
|
||||
$xaction_view,
|
||||
$timeline,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
final class AlmanacNetwork
|
||||
extends AlmanacDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
implements
|
||||
PhabricatorApplicationTransactionInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
|
||||
protected $name;
|
||||
protected $mailKey;
|
||||
|
@ -42,6 +44,22 @@ final class AlmanacNetwork
|
|||
}
|
||||
|
||||
|
||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||
|
||||
|
||||
public function getApplicationTransactionEditor() {
|
||||
return new AlmanacNetworkEditor();
|
||||
}
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionTemplate() {
|
||||
return new AlmanacNetworkTransaction();
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
||||
|
|
|
@ -144,7 +144,6 @@ final class PhabricatorAuthEditController
|
|||
->setContinueOnNoEffect(true)
|
||||
->applyTransactions($config, $xactions);
|
||||
|
||||
|
||||
if ($provider->hasSetupStep() && $is_new) {
|
||||
$id = $config->getID();
|
||||
$next_uri = $this->getApplicationURI('config/edit/'.$id.'/');
|
||||
|
@ -304,21 +303,15 @@ final class PhabricatorAuthEditController
|
|||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb($crumb);
|
||||
|
||||
$xaction_view = null;
|
||||
$timeline = null;
|
||||
if (!$is_new) {
|
||||
$xactions = id(new PhabricatorAuthProviderConfigTransactionQuery())
|
||||
->withObjectPHIDs(array($config->getPHID()))
|
||||
->setViewer($viewer)
|
||||
->execute();
|
||||
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$config,
|
||||
new PhabricatorAuthProviderConfigTransactionQuery());
|
||||
$xactions = $timeline->getTransactions();
|
||||
foreach ($xactions as $xaction) {
|
||||
$xaction->setProvider($provider);
|
||||
}
|
||||
|
||||
$xaction_view = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($config->getPHID())
|
||||
->setTransactions($xactions);
|
||||
}
|
||||
|
||||
$form_box = id(new PHUIObjectBoxView())
|
||||
|
@ -331,7 +324,7 @@ final class PhabricatorAuthEditController
|
|||
$crumbs,
|
||||
$form_box,
|
||||
$footer,
|
||||
$xaction_view,
|
||||
$timeline,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorAuthAuthProviderPHIDType extends PhabricatorPHIDType {
|
||||
|
||||
const TYPECONST = 'AUTH';
|
||||
|
||||
public function getTypeName() {
|
||||
return pht('Auth Provider');
|
||||
}
|
||||
|
||||
public function newObject() {
|
||||
return new PhabricatorAuthProviderConfig();
|
||||
}
|
||||
|
||||
protected function buildQueryForObjects(
|
||||
PhabricatorObjectQuery $query,
|
||||
array $phids) {
|
||||
|
||||
return id(new PhabricatorAuthProviderConfigQuery())
|
||||
->withPHIDs($phids);
|
||||
}
|
||||
|
||||
public function loadHandles(
|
||||
PhabricatorHandleQuery $query,
|
||||
array $handles,
|
||||
array $objects) {
|
||||
|
||||
foreach ($handles as $phid => $handle) {
|
||||
$provider = $objects[$phid];
|
||||
|
||||
$handle->setName($provider->getProviderName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -159,7 +159,7 @@ abstract class PhabricatorOAuth2AuthProvider
|
|||
'%s set the OAuth application secret for this provider.',
|
||||
$xaction->renderHandleLink($author_phid));
|
||||
}
|
||||
case self::PROPERTY_APP_NOTE:
|
||||
case self::PROPERTY_NOTE:
|
||||
if (strlen($old)) {
|
||||
return pht(
|
||||
'%s updated the OAuth application notes for this provider.',
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
final class PhabricatorAuthProviderConfig
|
||||
extends PhabricatorAuthDAO
|
||||
implements
|
||||
PhabricatorApplicationTransactionInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
|
||||
protected $providerClass;
|
||||
protected $providerType;
|
||||
|
@ -20,7 +23,7 @@ final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO
|
|||
|
||||
public function generatePHID() {
|
||||
return PhabricatorPHID::generateNewPHID(
|
||||
PhabricatorPHIDConstants::PHID_TYPE_AUTH);
|
||||
PhabricatorAuthAuthProviderPHIDType::TYPECONST);
|
||||
}
|
||||
|
||||
public function getConfiguration() {
|
||||
|
@ -79,6 +82,22 @@ final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO
|
|||
}
|
||||
|
||||
|
||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||
|
||||
|
||||
public function getApplicationTransactionEditor() {
|
||||
return new PhabricatorAuthProviderConfigEditor();
|
||||
}
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionTemplate() {
|
||||
return new PhabricatorAuthProviderConfigTransaction();
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ final class PhabricatorAuthProviderConfigTransaction
|
|||
}
|
||||
|
||||
public function getApplicationTransactionType() {
|
||||
return PhabricatorPHIDConstants::PHID_TYPE_AUTH;
|
||||
return PhabricatorAuthAuthProviderPHIDType::TYPECONST;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionCommentObject() {
|
||||
|
|
|
@ -51,7 +51,9 @@ final class HeraldRuleViewController extends HeraldController {
|
|||
->setHeader($header)
|
||||
->addPropertyList($properties);
|
||||
|
||||
$timeline = $this->buildTimeline($rule);
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$rule,
|
||||
new HeraldTransactionQuery());
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
|
@ -158,31 +160,4 @@ final class HeraldRuleViewController extends HeraldController {
|
|||
return $view;
|
||||
}
|
||||
|
||||
private function buildTimeline(HeraldRule $rule) {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$xactions = id(new HeraldTransactionQuery())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($rule->getPHID()))
|
||||
->needComments(true)
|
||||
->execute();
|
||||
|
||||
$engine = id(new PhabricatorMarkupEngine())
|
||||
->setViewer($viewer);
|
||||
foreach ($xactions as $xaction) {
|
||||
if ($xaction->getComment()) {
|
||||
$engine->addObject(
|
||||
$xaction->getComment(),
|
||||
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
||||
}
|
||||
}
|
||||
$engine->process();
|
||||
|
||||
return id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($rule->getPHID())
|
||||
->setTransactions($xactions)
|
||||
->setMarkupEngine($engine);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
final class HeraldRule extends HeraldDAO
|
||||
implements
|
||||
PhabricatorApplicationTransactionInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorDestructibleInterface {
|
||||
|
@ -264,6 +265,19 @@ final class HeraldRule extends HeraldDAO
|
|||
return sprintf('~%d%010d', $type_order, $this->getID());
|
||||
}
|
||||
|
||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||
|
||||
public function getApplicationTransactionEditor() {
|
||||
return new HeraldRuleEditor();
|
||||
}
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionTemplate() {
|
||||
return new HeraldRuleTransaction();
|
||||
}
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ final class PhabricatorPHIDConstants {
|
|||
|
||||
const PHID_TYPE_XCMT = 'XCMT';
|
||||
|
||||
const PHID_TYPE_AUTH = 'AUTH';
|
||||
const PHID_TYPE_XOBJ = 'XOBJ';
|
||||
|
||||
const PHID_TYPE_VOID = 'VOID';
|
||||
|
|
|
@ -54,7 +54,9 @@ final class PhabricatorSlowvotePollController
|
|||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs->addTextCrumb('V'.$poll->getID());
|
||||
|
||||
$xactions = $this->buildTransactions($poll);
|
||||
$timeline = $this->buildTransactionTimeline(
|
||||
$poll,
|
||||
new PhabricatorSlowvoteTransactionQuery());
|
||||
$add_comment = $this->buildCommentForm($poll);
|
||||
|
||||
$object_box = id(new PHUIObjectBoxView())
|
||||
|
@ -71,7 +73,7 @@ final class PhabricatorSlowvotePollController
|
|||
'class' => 'mlt mml mmr',
|
||||
),
|
||||
$poll_view),
|
||||
$xactions,
|
||||
$timeline,
|
||||
$add_comment,
|
||||
),
|
||||
array(
|
||||
|
@ -140,34 +142,6 @@ final class PhabricatorSlowvotePollController
|
|||
return $view;
|
||||
}
|
||||
|
||||
private function buildTransactions(PhabricatorSlowvotePoll $poll) {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
$xactions = id(new PhabricatorSlowvoteTransactionQuery())
|
||||
->setViewer($viewer)
|
||||
->withObjectPHIDs(array($poll->getPHID()))
|
||||
->execute();
|
||||
|
||||
$engine = id(new PhabricatorMarkupEngine())
|
||||
->setViewer($viewer);
|
||||
foreach ($xactions as $xaction) {
|
||||
if ($xaction->getComment()) {
|
||||
$engine->addObject(
|
||||
$xaction->getComment(),
|
||||
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
||||
}
|
||||
}
|
||||
$engine->process();
|
||||
|
||||
$timeline = id(new PhabricatorApplicationTransactionView())
|
||||
->setUser($viewer)
|
||||
->setObjectPHID($poll->getPHID())
|
||||
->setTransactions($xactions)
|
||||
->setMarkupEngine($engine);
|
||||
|
||||
return $timeline;
|
||||
}
|
||||
|
||||
private function buildCommentForm(PhabricatorSlowvotePoll $poll) {
|
||||
$viewer = $this->getRequest()->getUser();
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
||||
implements
|
||||
PhabricatorApplicationTransactionInterface,
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
|
@ -103,6 +104,22 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
|||
}
|
||||
|
||||
|
||||
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
|
||||
|
||||
|
||||
public function getApplicationTransactionEditor() {
|
||||
return new PhabricatorSlowvoteEditor();
|
||||
}
|
||||
|
||||
public function getApplicationTransactionObject() {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getApplicationTransactionTemplate() {
|
||||
return new PhabricatorSlowvoteTransaction();
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
||||
|
|
|
@ -67,6 +67,10 @@ class PhabricatorApplicationTransactionView extends AphrontView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getTransactions() {
|
||||
return $this->transactions;
|
||||
}
|
||||
|
||||
public function setShouldTerminate($term) {
|
||||
$this->shouldTerminate = $term;
|
||||
return $this;
|
||||
|
|
Loading…
Reference in a new issue