1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 09:18:48 +02: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:
Bob Trahan 2014-12-02 14:33:59 -08:00
parent f88b8a4520
commit 69cc5df645
17 changed files with 152 additions and 122 deletions

View file

@ -1288,6 +1288,7 @@ phutil_register_library_map(array(
'PhabricatorAuthAccountView' => 'applications/auth/view/PhabricatorAuthAccountView.php', 'PhabricatorAuthAccountView' => 'applications/auth/view/PhabricatorAuthAccountView.php',
'PhabricatorAuthApplication' => 'applications/auth/application/PhabricatorAuthApplication.php', 'PhabricatorAuthApplication' => 'applications/auth/application/PhabricatorAuthApplication.php',
'PhabricatorAuthAuthFactorPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthFactorPHIDType.php', 'PhabricatorAuthAuthFactorPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthFactorPHIDType.php',
'PhabricatorAuthAuthProviderPHIDType' => 'applications/auth/phid/PhabricatorAuthAuthProviderPHIDType.php',
'PhabricatorAuthConfirmLinkController' => 'applications/auth/controller/PhabricatorAuthConfirmLinkController.php', 'PhabricatorAuthConfirmLinkController' => 'applications/auth/controller/PhabricatorAuthConfirmLinkController.php',
'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php', 'PhabricatorAuthController' => 'applications/auth/controller/PhabricatorAuthController.php',
'PhabricatorAuthDAO' => 'applications/auth/storage/PhabricatorAuthDAO.php', 'PhabricatorAuthDAO' => 'applications/auth/storage/PhabricatorAuthDAO.php',
@ -3054,6 +3055,7 @@ phutil_register_library_map(array(
'AlmanacNamesTestCase' => 'PhabricatorTestCase', 'AlmanacNamesTestCase' => 'PhabricatorTestCase',
'AlmanacNetwork' => array( 'AlmanacNetwork' => array(
'AlmanacDAO', 'AlmanacDAO',
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
), ),
'AlmanacNetworkController' => 'AlmanacController', 'AlmanacNetworkController' => 'AlmanacController',
@ -3927,6 +3929,7 @@ phutil_register_library_map(array(
'HeraldRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'HeraldRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'HeraldRule' => array( 'HeraldRule' => array(
'HeraldDAO', 'HeraldDAO',
'PhabricatorApplicationTransactionInterface',
'PhabricatorFlaggableInterface', 'PhabricatorFlaggableInterface',
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
@ -4372,6 +4375,7 @@ phutil_register_library_map(array(
'PhabricatorAuthAccountView' => 'AphrontView', 'PhabricatorAuthAccountView' => 'AphrontView',
'PhabricatorAuthApplication' => 'PhabricatorApplication', 'PhabricatorAuthApplication' => 'PhabricatorApplication',
'PhabricatorAuthAuthFactorPHIDType' => 'PhabricatorPHIDType', 'PhabricatorAuthAuthFactorPHIDType' => 'PhabricatorPHIDType',
'PhabricatorAuthAuthProviderPHIDType' => 'PhabricatorPHIDType',
'PhabricatorAuthConfirmLinkController' => 'PhabricatorAuthController', 'PhabricatorAuthConfirmLinkController' => 'PhabricatorAuthController',
'PhabricatorAuthController' => 'PhabricatorController', 'PhabricatorAuthController' => 'PhabricatorController',
'PhabricatorAuthDAO' => 'PhabricatorLiskDAO', 'PhabricatorAuthDAO' => 'PhabricatorLiskDAO',
@ -4400,6 +4404,7 @@ phutil_register_library_map(array(
'PhabricatorAuthOneTimeLoginController' => 'PhabricatorAuthController', 'PhabricatorAuthOneTimeLoginController' => 'PhabricatorAuthController',
'PhabricatorAuthProviderConfig' => array( 'PhabricatorAuthProviderConfig' => array(
'PhabricatorAuthDAO', 'PhabricatorAuthDAO',
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
), ),
'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthController', 'PhabricatorAuthProviderConfigController' => 'PhabricatorAuthController',
@ -5516,6 +5521,7 @@ phutil_register_library_map(array(
'PhabricatorSlowvoteOption' => 'PhabricatorSlowvoteDAO', 'PhabricatorSlowvoteOption' => 'PhabricatorSlowvoteDAO',
'PhabricatorSlowvotePoll' => array( 'PhabricatorSlowvotePoll' => array(
'PhabricatorSlowvoteDAO', 'PhabricatorSlowvoteDAO',
'PhabricatorApplicationTransactionInterface',
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
'PhabricatorSubscribableInterface', 'PhabricatorSubscribableInterface',
'PhabricatorFlaggableInterface', 'PhabricatorFlaggableInterface',

View file

@ -42,23 +42,17 @@ final class AlmanacBindingViewController
$crumbs->addTextCrumb($service->getName(), $service_uri); $crumbs->addTextCrumb($service->getName(), $service_uri);
$crumbs->addTextCrumb($title); $crumbs->addTextCrumb($title);
$xactions = id(new AlmanacBindingTransactionQuery()) $timeline = $this->buildTransactionTimeline(
->setViewer($viewer) $binding,
->withObjectPHIDs(array($binding->getPHID())) new AlmanacBindingTransactionQuery());
->execute(); $timeline->setShouldTerminate(true);
$xaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($binding->getPHID())
->setTransactions($xactions)
->setShouldTerminate(true);
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(
$crumbs, $crumbs,
$box, $box,
$this->buildAlmanacPropertiesTable($binding), $this->buildAlmanacPropertiesTable($binding),
$xaction_view, $timeline,
), ),
array( array(
'title' => $title, 'title' => $title,

View file

@ -40,16 +40,10 @@ final class AlmanacDeviceViewController
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($device->getName()); $crumbs->addTextCrumb($device->getName());
$xactions = id(new AlmanacDeviceTransactionQuery()) $timeline = $this->buildTransactionTimeline(
->setViewer($viewer) $device,
->withObjectPHIDs(array($device->getPHID())) new AlmanacDeviceTransactionQuery());
->execute(); $timeline->setShouldTerminate(true);
$xaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($device->getPHID())
->setTransactions($xactions)
->setShouldTerminate(true);
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(
@ -58,7 +52,7 @@ final class AlmanacDeviceViewController
$interfaces, $interfaces,
$this->buildAlmanacPropertiesTable($device), $this->buildAlmanacPropertiesTable($device),
$this->buildSSHKeysTable($device), $this->buildSSHKeysTable($device),
$xaction_view, $timeline,
), ),
array( array(
'title' => $title, 'title' => $title,

View file

@ -38,22 +38,16 @@ final class AlmanacNetworkViewController
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($network->getName()); $crumbs->addTextCrumb($network->getName());
$xactions = id(new AlmanacNetworkTransactionQuery()) $timeline = $this->buildTransactionTimeline(
->setViewer($viewer) $network,
->withObjectPHIDs(array($network->getPHID())) new AlmanacNetworkTransactionQuery());
->execute(); $timeline->setShouldTerminate(true);
$xaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($network->getPHID())
->setTransactions($xactions)
->setShouldTerminate(true);
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(
$crumbs, $crumbs,
$box, $box,
$xaction_view, $timeline,
), ),
array( array(
'title' => $title, 'title' => $title,

View file

@ -40,16 +40,10 @@ final class AlmanacServiceViewController
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($service->getName()); $crumbs->addTextCrumb($service->getName());
$xactions = id(new AlmanacServiceTransactionQuery()) $timeline = $this->buildTransactionTimeline(
->setViewer($viewer) $service,
->withObjectPHIDs(array($service->getPHID())) new AlmanacServiceTransactionQuery());
->execute(); $timeline->setShouldTerminate(true);
$xaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($service->getPHID())
->setTransactions($xactions)
->setShouldTerminate(true);
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(
@ -57,7 +51,7 @@ final class AlmanacServiceViewController
$box, $box,
$bindings, $bindings,
$this->buildAlmanacPropertiesTable($service), $this->buildAlmanacPropertiesTable($service),
$xaction_view, $timeline,
), ),
array( array(
'title' => $title, 'title' => $title,

View file

@ -2,7 +2,9 @@
final class AlmanacNetwork final class AlmanacNetwork
extends AlmanacDAO extends AlmanacDAO
implements PhabricatorPolicyInterface { implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface {
protected $name; protected $name;
protected $mailKey; 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 )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -144,7 +144,6 @@ final class PhabricatorAuthEditController
->setContinueOnNoEffect(true) ->setContinueOnNoEffect(true)
->applyTransactions($config, $xactions); ->applyTransactions($config, $xactions);
if ($provider->hasSetupStep() && $is_new) { if ($provider->hasSetupStep() && $is_new) {
$id = $config->getID(); $id = $config->getID();
$next_uri = $this->getApplicationURI('config/edit/'.$id.'/'); $next_uri = $this->getApplicationURI('config/edit/'.$id.'/');
@ -304,21 +303,15 @@ final class PhabricatorAuthEditController
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($crumb); $crumbs->addTextCrumb($crumb);
$xaction_view = null; $timeline = null;
if (!$is_new) { if (!$is_new) {
$xactions = id(new PhabricatorAuthProviderConfigTransactionQuery()) $timeline = $this->buildTransactionTimeline(
->withObjectPHIDs(array($config->getPHID())) $config,
->setViewer($viewer) new PhabricatorAuthProviderConfigTransactionQuery());
->execute(); $xactions = $timeline->getTransactions();
foreach ($xactions as $xaction) { foreach ($xactions as $xaction) {
$xaction->setProvider($provider); $xaction->setProvider($provider);
} }
$xaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($config->getPHID())
->setTransactions($xactions);
} }
$form_box = id(new PHUIObjectBoxView()) $form_box = id(new PHUIObjectBoxView())
@ -331,7 +324,7 @@ final class PhabricatorAuthEditController
$crumbs, $crumbs,
$form_box, $form_box,
$footer, $footer,
$xaction_view, $timeline,
), ),
array( array(
'title' => $title, 'title' => $title,

View file

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

View file

@ -159,7 +159,7 @@ abstract class PhabricatorOAuth2AuthProvider
'%s set the OAuth application secret for this provider.', '%s set the OAuth application secret for this provider.',
$xaction->renderHandleLink($author_phid)); $xaction->renderHandleLink($author_phid));
} }
case self::PROPERTY_APP_NOTE: case self::PROPERTY_NOTE:
if (strlen($old)) { if (strlen($old)) {
return pht( return pht(
'%s updated the OAuth application notes for this provider.', '%s updated the OAuth application notes for this provider.',

View file

@ -1,7 +1,10 @@
<?php <?php
final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO final class PhabricatorAuthProviderConfig
implements PhabricatorPolicyInterface { extends PhabricatorAuthDAO
implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface {
protected $providerClass; protected $providerClass;
protected $providerType; protected $providerType;
@ -20,7 +23,7 @@ final class PhabricatorAuthProviderConfig extends PhabricatorAuthDAO
public function generatePHID() { public function generatePHID() {
return PhabricatorPHID::generateNewPHID( return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_AUTH); PhabricatorAuthAuthProviderPHIDType::TYPECONST);
} }
public function getConfiguration() { 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 )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -28,7 +28,7 @@ final class PhabricatorAuthProviderConfigTransaction
} }
public function getApplicationTransactionType() { public function getApplicationTransactionType() {
return PhabricatorPHIDConstants::PHID_TYPE_AUTH; return PhabricatorAuthAuthProviderPHIDType::TYPECONST;
} }
public function getApplicationTransactionCommentObject() { public function getApplicationTransactionCommentObject() {

View file

@ -51,7 +51,9 @@ final class HeraldRuleViewController extends HeraldController {
->setHeader($header) ->setHeader($header)
->addPropertyList($properties); ->addPropertyList($properties);
$timeline = $this->buildTimeline($rule); $timeline = $this->buildTransactionTimeline(
$rule,
new HeraldTransactionQuery());
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(
@ -158,31 +160,4 @@ final class HeraldRuleViewController extends HeraldController {
return $view; 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);
}
} }

View file

@ -2,6 +2,7 @@
final class HeraldRule extends HeraldDAO final class HeraldRule extends HeraldDAO
implements implements
PhabricatorApplicationTransactionInterface,
PhabricatorFlaggableInterface, PhabricatorFlaggableInterface,
PhabricatorPolicyInterface, PhabricatorPolicyInterface,
PhabricatorDestructibleInterface { PhabricatorDestructibleInterface {
@ -264,6 +265,19 @@ final class HeraldRule extends HeraldDAO
return sprintf('~%d%010d', $type_order, $this->getID()); 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 )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -11,7 +11,6 @@ final class PhabricatorPHIDConstants {
const PHID_TYPE_XCMT = 'XCMT'; const PHID_TYPE_XCMT = 'XCMT';
const PHID_TYPE_AUTH = 'AUTH';
const PHID_TYPE_XOBJ = 'XOBJ'; const PHID_TYPE_XOBJ = 'XOBJ';
const PHID_TYPE_VOID = 'VOID'; const PHID_TYPE_VOID = 'VOID';

View file

@ -54,7 +54,9 @@ final class PhabricatorSlowvotePollController
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb('V'.$poll->getID()); $crumbs->addTextCrumb('V'.$poll->getID());
$xactions = $this->buildTransactions($poll); $timeline = $this->buildTransactionTimeline(
$poll,
new PhabricatorSlowvoteTransactionQuery());
$add_comment = $this->buildCommentForm($poll); $add_comment = $this->buildCommentForm($poll);
$object_box = id(new PHUIObjectBoxView()) $object_box = id(new PHUIObjectBoxView())
@ -71,7 +73,7 @@ final class PhabricatorSlowvotePollController
'class' => 'mlt mml mmr', 'class' => 'mlt mml mmr',
), ),
$poll_view), $poll_view),
$xactions, $timeline,
$add_comment, $add_comment,
), ),
array( array(
@ -140,34 +142,6 @@ final class PhabricatorSlowvotePollController
return $view; 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) { private function buildCommentForm(PhabricatorSlowvotePoll $poll) {
$viewer = $this->getRequest()->getUser(); $viewer = $this->getRequest()->getUser();

View file

@ -2,6 +2,7 @@
final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
implements implements
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface, PhabricatorPolicyInterface,
PhabricatorSubscribableInterface, PhabricatorSubscribableInterface,
PhabricatorFlaggableInterface, 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 )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -67,6 +67,10 @@ class PhabricatorApplicationTransactionView extends AphrontView {
return $this; return $this;
} }
public function getTransactions() {
return $this->transactions;
}
public function setShouldTerminate($term) { public function setShouldTerminate($term) {
$this->shouldTerminate = $term; $this->shouldTerminate = $term;
return $this; return $this;