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

Persist remarkup metadata in "VersionedDrafts" and record explicit file uploads

Summary:
Ref T13603. Allow "VersionedDraft" to persist remarkup comment area metadata from stacked actions controls.

When files are dragged and dropped, record them as explicit uploads in comment metadata.

Test Plan: Dragged and dropped files into Remarkup stacked action text areas (e.g., in Maniphest), reloaded page, saw metadata persist across reloads.

Maniphest Tasks: T13603

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

+54 -27
+10 -10
resources/celerity/map.php
··· 13 13 'core.pkg.js' => 'd2de90d9', 14 14 'dark-console.pkg.js' => '187792c2', 15 15 'differential.pkg.css' => 'ffb69e3d', 16 - 'differential.pkg.js' => 'e31329dc', 16 + 'differential.pkg.js' => 'c60bec1b', 17 17 'diffusion.pkg.css' => '42c75c37', 18 18 'diffusion.pkg.js' => '78c9885d', 19 19 'maniphest.pkg.css' => '35995d6d', ··· 473 473 'rsrc/js/core/behavior-copy.js' => 'cf32921f', 474 474 'rsrc/js/core/behavior-detect-timezone.js' => '78bc5d94', 475 475 'rsrc/js/core/behavior-device.js' => 'ac2b1e01', 476 - 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '7df68a45', 476 + 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '3277c62d', 477 477 'rsrc/js/core/behavior-fancy-datepicker.js' => '36821f8d', 478 478 'rsrc/js/core/behavior-form.js' => '55d7b788', 479 479 'rsrc/js/core/behavior-gesture.js' => 'b58d1a2a', ··· 589 589 'javelin-behavior-aphlict-listen' => '4e61fa88', 590 590 'javelin-behavior-aphlict-status' => 'c3703a16', 591 591 'javelin-behavior-aphront-basic-tokenizer' => '3b4899b0', 592 - 'javelin-behavior-aphront-drag-and-drop-textarea' => '7df68a45', 592 + 'javelin-behavior-aphront-drag-and-drop-textarea' => '3277c62d', 593 593 'javelin-behavior-aphront-form-disable-on-submit' => '55d7b788', 594 594 'javelin-behavior-aphront-more' => '506aa3f4', 595 595 'javelin-behavior-audio-source' => '3dc5ad43', ··· 1195 1195 'javelin-install', 1196 1196 'javelin-util', 1197 1197 ), 1198 + '3277c62d' => array( 1199 + 'javelin-behavior', 1200 + 'javelin-dom', 1201 + 'javelin-json', 1202 + 'phabricator-drag-and-drop-file-upload', 1203 + 'phabricator-textareautils', 1204 + ), 1198 1205 '32db8374' => array( 1199 1206 'javelin-behavior', 1200 1207 'javelin-stratcom', ··· 1613 1620 '7c4d8998' => array( 1614 1621 'javelin-install', 1615 1622 'javelin-dom', 1616 - ), 1617 - '7df68a45' => array( 1618 - 'javelin-behavior', 1619 - 'javelin-dom', 1620 - 'javelin-json', 1621 - 'phabricator-drag-and-drop-file-upload', 1622 - 'phabricator-textareautils', 1623 1623 ), 1624 1624 '80bff3af' => array( 1625 1625 'javelin-install',
+6 -2
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 1908 1908 1909 1909 $comment_text = $request->getStr('comment'); 1910 1910 1911 + $comment_metadata = $request->getStr('comment_metadata'); 1912 + if (strlen($comment_metadata)) { 1913 + $comment_metadata = phutil_json_decode($comment_metadata); 1914 + } 1915 + 1911 1916 $actions = $request->getStr('editengine.actions'); 1912 1917 if ($actions) { 1913 1918 $actions = phutil_json_decode($actions); ··· 1923 1928 $viewer->getPHID(), 1924 1929 $current_version); 1925 1930 1926 - $is_empty = (!strlen($comment_text) && !$actions); 1927 - 1928 1931 $draft 1929 1932 ->setProperty('comment', $comment_text) 1933 + ->setProperty('metadata', $comment_metadata) 1930 1934 ->setProperty('actions', $actions) 1931 1935 ->save(); 1932 1936
+27 -14
src/applications/transactions/view/PhabricatorApplicationTransactionCommentView.php
··· 294 294 } 295 295 296 296 private function renderCommentPanel() { 297 + $viewer = $this->getViewer(); 298 + 299 + $remarkup_control = id(new PhabricatorRemarkupControl()) 300 + ->setViewer($viewer) 301 + ->setID($this->getCommentID()) 302 + ->addClass('phui-comment-fullwidth-control') 303 + ->addClass('phui-comment-textarea-control') 304 + ->setCanPin(true) 305 + ->setName('comment'); 306 + 297 307 $draft_comment = ''; 308 + $draft_metadata = array(); 298 309 $draft_key = null; 299 - if ($this->getDraft()) { 300 - $draft_comment = $this->getDraft()->getDraft(); 301 - $draft_key = $this->getDraft()->getDraftKey(); 310 + 311 + $legacy_draft = $this->getDraft(); 312 + if ($legacy_draft) { 313 + $draft_comment = $legacy_draft->getDraft(); 314 + $draft_key = $legacy_draft->getDraftKey(); 302 315 } 303 316 304 317 $versioned_draft = $this->getVersionedDraft(); 305 318 if ($versioned_draft) { 306 - $draft_comment = $versioned_draft->getProperty('comment', ''); 319 + $draft_comment = $versioned_draft->getProperty( 320 + 'comment', 321 + $draft_comment); 322 + $draft_metadata = $versioned_draft->getProperty( 323 + 'metadata', 324 + $draft_metadata); 307 325 } 326 + 327 + $remarkup_control->setValue($draft_comment); 328 + $remarkup_control->setRemarkupMetadata($draft_metadata); 308 329 309 330 if (!$this->getObjectPHID()) { 310 331 throw new PhutilInvalidStateException('setObjectPHID', 'render'); ··· 314 335 $version_value = $this->getCurrentVersion(); 315 336 316 337 $form = id(new AphrontFormView()) 317 - ->setUser($this->getUser()) 338 + ->setUser($viewer) 318 339 ->addSigil('transaction-append') 319 340 ->setWorkflow(true) 320 341 ->setFullWidth($this->fullWidth) ··· 465 486 ->setValue($this->getSubmitButtonName()); 466 487 467 488 $form 468 - ->appendChild( 469 - id(new PhabricatorRemarkupControl()) 470 - ->setID($this->getCommentID()) 471 - ->addClass('phui-comment-fullwidth-control') 472 - ->addClass('phui-comment-textarea-control') 473 - ->setCanPin(true) 474 - ->setName('comment') 475 - ->setUser($this->getUser()) 476 - ->setValue($draft_comment)) 489 + ->appendChild($remarkup_control) 477 490 ->appendChild( 478 491 id(new AphrontFormSubmitControl()) 479 492 ->addClass('phui-comment-fullwidth-control')
+11 -1
webroot/rsrc/js/core/behavior-drag-and-drop-textarea.js
··· 16 16 17 17 function set_metadata(key, value) { 18 18 metadata_value[key] = value; 19 - metadata_node.value = JX.JSON.stringify(metadata_value); 19 + write_metadata(); 20 20 } 21 21 22 22 function get_metadata(key, default_value) { ··· 26 26 return default_value; 27 27 } 28 28 29 + function write_metadata() { 30 + metadata_node.value = JX.JSON.stringify(metadata_value); 31 + } 32 + 33 + write_metadata(); 34 + 29 35 if (JX.PhabricatorDragAndDropFileUpload.isSupported()) { 30 36 var drop = new JX.PhabricatorDragAndDropFileUpload(target) 31 37 .setURI(config.uri) ··· 41 47 42 48 drop.listen('didUpload', function(file) { 43 49 JX.TextAreaUtils.insertFileReference(target, file); 50 + 51 + var phids = get_metadata('attachedFilePHIDs', []); 52 + phids.push(file.getPHID()); 53 + set_metadata('attachedFilePHIDs', phids); 44 54 }); 45 55 46 56 drop.start();