1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Remove "willRenderTimeline()" from ApplicationTransactionInterface

Summary:
Depends on D19914. Ref T11351. Some of the Phoilo rabbit holes go very deep.

`PhabricatorApplicationTransactionInterface` currently requires you to implement `willRenderTimeline()`. Almost every object just implements this as `return $timeline`; only Pholio, Diffusion, and Differential specialize it. In all cases, they are specializing it mostly to render inline comments.

The actual implementations are a bit of a weird mess and the way the data is threaded through the call stack is weird and not very modern.

Try to clean this up:

  - Stop requiring `willRenderTimeline()` to be implemented.
  - Stop requiring `getApplicationTransactionViewObject()` to be implemented (only the three above, plus Legalpad, implement this, and Legalpad's implementation is a no-op). These two methods are inherently pretty coupled for almost any reasonable thing you might want to do with the timeline.
  - Simplify the handling of "renderdata" and call it "View Data". This is additional information about the current view of the transaction timeline that is required to render it correctly. This is only used in Differential, to decide if we can link an inline comment to an anchor on the same page or should link it to another page. We could perhaps do this on the client instead, but having this data doesn't seem inherently bad to me.
  - If objects want to customize timeline rendering, they now implement `PhabricatorTimelineInterface` and provide a `TimelineEngine` which gets a nice formal stack.

This leaves a lot of empty `willRenderTimeline()` implementations hanging around. I'll remove these in the next change, it's just going to be deleting a couple dozen copies of an identical empty method implementation.

Test Plan:
  - Viewed audits, revisions, and mocks with inline comments.
  - Used "Show Older" to page a revision back in history (this is relevant for "View Data").
  - Grepped for symbols: willRenderTimeline, getApplicationTransactionViewObject, Legalpad classes.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T11351

Differential Revision: https://secure.phabricator.com/D19918
This commit is contained in:
epriestley 2018-12-19 11:52:53 -08:00
parent 21f07bf6f7
commit 6c43d1d52c
33 changed files with 366 additions and 230 deletions

View file

@ -10,7 +10,7 @@ return array(
'conpherence.pkg.css' => 'e68cf1fa', 'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => '15191c65', 'conpherence.pkg.js' => '15191c65',
'core.pkg.css' => '9d1148a4', 'core.pkg.css' => '9d1148a4',
'core.pkg.js' => '4bde473b', 'core.pkg.js' => 'bd89cb1d',
'differential.pkg.css' => '06dc617c', 'differential.pkg.css' => '06dc617c',
'differential.pkg.js' => 'ef0b989b', 'differential.pkg.js' => 'ef0b989b',
'diffusion.pkg.css' => 'a2d17c7d', 'diffusion.pkg.css' => 'a2d17c7d',
@ -425,7 +425,7 @@ return array(
'rsrc/js/application/transactions/behavior-comment-actions.js' => '59e27e74', 'rsrc/js/application/transactions/behavior-comment-actions.js' => '59e27e74',
'rsrc/js/application/transactions/behavior-reorder-configs.js' => 'd7a74243', 'rsrc/js/application/transactions/behavior-reorder-configs.js' => 'd7a74243',
'rsrc/js/application/transactions/behavior-reorder-fields.js' => 'b59e1e96', 'rsrc/js/application/transactions/behavior-reorder-fields.js' => 'b59e1e96',
'rsrc/js/application/transactions/behavior-show-older-transactions.js' => '8f29b364', 'rsrc/js/application/transactions/behavior-show-older-transactions.js' => '0e1eca96',
'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => 'b23b49e6', 'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => 'b23b49e6',
'rsrc/js/application/transactions/behavior-transaction-list.js' => '1f6794f6', 'rsrc/js/application/transactions/behavior-transaction-list.js' => '1f6794f6',
'rsrc/js/application/typeahead/behavior-typeahead-browse.js' => '635de1ec', 'rsrc/js/application/typeahead/behavior-typeahead-browse.js' => '635de1ec',
@ -639,7 +639,7 @@ return array(
'javelin-behavior-phabricator-remarkup-assist' => 'acd29eee', 'javelin-behavior-phabricator-remarkup-assist' => 'acd29eee',
'javelin-behavior-phabricator-reveal-content' => '60821bc7', 'javelin-behavior-phabricator-reveal-content' => '60821bc7',
'javelin-behavior-phabricator-search-typeahead' => 'c3e917d9', 'javelin-behavior-phabricator-search-typeahead' => 'c3e917d9',
'javelin-behavior-phabricator-show-older-transactions' => '8f29b364', 'javelin-behavior-phabricator-show-older-transactions' => '0e1eca96',
'javelin-behavior-phabricator-tooltips' => 'c420b0b9', 'javelin-behavior-phabricator-tooltips' => 'c420b0b9',
'javelin-behavior-phabricator-transaction-comment-form' => 'b23b49e6', 'javelin-behavior-phabricator-transaction-comment-form' => 'b23b49e6',
'javelin-behavior-phabricator-transaction-list' => '1f6794f6', 'javelin-behavior-phabricator-transaction-list' => '1f6794f6',
@ -950,6 +950,12 @@ return array(
'javelin-install', 'javelin-install',
'phuix-button-view', 'phuix-button-view',
), ),
'0e1eca96' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-busy',
),
'0f764c35' => array( '0f764c35' => array(
'javelin-install', 'javelin-install',
'javelin-util', 'javelin-util',
@ -1581,12 +1587,6 @@ return array(
'8e1baf68' => array( '8e1baf68' => array(
'phui-button-css', 'phui-button-css',
), ),
'8f29b364' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-busy',
),
'8ff5e24c' => array( '8ff5e24c' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',

View file

@ -647,6 +647,7 @@ phutil_register_library_map(array(
'DifferentialRevisionSummaryTransaction' => 'applications/differential/xaction/DifferentialRevisionSummaryTransaction.php', 'DifferentialRevisionSummaryTransaction' => 'applications/differential/xaction/DifferentialRevisionSummaryTransaction.php',
'DifferentialRevisionTestPlanHeraldField' => 'applications/differential/herald/DifferentialRevisionTestPlanHeraldField.php', 'DifferentialRevisionTestPlanHeraldField' => 'applications/differential/herald/DifferentialRevisionTestPlanHeraldField.php',
'DifferentialRevisionTestPlanTransaction' => 'applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php', 'DifferentialRevisionTestPlanTransaction' => 'applications/differential/xaction/DifferentialRevisionTestPlanTransaction.php',
'DifferentialRevisionTimelineEngine' => 'applications/differential/engine/DifferentialRevisionTimelineEngine.php',
'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php', 'DifferentialRevisionTitleHeraldField' => 'applications/differential/herald/DifferentialRevisionTitleHeraldField.php',
'DifferentialRevisionTitleTransaction' => 'applications/differential/xaction/DifferentialRevisionTitleTransaction.php', 'DifferentialRevisionTitleTransaction' => 'applications/differential/xaction/DifferentialRevisionTitleTransaction.php',
'DifferentialRevisionTransactionType' => 'applications/differential/xaction/DifferentialRevisionTransactionType.php', 'DifferentialRevisionTransactionType' => 'applications/differential/xaction/DifferentialRevisionTransactionType.php',
@ -769,6 +770,7 @@ phutil_register_library_map(array(
'DiffusionCommitSearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitSearchConduitAPIMethod.php', 'DiffusionCommitSearchConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitSearchConduitAPIMethod.php',
'DiffusionCommitStateTransaction' => 'applications/diffusion/xaction/DiffusionCommitStateTransaction.php', 'DiffusionCommitStateTransaction' => 'applications/diffusion/xaction/DiffusionCommitStateTransaction.php',
'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php', 'DiffusionCommitTagsController' => 'applications/diffusion/controller/DiffusionCommitTagsController.php',
'DiffusionCommitTimelineEngine' => 'applications/diffusion/engine/DiffusionCommitTimelineEngine.php',
'DiffusionCommitTransactionType' => 'applications/diffusion/xaction/DiffusionCommitTransactionType.php', 'DiffusionCommitTransactionType' => 'applications/diffusion/xaction/DiffusionCommitTransactionType.php',
'DiffusionCommitVerifyTransaction' => 'applications/diffusion/xaction/DiffusionCommitVerifyTransaction.php', 'DiffusionCommitVerifyTransaction' => 'applications/diffusion/xaction/DiffusionCommitVerifyTransaction.php',
'DiffusionCompareController' => 'applications/diffusion/controller/DiffusionCompareController.php', 'DiffusionCompareController' => 'applications/diffusion/controller/DiffusionCompareController.php',
@ -1630,7 +1632,6 @@ phutil_register_library_map(array(
'LegalpadTransaction' => 'applications/legalpad/storage/LegalpadTransaction.php', 'LegalpadTransaction' => 'applications/legalpad/storage/LegalpadTransaction.php',
'LegalpadTransactionComment' => 'applications/legalpad/storage/LegalpadTransactionComment.php', 'LegalpadTransactionComment' => 'applications/legalpad/storage/LegalpadTransactionComment.php',
'LegalpadTransactionQuery' => 'applications/legalpad/query/LegalpadTransactionQuery.php', 'LegalpadTransactionQuery' => 'applications/legalpad/query/LegalpadTransactionQuery.php',
'LegalpadTransactionView' => 'applications/legalpad/view/LegalpadTransactionView.php',
'LiskChunkTestCase' => 'infrastructure/storage/lisk/__tests__/LiskChunkTestCase.php', 'LiskChunkTestCase' => 'infrastructure/storage/lisk/__tests__/LiskChunkTestCase.php',
'LiskDAO' => 'infrastructure/storage/lisk/LiskDAO.php', 'LiskDAO' => 'infrastructure/storage/lisk/LiskDAO.php',
'LiskDAOTestCase' => 'infrastructure/storage/lisk/__tests__/LiskDAOTestCase.php', 'LiskDAOTestCase' => 'infrastructure/storage/lisk/__tests__/LiskDAOTestCase.php',
@ -4433,6 +4434,7 @@ phutil_register_library_map(array(
'PhabricatorStandardCustomFieldUsers' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php', 'PhabricatorStandardCustomFieldUsers' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php',
'PhabricatorStandardPageView' => 'view/page/PhabricatorStandardPageView.php', 'PhabricatorStandardPageView' => 'view/page/PhabricatorStandardPageView.php',
'PhabricatorStandardSelectCustomFieldDatasource' => 'infrastructure/customfield/datasource/PhabricatorStandardSelectCustomFieldDatasource.php', 'PhabricatorStandardSelectCustomFieldDatasource' => 'infrastructure/customfield/datasource/PhabricatorStandardSelectCustomFieldDatasource.php',
'PhabricatorStandardTimelineEngine' => 'applications/transactions/engine/PhabricatorStandardTimelineEngine.php',
'PhabricatorStaticEditField' => 'applications/transactions/editfield/PhabricatorStaticEditField.php', 'PhabricatorStaticEditField' => 'applications/transactions/editfield/PhabricatorStaticEditField.php',
'PhabricatorStatusController' => 'applications/system/controller/PhabricatorStatusController.php', 'PhabricatorStatusController' => 'applications/system/controller/PhabricatorStatusController.php',
'PhabricatorStatusUIExample' => 'applications/uiexample/examples/PhabricatorStatusUIExample.php', 'PhabricatorStatusUIExample' => 'applications/uiexample/examples/PhabricatorStatusUIExample.php',
@ -4532,6 +4534,8 @@ phutil_register_library_map(array(
'PhabricatorTimeFormatSetting' => 'applications/settings/setting/PhabricatorTimeFormatSetting.php', 'PhabricatorTimeFormatSetting' => 'applications/settings/setting/PhabricatorTimeFormatSetting.php',
'PhabricatorTimeGuard' => 'infrastructure/time/PhabricatorTimeGuard.php', 'PhabricatorTimeGuard' => 'infrastructure/time/PhabricatorTimeGuard.php',
'PhabricatorTimeTestCase' => 'infrastructure/time/__tests__/PhabricatorTimeTestCase.php', 'PhabricatorTimeTestCase' => 'infrastructure/time/__tests__/PhabricatorTimeTestCase.php',
'PhabricatorTimelineEngine' => 'applications/transactions/engine/PhabricatorTimelineEngine.php',
'PhabricatorTimelineInterface' => 'applications/transactions/interface/PhabricatorTimelineInterface.php',
'PhabricatorTimezoneIgnoreOffsetSetting' => 'applications/settings/setting/PhabricatorTimezoneIgnoreOffsetSetting.php', 'PhabricatorTimezoneIgnoreOffsetSetting' => 'applications/settings/setting/PhabricatorTimezoneIgnoreOffsetSetting.php',
'PhabricatorTimezoneSetting' => 'applications/settings/setting/PhabricatorTimezoneSetting.php', 'PhabricatorTimezoneSetting' => 'applications/settings/setting/PhabricatorTimezoneSetting.php',
'PhabricatorTimezoneSetupCheck' => 'applications/config/check/PhabricatorTimezoneSetupCheck.php', 'PhabricatorTimezoneSetupCheck' => 'applications/config/check/PhabricatorTimezoneSetupCheck.php',
@ -4871,6 +4875,7 @@ phutil_register_library_map(array(
'PholioMockSearchEngine' => 'applications/pholio/query/PholioMockSearchEngine.php', 'PholioMockSearchEngine' => 'applications/pholio/query/PholioMockSearchEngine.php',
'PholioMockStatusTransaction' => 'applications/pholio/xaction/PholioMockStatusTransaction.php', 'PholioMockStatusTransaction' => 'applications/pholio/xaction/PholioMockStatusTransaction.php',
'PholioMockThumbGridView' => 'applications/pholio/view/PholioMockThumbGridView.php', 'PholioMockThumbGridView' => 'applications/pholio/view/PholioMockThumbGridView.php',
'PholioMockTimelineEngine' => 'applications/pholio/engine/PholioMockTimelineEngine.php',
'PholioMockTransactionType' => 'applications/pholio/xaction/PholioMockTransactionType.php', 'PholioMockTransactionType' => 'applications/pholio/xaction/PholioMockTransactionType.php',
'PholioMockViewController' => 'applications/pholio/controller/PholioMockViewController.php', 'PholioMockViewController' => 'applications/pholio/controller/PholioMockViewController.php',
'PholioRemarkupRule' => 'applications/pholio/remarkup/PholioRemarkupRule.php', 'PholioRemarkupRule' => 'applications/pholio/remarkup/PholioRemarkupRule.php',
@ -5991,6 +5996,7 @@ phutil_register_library_map(array(
'PhabricatorSubscribableInterface', 'PhabricatorSubscribableInterface',
'PhabricatorCustomFieldInterface', 'PhabricatorCustomFieldInterface',
'PhabricatorApplicationTransactionInterface', 'PhabricatorApplicationTransactionInterface',
'PhabricatorTimelineInterface',
'PhabricatorMentionableInterface', 'PhabricatorMentionableInterface',
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
'PhabricatorProjectInterface', 'PhabricatorProjectInterface',
@ -6072,6 +6078,7 @@ phutil_register_library_map(array(
'DifferentialRevisionSummaryTransaction' => 'DifferentialRevisionTransactionType', 'DifferentialRevisionSummaryTransaction' => 'DifferentialRevisionTransactionType',
'DifferentialRevisionTestPlanHeraldField' => 'DifferentialRevisionHeraldField', 'DifferentialRevisionTestPlanHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionTestPlanTransaction' => 'DifferentialRevisionTransactionType', 'DifferentialRevisionTestPlanTransaction' => 'DifferentialRevisionTransactionType',
'DifferentialRevisionTimelineEngine' => 'PhabricatorTimelineEngine',
'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField', 'DifferentialRevisionTitleHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionTitleTransaction' => 'DifferentialRevisionTransactionType', 'DifferentialRevisionTitleTransaction' => 'DifferentialRevisionTransactionType',
'DifferentialRevisionTransactionType' => 'PhabricatorModularTransactionType', 'DifferentialRevisionTransactionType' => 'PhabricatorModularTransactionType',
@ -6194,6 +6201,7 @@ phutil_register_library_map(array(
'DiffusionCommitSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod', 'DiffusionCommitSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'DiffusionCommitStateTransaction' => 'DiffusionCommitTransactionType', 'DiffusionCommitStateTransaction' => 'DiffusionCommitTransactionType',
'DiffusionCommitTagsController' => 'DiffusionController', 'DiffusionCommitTagsController' => 'DiffusionController',
'DiffusionCommitTimelineEngine' => 'PhabricatorTimelineEngine',
'DiffusionCommitTransactionType' => 'PhabricatorModularTransactionType', 'DiffusionCommitTransactionType' => 'PhabricatorModularTransactionType',
'DiffusionCommitVerifyTransaction' => 'DiffusionCommitAuditTransaction', 'DiffusionCommitVerifyTransaction' => 'DiffusionCommitAuditTransaction',
'DiffusionCompareController' => 'DiffusionController', 'DiffusionCompareController' => 'DiffusionController',
@ -7201,7 +7209,6 @@ phutil_register_library_map(array(
'LegalpadTransaction' => 'PhabricatorModularTransaction', 'LegalpadTransaction' => 'PhabricatorModularTransaction',
'LegalpadTransactionComment' => 'PhabricatorApplicationTransactionComment', 'LegalpadTransactionComment' => 'PhabricatorApplicationTransactionComment',
'LegalpadTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'LegalpadTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'LegalpadTransactionView' => 'PhabricatorApplicationTransactionView',
'LiskChunkTestCase' => 'PhabricatorTestCase', 'LiskChunkTestCase' => 'PhabricatorTestCase',
'LiskDAO' => array( 'LiskDAO' => array(
'Phobject', 'Phobject',
@ -10079,6 +10086,7 @@ phutil_register_library_map(array(
'HarbormasterBuildkiteBuildableInterface', 'HarbormasterBuildkiteBuildableInterface',
'PhabricatorCustomFieldInterface', 'PhabricatorCustomFieldInterface',
'PhabricatorApplicationTransactionInterface', 'PhabricatorApplicationTransactionInterface',
'PhabricatorTimelineInterface',
'PhabricatorFulltextInterface', 'PhabricatorFulltextInterface',
'PhabricatorFerretInterface', 'PhabricatorFerretInterface',
'PhabricatorConduitResultInterface', 'PhabricatorConduitResultInterface',
@ -10469,6 +10477,7 @@ phutil_register_library_map(array(
'AphrontResponseProducerInterface', 'AphrontResponseProducerInterface',
), ),
'PhabricatorStandardSelectCustomFieldDatasource' => 'PhabricatorTypeaheadDatasource', 'PhabricatorStandardSelectCustomFieldDatasource' => 'PhabricatorTypeaheadDatasource',
'PhabricatorStandardTimelineEngine' => 'PhabricatorTimelineEngine',
'PhabricatorStaticEditField' => 'PhabricatorEditField', 'PhabricatorStaticEditField' => 'PhabricatorEditField',
'PhabricatorStatusController' => 'PhabricatorController', 'PhabricatorStatusController' => 'PhabricatorController',
'PhabricatorStatusUIExample' => 'PhabricatorUIExample', 'PhabricatorStatusUIExample' => 'PhabricatorUIExample',
@ -10567,6 +10576,7 @@ phutil_register_library_map(array(
'PhabricatorTimeFormatSetting' => 'PhabricatorSelectSetting', 'PhabricatorTimeFormatSetting' => 'PhabricatorSelectSetting',
'PhabricatorTimeGuard' => 'Phobject', 'PhabricatorTimeGuard' => 'Phobject',
'PhabricatorTimeTestCase' => 'PhabricatorTestCase', 'PhabricatorTimeTestCase' => 'PhabricatorTestCase',
'PhabricatorTimelineEngine' => 'Phobject',
'PhabricatorTimezoneIgnoreOffsetSetting' => 'PhabricatorInternalSetting', 'PhabricatorTimezoneIgnoreOffsetSetting' => 'PhabricatorInternalSetting',
'PhabricatorTimezoneSetting' => 'PhabricatorOptionGroupSetting', 'PhabricatorTimezoneSetting' => 'PhabricatorOptionGroupSetting',
'PhabricatorTimezoneSetupCheck' => 'PhabricatorSetupCheck', 'PhabricatorTimezoneSetupCheck' => 'PhabricatorSetupCheck',
@ -10967,6 +10977,7 @@ phutil_register_library_map(array(
'PhabricatorTokenReceiverInterface', 'PhabricatorTokenReceiverInterface',
'PhabricatorFlaggableInterface', 'PhabricatorFlaggableInterface',
'PhabricatorApplicationTransactionInterface', 'PhabricatorApplicationTransactionInterface',
'PhabricatorTimelineInterface',
'PhabricatorProjectInterface', 'PhabricatorProjectInterface',
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
'PhabricatorSpacesInterface', 'PhabricatorSpacesInterface',
@ -11001,6 +11012,7 @@ phutil_register_library_map(array(
'PholioMockSearchEngine' => 'PhabricatorApplicationSearchEngine', 'PholioMockSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PholioMockStatusTransaction' => 'PholioMockTransactionType', 'PholioMockStatusTransaction' => 'PholioMockTransactionType',
'PholioMockThumbGridView' => 'AphrontView', 'PholioMockThumbGridView' => 'AphrontView',
'PholioMockTimelineEngine' => 'PhabricatorTimelineEngine',
'PholioMockTransactionType' => 'PholioTransactionType', 'PholioMockTransactionType' => 'PholioTransactionType',
'PholioMockViewController' => 'PholioController', 'PholioMockViewController' => 'PholioController',
'PholioRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'PholioRemarkupRule' => 'PhabricatorObjectRemarkupRule',

View file

@ -32,10 +32,6 @@ final class PhabricatorAuditTransaction
return new PhabricatorAuditTransactionComment(); return new PhabricatorAuditTransactionComment();
} }
public function getApplicationTransactionViewObject() {
return new PhabricatorAuditTransactionView();
}
public function getRemarkupBlocks() { public function getRemarkupBlocks() {
$blocks = parent::getRemarkupBlocks(); $blocks = parent::getRemarkupBlocks();

View file

@ -51,6 +51,7 @@ final class PhabricatorBadgesCommentController
if ($request->isAjax() && $is_preview) { if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setObject($badge)
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview); ->setIsPreview($is_preview);

View file

@ -482,14 +482,14 @@ abstract class PhabricatorController extends AphrontController {
PhabricatorApplicationTransactionInterface $object, PhabricatorApplicationTransactionInterface $object,
PhabricatorApplicationTransactionQuery $query, PhabricatorApplicationTransactionQuery $query,
PhabricatorMarkupEngine $engine = null, PhabricatorMarkupEngine $engine = null,
$render_data = array()) { $view_data = array()) {
$viewer = $this->getRequest()->getUser(); $request = $this->getRequest();
$viewer = $this->getViewer();
$xaction = $object->getApplicationTransactionTemplate(); $xaction = $object->getApplicationTransactionTemplate();
$view = $xaction->getApplicationTransactionViewObject();
$pager = id(new AphrontCursorPagerView()) $pager = id(new AphrontCursorPagerView())
->readFromRequest($this->getRequest()) ->readFromRequest($request)
->setURI(new PhutilURI( ->setURI(new PhutilURI(
'/transactions/showolder/'.$object->getPHID().'/')); '/transactions/showolder/'.$object->getPHID().'/'));
@ -500,6 +500,13 @@ abstract class PhabricatorController extends AphrontController {
->executeWithCursorPager($pager); ->executeWithCursorPager($pager);
$xactions = array_reverse($xactions); $xactions = array_reverse($xactions);
$timeline_engine = PhabricatorTimelineEngine::newForObject($object)
->setViewer($viewer)
->setTransactions($xactions)
->setViewData($view_data);
$view = $timeline_engine->buildTimelineView();
if ($engine) { if ($engine) {
foreach ($xactions as $xaction) { foreach ($xactions as $xaction) {
if ($xaction->getComment()) { if ($xaction->getComment()) {
@ -513,14 +520,9 @@ abstract class PhabricatorController extends AphrontController {
} }
$timeline = $view $timeline = $view
->setUser($viewer)
->setObjectPHID($object->getPHID())
->setTransactions($xactions)
->setPager($pager) ->setPager($pager)
->setRenderData($render_data)
->setQuoteTargetID($this->getRequest()->getStr('quoteTargetID')) ->setQuoteTargetID($this->getRequest()->getStr('quoteTargetID'))
->setQuoteRef($this->getRequest()->getStr('quoteRef')); ->setQuoteRef($this->getRequest()->getStr('quoteRef'));
$object->willRenderTimeline($timeline, $this->getRequest());
return $timeline; return $timeline;
} }

View file

@ -16,18 +16,14 @@ final class PhabricatorConfigHistoryController
$xaction = $object->getApplicationTransactionTemplate(); $xaction = $object->getApplicationTransactionTemplate();
$view = $xaction->getApplicationTransactionViewObject(); $timeline = id(new PhabricatorApplicationTransactionView())
->setViewer($viewer)
$timeline = $view
->setUser($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setRenderAsFeed(true) ->setRenderAsFeed(true)
->setObjectPHID(PhabricatorPHIDConstants::PHID_VOID); ->setObjectPHID(PhabricatorPHIDConstants::PHID_VOID);
$timeline->setShouldTerminate(true); $timeline->setShouldTerminate(true);
$object->willRenderTimeline($timeline, $this->getRequest());
$title = pht('Settings History'); $title = pht('Settings History');
$header = $this->buildHeaderView($title); $header = $this->buildHeaderView($title);

View file

@ -0,0 +1,78 @@
<?php
final class DifferentialRevisionTimelineEngine
extends PhabricatorTimelineEngine {
protected function newTimelineView() {
$viewer = $this->getViewer();
$xactions = $this->getTransactions();
$revision = $this->getObject();
$view_data = $this->getViewData();
if (!$view_data) {
$view_data = array();
}
$left = idx($view_data, 'left');
$right = idx($view_data, 'right');
$diffs = id(new DifferentialDiffQuery())
->setViewer($viewer)
->withIDs(array($left, $right))
->execute();
$diffs = mpull($diffs, null, 'getID');
$left_diff = $diffs[$left];
$right_diff = $diffs[$right];
$old_ids = idx($view_data, 'old');
$new_ids = idx($view_data, 'new');
$old_ids = array_filter(explode(',', $old_ids));
$new_ids = array_filter(explode(',', $new_ids));
$type_inline = DifferentialTransaction::TYPE_INLINE;
$changeset_ids = array_merge($old_ids, $new_ids);
$inlines = array();
foreach ($xactions as $xaction) {
if ($xaction->getTransactionType() == $type_inline) {
$inlines[] = $xaction->getComment();
$changeset_ids[] = $xaction->getComment()->getChangesetID();
}
}
if ($changeset_ids) {
$changesets = id(new DifferentialChangesetQuery())
->setViewer($viewer)
->withIDs($changeset_ids)
->execute();
$changesets = mpull($changesets, null, 'getID');
} else {
$changesets = array();
}
foreach ($inlines as $key => $inline) {
$inlines[$key] = DifferentialInlineComment::newFromModernComment(
$inline);
}
$query = id(new DifferentialInlineCommentQuery())
->needHidden(true)
->setViewer($viewer);
// NOTE: This is a bit sketchy: this method adjusts the inlines as a
// side effect, which means it will ultimately adjust the transaction
// comments and affect timeline rendering.
$query->adjustInlinesForChangesets(
$inlines,
array_select_keys($changesets, $old_ids),
array_select_keys($changesets, $new_ids),
$revision);
return id(new DifferentialTransactionView())
->setViewData($view_data)
->setChangesets($changesets)
->setRevision($revision)
->setLeftDiff($left_diff)
->setRightDiff($right_diff);
}
}

View file

@ -11,6 +11,7 @@ final class DifferentialRevision extends DifferentialDAO
PhabricatorSubscribableInterface, PhabricatorSubscribableInterface,
PhabricatorCustomFieldInterface, PhabricatorCustomFieldInterface,
PhabricatorApplicationTransactionInterface, PhabricatorApplicationTransactionInterface,
PhabricatorTimelineInterface,
PhabricatorMentionableInterface, PhabricatorMentionableInterface,
PhabricatorDestructibleInterface, PhabricatorDestructibleInterface,
PhabricatorProjectInterface, PhabricatorProjectInterface,
@ -998,73 +999,6 @@ final class DifferentialRevision extends DifferentialDAO
return new DifferentialTransaction(); return new DifferentialTransaction();
} }
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
$viewer = $request->getViewer();
$render_data = $timeline->getRenderData();
$left = $request->getInt('left', idx($render_data, 'left'));
$right = $request->getInt('right', idx($render_data, 'right'));
$diffs = id(new DifferentialDiffQuery())
->setViewer($request->getUser())
->withIDs(array($left, $right))
->execute();
$diffs = mpull($diffs, null, 'getID');
$left_diff = $diffs[$left];
$right_diff = $diffs[$right];
$old_ids = $request->getStr('old', idx($render_data, 'old'));
$new_ids = $request->getStr('new', idx($render_data, 'new'));
$old_ids = array_filter(explode(',', $old_ids));
$new_ids = array_filter(explode(',', $new_ids));
$type_inline = DifferentialTransaction::TYPE_INLINE;
$changeset_ids = array_merge($old_ids, $new_ids);
$inlines = array();
foreach ($timeline->getTransactions() as $xaction) {
if ($xaction->getTransactionType() == $type_inline) {
$inlines[] = $xaction->getComment();
$changeset_ids[] = $xaction->getComment()->getChangesetID();
}
}
if ($changeset_ids) {
$changesets = id(new DifferentialChangesetQuery())
->setViewer($request->getUser())
->withIDs($changeset_ids)
->execute();
$changesets = mpull($changesets, null, 'getID');
} else {
$changesets = array();
}
foreach ($inlines as $key => $inline) {
$inlines[$key] = DifferentialInlineComment::newFromModernComment(
$inline);
}
$query = id(new DifferentialInlineCommentQuery())
->needHidden(true)
->setViewer($viewer);
// NOTE: This is a bit sketchy: this method adjusts the inlines as a
// side effect, which means it will ultimately adjust the transaction
// comments and affect timeline rendering.
$query->adjustInlinesForChangesets(
$inlines,
array_select_keys($changesets, $old_ids),
array_select_keys($changesets, $new_ids),
$this);
return $timeline
->setChangesets($changesets)
->setRevision($this)
->setLeftDiff($left_diff)
->setRightDiff($right_diff);
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */ /* -( PhabricatorDestructibleInterface )----------------------------------- */
@ -1206,4 +1140,13 @@ final class DifferentialRevision extends DifferentialDAO
return new DifferentialRevisionDraftEngine(); return new DifferentialRevisionDraftEngine();
} }
/* -( PhabricatorTimelineInterface )--------------------------------------- */
public function newTimelineEngine() {
return new DifferentialRevisionTimelineEngine();
}
} }

View file

@ -65,10 +65,6 @@ final class DifferentialTransaction
return new DifferentialTransactionComment(); return new DifferentialTransactionComment();
} }
public function getApplicationTransactionViewObject() {
return new DifferentialTransactionView();
}
public function shouldHide() { public function shouldHide() {
$old = $this->getOldValue(); $old = $this->getOldValue();
$new = $this->getNewValue(); $new = $this->getNewValue();

View file

@ -740,8 +740,6 @@ final class DiffusionCommitController extends DiffusionController {
$commit, $commit,
new PhabricatorAuditTransactionQuery()); new PhabricatorAuditTransactionQuery());
$commit->willRenderTimeline($timeline, $this->getRequest());
$timeline->setQuoteRef($commit->getMonogram()); $timeline->setQuoteRef($commit->getMonogram());
return $timeline; return $timeline;

View file

@ -0,0 +1,30 @@
<?php
final class DiffusionCommitTimelineEngine
extends PhabricatorTimelineEngine {
protected function newTimelineView() {
$xactions = $this->getTransactions();
$path_ids = array();
foreach ($xactions as $xaction) {
if ($xaction->hasComment()) {
$path_id = $xaction->getComment()->getPathID();
if ($path_id) {
$path_ids[] = $path_id;
}
}
}
$path_map = array();
if ($path_ids) {
$path_map = id(new DiffusionPathQuery())
->withPathIDs($path_ids)
->execute();
$path_map = ipull($path_map, 'path', 'id');
}
return id(new PhabricatorAuditTransactionView())
->setPathMap($path_map);
}
}

View file

@ -14,10 +14,6 @@ final class LegalpadTransaction extends PhabricatorModularTransaction {
return new LegalpadTransactionComment(); return new LegalpadTransactionComment();
} }
public function getApplicationTransactionViewObject() {
return new LegalpadTransactionView();
}
public function getBaseTransactionClass() { public function getBaseTransactionClass() {
return 'LegalpadDocumentTransactionType'; return 'LegalpadDocumentTransactionType';
} }

View file

@ -1,4 +0,0 @@
<?php
final class LegalpadTransactionView
extends PhabricatorApplicationTransactionView {}

View file

@ -68,13 +68,10 @@ final class PholioMockCommentController extends PholioController {
} }
if ($request->isAjax() && $is_preview) { if ($request->isAjax() && $is_preview) {
$xaction_view = id(new PholioTransactionView())
->setMock($mock);
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setObject($mock)
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setTransactionView($xaction_view)
->setIsPreview($is_preview); ->setIsPreview($is_preview);
} else { } else {
return id(new AphrontRedirectResponse())->setURI($mock_uri); return id(new AphrontRedirectResponse())->setURI($mock_uri);

View file

@ -0,0 +1,19 @@
<?php
final class PholioMockTimelineEngine
extends PhabricatorTimelineEngine {
protected function newTimelineView() {
$viewer = $this->getViewer();
$object = $this->getObject();
PholioMockQuery::loadImages(
$viewer,
array($object),
$need_inline_comments = true);
return id(new PholioTransactionView())
->setMock($object);
}
}

View file

@ -7,6 +7,7 @@ final class PholioMock extends PholioDAO
PhabricatorTokenReceiverInterface, PhabricatorTokenReceiverInterface,
PhabricatorFlaggableInterface, PhabricatorFlaggableInterface,
PhabricatorApplicationTransactionInterface, PhabricatorApplicationTransactionInterface,
PhabricatorTimelineInterface,
PhabricatorProjectInterface, PhabricatorProjectInterface,
PhabricatorDestructibleInterface, PhabricatorDestructibleInterface,
PhabricatorSpacesInterface, PhabricatorSpacesInterface,
@ -228,17 +229,6 @@ final class PholioMock extends PholioDAO
return new PholioTransaction(); return new PholioTransaction();
} }
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
PholioMockQuery::loadImages(
$request->getUser(),
array($this),
$need_inline_comments = true);
$timeline->setMock($this);
return $timeline;
}
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */ /* -( PhabricatorTokenReceiverInterface )---------------------------------- */
@ -288,9 +278,18 @@ final class PholioMock extends PholioDAO
/* -( PhabricatorFerretInterface )----------------------------------------- */ /* -( PhabricatorFerretInterface )----------------------------------------- */
public function newFerretEngine() { public function newFerretEngine() {
return new PholioMockFerretEngine(); return new PholioMockFerretEngine();
} }
/* -( PhabricatorTimelineInterace )---------------------------------------- */
public function newTimelineEngine() {
return new PholioMockTimelineEngine();
}
} }

View file

@ -23,10 +23,6 @@ final class PholioTransaction extends PhabricatorModularTransaction {
return new PholioTransactionComment(); return new PholioTransactionComment();
} }
public function getApplicationTransactionViewObject() {
return new PholioTransactionView();
}
public function getMailTags() { public function getMailTags() {
$tags = array(); $tags = array();
switch ($this->getTransactionType()) { switch ($this->getTransactionType()) {

View file

@ -50,6 +50,7 @@ final class PonderAnswerCommentController extends PonderController {
if ($request->isAjax() && $is_preview) { if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setObject($answer)
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview); ->setIsPreview($is_preview);

View file

@ -46,6 +46,7 @@ final class PonderQuestionCommentController extends PonderController {
if ($request->isAjax() && $is_preview) { if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setObject($question)
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview); ->setIsPreview($is_preview);

View file

@ -51,6 +51,7 @@ final class ReleephRequestCommentController
if ($request->isAjax() && $is_preview) { if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setObject($pull)
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview); ->setIsPreview($is_preview);

View file

@ -14,6 +14,7 @@ final class PhabricatorRepositoryCommit
HarbormasterBuildkiteBuildableInterface, HarbormasterBuildkiteBuildableInterface,
PhabricatorCustomFieldInterface, PhabricatorCustomFieldInterface,
PhabricatorApplicationTransactionInterface, PhabricatorApplicationTransactionInterface,
PhabricatorTimelineInterface,
PhabricatorFulltextInterface, PhabricatorFulltextInterface,
PhabricatorFerretInterface, PhabricatorFerretInterface,
PhabricatorConduitResultInterface, PhabricatorConduitResultInterface,
@ -738,33 +739,6 @@ final class PhabricatorRepositoryCommit
return new PhabricatorAuditTransaction(); return new PhabricatorAuditTransaction();
} }
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
$xactions = $timeline->getTransactions();
$path_ids = array();
foreach ($xactions as $xaction) {
if ($xaction->hasComment()) {
$path_id = $xaction->getComment()->getPathID();
if ($path_id) {
$path_ids[] = $path_id;
}
}
}
$path_map = array();
if ($path_ids) {
$path_map = id(new DiffusionPathQuery())
->withPathIDs($path_ids)
->execute();
$path_map = ipull($path_map, 'path', 'id');
}
return $timeline->setPathMap($path_map);
}
/* -( PhabricatorFulltextInterface )--------------------------------------- */ /* -( PhabricatorFulltextInterface )--------------------------------------- */
@ -916,4 +890,12 @@ final class PhabricatorRepositoryCommit
return $this; return $this;
} }
/* -( PhabricatorTimelineInterface )--------------------------------------- */
public function newTimelineEngine() {
return new DiffusionCommitTimelineEngine();
}
} }

View file

@ -51,6 +51,7 @@ final class PhabricatorSlowvoteCommentController
if ($request->isAjax() && $is_preview) { if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setObject($poll)
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview); ->setIsPreview($is_preview);

View file

@ -27,7 +27,18 @@ final class PhabricatorApplicationTransactionShowOlderController
return new Aphront404Response(); return new Aphront404Response();
} }
$timeline = $this->buildTransactionTimeline($object, $query); $raw_view_data = $request->getStr('viewData');
try {
$view_data = phutil_json_decode($raw_view_data);
} catch (Exception $ex) {
$view_data = array();
}
$timeline = $this->buildTransactionTimeline(
$object,
$query,
null,
$view_data);
$phui_timeline = $timeline->buildPHUITimelineView($with_hiding = false); $phui_timeline = $timeline->buildPHUITimelineView($with_hiding = false);
$phui_timeline->setShouldAddSpacers(false); $phui_timeline->setShouldAddSpacers(false);

View file

@ -1955,6 +1955,7 @@ abstract class PhabricatorEditEngine
$preview_content = $this->newCommentPreviewContent($object, $xactions); $preview_content = $this->newCommentPreviewContent($object, $xactions);
return id(new PhabricatorApplicationTransactionResponse()) return id(new PhabricatorApplicationTransactionResponse())
->setObject($object)
->setViewer($viewer) ->setViewer($viewer)
->setTransactions($xactions) ->setTransactions($xactions)
->setIsPreview($is_preview) ->setIsPreview($is_preview)

View file

@ -0,0 +1,4 @@
<?php
final class PhabricatorStandardTimelineEngine
extends PhabricatorTimelineEngine {}

View file

@ -0,0 +1,95 @@
<?php
abstract class PhabricatorTimelineEngine
extends Phobject {
private $viewer;
private $object;
private $xactions;
private $viewData;
final public static function newForObject($object) {
if ($object instanceof PhabricatorTimelineInterface) {
$engine = $object->newTimelineEngine();
} else {
$engine = new PhabricatorStandardTimelineEngine();
}
$engine->setObject($object);
return $engine;
}
final public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
final public function getViewer() {
return $this->viewer;
}
final public function setObject($object) {
$this->object = $object;
return $this;
}
final public function getObject() {
return $this->object;
}
final public function setTransactions(array $xactions) {
assert_instances_of($xactions, 'PhabricatorApplicationTransaction');
$this->xactions = $xactions;
return $this;
}
final public function getTransactions() {
return $this->xactions;
}
final public function setRequest(AphrontRequest $request) {
$this->request = $request;
return $this;
}
final public function getRequest() {
return $this->request;
}
final public function setViewData(array $view_data) {
$this->viewData = $view_data;
return $this;
}
final public function getViewData() {
return $this->viewData;
}
final public function buildTimelineView() {
$view = $this->newTimelineView();
if (!($view instanceof PhabricatorApplicationTransactionView)) {
throw new Exception(
pht(
'Expected "newTimelineView()" to return an object of class "%s" '.
'(in engine "%s").',
'PhabricatorApplicationTransactionView',
get_class($this)));
}
$viewer = $this->getViewer();
$object = $this->getObject();
$xactions = $this->getTransactions();
return $view
->setViewer($viewer)
->setObjectPHID($object->getPHID())
->setTransactions($xactions);
}
protected function newTimelineView() {
return new PhabricatorApplicationTransactionView();
}
}

View file

@ -35,15 +35,6 @@ interface PhabricatorApplicationTransactionInterface {
*/ */
public function getApplicationTransactionTemplate(); public function getApplicationTransactionTemplate();
/**
* Hook to augment the $timeline with additional data for rendering.
*
* @return PhabricatorApplicationTransactionView
*/
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request);
} }
// TEMPLATE IMPLEMENTATION ///////////////////////////////////////////////////// // TEMPLATE IMPLEMENTATION /////////////////////////////////////////////////////
@ -64,11 +55,4 @@ interface PhabricatorApplicationTransactionInterface {
return new <<<???>>>Transaction(); return new <<<???>>>Transaction();
} }
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
*/ */

View file

@ -0,0 +1,7 @@
<?php
interface PhabricatorTimelineInterface {
public function newTimelineEngine();
}

View file

@ -6,17 +6,8 @@ final class PhabricatorApplicationTransactionResponse
private $viewer; private $viewer;
private $transactions; private $transactions;
private $isPreview; private $isPreview;
private $transactionView;
private $previewContent; private $previewContent;
private $object;
public function setTransactionView($transaction_view) {
$this->transactionView = $transaction_view;
return $this;
}
public function getTransactionView() {
return $this->transactionView;
}
protected function buildProxy() { protected function buildProxy() {
return new AphrontAjaxResponse(); return new AphrontAjaxResponse();
@ -33,6 +24,15 @@ final class PhabricatorApplicationTransactionResponse
return $this->transactions; return $this->transactions;
} }
public function setObject($object) {
$this->object = $object;
return $this;
}
public function getObject() {
return $this->object;
}
public function setViewer(PhabricatorUser $viewer) { public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer; $this->viewer = $viewer;
return $this; return $this;
@ -57,19 +57,17 @@ final class PhabricatorApplicationTransactionResponse
} }
public function reduceProxyResponse() { public function reduceProxyResponse() {
if ($this->transactionView) { $object = $this->getObject();
$view = $this->transactionView; $viewer = $this->getViewer();
} else if ($this->getTransactions()) { $xactions = $this->getTransactions();
$view = head($this->getTransactions())
->getApplicationTransactionViewObject();
} else {
$view = new PhabricatorApplicationTransactionView();
}
$view $timeline_engine = PhabricatorTimelineEngine::newForObject($object)
->setUser($this->getViewer()) ->setViewer($viewer)
->setTransactions($this->getTransactions()) ->setTransactions($xactions);
->setIsPreview($this->isPreview);
$view = $timeline_engine->buildTimelineView();
$view->setIsPreview($this->isPreview);
if ($this->isPreview) { if ($this->isPreview) {
$xactions = mpull($view->buildEvents(), 'render'); $xactions = mpull($view->buildEvents(), 'render');

View file

@ -79,10 +79,6 @@ abstract class PhabricatorApplicationTransaction
throw new PhutilMethodNotImplementedException(); throw new PhutilMethodNotImplementedException();
} }
public function getApplicationTransactionViewObject() {
return new PhabricatorApplicationTransactionView();
}
public function getMetadataValue($key, $default = null) { public function getMetadataValue($key, $default = null) {
return idx($this->metadata, $key, $default); return idx($this->metadata, $key, $default);
} }

View file

@ -15,8 +15,8 @@ class PhabricatorApplicationTransactionView extends AphrontView {
private $quoteRef; private $quoteRef;
private $pager; private $pager;
private $renderAsFeed; private $renderAsFeed;
private $renderData = array();
private $hideCommentOptions = false; private $hideCommentOptions = false;
private $viewData = array();
public function setRenderAsFeed($feed) { public function setRenderAsFeed($feed) {
$this->renderAsFeed = $feed; $this->renderAsFeed = $feed;
@ -97,21 +97,6 @@ class PhabricatorApplicationTransactionView extends AphrontView {
return $this->pager; return $this->pager;
} }
/**
* This is additional data that may be necessary to render the next set
* of transactions. Objects that implement
* PhabricatorApplicationTransactionInterface use this data in
* willRenderTimeline.
*/
public function setRenderData(array $data) {
$this->renderData = $data;
return $this;
}
public function getRenderData() {
return $this->renderData;
}
public function setHideCommentOptions($hide_comment_options) { public function setHideCommentOptions($hide_comment_options) {
$this->hideCommentOptions = $hide_comment_options; $this->hideCommentOptions = $hide_comment_options;
return $this; return $this;
@ -121,6 +106,15 @@ class PhabricatorApplicationTransactionView extends AphrontView {
return $this->hideCommentOptions; return $this->hideCommentOptions;
} }
public function setViewData(array $view_data) {
$this->viewData = $view_data;
return $this;
}
public function getViewData() {
return $this->viewData;
}
public function buildEvents($with_hiding = false) { public function buildEvents($with_hiding = false) {
$user = $this->getUser(); $user = $this->getUser();
@ -216,10 +210,11 @@ class PhabricatorApplicationTransactionView extends AphrontView {
} }
$view = id(new PHUITimelineView()) $view = id(new PHUITimelineView())
->setUser($this->getUser()) ->setViewer($this->getViewer())
->setShouldTerminate($this->shouldTerminate) ->setShouldTerminate($this->shouldTerminate)
->setQuoteTargetID($this->getQuoteTargetID()) ->setQuoteTargetID($this->getQuoteTargetID())
->setQuoteRef($this->getQuoteRef()); ->setQuoteRef($this->getQuoteRef())
->setViewData($this->getViewData());
$events = $this->buildEvents($with_hiding); $events = $this->buildEvents($with_hiding);
foreach ($events as $event) { foreach ($events as $event) {
@ -230,10 +225,6 @@ class PhabricatorApplicationTransactionView extends AphrontView {
$view->setPager($this->getPager()); $view->setPager($this->getPager());
} }
if ($this->getRenderData()) {
$view->setRenderData($this->getRenderData());
}
return $view; return $view;
} }
@ -246,7 +237,7 @@ class PhabricatorApplicationTransactionView extends AphrontView {
$field = PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT; $field = PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT;
$engine = id(new PhabricatorMarkupEngine()) $engine = id(new PhabricatorMarkupEngine())
->setViewer($this->getUser()); ->setViewer($this->getViewer());
foreach ($this->transactions as $xaction) { foreach ($this->transactions as $xaction) {
if (!$xaction->hasComment()) { if (!$xaction->hasComment()) {
continue; continue;
@ -414,10 +405,10 @@ class PhabricatorApplicationTransactionView extends AphrontView {
private function renderEvent( private function renderEvent(
PhabricatorApplicationTransaction $xaction, PhabricatorApplicationTransaction $xaction,
array $group) { array $group) {
$viewer = $this->getUser(); $viewer = $this->getViewer();
$event = id(new PHUITimelineEventView()) $event = id(new PHUITimelineEventView())
->setUser($viewer) ->setViewer($viewer)
->setAuthorPHID($xaction->getAuthorPHID()) ->setAuthorPHID($xaction->getAuthorPHID())
->setTransactionPHID($xaction->getPHID()) ->setTransactionPHID($xaction->getPHID())
->setUserHandle($xaction->getHandle($xaction->getAuthorPHID())) ->setUserHandle($xaction->getHandle($xaction->getAuthorPHID()))

View file

@ -7,7 +7,7 @@ final class PHUITimelineView extends AphrontView {
private $shouldTerminate = false; private $shouldTerminate = false;
private $shouldAddSpacers = true; private $shouldAddSpacers = true;
private $pager; private $pager;
private $renderData = array(); private $viewData = array();
private $quoteTargetID; private $quoteTargetID;
private $quoteRef; private $quoteRef;
@ -40,11 +40,15 @@ final class PHUITimelineView extends AphrontView {
return $this; return $this;
} }
public function setRenderData(array $data) { public function setViewData(array $data) {
$this->renderData = $data; $this->viewData = $data;
return $this; return $this;
} }
public function getViewData() {
return $this->viewData;
}
public function setQuoteTargetID($quote_target_id) { public function setQuoteTargetID($quote_target_id) {
$this->quoteTargetID = $quote_target_id; $this->quoteTargetID = $quote_target_id;
return $this; return $this;
@ -72,7 +76,7 @@ final class PHUITimelineView extends AphrontView {
'phabricator-show-older-transactions', 'phabricator-show-older-transactions',
array( array(
'timelineID' => $this->id, 'timelineID' => $this->id,
'renderData' => $this->renderData, 'viewData' => $this->getViewData(),
)); ));
} }
$events = $this->buildEvents(); $events = $this->buildEvents();

View file

@ -83,7 +83,11 @@ JX.behavior('phabricator-show-older-transactions', function(config) {
}; };
var fetch_older_workflow = function(href, callback, swap) { var fetch_older_workflow = function(href, callback, swap) {
return new JX.Workflow(href, config.renderData) var params = {
viewData: JX.JSON.stringify(config.viewData)
};
return new JX.Workflow(href, params)
.setHandler(JX.bind(null, callback, swap)); .setHandler(JX.bind(null, callback, swap));
}; };