@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.

Remove ajaxey comment magic in Pholio, and also some bugs

Summary:
Fixes T5424.

- One concrete issue: drafts were not being cleared properly because `__draft__` was not set on submission. This (mostly) fixes phantom drafts.
- This ajax comment magic feels weird and floaty and generally has problems. For example, if you add subscribers or inlines, all the stuff on the page which represents those won't update automatically. Instead, just reload. Maybe we'll ajax this stuff some day, but it feels like a net negative for now.
- Also remove it from other applications where it's currently used.
- Fix an issue with inline previews.

Test Plan: Made some comments on a mock, everything worked normally like I expected it to.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5424

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

+53 -174
+22 -24
resources/celerity/map.php
··· 8 8 'names' => 9 9 array( 10 10 'core.pkg.css' => '8feeb38a', 11 - 'core.pkg.js' => '07b01d4f', 11 + 'core.pkg.js' => 'b440d8d7', 12 12 'darkconsole.pkg.js' => 'ca8671ce', 13 13 'differential.pkg.css' => '4a93db37', 14 14 'differential.pkg.js' => '5b252007', ··· 418 418 'rsrc/js/application/repository/repository-crossreference.js' => '8ab282be', 419 419 'rsrc/js/application/search/behavior-reorder-queries.js' => '37871df4', 420 420 'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => 'a51fdb2e', 421 - 'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '9084a36f', 422 - 'rsrc/js/application/transactions/behavior-transaction-list.js' => 'cf656c84', 421 + 'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => '9f7309fb', 422 + 'rsrc/js/application/transactions/behavior-transaction-list.js' => 'fd6c2b32', 423 423 'rsrc/js/application/uiexample/JavelinViewExample.js' => 'd4a14807', 424 424 'rsrc/js/application/uiexample/ReactorButtonExample.js' => '44524435', 425 425 'rsrc/js/application/uiexample/ReactorCheckboxExample.js' => '7ba325ee', ··· 621 621 'javelin-behavior-phabricator-search-typeahead' => 'fbeabd1e', 622 622 'javelin-behavior-phabricator-show-all-transactions' => '7c273581', 623 623 'javelin-behavior-phabricator-tooltips' => '48db4145', 624 - 'javelin-behavior-phabricator-transaction-comment-form' => '9084a36f', 625 - 'javelin-behavior-phabricator-transaction-list' => 'cf656c84', 624 + 'javelin-behavior-phabricator-transaction-comment-form' => '9f7309fb', 625 + 'javelin-behavior-phabricator-transaction-list' => 'fd6c2b32', 626 626 'javelin-behavior-phabricator-watch-anchor' => '06e05112', 627 627 'javelin-behavior-phame-post-preview' => '61d927ec', 628 628 'javelin-behavior-pholio-mock-edit' => '1e1e8bb0', ··· 1520 1520 3 => 'javelin-mask', 1521 1521 4 => 'phabricator-drag-and-drop-file-upload', 1522 1522 ), 1523 - '9084a36f' => 1524 - array( 1525 - 0 => 'javelin-behavior', 1526 - 1 => 'javelin-dom', 1527 - 2 => 'javelin-util', 1528 - 3 => 'javelin-fx', 1529 - 4 => 'javelin-request', 1530 - 5 => 'phabricator-shaped-request', 1531 - ), 1532 1523 '929d95eb' => 1533 1524 array( 1534 1525 0 => 'javelin-behavior', ··· 1595 1586 2 => 'javelin-uri', 1596 1587 3 => 'javelin-request', 1597 1588 ), 1589 + '9f7309fb' => 1590 + array( 1591 + 0 => 'javelin-behavior', 1592 + 1 => 'javelin-dom', 1593 + 2 => 'javelin-util', 1594 + 3 => 'javelin-request', 1595 + 4 => 'phabricator-shaped-request', 1596 + ), 1598 1597 'a3e2244e' => 1599 1598 array( 1600 1599 0 => 'javelin-behavior', ··· 1851 1850 0 => 'javelin-install', 1852 1851 1 => 'javelin-typeahead-source', 1853 1852 ), 1854 - 'cf656c84' => 1855 - array( 1856 - 0 => 'javelin-behavior', 1857 - 1 => 'javelin-stratcom', 1858 - 2 => 'javelin-workflow', 1859 - 3 => 'javelin-dom', 1860 - 4 => 'javelin-fx', 1861 - 5 => 'javelin-uri', 1862 - 6 => 'phabricator-textareautils', 1863 - ), 1864 1853 'cf76cfd5' => 1865 1854 array( 1866 1855 0 => 'javelin-behavior', ··· 2092 2081 4 => 'javelin-uri', 2093 2082 5 => 'javelin-util', 2094 2083 6 => 'javelin-stratcom', 2084 + ), 2085 + 'fd6c2b32' => 2086 + array( 2087 + 0 => 'javelin-behavior', 2088 + 1 => 'javelin-stratcom', 2089 + 2 => 'javelin-workflow', 2090 + 3 => 'javelin-dom', 2091 + 4 => 'javelin-uri', 2092 + 5 => 'phabricator-textareautils', 2095 2093 ), 2096 2094 'fe2e0ba4' => 2097 2095 array(
+1 -1
src/applications/files/controller/PhabricatorFileCommentController.php
··· 58 58 $draft->replaceOrDelete(); 59 59 } 60 60 61 - if ($request->isAjax()) { 61 + if ($request->isAjax() && $is_preview) { 62 62 return id(new PhabricatorApplicationTransactionResponse()) 63 63 ->setViewer($user) 64 64 ->setTransactions($xactions)
+1 -1
src/applications/legalpad/controller/LegalpadDocumentCommentController.php
··· 68 68 $draft->replaceOrDelete(); 69 69 } 70 70 71 - if ($request->isAjax()) { 71 + if ($request->isAjax() && $is_preview) { 72 72 return id(new PhabricatorApplicationTransactionResponse()) 73 73 ->setViewer($user) 74 74 ->setTransactions($xactions)
+1 -1
src/applications/macro/controller/PhabricatorMacroCommentController.php
··· 55 55 $draft->replaceOrDelete(); 56 56 } 57 57 58 - if ($request->isAjax()) { 58 + if ($request->isAjax() && $is_preview) { 59 59 return id(new PhabricatorApplicationTransactionResponse()) 60 60 ->setViewer($user) 61 61 ->setTransactions($xactions)
+1 -1
src/applications/paste/controller/PhabricatorPasteCommentController.php
··· 58 58 $draft->replaceOrDelete(); 59 59 } 60 60 61 - if ($request->isAjax()) { 61 + if ($request->isAjax() && $is_preview) { 62 62 return id(new PhabricatorApplicationTransactionResponse()) 63 63 ->setViewer($user) 64 64 ->setTransactions($xactions)
+5 -1
src/applications/pholio/controller/PholioMockCommentController.php
··· 76 76 $draft->replaceOrDelete(); 77 77 } 78 78 79 - if ($request->isAjax()) { 79 + if ($request->isAjax() && $is_preview) { 80 + $xaction_view = id(new PholioTransactionView()) 81 + ->setMock($mock); 82 + 80 83 return id(new PhabricatorApplicationTransactionResponse()) 81 84 ->setViewer($user) 82 85 ->setTransactions($xactions) 86 + ->setTransactionView($xaction_view) 83 87 ->setIsPreview($is_preview) 84 88 ->setAnchorOffset($request->getStr('anchor')); 85 89 } else {
+1 -1
src/applications/ponder/controller/PonderAnswerCommentController.php
··· 56 56 // $draft->replaceOrDelete(); 57 57 // } 58 58 59 - if ($request->isAjax()) { 59 + if ($request->isAjax() && $is_preview) { 60 60 return id(new PhabricatorApplicationTransactionResponse()) 61 61 ->setViewer($viewer) 62 62 ->setTransactions($xactions)
+1 -1
src/applications/ponder/controller/PonderQuestionCommentController.php
··· 55 55 // $draft->replaceOrDelete(); 56 56 // } 57 57 58 - if ($request->isAjax()) { 58 + if ($request->isAjax() && $is_preview) { 59 59 return id(new PhabricatorApplicationTransactionResponse()) 60 60 ->setViewer($viewer) 61 61 ->setTransactions($xactions)
+1 -1
src/applications/releeph/controller/request/ReleephRequestCommentController.php
··· 55 55 $draft->replaceOrDelete(); 56 56 } 57 57 58 - if ($request->isAjax()) { 58 + if ($request->isAjax() && $is_preview) { 59 59 return id(new PhabricatorApplicationTransactionResponse()) 60 60 ->setViewer($viewer) 61 61 ->setTransactions($xactions)
+1 -1
src/applications/slowvote/controller/PhabricatorSlowvoteCommentController.php
··· 55 55 $draft->replaceOrDelete(); 56 56 } 57 57 58 - if ($request->isAjax()) { 58 + if ($request->isAjax() && $is_preview) { 59 59 return id(new PhabricatorApplicationTransactionResponse()) 60 60 ->setViewer($user) 61 61 ->setTransactions($xactions)
+13 -1
src/applications/transactions/response/PhabricatorApplicationTransactionResponse.php
··· 7 7 private $transactions; 8 8 private $anchorOffset; 9 9 private $isPreview; 10 + private $transactionView; 11 + 12 + public function setTransactionView($transaction_view) { 13 + $this->transactionView = $transaction_view; 14 + return $this; 15 + } 16 + 17 + public function getTransactionView() { 18 + return $this->transactionView; 19 + } 10 20 11 21 protected function buildProxy() { 12 22 return new AphrontAjaxResponse(); ··· 47 57 } 48 58 49 59 public function reduceProxyResponse() { 50 - if ($this->getTransactions()) { 60 + if ($this->transactionView) { 61 + $view = $this->transactionView; 62 + } else if ($this->getTransactions()) { 51 63 $view = head($this->getTransactions()) 52 64 ->getApplicationTransactionViewObject(); 53 65 } else {
+3 -3
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
··· 124 124 'showPreview' => $this->getShowPreview(), 125 125 126 126 'actionURI' => $this->getAction(), 127 - 'draftKey' => $this->getDraft() 128 - ? $this->getDraft()->getDraftKey() 129 - : null, 130 127 )); 131 128 132 129 $comment_box = id(new PHUIObjectBoxView()) ··· 146 143 ''); 147 144 148 145 $draft_comment = ''; 146 + $draft_key = null; 149 147 if ($this->getDraft()) { 150 148 $draft_comment = $this->getDraft()->getDraft(); 149 + $draft_key = $this->getDraft()->getDraftKey(); 151 150 } 152 151 153 152 if (!$this->getObjectPHID()) { ··· 164 163 )) 165 164 ->setAction($this->getAction()) 166 165 ->setID($this->getFormID()) 166 + ->addHiddenInput('__draft__', $draft_key) 167 167 ->appendChild( 168 168 id(new PhabricatorRemarkupControl()) 169 169 ->setID($this->getCommentID())
+2 -30
webroot/rsrc/js/application/transactions/behavior-transaction-comment-form.js
··· 3 3 * @requires javelin-behavior 4 4 * javelin-dom 5 5 * javelin-util 6 - * javelin-fx 7 6 * javelin-request 8 7 * phabricator-shaped-request 9 8 */ ··· 12 11 13 12 var form = JX.$(config.formID); 14 13 15 - JX.DOM.listen(form, 'willSubmit', null, function (e) { 16 - e.kill(); 17 - if (config.showPreview) { 18 - var preview = JX.$(config.panelID); 19 - preview.style.opacity = 0.5; 20 - } 21 - }); 22 - 23 - JX.DOM.listen(form, 'willClear', null, function(e) { 24 - JX.$(config.commentID).value = ''; 25 - 26 - if (config.showPreview) { 27 - var preview = JX.$(config.panelID); 28 - new JX.FX(preview) 29 - .setDuration(500) 30 - .then(function () { 31 - new JX.FX(preview).setDuration(1000).start({opacity: [0, 1]}); 32 - }) 33 - .start({opacity: [0.5, 0]}); 34 - } 35 - }); 36 - 37 14 var getdata = function() { 38 15 var obj = JX.DOM.convertFormToDictionary(form); 39 16 obj.__preview__ = 1; 40 - 41 - if (config.draftKey) { 42 - obj.__draft__ = config.draftKey; 43 - } 44 - 45 17 return obj; 46 18 }; 47 19 ··· 70 42 JX.DOM.listen(form, 'keydown', null, trigger); 71 43 var always_trigger = function() { 72 44 new JX.Request(config.actionURI, onresponse) 73 - .setData(getdata()) 74 - .send(); 45 + .setData(getdata()) 46 + .send(); 75 47 }; 76 48 JX.DOM.listen(form, 'shouldRefresh', null, always_trigger); 77 49
-107
webroot/rsrc/js/application/transactions/behavior-transaction-list.js
··· 4 4 * javelin-stratcom 5 5 * javelin-workflow 6 6 * javelin-dom 7 - * javelin-fx 8 7 * javelin-uri 9 8 * phabricator-textareautils 10 9 */ ··· 15 14 var xaction_nodes = null; 16 15 var next_anchor = config.nextAnchor; 17 16 18 - function get_xaction_nodes() { 19 - if (xaction_nodes === null) { 20 - xaction_nodes = {}; 21 - var xactions = JX.DOM.scry(list, 'div', 'transaction'); 22 - for (var ii = 0; ii < xactions.length; ii++) { 23 - xaction_nodes[JX.Stratcom.getData(xactions[ii]).phid] = xactions[ii]; 24 - } 25 - } 26 - return xaction_nodes; 27 - } 28 - 29 - function ontransactions(response) { 30 - var fade_in = []; 31 - var first_new = null; 32 - 33 - var nodes = get_xaction_nodes(); 34 - for (var phid in response.xactions) { 35 - var new_node = JX.$H(response.xactions[phid]).getFragment().firstChild; 36 - fade_in.push(new_node); 37 - 38 - if (nodes[phid]) { 39 - JX.DOM.replace(nodes[phid], new_node); 40 - } else { 41 - if (first_new === null) { 42 - first_new = new_node; 43 - } 44 - list.appendChild(new_node); 45 - 46 - // Add a spacer after new transactions. 47 - var spacer = JX.$H(response.spacer).getFragment().firstChild; 48 - list.appendChild(spacer); 49 - fade_in.push(spacer); 50 - 51 - next_anchor++; 52 - } 53 - nodes[phid] = new_node; 54 - } 55 - 56 - // Scroll to the first new transaction, if transactions were added. 57 - if (first_new) { 58 - JX.DOM.scrollTo(first_new); 59 - } 60 - 61 - // Make any new or updated transactions fade in. 62 - for (var ii = 0; ii < fade_in.length; ii++) { 63 - new JX.FX(fade_in[ii]).setDuration(500).start({opacity: [0, 1]}); 64 - } 65 - } 66 - 67 17 JX.Stratcom.listen( 68 18 'click', 69 19 [['transaction-edit'], ['transaction-remove']], ··· 120 70 .start(); 121 71 }); 122 72 123 - JX.Stratcom.listen( 124 - ['submit', 'didSyntheticSubmit'], 125 - 'transaction-append', 126 - function(e) { 127 - var form = e.getTarget(); 128 - if (JX.Stratcom.getData(form).objectPHID != config.objectPHID) { 129 - // This indicates there are several forms on the page, and the user 130 - // submitted a different one than the one we're in control of. 131 - return; 132 - } 133 - 134 - e.kill(); 135 - 136 - JX.DOM.invoke(form, 'willSubmit'); 137 - 138 - JX.Workflow.newFromForm(form, { anchor : next_anchor }) 139 - .setHandler(function(response) { 140 - ontransactions(response); 141 - 142 - var e = JX.DOM.invoke(form, 'willClear'); 143 - if (!e.getPrevented()) { 144 - var ii; 145 - var textareas = JX.DOM.scry(form, 'textarea'); 146 - for (ii = 0; ii < textareas.length; ii++) { 147 - textareas[ii].value = ''; 148 - } 149 - 150 - var inputs = JX.DOM.scry(form, 'input'); 151 - for (ii = 0; ii < inputs.length; ii++) { 152 - switch (inputs[ii].type) { 153 - case 'password': 154 - case 'text': 155 - inputs[ii].value = ''; 156 - break; 157 - case 'checkbox': 158 - case 'radio': 159 - inputs[ii].checked = false; 160 - break; 161 - } 162 - } 163 - 164 - var selects = JX.DOM.scry(form, 'select'); 165 - var jj; 166 - for (ii = 0; ii < selects.length; ii++) { 167 - if (selects[ii].type == 'select-one') { 168 - selects[ii].selectedIndex = 0; 169 - } else { 170 - for (jj = 0; jj < selects[ii].options.length; jj++) { 171 - selects[ii].options[jj].selected = false; 172 - } 173 - } 174 - } 175 - } 176 - }) 177 - .start(); 178 - 179 - }); 180 73 });