From f6e635c8d279718dc9ad43fdb490630438f2cd44 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 3 Dec 2014 15:35:47 -0800 Subject: [PATCH] Transactions - deploy buildTransactionTimeline to remaining applications Summary: Ref T4712. Specifically... - Differential - needed getApplicationTransactionViewObject() implemented - Audit - needed getApplicationTransactionViewObject() implemented - Repository - one object needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) - Ponder - BONUS BUG FIX - leaving a comment on an answer had a bad redirect URI - both PonderQuestion and PonderAnswer needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on both "history" controllers - left a "TODO" on buildAnswers on the question view controller, which is non-standard and should be re-written eventually - Phortune - BONUS BUG FIX - fix new user "createNewAccount" code to not fatal - PhortuneAccount, PhortuneMerchant, and PhortuneCart needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) on Account view, merchant view, and cart view controller - Fund - Legalpad - Nuance - NuanceSource needed PhabricatorApplicationTransactionInterface implemented - Releeph (this product is kind of a mess...) - HACKQUEST - had to manually create an arcanist project to even be able to make a "product" and get started...! - BONUS BUG FIX - make sure to "setName" on product edit - ReleephProject (should be ReleepProduct...?), ReleephBranch, and ReleepRequest needed PhabricatorApplicationTransactionInterface implemented - Harbormaster - HarbormasterBuildable, HarbormasterBuild, HarbormasterBuildPlan, and HarbormasterBuildStep all needed PhabricatorApplicationTransactionInterface implemented - setShouldTerminate(true) all over the place Test Plan: foreach application, viewed the timeline(s) and made sure they still rendered Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4712 Differential Revision: https://secure.phabricator.com/D10925 --- src/__phutil_library_map__.php | 14 ++++++++ .../storage/PhabricatorAuditTransaction.php | 4 +++ .../DifferentialRevisionViewController.php | 18 +++------- .../storage/DifferentialTransaction.php | 4 +++ .../controller/DiffusionCommitController.php | 17 +++------ .../DiffusionRepositoryEditMainController.php | 27 +++----------- .../FundInitiativeViewController.php | 12 +++---- .../HarbormasterBuildViewController.php | 12 +++---- .../HarbormasterBuildableViewController.php | 12 +++---- .../HarbormasterPlanViewController.php | 16 +++------ .../HarbormasterStepEditController.php | 16 +++------ .../storage/HarbormasterBuildable.php | 17 +++++++++ .../storage/build/HarbormasterBuild.php | 20 ++++++++++- .../configuration/HarbormasterBuildPlan.php | 17 +++++++++ .../configuration/HarbormasterBuildStep.php | 17 +++++++++ .../LegalpadDocumentManageController.php | 25 +++---------- .../controller/NuanceSourceViewController.php | 16 +++------ .../nuance/storage/NuanceSource.php | 21 ++++++++++- .../PhortuneAccountViewController.php | 24 +++---------- .../controller/PhortuneCartViewController.php | 17 ++++----- .../controller/PhortuneLandingController.php | 4 ++- .../PhortuneMerchantViewController.php | 13 +++---- .../phortune/storage/PhortuneAccount.php | 20 ++++++++++- .../phortune/storage/PhortuneCart.php | 20 ++++++++++- .../phortune/storage/PhortuneMerchant.php | 20 ++++++++++- .../PonderAnswerCommentController.php | 2 +- .../PonderAnswerHistoryController.php | 24 +++---------- .../PonderQuestionHistoryController.php | 25 +++---------- .../PonderQuestionViewController.php | 36 +++++++------------ .../ponder/storage/PonderAnswer.php | 18 ++++++++++ .../ponder/storage/PonderQuestion.php | 18 ++++++++++ .../branch/ReleephBranchHistoryController.php | 13 +++---- .../product/ReleephProductEditController.php | 1 + .../ReleephProductHistoryController.php | 14 +++----- .../request/ReleephRequestViewController.php | 12 ++----- .../releeph/storage/ReleephBranch.php | 20 ++++++++++- .../releeph/storage/ReleephProject.php | 22 +++++++++++- .../releeph/storage/ReleephRequest.php | 17 +++++++++ .../storage/PhabricatorRepository.php | 17 +++++++++ 39 files changed, 377 insertions(+), 265 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index b417fe9407..c82e0e5555 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3789,6 +3789,7 @@ phutil_register_library_map(array( 'FundSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'HarbormasterBuild' => array( 'HarbormasterDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', ), 'HarbormasterBuildAbortedException' => 'Exception', @@ -3820,6 +3821,7 @@ phutil_register_library_map(array( 'HarbormasterBuildPHIDType' => 'PhabricatorPHIDType', 'HarbormasterBuildPlan' => array( 'HarbormasterDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'PhabricatorSubscribableInterface', ), @@ -3833,6 +3835,7 @@ phutil_register_library_map(array( 'HarbormasterBuildQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'HarbormasterBuildStep' => array( 'HarbormasterDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'PhabricatorCustomFieldInterface', ), @@ -3859,6 +3862,7 @@ phutil_register_library_map(array( 'HarbormasterBuildWorker' => 'HarbormasterWorker', 'HarbormasterBuildable' => array( 'HarbormasterDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'HarbormasterBuildableInterface', ), @@ -4154,6 +4158,7 @@ phutil_register_library_map(array( 'NuanceSchemaSpec' => 'PhabricatorConfigSchemaSpec', 'NuanceSource' => array( 'NuanceDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', ), 'NuanceSourceDefaultEditCapability' => 'PhabricatorPolicyCapability', @@ -5312,6 +5317,7 @@ phutil_register_library_map(array( 'PhabricatorRepositoriesApplication' => 'PhabricatorApplication', 'PhabricatorRepository' => array( 'PhabricatorRepositoryDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'PhabricatorFlaggableInterface', 'PhabricatorMarkupInterface', @@ -5837,6 +5843,7 @@ phutil_register_library_map(array( 'PholioUploadedImageView' => 'AphrontView', 'PhortuneAccount' => array( 'PhortuneDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', ), 'PhortuneAccountEditController' => 'PhortuneController', @@ -5851,6 +5858,7 @@ phutil_register_library_map(array( 'PhortuneBalancedPaymentProvider' => 'PhortunePaymentProvider', 'PhortuneCart' => array( 'PhortuneDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', ), 'PhortuneCartAcceptController' => 'PhortuneCartController', @@ -5887,6 +5895,7 @@ phutil_register_library_map(array( 'PhortuneMemberHasMerchantEdgeType' => 'PhabricatorEdgeType', 'PhortuneMerchant' => array( 'PhortuneDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', ), 'PhortuneMerchantCapability' => 'PhabricatorPolicyCapability', @@ -6056,6 +6065,7 @@ phutil_register_library_map(array( 'PonderAddAnswerView' => 'AphrontView', 'PonderAnswer' => array( 'PonderDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorMarkupInterface', 'PonderVotableInterface', 'PhabricatorPolicyInterface', @@ -6079,6 +6089,7 @@ phutil_register_library_map(array( 'PonderEditor' => 'PhabricatorApplicationTransactionEditor', 'PonderQuestion' => array( 'PonderDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorMarkupInterface', 'PonderVotableInterface', 'PhabricatorSubscribableInterface', @@ -6126,6 +6137,7 @@ phutil_register_library_map(array( 'ReleephAuthorFieldSpecification' => 'ReleephFieldSpecification', 'ReleephBranch' => array( 'ReleephDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', ), 'ReleephBranchAccessController' => 'ReleephBranchController', @@ -6183,6 +6195,7 @@ phutil_register_library_map(array( ), 'ReleephProject' => array( 'ReleephDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', ), 'ReleephProjectInfoConduitAPIMethod' => 'ReleephConduitAPIMethod', @@ -6192,6 +6205,7 @@ phutil_register_library_map(array( 'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification', 'ReleephRequest' => array( 'ReleephDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'PhabricatorCustomFieldInterface', ), diff --git a/src/applications/audit/storage/PhabricatorAuditTransaction.php b/src/applications/audit/storage/PhabricatorAuditTransaction.php index 2932364350..01b947da6d 100644 --- a/src/applications/audit/storage/PhabricatorAuditTransaction.php +++ b/src/applications/audit/storage/PhabricatorAuditTransaction.php @@ -28,6 +28,10 @@ final class PhabricatorAuditTransaction return new PhabricatorAuditTransactionComment(); } + public function getApplicationTransactionViewObject() { + return new PhabricatorAuditTransactionView(); + } + public function getRemarkupBlocks() { $blocks = parent::getRemarkupBlocks(); diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php index e2afe57248..85faa55ce7 100644 --- a/src/applications/differential/controller/DifferentialRevisionViewController.php +++ b/src/applications/differential/controller/DifferentialRevisionViewController.php @@ -926,22 +926,14 @@ final class DifferentialRevisionViewController extends DifferentialController { DifferentialDiff $right_diff, array $changesets) { - $viewer = $this->getRequest()->getUser(); - - $xactions = id(new DifferentialTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($revision->getPHID())) - ->needComments(true) - ->execute(); - - $timeline = id(new DifferentialTransactionView()) - ->setUser($viewer) - ->setObjectPHID($revision->getPHID()) + $timeline = $this->buildTransactionTimeline( + $revision, + new DifferentialTransactionQuery()); + $timeline ->setChangesets($changesets) ->setRevision($revision) ->setLeftDiff($left_diff) - ->setRightDiff($right_diff) - ->setTransactions($xactions); + ->setRightDiff($right_diff); return $timeline; } diff --git a/src/applications/differential/storage/DifferentialTransaction.php b/src/applications/differential/storage/DifferentialTransaction.php index b6df7cf4f5..b0c946ebb1 100644 --- a/src/applications/differential/storage/DifferentialTransaction.php +++ b/src/applications/differential/storage/DifferentialTransaction.php @@ -31,6 +31,10 @@ final class DifferentialTransaction extends PhabricatorApplicationTransaction { return new DifferentialTransactionComment(); } + public function getApplicationTransactionViewObject() { + return new DifferentialTransactionView(); + } + public function shouldHide() { $old = $this->getOldValue(); $new = $this->getNewValue(); diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php index 54abc7e4d5..b41ad5cda5 100644 --- a/src/applications/diffusion/controller/DiffusionCommitController.php +++ b/src/applications/diffusion/controller/DiffusionCommitController.php @@ -628,13 +628,10 @@ final class DiffusionCommitController extends DiffusionController { } private function buildComments(PhabricatorRepositoryCommit $commit) { - $viewer = $this->getRequest()->getUser(); - - $xactions = id(new PhabricatorAuditTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($commit->getPHID())) - ->needComments(true) - ->execute(); + $timeline = $this->buildTransactionTimeline( + $commit, + new PhabricatorAuditTransactionQuery()); + $xactions = $timeline->getTransactions(); $path_ids = array(); foreach ($xactions as $xaction) { @@ -654,11 +651,7 @@ final class DiffusionCommitController extends DiffusionController { $path_map = ipull($path_map, 'path', 'id'); } - return id(new PhabricatorAuditTransactionView()) - ->setUser($viewer) - ->setObjectPHID($commit->getPHID()) - ->setPathMap($path_map) - ->setTransactions($xactions); + return $timeline->setPathMap($path_map); } private function renderAddCommentPanel( diff --git a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php index 8cf00006f8..d955b13a08 100644 --- a/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php +++ b/src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php @@ -93,27 +93,10 @@ final class DiffusionRepositoryEditMainController $repository, $this->buildActionsActions($repository)); - $xactions = id(new PhabricatorRepositoryTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($repository->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(); - - $xaction_view = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($repository->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $repository, + new PhabricatorRepositoryTransactionQuery()); + $timeline->setShouldTerminate(true); $boxes = array(); @@ -187,7 +170,7 @@ final class DiffusionRepositoryEditMainController array( $crumbs, $boxes, - $xaction_view, + $timeline, ), array( 'title' => $title, diff --git a/src/applications/fund/controller/FundInitiativeViewController.php b/src/applications/fund/controller/FundInitiativeViewController.php index c3c64b7556..f8e367f1a1 100644 --- a/src/applications/fund/controller/FundInitiativeViewController.php +++ b/src/applications/fund/controller/FundInitiativeViewController.php @@ -60,15 +60,11 @@ final class FundInitiativeViewController ->setHeader($header) ->appendChild($properties); - $xactions = id(new FundInitiativeTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($initiative->getPHID())) - ->execute(); - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($initiative->getPHID()) - ->setTransactions($xactions) + $timeline = $this->buildTransactionTimeline( + $initiative, + new FundInitiativeTransactionQuery()); + $timeline ->setShouldTerminate(true); return $this->buildApplicationPage( diff --git a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php index 6a3b3f9cd1..9fd6b0d2ef 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php @@ -191,14 +191,10 @@ final class HarbormasterBuildViewController $targets[] = $this->buildLog($build, $build_target); } - $xactions = id(new HarbormasterBuildTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($build->getPHID())) - ->execute(); - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($build->getPHID()) - ->setTransactions($xactions); + $timeline = $this->buildTransactionTimeline( + $build, + new HarbormasterBuildTransactionQuery()); + $timeline->setShouldTerminate(true); return $this->buildApplicationPage( array( diff --git a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php index e75022914b..ecb7605657 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildableViewController.php @@ -46,14 +46,10 @@ final class HarbormasterBuildableViewController $box = id(new PHUIObjectBoxView()) ->setHeader($header); - $xactions = id(new HarbormasterBuildableTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($buildable->getPHID())) - ->execute(); - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($buildable->getPHID()) - ->setTransactions($xactions); + $timeline = $this->buildTransactionTimeline( + $buildable, + new HarbormasterBuildableTransactionQuery()); + $timeline->setShouldTerminate(true); $actions = $this->buildActionList($buildable); $this->buildPropertyLists($box, $buildable, $actions); diff --git a/src/applications/harbormaster/controller/HarbormasterPlanViewController.php b/src/applications/harbormaster/controller/HarbormasterPlanViewController.php index 9f52e93a09..c6fd4a1155 100644 --- a/src/applications/harbormaster/controller/HarbormasterPlanViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterPlanViewController.php @@ -22,16 +22,10 @@ final class HarbormasterPlanViewController extends HarbormasterPlanController { return new Aphront404Response(); } - $xactions = id(new HarbormasterBuildPlanTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($plan->getPHID())) - ->execute(); - - $xaction_view = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($plan->getPHID()) - ->setTransactions($xactions) - ->setShouldTerminate(true); + $timeline = $this->buildTransactionTimeline( + $plan, + new HarbormasterBuildPlanTransactionQuery()); + $timeline->setShouldTerminate(true); $title = pht('Plan %d', $id); @@ -77,7 +71,7 @@ final class HarbormasterPlanViewController extends HarbormasterPlanController { $crumbs, $box, $step_list, - $xaction_view, + $timeline, ), array( 'title' => $title, diff --git a/src/applications/harbormaster/controller/HarbormasterStepEditController.php b/src/applications/harbormaster/controller/HarbormasterStepEditController.php index 12631db71a..403dfa8cce 100644 --- a/src/applications/harbormaster/controller/HarbormasterStepEditController.php +++ b/src/applications/harbormaster/controller/HarbormasterStepEditController.php @@ -191,16 +191,10 @@ final class HarbormasterStepEditController extends HarbormasterController { if ($is_new) { $xaction_view = null; } else { - $xactions = id(new HarbormasterBuildStepTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($step->getPHID())) - ->execute(); - - $xaction_view = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($step->getPHID()) - ->setTransactions($xactions) - ->setShouldTerminate(true); + $timeline = $this->buildTransactionTimeline( + $step, + new HarbormasterBuildStepTransactionQuery()); + $timeline->setShouldTerminate(true); } return $this->buildApplicationPage( @@ -208,7 +202,7 @@ final class HarbormasterStepEditController extends HarbormasterController { $crumbs, $box, $variables, - $xaction_view, + $timeline, ), array( 'title' => $implementation->getName(), diff --git a/src/applications/harbormaster/storage/HarbormasterBuildable.php b/src/applications/harbormaster/storage/HarbormasterBuildable.php index f7e6ab51f7..17cfd8350f 100644 --- a/src/applications/harbormaster/storage/HarbormasterBuildable.php +++ b/src/applications/harbormaster/storage/HarbormasterBuildable.php @@ -2,6 +2,7 @@ final class HarbormasterBuildable extends HarbormasterDAO implements + PhabricatorApplicationTransactionInterface, PhabricatorPolicyInterface, HarbormasterBuildableInterface { @@ -226,6 +227,22 @@ final class HarbormasterBuildable extends HarbormasterDAO } +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new HarbormasterBuildableTransactionEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new HarbormasterBuildableTransaction(); + } + + /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php index 4b05a5937a..db8cbd2818 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php @@ -1,7 +1,9 @@ setViewer($user) - ->withObjectPHIDs(array($document->getPHID())) - ->execute(); - $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID( $document->getPHID()); @@ -53,14 +48,10 @@ final class LegalpadDocumentManageController extends LegalpadController { $engine->addObject( $document_body, LegalpadDocumentBody::MARKUP_FIELD_TEXT); - foreach ($xactions as $xaction) { - if ($xaction->getComment()) { - $engine->addObject( - $xaction->getComment(), - PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); - } - } - $engine->process(); + $timeline = $this->buildTransactionTimeline( + $document, + new LegalpadTransactionQuery(), + $engine); $title = $document_body->getTitle(); @@ -74,12 +65,6 @@ final class LegalpadDocumentManageController extends LegalpadController { $comment_form_id = celerity_generate_unique_node_id(); - $xaction_view = id(new LegalpadTransactionView()) - ->setUser($this->getRequest()->getUser()) - ->setObjectPHID($document->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); - $add_comment = $this->buildAddCommentView($document, $comment_form_id); $crumbs = $this->buildApplicationCrumbs($this->buildSideNav()); @@ -97,7 +82,7 @@ final class LegalpadDocumentManageController extends LegalpadController { $content = array( $crumbs, $object_box, - $xaction_view, + $timeline, $add_comment, ); diff --git a/src/applications/nuance/controller/NuanceSourceViewController.php b/src/applications/nuance/controller/NuanceSourceViewController.php index 781185e2c2..60487582d1 100644 --- a/src/applications/nuance/controller/NuanceSourceViewController.php +++ b/src/applications/nuance/controller/NuanceSourceViewController.php @@ -31,19 +31,11 @@ final class NuanceSourceViewController extends NuanceController { } $source_phid = $source->getPHID(); - $xactions = id(new NuanceSourceTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($source_phid)) - ->execute(); - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($viewer); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($source_phid) - ->setMarkupEngine($engine) - ->setTransactions($xactions); + $timeline = $this->buildTransactionTimeline( + $source, + new NuanceSourceTransactionQuery()); + $timeline->setShouldTerminate(true); $title = pht('%s', $source->getName()); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/nuance/storage/NuanceSource.php b/src/applications/nuance/storage/NuanceSource.php index 025a60dd89..0bf955a875 100644 --- a/src/applications/nuance/storage/NuanceSource.php +++ b/src/applications/nuance/storage/NuanceSource.php @@ -1,7 +1,9 @@ setType($lucky_definition->getSourceTypeConstant()); } + +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new NuanceSourceEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new NuanceSourceTransaction(); + } + + public function getCapabilities() { return array( PhabricatorPolicyCapability::CAN_VIEW, diff --git a/src/applications/phortune/controller/PhortuneAccountViewController.php b/src/applications/phortune/controller/PhortuneAccountViewController.php index 4d6198cf5b..b0eb23fc36 100644 --- a/src/applications/phortune/controller/PhortuneAccountViewController.php +++ b/src/applications/phortune/controller/PhortuneAccountViewController.php @@ -72,7 +72,10 @@ final class PhortuneAccountViewController extends PhortuneController { $payment_methods = $this->buildPaymentMethodsSection($account); $purchase_history = $this->buildPurchaseHistorySection($account); $charge_history = $this->buildChargeHistorySection($account); - $account_history = $this->buildAccountHistorySection($account); + $timeline = $this->buildTransactionTimeline( + $account, + new PhortuneAccountTransactionQuery()); + $timeline->setShouldTerminate(true); $object_box = id(new PHUIObjectBoxView()) ->setHeader($header) @@ -85,7 +88,7 @@ final class PhortuneAccountViewController extends PhortuneController { $payment_methods, $purchase_history, $charge_history, - $account_history, + $timeline, ), array( 'title' => $title, @@ -258,23 +261,6 @@ final class PhortuneAccountViewController extends PhortuneController { ->appendChild($table); } - private function buildAccountHistorySection(PhortuneAccount $account) { - $request = $this->getRequest(); - $user = $request->getUser(); - - $xactions = id(new PhortuneAccountTransactionQuery()) - ->setViewer($user) - ->withObjectPHIDs(array($account->getPHID())) - ->execute(); - - $xaction_view = id(new PhabricatorApplicationTransactionView()) - ->setUser($user) - ->setObjectPHID($account->getPHID()) - ->setTransactions($xactions); - - return $xaction_view; - } - protected function buildApplicationCrumbs() { $crumbs = parent::buildApplicationCrumbs(); diff --git a/src/applications/phortune/controller/PhortuneCartViewController.php b/src/applications/phortune/controller/PhortuneCartViewController.php index d02182ac36..580f92b2c4 100644 --- a/src/applications/phortune/controller/PhortuneCartViewController.php +++ b/src/applications/phortune/controller/PhortuneCartViewController.php @@ -161,23 +161,18 @@ final class PhortuneCartViewController $crumbs->addTextCrumb(pht('Cart %d', $cart->getID())); $crumbs->setActionList($actions); - $xactions = id(new PhortuneCartTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($cart->getPHID())) - ->execute(); - - $xaction_view = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($cart->getPHID()) - ->setTransactions($xactions) - ->setShouldTerminate(true); + $timeline = $this->buildTransactionTimeline( + $cart, + new PhortuneCartTransactionQuery()); + $timeline + ->setShouldTerminate(true); return $this->buildApplicationPage( array( $crumbs, $cart_box, $charges, - $xaction_view, + $timeline, ), array( 'title' => pht('Cart'), diff --git a/src/applications/phortune/controller/PhortuneLandingController.php b/src/applications/phortune/controller/PhortuneLandingController.php index a44790df88..ddff75f9ec 100644 --- a/src/applications/phortune/controller/PhortuneLandingController.php +++ b/src/applications/phortune/controller/PhortuneLandingController.php @@ -12,7 +12,9 @@ final class PhortuneLandingController extends PhortuneController { ->execute(); if (!$accounts) { - $account = $this->createUserAccount($user); + $account = PhortuneAccount::createNewAccount( + $user, + PhabricatorContentSource::newFromRequest($request)); $accounts = array($account); } diff --git a/src/applications/phortune/controller/PhortuneMerchantViewController.php b/src/applications/phortune/controller/PhortuneMerchantViewController.php index 2fe2b76716..01557a6fb9 100644 --- a/src/applications/phortune/controller/PhortuneMerchantViewController.php +++ b/src/applications/phortune/controller/PhortuneMerchantViewController.php @@ -53,15 +53,10 @@ final class PhortuneMerchantViewController ->setHeader($header) ->appendChild($properties); - $xactions = id(new PhortuneMerchantTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($merchant->getPHID())) - ->execute(); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($merchant->getPHID()) - ->setTransactions($xactions); + $timeline = $this->buildTransactionTimeline( + $merchant, + new PhortuneMerchantTransactionQuery()); + $timeline->setShouldTerminate(true); return $this->buildApplicationPage( array( diff --git a/src/applications/phortune/storage/PhortuneAccount.php b/src/applications/phortune/storage/PhortuneAccount.php index 316e9c3d62..30f9027eea 100644 --- a/src/applications/phortune/storage/PhortuneAccount.php +++ b/src/applications/phortune/storage/PhortuneAccount.php @@ -7,7 +7,9 @@ * a personal account). */ final class PhortuneAccount extends PhortuneDAO - implements PhabricatorPolicyInterface { + implements + PhabricatorApplicationTransactionInterface, + PhabricatorPolicyInterface { protected $name; @@ -95,6 +97,22 @@ final class PhortuneAccount extends PhortuneDAO } +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new PhortuneAccountEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new PhortuneAccountTransaction(); + } + + /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/phortune/storage/PhortuneCart.php b/src/applications/phortune/storage/PhortuneCart.php index 4edd523a5e..b90223253b 100644 --- a/src/applications/phortune/storage/PhortuneCart.php +++ b/src/applications/phortune/storage/PhortuneCart.php @@ -1,7 +1,9 @@ getQuestion()->getID(); $aid = $answer->getID(); - $view_uri = "Q{$qid}#A{$aid}"; + $view_uri = "/Q{$qid}#A{$aid}"; $xactions = array(); $xactions[] = id(new PonderAnswerTransaction()) diff --git a/src/applications/ponder/controller/PonderAnswerHistoryController.php b/src/applications/ponder/controller/PonderAnswerHistoryController.php index dbecfa1394..931c090e02 100644 --- a/src/applications/ponder/controller/PonderAnswerHistoryController.php +++ b/src/applications/ponder/controller/PonderAnswerHistoryController.php @@ -20,27 +20,11 @@ final class PonderAnswerHistoryController extends PonderController { return new Aphront404Response(); } - $xactions = id(new PonderAnswerTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($answer->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($answer->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $answer, + new PonderAnswerTransactionQuery()); + $timeline->setShouldTerminate(true); $qid = $answer->getQuestion()->getID(); $aid = $answer->getID(); diff --git a/src/applications/ponder/controller/PonderQuestionHistoryController.php b/src/applications/ponder/controller/PonderQuestionHistoryController.php index 196d5658eb..253dbcc26c 100644 --- a/src/applications/ponder/controller/PonderQuestionHistoryController.php +++ b/src/applications/ponder/controller/PonderQuestionHistoryController.php @@ -20,27 +20,10 @@ final class PonderQuestionHistoryController extends PonderController { return new Aphront404Response(); } - $xactions = id(new PonderQuestionTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($question->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($question->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $question, + new PonderQuestionTransactionQuery()); + $timeline->setShouldTerminate(true); $qid = $question->getID(); diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php index 2c046b50e2..e606bb2b93 100644 --- a/src/applications/ponder/controller/PonderQuestionViewController.php +++ b/src/applications/ponder/controller/PonderQuestionViewController.php @@ -178,31 +178,14 @@ final class PonderQuestionViewController extends PonderController { } private function buildQuestionTransactions(PonderQuestion $question) { - $viewer = $this->getRequest()->getUser(); + $viewer = $this->getViewer(); $id = $question->getID(); - $xactions = id(new PonderQuestionTransactionQuery()) - ->setViewer($viewer) - ->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)) - ->withObjectPHIDs(array($question->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($question->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $question, + id(new PonderQuestionTransactionQuery()) + ->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))); + $xactions = $timeline->getTransactions(); $add_comment = id(new PhabricatorApplicationTransactionCommentView()) ->setUser($viewer) @@ -220,6 +203,13 @@ final class PonderQuestionViewController extends PonderController { )); } + /** + * This is fairly non-standard; building N timelines at once (N = number of + * answers) is tricky business. + * + * TODO - re-factor this to ajax in one answer panel at a time in a more + * standard fashion. This is necessary to scale this application. + */ private function buildAnswers(array $answers) { $request = $this->getRequest(); $viewer = $request->getUser(); diff --git a/src/applications/ponder/storage/PonderAnswer.php b/src/applications/ponder/storage/PonderAnswer.php index a85aa6d3ad..6cdf079d45 100644 --- a/src/applications/ponder/storage/PonderAnswer.php +++ b/src/applications/ponder/storage/PonderAnswer.php @@ -2,6 +2,7 @@ final class PonderAnswer extends PonderDAO implements + PhabricatorApplicationTransactionInterface, PhabricatorMarkupInterface, PonderVotableInterface, PhabricatorPolicyInterface, @@ -112,6 +113,23 @@ final class PonderAnswer extends PonderDAO return self::MARKUP_FIELD_CONTENT; } + +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new PonderAnswerEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new PonderAnswerTransaction(); + } + + // Markup interface public function getMarkupFieldKey($field) { diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php index 5caa52ad78..abeda5e98c 100644 --- a/src/applications/ponder/storage/PonderQuestion.php +++ b/src/applications/ponder/storage/PonderQuestion.php @@ -2,6 +2,7 @@ final class PonderQuestion extends PonderDAO implements + PhabricatorApplicationTransactionInterface, PhabricatorMarkupInterface, PonderVotableInterface, PhabricatorSubscribableInterface, @@ -144,6 +145,23 @@ final class PonderQuestion extends PonderDAO return self::MARKUP_FIELD_CONTENT; } + +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new PonderQuestionEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new PonderQuestionTransaction(); + } + + // Markup interface public function getMarkupFieldKey($field) { diff --git a/src/applications/releeph/controller/branch/ReleephBranchHistoryController.php b/src/applications/releeph/controller/branch/ReleephBranchHistoryController.php index 67559c8d91..46c0b47f6c 100644 --- a/src/applications/releeph/controller/branch/ReleephBranchHistoryController.php +++ b/src/applications/releeph/controller/branch/ReleephBranchHistoryController.php @@ -25,15 +25,10 @@ final class ReleephBranchHistoryController extends ReleephBranchController { } $this->setBranch($branch); - $xactions = id(new ReleephBranchTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($branch->getPHID())) - ->execute(); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($branch->getPHID()) - ->setTransactions($xactions) + $timeline = $this->buildTransactionTimeline( + $branch, + new ReleephBranchTransactionQuery()); + $timeline ->setShouldTerminate(true); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/releeph/controller/product/ReleephProductEditController.php b/src/applications/releeph/controller/product/ReleephProductEditController.php index bd4a108ca1..34a3a48091 100644 --- a/src/applications/releeph/controller/product/ReleephProductEditController.php +++ b/src/applications/releeph/controller/product/ReleephProductEditController.php @@ -85,6 +85,7 @@ final class ReleephProductEditController extends ReleephProductController { } $product + ->setName($product_name) ->setTrunkBranch($trunk_branch) ->setDetail('pushers', $pusher_phids) ->setDetail('pick_failure_instructions', $pick_failure_instructions) diff --git a/src/applications/releeph/controller/product/ReleephProductHistoryController.php b/src/applications/releeph/controller/product/ReleephProductHistoryController.php index f55385a12c..15d7139854 100644 --- a/src/applications/releeph/controller/product/ReleephProductHistoryController.php +++ b/src/applications/releeph/controller/product/ReleephProductHistoryController.php @@ -25,16 +25,10 @@ final class ReleephProductHistoryController extends ReleephProductController { } $this->setProduct($product); - $xactions = id(new ReleephProductTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($product->getPHID())) - ->execute(); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($product->getPHID()) - ->setTransactions($xactions) - ->setShouldTerminate(true); + $timeline = $this->buildTransactionTimeline( + $product, + new ReleephProductTransactionQuery()); + $timeline->setShouldTerminate(true); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('History')); diff --git a/src/applications/releeph/controller/request/ReleephRequestViewController.php b/src/applications/releeph/controller/request/ReleephRequestViewController.php index 9644f6f025..04f91b5fc6 100644 --- a/src/applications/releeph/controller/request/ReleephRequestViewController.php +++ b/src/applications/releeph/controller/request/ReleephRequestViewController.php @@ -56,15 +56,9 @@ final class ReleephRequestViewController ->setCustomFields($field_list) ->setPullRequest($pull); - $xactions = id(new ReleephRequestTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($pull->getPHID())) - ->execute(); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($request->getUser()) - ->setObjectPHID($pull->getPHID()) - ->setTransactions($xactions); + $timeline = $this->buildTransactionTimeline( + $pull, + new ReleephRequestTransactionQuery()); $add_comment_header = pht('Plea or Yield'); diff --git a/src/applications/releeph/storage/ReleephBranch.php b/src/applications/releeph/storage/ReleephBranch.php index f6cb1834c9..bc83b5e0a2 100644 --- a/src/applications/releeph/storage/ReleephBranch.php +++ b/src/applications/releeph/storage/ReleephBranch.php @@ -1,7 +1,9 @@