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

Unify EditEngine preview behavior; prepare for saving complex drafts

Summary:
Ref T9132. We currently have an old preview/draft behavior and a new actions behavior.

Let the actions behavior do drafts/previews too, so we can eventually throw away the old thing.

This is pretty much just copying the old behavior into the new one, but with a few tweaks. The major change is that we submit all the stacked actions behavior now, so the preview reflects everything the change will do (and, soon, we can save it in the draft in a consistent way).

Also includes one hack-fix that I'll clean up at some point.

Test Plan: Added a bunch of stacked actions and observed meaningful previews.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9132

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

+95 -52
+10 -10
resources/celerity/map.php
··· 427 427 'rsrc/js/application/repository/repository-crossreference.js' => 'e5339c43', 428 428 'rsrc/js/application/search/behavior-reorder-queries.js' => 'e9581f08', 429 429 'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => '887ad43f', 430 - 'rsrc/js/application/transactions/behavior-comment-actions.js' => '2ada1547', 430 + 'rsrc/js/application/transactions/behavior-comment-actions.js' => 'f293e8a0', 431 431 'rsrc/js/application/transactions/behavior-reorder-fields.js' => 'b59e1e96', 432 432 'rsrc/js/application/transactions/behavior-show-older-transactions.js' => 'dbbf48b6', 433 433 'rsrc/js/application/transactions/behavior-transaction-comment-form.js' => 'b23b49e6', ··· 571 571 'javelin-behavior-audit-preview' => 'd835b03a', 572 572 'javelin-behavior-bulk-job-reload' => 'edf8a145', 573 573 'javelin-behavior-choose-control' => '6153c708', 574 - 'javelin-behavior-comment-actions' => '2ada1547', 574 + 'javelin-behavior-comment-actions' => 'f293e8a0', 575 575 'javelin-behavior-config-reorder-fields' => 'b6993408', 576 576 'javelin-behavior-conpherence-drag-and-drop-photo' => 'cf86d16a', 577 577 'javelin-behavior-conpherence-menu' => '1d45c74d', ··· 1042 1042 '29274e2b' => array( 1043 1043 'javelin-install', 1044 1044 'javelin-util', 1045 - ), 1046 - '2ada1547' => array( 1047 - 'javelin-behavior', 1048 - 'javelin-stratcom', 1049 - 'javelin-workflow', 1050 - 'javelin-dom', 1051 - 'phuix-form-control-view', 1052 - 'phuix-icon-view', 1053 1045 ), 1054 1046 '2b8de964' => array( 1055 1047 'javelin-install', ··· 1979 1971 'javelin-util', 1980 1972 'javelin-workflow', 1981 1973 'javelin-json', 1974 + ), 1975 + 'f293e8a0' => array( 1976 + 'javelin-behavior', 1977 + 'javelin-stratcom', 1978 + 'javelin-workflow', 1979 + 'javelin-dom', 1980 + 'phuix-form-control-view', 1981 + 'phuix-icon-view', 1982 1982 ), 1983 1983 'f36e01af' => array( 1984 1984 'javelin-behavior',
+8
src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
··· 44 44 return new AphrontPHIDListHTTPParameterType(); 45 45 } 46 46 47 + public function readValueFromComment($value) { 48 + // TODO: This is really hacky -- make sure we pass a plain PHID list to 49 + // the edit type. This method probably needs to move down to EditType, and 50 + // maybe more additional logic does too. 51 + $this->setUseEdgeTransactions(false); 52 + return parent::readValueFromComment($value); 53 + } 54 + 47 55 public function getValueForTransaction() { 48 56 $new = parent::getValueForTransaction(); 49 57
+16 -29
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
··· 12 12 private $previewTimelineID; 13 13 private $previewToggleID; 14 14 private $formID; 15 - private $statusID; 16 15 private $commentID; 17 16 private $draft; 18 17 private $requestURI; ··· 148 147 $preview = null; 149 148 } 150 149 151 - Javelin::initBehavior( 152 - 'phabricator-transaction-comment-form', 153 - array( 154 - 'formID' => $this->getFormID(), 155 - 'timelineID' => $this->getPreviewTimelineID(), 156 - 'panelID' => $this->getPreviewPanelID(), 157 - 'statusID' => $this->getStatusID(), 158 - 'commentID' => $this->getCommentID(), 159 - 160 - 'loadingString' => pht('Loading Preview...'), 161 - 'savingString' => pht('Saving Draft...'), 162 - 'draftString' => pht('Saved Draft'), 163 - 164 - 'showPreview' => $this->getShowPreview(), 165 - 166 - 'actionURI' => $this->getAction(), 167 - )); 150 + if (!$this->getEditTypes()) { 151 + Javelin::initBehavior( 152 + 'phabricator-transaction-comment-form', 153 + array( 154 + 'formID' => $this->getFormID(), 155 + 'timelineID' => $this->getPreviewTimelineID(), 156 + 'panelID' => $this->getPreviewPanelID(), 157 + 'showPreview' => $this->getShowPreview(), 158 + 'actionURI' => $this->getAction(), 159 + )); 160 + } 168 161 169 162 $comment_box = id(new PHUIObjectBoxView()) 170 163 ->setFlush(true) ··· 175 168 } 176 169 177 170 private function renderCommentPanel() { 178 - $status = phutil_tag( 179 - 'div', 180 - array( 181 - 'id' => $this->getStatusID(), 182 - ), 183 - ''); 184 - 185 171 $draft_comment = ''; 186 172 $draft_key = null; 187 173 if ($this->getDraft()) { ··· 269 255 'inputID' => $input_id, 270 256 'formID' => $this->getFormID(), 271 257 'placeID' => $place_id, 258 + 'panelID' => $this->getPreviewPanelID(), 259 + 'timelineID' => $this->getPreviewTimelineID(), 272 260 'actions' => $action_map, 261 + 'showPreview' => $this->getShowPreview(), 262 + 'actionURI' => $this->getAction(), 273 263 )); 274 264 } 275 265 ··· 283 273 ->setValue($draft_comment)) 284 274 ->appendChild( 285 275 id(new AphrontFormSubmitControl()) 286 - ->setValue($this->getSubmitButtonName())) 287 - ->appendChild( 288 - id(new AphrontFormMarkupControl()) 289 - ->setValue($status)); 276 + ->setValue($this->getSubmitButtonName())); 290 277 291 278 return $form; 292 279 }
+61 -13
webroot/rsrc/js/application/transactions/behavior-comment-actions.js
··· 34 34 } 35 35 }); 36 36 37 - JX.DOM.listen(form_node, 'submit', null, function() { 38 - var data = []; 39 - 40 - for (var k in rows) { 41 - data.push({ 42 - type: k, 43 - value: rows[k].getValue() 44 - }); 45 - } 46 - 47 - input_node.value = JX.JSON.stringify(data); 48 - }); 49 - 50 37 function add_row(option) { 51 38 var action = action_map[option.value]; 52 39 if (!action) { ··· 75 62 }); 76 63 77 64 place_node.parentNode.insertBefore(node, place_node); 65 + } 66 + 67 + function serialize_actions() { 68 + var data = []; 69 + 70 + for (var k in rows) { 71 + data.push({ 72 + type: k, 73 + value: rows[k].getValue() 74 + }); 75 + } 76 + 77 + return JX.JSON.stringify(data); 78 + } 79 + 80 + function get_data() { 81 + var data = JX.DOM.convertFormToDictionary(form_node); 82 + 83 + data.__preview__ = 1; 84 + data[input_node.name] = serialize_actions(); 85 + 86 + return data; 87 + } 88 + 89 + function onresponse(response) { 90 + var panel = JX.$(config.panelID); 91 + if (!response.xactions.length) { 92 + JX.DOM.hide(panel); 93 + } else { 94 + JX.DOM.setContent( 95 + JX.$(config.timelineID), 96 + [ 97 + JX.$H(response.spacer), 98 + JX.$H(response.xactions.join(response.spacer)) 99 + ]); 100 + JX.DOM.show(panel); 101 + } 102 + } 103 + 104 + JX.DOM.listen(form_node, 'submit', null, function() { 105 + input_node.value = serialize_actions(); 106 + }); 107 + 108 + if (config.showPreview) { 109 + var request = new JX.PhabricatorShapedRequest( 110 + config.actionURI, 111 + onresponse, 112 + get_data); 113 + 114 + var trigger = JX.bind(request, request.trigger); 115 + 116 + JX.DOM.listen(form_node, 'keydown', null, trigger); 117 + 118 + var always_trigger = function() { 119 + new JX.Request(config.actionURI, onresponse) 120 + .setData(get_data()) 121 + .send(); 122 + }; 123 + 124 + JX.DOM.listen(form_node, 'shouldRefresh', null, always_trigger); 125 + request.start(); 78 126 } 79 127 80 128 });