1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 16:30:59 +01:00

Transactions - adding willRenderTimeline to handle tricky cases

Summary: Fixes T6693.

Test Plan:
Made a bunch of comments on a diff with differential, being sure to leave inlines here and there. This reproduced the issue in T6693. With this patch this issue no longer reproduces!

Successfully "showed older changes" in Maniphest too.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6693

Differential Revision: https://secure.phabricator.com/D10931
This commit is contained in:
Bob Trahan 2014-12-04 13:58:52 -08:00
parent 20035fe9a8
commit 6ab3f06b6e
48 changed files with 373 additions and 19 deletions

View file

@ -421,7 +421,7 @@ return array(
'rsrc/js/application/repository/repository-crossreference.js' => 'f9539603',
'rsrc/js/application/search/behavior-reorder-queries.js' => 'e9581f08',
'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => 'd6f54db0',
'rsrc/js/application/transactions/behavior-show-older-transactions.js' => 'c30ccda9',
'rsrc/js/application/transactions/behavior-show-older-transactions.js' => '83458cbb',
'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '9f7309fb',
'rsrc/js/application/transactions/behavior-transaction-list.js' => '13c739ea',
'rsrc/js/application/uiexample/JavelinViewExample.js' => 'd4a14807',
@ -625,7 +625,7 @@ return array(
'javelin-behavior-phabricator-reveal-content' => '60821bc7',
'javelin-behavior-phabricator-search-typeahead' => '724b1247',
'javelin-behavior-phabricator-show-all-transactions' => '7c273581',
'javelin-behavior-phabricator-show-older-transactions' => 'c30ccda9',
'javelin-behavior-phabricator-show-older-transactions' => '83458cbb',
'javelin-behavior-phabricator-tooltips' => '3ee3408b',
'javelin-behavior-phabricator-transaction-comment-form' => '9f7309fb',
'javelin-behavior-phabricator-transaction-list' => '13c739ea',
@ -1375,6 +1375,12 @@ return array(
'82ce2142' => array(
'aphront-typeahead-control-css',
),
'83458cbb' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-busy',
),
'84845b5b' => array(
'javelin-behavior',
'javelin-dom',
@ -1668,12 +1674,6 @@ return array(
'javelin-util',
'phabricator-shaped-request',
),
'c30ccda9' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
'phabricator-busy',
),
'c4569c05' => array(
'javelin-magical-init',
'javelin-install',

View file

@ -184,4 +184,11 @@ final class AlmanacBinding
return new AlmanacBindingTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
}

View file

@ -162,6 +162,13 @@ final class AlmanacDevice
return new AlmanacDeviceTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorSSHPublicKeyInterface )----------------------------------- */

View file

@ -59,6 +59,13 @@ final class AlmanacNetwork
return new AlmanacNetworkTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -161,4 +161,11 @@ final class AlmanacService
return new AlmanacServiceTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
}

View file

@ -97,6 +97,13 @@ final class PhabricatorAuthProviderConfig
return new PhabricatorAuthProviderConfigTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -529,7 +529,8 @@ abstract class PhabricatorController extends AphrontController {
protected function buildTransactionTimeline(
PhabricatorApplicationTransactionInterface $object,
PhabricatorApplicationTransactionQuery $query,
PhabricatorMarkupEngine $engine = null) {
PhabricatorMarkupEngine $engine = null,
$render_data = array()) {
$viewer = $this->getRequest()->getUser();
$xaction = $object->getApplicationTransactionTemplate();
@ -564,7 +565,9 @@ abstract class PhabricatorController extends AphrontController {
->setUser($viewer)
->setObjectPHID($object->getPHID())
->setTransactions($xactions)
->setPager($pager);
->setPager($pager)
->setRenderData($render_data);
$object->willRenderTimeline($timeline, $this->getRequest());
return $timeline;
}

View file

@ -68,6 +68,13 @@ final class PhabricatorConfigEntry
return new PhabricatorConfigTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -99,6 +99,13 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
return new PhabricatorDashboardTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -105,6 +105,13 @@ final class PhabricatorDashboardPanel
return new PhabricatorDashboardPanelTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -928,12 +928,12 @@ final class DifferentialRevisionViewController extends DifferentialController {
$timeline = $this->buildTransactionTimeline(
$revision,
new DifferentialTransactionQuery());
$timeline
->setChangesets($changesets)
->setRevision($revision)
->setLeftDiff($left_diff)
->setRightDiff($right_diff);
new DifferentialTransactionQuery(),
$engine = null,
array(
'left' => $left_diff->getID(),
'right' => $right_diff->getID(),
));
return $timeline;
}

View file

@ -421,11 +421,9 @@ final class DifferentialDiff
public function getApplicationTransactionEditor() {
return new DifferentialDiffEditor();
}
public function getApplicationTransactionObject() {
return $this;
}
@ -434,6 +432,13 @@ final class DifferentialDiff
return new DifferentialDiffTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -475,6 +475,35 @@ final class DifferentialRevision extends DifferentialDAO
return new DifferentialTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
$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];
$changesets = id(new DifferentialChangesetQuery())
->setViewer($request->getUser())
->withDiffs(array($right_diff))
->execute();
$changesets = mpull($changesets, null, 'getID');
return $timeline
->setChangesets($changesets)
->setRevision($this)
->setLeftDiff($left_diff)
->setRightDiff($right_diff);
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -91,6 +91,13 @@ final class DrydockBlueprint extends DrydockDAO
return new DrydockBlueprintTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -1095,6 +1095,13 @@ final class PhabricatorFile extends PhabricatorFileDAO
return new PhabricatorFileTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */

View file

@ -118,4 +118,11 @@ final class FundBacker extends FundDAO
return new FundBackerTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
}

View file

@ -149,6 +149,13 @@ final class FundInitiative extends FundDAO
return new FundInitiativeTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */

View file

@ -242,6 +242,13 @@ final class HarbormasterBuildable extends HarbormasterDAO
return new HarbormasterBuildableTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -419,6 +419,13 @@ final class HarbormasterBuild extends HarbormasterDAO
return new HarbormasterBuildTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -85,6 +85,13 @@ final class HarbormasterBuildPlan extends HarbormasterDAO
return new HarbormasterBuildPlanTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -104,6 +104,13 @@ final class HarbormasterBuildStep extends HarbormasterDAO
return new HarbormasterBuildStepTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -265,8 +265,10 @@ final class HeraldRule extends HeraldDAO
return sprintf('~%d%010d', $type_order, $this->getID());
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
public function getApplicationTransactionEditor() {
return new HeraldRuleEditor();
}
@ -279,6 +281,14 @@ final class HeraldRule extends HeraldDAO
return new HeraldRuleTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -213,6 +213,13 @@ final class LegalpadDocument extends LegalpadDAO
return new LegalpadTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -95,6 +95,13 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
return new PhabricatorMacroTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */

View file

@ -374,4 +374,11 @@ final class ManiphestTask extends ManiphestDAO
return new ManiphestTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
}

View file

@ -82,6 +82,13 @@ final class NuanceSource extends NuanceDAO
return new NuanceSourceTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
public function getCapabilities() {
return array(

View file

@ -98,6 +98,13 @@ final class PassphraseCredential extends PassphraseDAO
return new PassphraseCredentialTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -194,4 +194,11 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
return new PhabricatorPasteTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
}

View file

@ -49,6 +49,13 @@ final class PhluxVariable extends PhluxDAO
return new PhluxTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -264,6 +264,13 @@ final class PholioMock extends PholioDAO
return new PholioTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
$timeline->setMock($this);
return $timeline;
}
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */

View file

@ -112,6 +112,13 @@ final class PhortuneAccount extends PhortuneDAO
return new PhortuneAccountTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -614,6 +614,13 @@ final class PhortuneCart extends PhortuneDAO
return new PhortuneCartTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -57,6 +57,13 @@ final class PhortuneMerchant extends PhortuneDAO
return new PhortuneMerchantTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -216,6 +216,12 @@ final class PhrictionDocument extends PhrictionDAO
return new PhrictionTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */

View file

@ -129,6 +129,13 @@ final class PonderAnswer extends PonderDAO
return new PonderAnswerTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
// Markup interface

View file

@ -161,6 +161,13 @@ final class PonderQuestion extends PonderDAO
return new PonderQuestionTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
// Markup interface

View file

@ -375,6 +375,13 @@ final class PhabricatorProject extends PhabricatorProjectDAO
return new PhabricatorProjectTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -151,6 +151,13 @@ final class PhabricatorProjectColumn
return new PhabricatorProjectColumnTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -166,6 +166,13 @@ final class ReleephBranch extends ReleephDAO
return new ReleephBranchTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -139,6 +139,13 @@ final class ReleephProject extends ReleephDAO
return new ReleephProductTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -312,6 +312,13 @@ final class ReleephRequest extends ReleephDAO
return new ReleephRequestTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -1528,6 +1528,13 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return new PhabricatorRepositoryTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -402,4 +402,11 @@ final class PhabricatorRepositoryCommit
return new PhabricatorAuditTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
}

View file

@ -119,6 +119,13 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
return new PhabricatorSlowvoteTransaction();
}
public function willRenderTimeline(
PhabricatorApplicationTransactionView $timeline,
AphrontRequest $request) {
return $timeline;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

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

View file

@ -14,6 +14,7 @@ class PhabricatorApplicationTransactionView extends AphrontView {
private $quoteTargetID;
private $quoteRef;
private $pager;
private $renderData = array();
public function setQuoteRef($quote_ref) {
$this->quoteRef = $quote_ref;
@ -85,6 +86,21 @@ class PhabricatorApplicationTransactionView extends AphrontView {
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 buildEvents($with_hiding = false) {
$user = $this->getUser();
@ -186,6 +202,9 @@ class PhabricatorApplicationTransactionView extends AphrontView {
if ($this->getPager()) {
$view->setPager($this->getPager());
}
if ($this->getRenderData()) {
$view->setRenderData($this->getRenderData());
}
return $view;
}

View file

@ -7,6 +7,7 @@ final class PHUITimelineView extends AphrontView {
private $shouldTerminate = false;
private $shouldAddSpacers = true;
private $pager;
private $renderData = array();
public function setID($id) {
$this->id = $id;
@ -37,6 +38,11 @@ final class PHUITimelineView extends AphrontView {
return $this;
}
public function setRenderData(array $data) {
$this->renderData = $data;
return $this;
}
public function render() {
if ($this->getPager()) {
if ($this->id === null) {
@ -46,6 +52,7 @@ final class PHUITimelineView extends AphrontView {
'phabricator-show-older-transactions',
array(
'timelineID' => $this->id,
'renderData' => $this->renderData,
));
}
$events = $this->buildEvents();

View file

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