@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Pass timeline view data to comment previews, restoring Differential comment previews

Summary:
Ref T13222. In D19918, I refactored how timelines get "view data". Today, this is always additional data about which images/changesets/diffs are visible on the current revision/commit/mock, so we can tell if inline comments should be linked to a `#anchor` on the same page (if the inline is rendered there somewhere) or to a `/D123?id=1&vs=2` full link on a different page (if it isn't), but in general this could be any sort of state information about the current page that affects how the timeline should render.

Previously, comment previews did not use any specialized object code and always rendered a "generic" timeline story. This was actually a bug, but none of the code we have today cares about this (since it's all inline related, and inlines render separately) so it never impacted anything.

After the `TimelineEngine` change, the preview renders with Differential-specific code. This is more correct, but we were not passing the preview the "view data" so it broke.

This preview doesn't actually need the view data and we could just make it bail out if it isn't present, but pass it through for consistency and so this works like we'd expect if we do something fancier with view data in the future.

Test Plan: Viewed comment and inline comment previews in Differential, saw old behavior restored.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13222

Differential Revision: https://secure.phabricator.com/D19943

+42 -141
+12 -23
resources/celerity/map.php
··· 12 12 'core.pkg.css' => '47535fd5', 13 13 'core.pkg.js' => 'bd89cb1d', 14 14 'differential.pkg.css' => '06dc617c', 15 - 'differential.pkg.js' => 'ef0b989b', 15 + 'differential.pkg.js' => '853c3461', 16 16 'diffusion.pkg.css' => 'a2d17c7d', 17 17 'diffusion.pkg.js' => '6134c5a1', 18 18 'maniphest.pkg.css' => '4845691a', ··· 376 376 'rsrc/js/application/diff/DiffChangesetList.js' => '0a84bcc1', 377 377 'rsrc/js/application/diff/DiffInline.js' => 'e83d28f3', 378 378 'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832', 379 - 'rsrc/js/application/differential/behavior-comment-preview.js' => '51c5ad07', 380 379 'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1', 381 380 'rsrc/js/application/differential/behavior-populate.js' => 'f0eb6708', 382 381 'rsrc/js/application/differential/behavior-user-select.js' => 'a8d8459d', ··· 422 421 'rsrc/js/application/repository/repository-crossreference.js' => '9a860428', 423 422 'rsrc/js/application/search/behavior-reorder-profile-menu-items.js' => 'e2e0a072', 424 423 'rsrc/js/application/search/behavior-reorder-queries.js' => 'e9581f08', 425 - 'rsrc/js/application/transactions/behavior-comment-actions.js' => '59e27e74', 424 + 'rsrc/js/application/transactions/behavior-comment-actions.js' => 'd848ec84', 426 425 'rsrc/js/application/transactions/behavior-reorder-configs.js' => 'd7a74243', 427 426 'rsrc/js/application/transactions/behavior-reorder-fields.js' => 'b59e1e96', 428 427 'rsrc/js/application/transactions/behavior-show-older-transactions.js' => '0e1eca96', ··· 575 574 'javelin-behavior-bulk-job-reload' => 'edf8a145', 576 575 'javelin-behavior-calendar-month-view' => 'fe33e256', 577 576 'javelin-behavior-choose-control' => '327a00d1', 578 - 'javelin-behavior-comment-actions' => '59e27e74', 577 + 'javelin-behavior-comment-actions' => 'd848ec84', 579 578 'javelin-behavior-config-reorder-fields' => 'b6993408', 580 579 'javelin-behavior-conpherence-menu' => '4047cd35', 581 580 'javelin-behavior-conpherence-participant-pane' => 'd057e45a', ··· 593 592 'javelin-behavior-device' => 'a3714c76', 594 593 'javelin-behavior-diff-preview-link' => '051c7832', 595 594 'javelin-behavior-differential-diff-radios' => 'e1ff79b1', 596 - 'javelin-behavior-differential-feedback-preview' => '51c5ad07', 597 595 'javelin-behavior-differential-populate' => 'f0eb6708', 598 596 'javelin-behavior-differential-user-select' => 'a8d8459d', 599 597 'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04', ··· 1246 1244 'javelin-typeahead-source', 1247 1245 'javelin-util', 1248 1246 ), 1249 - '51c5ad07' => array( 1250 - 'javelin-behavior', 1251 - 'javelin-stratcom', 1252 - 'javelin-dom', 1253 - 'javelin-request', 1254 - 'javelin-util', 1255 - 'phabricator-shaped-request', 1256 - ), 1257 1247 '522431f7' => array( 1258 1248 'javelin-behavior', 1259 1249 'javelin-util', ··· 1323 1313 'javelin-vector', 1324 1314 'javelin-dom', 1325 1315 ), 1326 - '59e27e74' => array( 1327 - 'javelin-behavior', 1328 - 'javelin-stratcom', 1329 - 'javelin-workflow', 1330 - 'javelin-dom', 1331 - 'phuix-form-control-view', 1332 - 'phuix-icon-view', 1333 - 'javelin-behavior-phabricator-gesture', 1334 - ), 1335 1316 '5c54cbf3' => array( 1336 1317 'javelin-behavior', 1337 1318 'javelin-stratcom', ··· 1991 1972 'javelin-util', 1992 1973 'phabricator-shaped-request', 1993 1974 ), 1975 + 'd848ec84' => array( 1976 + 'javelin-behavior', 1977 + 'javelin-stratcom', 1978 + 'javelin-workflow', 1979 + 'javelin-dom', 1980 + 'phuix-form-control-view', 1981 + 'phuix-icon-view', 1982 + 'javelin-behavior-phabricator-gesture', 1983 + ), 1994 1984 'db34a142' => array( 1995 1985 'phui-inline-comment-view-css', 1996 1986 ), ··· 2335 2325 'differential.pkg.js' => array( 2336 2326 'phabricator-drag-and-drop-file-upload', 2337 2327 'phabricator-shaped-request', 2338 - 'javelin-behavior-differential-feedback-preview', 2339 2328 'javelin-behavior-differential-populate', 2340 2329 'javelin-behavior-differential-diff-radios', 2341 2330 'javelin-behavior-aphront-drag-and-drop-textarea',
-1
resources/celerity/packages.php
··· 193 193 'phabricator-drag-and-drop-file-upload', 194 194 'phabricator-shaped-request', 195 195 196 - 'javelin-behavior-differential-feedback-preview', 197 196 'javelin-behavior-differential-populate', 198 197 'javelin-behavior-differential-diff-radios', 199 198 'javelin-behavior-aphront-drag-and-drop-textarea',
+8
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 1958 1958 if ($request->isAjax() && $is_preview) { 1959 1959 $preview_content = $this->newCommentPreviewContent($object, $xactions); 1960 1960 1961 + $raw_view_data = $request->getStr('viewData'); 1962 + try { 1963 + $view_data = phutil_json_decode($raw_view_data); 1964 + } catch (Exception $ex) { 1965 + $view_data = array(); 1966 + } 1967 + 1961 1968 return id(new PhabricatorApplicationTransactionResponse()) 1962 1969 ->setObject($object) 1963 1970 ->setViewer($viewer) 1964 1971 ->setTransactions($xactions) 1965 1972 ->setIsPreview($is_preview) 1973 + ->setViewData($view_data) 1966 1974 ->setPreviewContent($preview_content); 1967 1975 } else { 1968 1976 return id(new AphrontRedirectResponse())
+12 -1
src/applications/transactions/response/PhabricatorApplicationTransactionResponse.php
··· 8 8 private $isPreview; 9 9 private $previewContent; 10 10 private $object; 11 + private $viewData = array(); 11 12 12 13 protected function buildProxy() { 13 14 return new AphrontAjaxResponse(); ··· 56 57 return $this->previewContent; 57 58 } 58 59 60 + public function setViewData(array $view_data) { 61 + $this->viewData = $view_data; 62 + return $this; 63 + } 64 + 65 + public function getViewData() { 66 + return $this->viewData; 67 + } 68 + 59 69 public function reduceProxyResponse() { 60 70 $object = $this->getObject(); 61 71 $viewer = $this->getViewer(); ··· 63 73 64 74 $timeline_engine = PhabricatorTimelineEngine::newForObject($object) 65 75 ->setViewer($viewer) 66 - ->setTransactions($xactions); 76 + ->setTransactions($xactions) 77 + ->setViewData($this->viewData); 67 78 68 79 $view = $timeline_engine->buildTimelineView(); 69 80
+8
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
··· 391 391 $form->appendChild($invisi_bar); 392 392 $form->addClass('phui-comment-has-actions'); 393 393 394 + $timeline = $this->transactionTimeline; 395 + 396 + $view_data = array(); 397 + if ($timeline) { 398 + $view_data = $timeline->getViewData(); 399 + } 400 + 394 401 Javelin::initBehavior( 395 402 'comment-actions', 396 403 array( ··· 405 412 'actionURI' => $this->getAction(), 406 413 'drafts' => $draft_keys, 407 414 'defaultButtonText' => $this->getSubmitButtonName(), 415 + 'viewData' => $view_data, 408 416 )); 409 417 } 410 418
-116
webroot/rsrc/js/application/differential/behavior-comment-preview.js
··· 1 - /** 2 - * @provides javelin-behavior-differential-feedback-preview 3 - * @requires javelin-behavior 4 - * javelin-stratcom 5 - * javelin-dom 6 - * javelin-request 7 - * javelin-util 8 - * phabricator-shaped-request 9 - */ 10 - 11 - JX.behavior('differential-feedback-preview', function(config) { 12 - 13 - var action = JX.$(config.action); 14 - var content = JX.$(config.content); 15 - var previewTokenizers = {}; 16 - var field; 17 - for (field in config.previewTokenizers) { 18 - var tokenizer = JX.$(config.previewTokenizers[field]); 19 - previewTokenizers[field] = JX.Stratcom.getData(tokenizer).tokenizer; 20 - } 21 - 22 - var callback = function(r) { 23 - var preview = JX.$(config.preview); 24 - var data = getdata(); 25 - var hide = true; 26 - for (var field in data) { 27 - if (field == 'action') { 28 - continue; 29 - } 30 - if (data[field]) { 31 - hide = false; 32 - } 33 - } 34 - if (hide) { 35 - JX.DOM.hide(preview); 36 - } else { 37 - JX.DOM.setContent(preview, JX.$H(r)); 38 - JX.Stratcom.invoke('differential-preview-update', null, { 39 - container: preview 40 - }); 41 - JX.DOM.show(preview); 42 - } 43 - }; 44 - 45 - var getdata = function() { 46 - var data = { 47 - content : content.value, 48 - action : action.value 49 - }; 50 - for (var field in previewTokenizers) { 51 - data[field] = JX.keys(previewTokenizers[field].getTokens()).join(','); 52 - } 53 - return data; 54 - }; 55 - 56 - var request = new JX.PhabricatorShapedRequest(config.uri, callback, getdata); 57 - var trigger = JX.bind(request, request.trigger); 58 - 59 - JX.DOM.listen(content, 'keydown', null, trigger); 60 - JX.DOM.listen(action, 'change', null, trigger); 61 - for (field in previewTokenizers) { 62 - previewTokenizers[field].listen('change', trigger); 63 - } 64 - 65 - request.start(); 66 - 67 - function refreshInlinePreview() { 68 - new JX.Request(config.inlineuri, function(r) { 69 - var inline = JX.$(config.inline); 70 - 71 - JX.DOM.setContent(inline, JX.$H(r)); 72 - JX.Stratcom.invoke('differential-preview-update', null, { 73 - container: inline 74 - }); 75 - 76 - updateLinks(); 77 - 78 - JX.Stratcom.invoke('resize'); 79 - }) 80 - .setTimeout(5000) 81 - .send(); 82 - } 83 - 84 - function updateLinks() { 85 - var inline = JX.$(config.inline); 86 - 87 - var links = JX.DOM.scry( 88 - inline, 89 - 'a', 90 - 'differential-inline-preview-jump'); 91 - 92 - for (var ii = 0; ii < links.length; ii++) { 93 - var data = JX.Stratcom.getData(links[ii]); 94 - try { 95 - JX.$(data.anchor); 96 - links[ii].href = '#' + data.anchor; 97 - JX.DOM.setContent(links[ii], 'View'); 98 - } catch (ignored) { 99 - // This inline comment isn't visible, e.g. on some other diff. 100 - } 101 - } 102 - } 103 - 104 - 105 - JX.Stratcom.listen( 106 - 'differential-inline-comment-update', 107 - null, 108 - refreshInlinePreview); 109 - 110 - JX.Stratcom.listen( 111 - 'differential-inline-comment-refresh', 112 - null, 113 - updateLinks); 114 - 115 - refreshInlinePreview(); 116 - });
+2
webroot/rsrc/js/application/transactions/behavior-comment-actions.js
··· 90 90 data.__preview__ = 1; 91 91 data[input_node.name] = serialize_actions(); 92 92 93 + data.viewData = JX.JSON.stringify(config.viewData); 94 + 93 95 return data; 94 96 } 95 97