From 5e8600442d73770f43cecdf1580a80d8e836f157 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Wed, 3 Dec 2014 13:16:15 -0800 Subject: [PATCH] Transactions - land buildTransactionTimeline in a bunch more apps Summary: Ref T4712. Specifically... - Dashboards - two objects needed PhabricatorApplicationTransactionInterface - Macros - Paste - Phlux - one object needed PhabricatorApplicationTransactionInterface - added setShouldTerminate(true) - Files - one object needed PhabricatorApplicationTransactionInterface - Passphrase - one object needed PhabricatorApplicationTransactionInterface - added setShouldTerminate(true) - Drydock - one object needed PhabricatorApplicationTransactionInterface - added setShouldTerminate(true) Test Plan: foreach application, verify that the timeline(s) showed up correctly, including with appropriate setShouldTerminate-ness Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T4712 Differential Revision: https://secure.phabricator.com/D10924 --- src/__phutil_library_map__.php | 6 ++++ .../PhabricatorDashboardHistoryController.php | 22 +++----------- ...habricatorDashboardPanelViewController.php | 25 +++------------- .../storage/PhabricatorDashboard.php | 17 +++++++++++ .../storage/PhabricatorDashboardPanel.php | 17 +++++++++++ .../DrydockBlueprintViewController.php | 17 +++-------- .../drydock/storage/DrydockBlueprint.php | 17 +++++++++++ .../PhabricatorFileInfoController.php | 29 ++++--------------- .../files/storage/PhabricatorFile.php | 17 +++++++++++ .../PhabricatorMacroViewController.php | 24 ++------------- .../PassphraseCredentialViewController.php | 16 +++------- .../storage/PassphraseCredential.php | 22 ++++++++++++-- .../PhabricatorPasteViewController.php | 24 ++------------- .../phlux/controller/PhluxViewController.php | 19 ++++-------- .../phlux/storage/PhluxVariable.php | 17 +++++++++++ 15 files changed, 143 insertions(+), 146 deletions(-) diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index e4d72a5afe..b417fe9407 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -3649,6 +3649,7 @@ phutil_register_library_map(array( 'DrydockApacheWebrootInterface' => 'DrydockWebrootInterface', 'DrydockBlueprint' => array( 'DrydockDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'PhabricatorCustomFieldInterface', ), @@ -4240,6 +4241,7 @@ phutil_register_library_map(array( 'PassphraseController' => 'PhabricatorController', 'PassphraseCredential' => array( 'PassphraseDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'PhabricatorDestructibleInterface', ), @@ -4657,6 +4659,7 @@ phutil_register_library_map(array( 'PhabricatorDaemonsApplication' => 'PhabricatorApplication', 'PhabricatorDashboard' => array( 'PhabricatorDashboardDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'PhabricatorDestructibleInterface', ), @@ -4675,6 +4678,7 @@ phutil_register_library_map(array( 'PhabricatorDashboardMovePanelController' => 'PhabricatorDashboardController', 'PhabricatorDashboardPanel' => array( 'PhabricatorDashboardDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorPolicyInterface', 'PhabricatorCustomFieldInterface', 'PhabricatorDestructibleInterface', @@ -4808,6 +4812,7 @@ phutil_register_library_map(array( 'PhabricatorFeedStoryTypeConstants' => 'PhabricatorFeedConstants', 'PhabricatorFile' => array( 'PhabricatorFileDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorTokenReceiverInterface', 'PhabricatorSubscribableInterface', 'PhabricatorFlaggableInterface', @@ -5773,6 +5778,7 @@ phutil_register_library_map(array( 'PhluxTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhluxVariable' => array( 'PhluxDAO', + 'PhabricatorApplicationTransactionInterface', 'PhabricatorFlaggableInterface', 'PhabricatorPolicyInterface', ), diff --git a/src/applications/dashboard/controller/PhabricatorDashboardHistoryController.php b/src/applications/dashboard/controller/PhabricatorDashboardHistoryController.php index 6a105886b6..641f642bd4 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardHistoryController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardHistoryController.php @@ -35,7 +35,10 @@ final class PhabricatorDashboardHistoryController $dashboard_manage_uri); $crumbs->addTextCrumb(pht('History')); - $timeline = $this->buildTransactions($dashboard); + $timeline = $this->buildTransactionTimeline( + $dashboard, + new PhabricatorDashboardTransactionQuery()); + $timeline->setShouldTerminate(true); return $this->buildApplicationPage( array( @@ -47,21 +50,4 @@ final class PhabricatorDashboardHistoryController )); } - private function buildTransactions(PhabricatorDashboard $dashboard) { - $viewer = $this->getRequest()->getUser(); - - $xactions = id(new PhabricatorDashboardTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($dashboard->getPHID())) - ->execute(); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setShouldTerminate(true) - ->setObjectPHID($dashboard->getPHID()) - ->setTransactions($xactions); - - return $timeline; - } - } diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php index dd594d01b7..866504d374 100644 --- a/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php +++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php @@ -35,7 +35,10 @@ final class PhabricatorDashboardPanelViewController $header = $this->buildHeaderView($panel); $actions = $this->buildActionView($panel); $properties = $this->buildPropertyView($panel); - $timeline = $this->buildTransactions($panel); + $timeline = $this->buildTransactionTimeline( + $panel, + new PhabricatorDashboardPanelTransactionQuery()); + $timeline->setShouldTerminate(true); $properties->setActionList($actions); $box = id(new PHUIObjectBoxView()) @@ -167,24 +170,4 @@ final class PhabricatorDashboardPanelViewController return $properties; } - private function buildTransactions(PhabricatorDashboardPanel $panel) { - $viewer = $this->getRequest()->getUser(); - - $xactions = id(new PhabricatorDashboardPanelTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($panel->getPHID())) - ->execute(); - - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($viewer); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setShouldTerminate(true) - ->setObjectPHID($panel->getPHID()) - ->setTransactions($xactions); - - return $timeline; - } - } diff --git a/src/applications/dashboard/storage/PhabricatorDashboard.php b/src/applications/dashboard/storage/PhabricatorDashboard.php index e2501c3756..1dd06b851a 100644 --- a/src/applications/dashboard/storage/PhabricatorDashboard.php +++ b/src/applications/dashboard/storage/PhabricatorDashboard.php @@ -5,6 +5,7 @@ */ final class PhabricatorDashboard extends PhabricatorDashboardDAO implements + PhabricatorApplicationTransactionInterface, PhabricatorPolicyInterface, PhabricatorDestructibleInterface { @@ -83,6 +84,22 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO } +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new PhabricatorDashboardTransactionEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new PhabricatorDashboardTransaction(); + } + + /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php index 555c370617..a18c1c8f98 100644 --- a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php +++ b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php @@ -6,6 +6,7 @@ final class PhabricatorDashboardPanel extends PhabricatorDashboardDAO implements + PhabricatorApplicationTransactionInterface, PhabricatorPolicyInterface, PhabricatorCustomFieldInterface, PhabricatorDestructibleInterface { @@ -89,6 +90,22 @@ final class PhabricatorDashboardPanel } +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new PhabricatorDashboardPanelTransactionEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new PhabricatorDashboardPanelTransaction(); + } + + /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/drydock/controller/DrydockBlueprintViewController.php b/src/applications/drydock/controller/DrydockBlueprintViewController.php index 9f82dc967a..0db5313c37 100644 --- a/src/applications/drydock/controller/DrydockBlueprintViewController.php +++ b/src/applications/drydock/controller/DrydockBlueprintViewController.php @@ -56,11 +56,6 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController { ->setHeader($header) ->addPropertyList($properties); - $xactions = id(new DrydockBlueprintTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($blueprint->getPHID())) - ->execute(); - $field_list = PhabricatorCustomField::getObjectFields( $blueprint, PhabricatorCustomField::ROLE_VIEW); @@ -73,14 +68,10 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController { $viewer, $properties); - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($viewer); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($blueprint->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $blueprint, + new DrydockBlueprintTransactionQuery()); + $timeline->setShouldTerminate(true); return $this->buildApplicationPage( array( diff --git a/src/applications/drydock/storage/DrydockBlueprint.php b/src/applications/drydock/storage/DrydockBlueprint.php index 8d8f91cfa2..f2f45c1213 100644 --- a/src/applications/drydock/storage/DrydockBlueprint.php +++ b/src/applications/drydock/storage/DrydockBlueprint.php @@ -2,6 +2,7 @@ final class DrydockBlueprint extends DrydockDAO implements + PhabricatorApplicationTransactionInterface, PhabricatorPolicyInterface, PhabricatorCustomFieldInterface { @@ -75,6 +76,22 @@ final class DrydockBlueprint extends DrydockDAO } +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new DrydockBlueprintEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new DrydockBlueprintTransaction(); + } + + /* -( PhabricatorPolicyInterface )----------------------------------------- */ diff --git a/src/applications/files/controller/PhabricatorFileInfoController.php b/src/applications/files/controller/PhabricatorFileInfoController.php index cf7e9f2b4e..3939f01e9d 100644 --- a/src/applications/files/controller/PhabricatorFileInfoController.php +++ b/src/applications/files/controller/PhabricatorFileInfoController.php @@ -38,10 +38,6 @@ final class PhabricatorFileInfoController extends PhabricatorFileController { } $phid = $file->getPHID(); - $xactions = id(new PhabricatorFileTransactionQuery()) - ->setViewer($user) - ->withObjectPHIDs(array($phid)) - ->execute(); $handle_phids = array_merge( array($file->getAuthorPHID()), @@ -62,7 +58,7 @@ final class PhabricatorFileInfoController extends PhabricatorFileController { } $actions = $this->buildActionView($file); - $timeline = $this->buildTransactionView($file, $xactions); + $timeline = $this->buildTransactionView($file); $crumbs = $this->buildApplicationCrumbs(); $crumbs->setActionList($actions); $crumbs->addTextCrumb( @@ -86,27 +82,12 @@ final class PhabricatorFileInfoController extends PhabricatorFileController { )); } - private function buildTransactionView( - PhabricatorFile $file, - array $xactions) { - + private function buildTransactionView(PhabricatorFile $file) { $user = $this->getRequest()->getUser(); - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($user); - foreach ($xactions as $xaction) { - if ($xaction->getComment()) { - $engine->addObject( - $xaction->getComment(), - PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); - } - } - $engine->process(); - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($user) - ->setObjectPHID($file->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $file, + new PhabricatorFileTransactionQuery()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); diff --git a/src/applications/files/storage/PhabricatorFile.php b/src/applications/files/storage/PhabricatorFile.php index 48c178fa55..fff4abddbd 100644 --- a/src/applications/files/storage/PhabricatorFile.php +++ b/src/applications/files/storage/PhabricatorFile.php @@ -18,6 +18,7 @@ */ final class PhabricatorFile extends PhabricatorFileDAO implements + PhabricatorApplicationTransactionInterface, PhabricatorTokenReceiverInterface, PhabricatorSubscribableInterface, PhabricatorFlaggableInterface, @@ -1079,6 +1080,22 @@ final class PhabricatorFile extends PhabricatorFileDAO } +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new PhabricatorFileEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new PhabricatorFileTransaction(); + } + + /* -( PhabricatorPolicyInterface Implementation )-------------------------- */ diff --git a/src/applications/macro/controller/PhabricatorMacroViewController.php b/src/applications/macro/controller/PhabricatorMacroViewController.php index da9bc83260..3726c627a7 100644 --- a/src/applications/macro/controller/PhabricatorMacroViewController.php +++ b/src/applications/macro/controller/PhabricatorMacroViewController.php @@ -51,27 +51,9 @@ final class PhabricatorMacroViewController ))); } - $xactions = id(new PhabricatorMacroTransactionQuery()) - ->setViewer($request->getUser()) - ->withObjectPHIDs(array($macro->getPHID())) - ->execute(); - - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($user); - foreach ($xactions as $xaction) { - if ($xaction->getComment()) { - $engine->addObject( - $xaction->getComment(), - PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); - } - } - $engine->process(); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($user) - ->setObjectPHID($macro->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $macro, + new PhabricatorMacroTransactionQuery()); $header = id(new PHUIHeaderView()) ->setUser($user) diff --git a/src/applications/passphrase/controller/PassphraseCredentialViewController.php b/src/applications/passphrase/controller/PassphraseCredentialViewController.php index e99484a61b..18df3fe9af 100644 --- a/src/applications/passphrase/controller/PassphraseCredentialViewController.php +++ b/src/applications/passphrase/controller/PassphraseCredentialViewController.php @@ -26,18 +26,10 @@ final class PassphraseCredentialViewController extends PassphraseController { throw new Exception(pht('Credential has invalid type "%s"!', $type)); } - $xactions = id(new PassphraseCredentialTransactionQuery()) - ->setViewer($viewer) - ->withObjectPHIDs(array($credential->getPHID())) - ->execute(); - - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($viewer); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($viewer) - ->setObjectPHID($credential->getPHID()) - ->setTransactions($xactions); + $timeline = $this->buildTransactionTimeline( + $credential, + new PassphraseCredentialTransactionQuery()); + $timeline->setShouldTerminate(true); $title = pht('%s %s', 'K'.$credential->getID(), $credential->getName()); $crumbs = $this->buildApplicationCrumbs(); diff --git a/src/applications/passphrase/storage/PassphraseCredential.php b/src/applications/passphrase/storage/PassphraseCredential.php index 641988714d..ae1fe9d49a 100644 --- a/src/applications/passphrase/storage/PassphraseCredential.php +++ b/src/applications/passphrase/storage/PassphraseCredential.php @@ -1,8 +1,10 @@ setActionList($actions) ->addTextCrumb('P'.$paste->getID(), '/P'.$paste->getID()); - $xactions = id(new PhabricatorPasteTransactionQuery()) - ->setViewer($request->getUser()) - ->withObjectPHIDs(array($paste->getPHID())) - ->execute(); - - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($user); - foreach ($xactions as $xaction) { - if ($xaction->getComment()) { - $engine->addObject( - $xaction->getComment(), - PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT); - } - } - $engine->process(); - - $timeline = id(new PhabricatorApplicationTransactionView()) - ->setUser($user) - ->setObjectPHID($paste->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $paste, + new PhabricatorPasteTransactionQuery()); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); diff --git a/src/applications/phlux/controller/PhluxViewController.php b/src/applications/phlux/controller/PhluxViewController.php index f949b7f849..be19e7bd28 100644 --- a/src/applications/phlux/controller/PhluxViewController.php +++ b/src/applications/phlux/controller/PhluxViewController.php @@ -58,19 +58,10 @@ final class PhluxViewController extends PhluxController { ->setActionList($actions) ->addProperty(pht('Value'), $display_value); - $xactions = id(new PhluxTransactionQuery()) - ->setViewer($user) - ->withObjectPHIDs(array($var->getPHID())) - ->execute(); - - $engine = id(new PhabricatorMarkupEngine()) - ->setViewer($user); - - $xaction_view = id(new PhabricatorApplicationTransactionView()) - ->setUser($user) - ->setObjectPHID($var->getPHID()) - ->setTransactions($xactions) - ->setMarkupEngine($engine); + $timeline = $this->buildTransactionTimeline( + $var, + new PhluxTransactionQuery()); + $timeline->setShouldTerminate(true); $object_box = id(new PHUIObjectBoxView()) ->setHeader($header) @@ -80,7 +71,7 @@ final class PhluxViewController extends PhluxController { array( $crumbs, $object_box, - $xaction_view, + $timeline, ), array( 'title' => $title, diff --git a/src/applications/phlux/storage/PhluxVariable.php b/src/applications/phlux/storage/PhluxVariable.php index a6f27761c9..845bb27b63 100644 --- a/src/applications/phlux/storage/PhluxVariable.php +++ b/src/applications/phlux/storage/PhluxVariable.php @@ -2,6 +2,7 @@ final class PhluxVariable extends PhluxDAO implements + PhabricatorApplicationTransactionInterface, PhabricatorFlaggableInterface, PhabricatorPolicyInterface { @@ -33,6 +34,22 @@ final class PhluxVariable extends PhluxDAO } +/* -( PhabricatorApplicationTransactionInterface )------------------------- */ + + + public function getApplicationTransactionEditor() { + return new PhluxVariableEditor(); + } + + public function getApplicationTransactionObject() { + return $this; + } + + public function getApplicationTransactionTemplate() { + return new PhluxTransaction(); + } + + /* -( PhabricatorPolicyInterface )----------------------------------------- */