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

Allow cancelled inlines, edits, and replies to be undone to get the text back again

Summary: Ref T12616. The ability to do {nav Edit > Cancel > Undo} to get your text back on inlines got dropped during the conversion. Restore it.

Test Plan:
Created, replied, and edited inlines, typed text, then cancelled. Was able to undo.

Also undid normal deletion.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12616

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

+69 -30
+9 -9
resources/celerity/map.php
··· 12 12 'core.pkg.css' => 'ee5f28cd', 13 13 'core.pkg.js' => '8c5f913d', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 - 'differential.pkg.css' => '7b1c772c', 16 - 'differential.pkg.js' => 'f1b636fb', 15 + 'differential.pkg.css' => '4ff77743', 16 + 'differential.pkg.js' => '85543704', 17 17 'diffusion.pkg.css' => 'b93d9b8c', 18 18 'diffusion.pkg.js' => '84c8f8fd', 19 19 'favicon.ico' => '30672e08', ··· 66 66 'rsrc/css/application/differential/add-comment.css' => 'c47f8c40', 67 67 'rsrc/css/application/differential/changeset-view.css' => '69a3c268', 68 68 'rsrc/css/application/differential/core.css' => '5b7b8ff4', 69 - 'rsrc/css/application/differential/phui-inline-comment.css' => 'e0a2b52e', 69 + 'rsrc/css/application/differential/phui-inline-comment.css' => 'ffd1a542', 70 70 'rsrc/css/application/differential/revision-comment.css' => '14b8565a', 71 71 'rsrc/css/application/differential/revision-history.css' => '0e8eb855', 72 72 'rsrc/css/application/differential/revision-list.css' => 'f3c47d33', ··· 392 392 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63', 393 393 'rsrc/js/application/diff/DiffChangeset.js' => 'c5742feb', 394 394 'rsrc/js/application/diff/DiffChangesetList.js' => 'f1101e6e', 395 - 'rsrc/js/application/diff/DiffInline.js' => 'bdf6b568', 395 + 'rsrc/js/application/diff/DiffInline.js' => 'a81c29d4', 396 396 'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832', 397 397 'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76', 398 398 'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1', ··· 781 781 'phabricator-dashboard-css' => 'fe5b1869', 782 782 'phabricator-diff-changeset' => 'c5742feb', 783 783 'phabricator-diff-changeset-list' => 'f1101e6e', 784 - 'phabricator-diff-inline' => 'bdf6b568', 784 + 'phabricator-diff-inline' => 'a81c29d4', 785 785 'phabricator-drag-and-drop-file-upload' => '58dea2fa', 786 786 'phabricator-draggable-list' => 'bea6e7f4', 787 787 'phabricator-fatal-config-template-css' => '8f18fa41', ··· 864 864 'phui-image-mask-css' => 'a8498f9c', 865 865 'phui-info-panel-css' => '27ea50a1', 866 866 'phui-info-view-css' => '6e217679', 867 - 'phui-inline-comment-view-css' => 'e0a2b52e', 867 + 'phui-inline-comment-view-css' => 'ffd1a542', 868 868 'phui-invisible-character-view-css' => '6993d9f0', 869 869 'phui-lightbox-css' => '0a035e40', 870 870 'phui-list-view-css' => '12eb8ce6', ··· 1718 1718 'javelin-stratcom', 1719 1719 'javelin-dom', 1720 1720 ), 1721 + 'a81c29d4' => array( 1722 + 'javelin-dom', 1723 + ), 1721 1724 'a8beebea' => array( 1722 1725 'phui-oi-list-view-css', 1723 1726 ), ··· 1871 1874 'javelin-dom', 1872 1875 'javelin-util', 1873 1876 'javelin-request', 1874 - ), 1875 - 'bdf6b568' => array( 1876 - 'javelin-dom', 1877 1877 ), 1878 1878 'bea6e7f4' => array( 1879 1879 'javelin-install',
+1 -3
webroot/rsrc/css/application/differential/phui-inline-comment.css
··· 318 318 319 319 .differential-inline-undo { 320 320 padding: 8px; 321 - margin: 8px 12px; 321 + margin: 4px 12px; 322 322 text-align: center; 323 323 background: {$sh-yellowbackground}; 324 324 border: 1px solid {$sh-yellowborder}; 325 - margin: 4px 0; 326 325 color: {$darkgreytext}; 327 326 font: {$basefont}; 328 327 font-size: {$normalfontsize}; ··· 396 395 background: {$lightgreybackground}; 397 396 padding: 2px 16px; 398 397 color: {$lightgreytext}; 399 - font-size: {$smallerfontsize}; 400 398 display: none; 401 399 font: {$basefont}; 402 400 white-space: nowrap;
+59 -18
webroot/rsrc/js/application/diff/DiffInline.js
··· 25 25 _isNewFile: null, 26 26 _undoRow: null, 27 27 _replyToCommentPHID: null, 28 + _originalText: null, 28 29 29 30 _isDeleted: false, 30 31 _isInvisible: false, ··· 57 58 58 59 this._number = data.number; 59 60 this._length = data.length; 61 + this._originalText = data.original; 60 62 this._isNewFile = 61 63 (this.getDisplaySide() == 'right') || 62 64 (data.left != data.right); ··· 165 167 this._phid = null; 166 168 this._hidden = false; 167 169 170 + this._originalText = null; 171 + 168 172 return row; 169 173 }, 170 174 ··· 231 235 this._didUpdate(); 232 236 }, 233 237 234 - create: function() { 238 + create: function(text) { 235 239 var uri = this._getInlineURI(); 236 240 var handler = JX.bind(this, this._oncreateresponse); 237 - var data = this._newRequestData('new'); 241 + var data = this._newRequestData('new', text); 238 242 239 243 this.setLoading(true); 240 244 ··· 248 252 return changeset.newInlineReply(this); 249 253 }, 250 254 251 - edit: function() { 255 + edit: function(text) { 252 256 var uri = this._getInlineURI(); 253 257 var handler = JX.bind(this, this._oneditresponse); 254 - var data = this._newRequestData('edit'); 258 + var data = this._newRequestData('edit', text || null); 255 259 256 260 this.setLoading(true); 257 261 ··· 336 340 return this; 337 341 }, 338 342 339 - _newRequestData: function(operation) { 343 + _newRequestData: function(operation, text) { 340 344 return { 341 345 op: operation, 342 346 id: this._id, ··· 347 351 is_new: this.isNewFile(), 348 352 changesetID: this.getChangesetID(), 349 353 replyToCommentPHID: this.getReplyToCommentPHID() || '', 354 + text: text || '' 350 355 }; 351 356 }, 352 357 ··· 366 371 }, 367 372 368 373 _ondeleteresponse: function() { 369 - this._drawUndoRows(); 374 + this._drawUndeleteRows(); 370 375 371 376 this.setLoading(false); 372 377 this.setDeleted(true); ··· 374 379 this._didUpdate(); 375 380 }, 376 381 377 - _drawUndoRows: function() { 382 + _drawUndeleteRows: function() { 383 + return this._drawUndoRows('undelete', this._row); 384 + }, 385 + 386 + _drawUneditRows: function(text) { 387 + return this._drawUndoRows('unedit', null, text); 388 + }, 389 + 390 + _drawUndoRows: function(mode, cursor, text) { 378 391 var templates = this.getChangeset().getUndoTemplates(); 379 392 380 393 var template; ··· 385 398 } 386 399 template = JX.$H(template).getNode(); 387 400 388 - this._undoRow = this._drawRows(template, this._row, 'undo'); 401 + this._undoRow = this._drawRows(template, cursor, mode, text); 389 402 }, 390 403 391 404 _drawEditRows: function(rows) { 392 405 return this._drawRows(rows, null, 'edit'); 393 406 }, 394 407 395 - _drawRows: function(rows, cursor, type) { 408 + _drawRows: function(rows, cursor, type, text) { 396 409 var first_row = JX.DOM.scry(rows, 'tr')[0]; 397 410 var first_meta; 398 411 var row = first_row; ··· 410 423 var row_meta = { 411 424 node: row, 412 425 type: type, 426 + text: text || null, 413 427 listeners: [] 414 428 }; 415 429 ··· 476 490 477 491 this._removeRow(row); 478 492 479 - var uri = this._getInlineURI(); 480 - var data = this._newRequestData('undelete'); 481 - var handler = JX.bind(this, this._onundelete); 493 + if (row.type == 'undelete') { 494 + var uri = this._getInlineURI(); 495 + var data = this._newRequestData('undelete'); 496 + var handler = JX.bind(this, this._onundelete); 497 + 498 + this.setDeleted(false); 499 + this.setLoading(true); 482 500 483 - this.setDeleted(false); 484 - this.setLoading(true); 501 + new JX.Request(uri, handler) 502 + .setData(data) 503 + .send(); 504 + } 485 505 486 - new JX.Request(uri, handler) 487 - .setData(data) 488 - .send(); 506 + if (row.type == 'unedit') { 507 + if (this.getID()) { 508 + this.edit(row.text); 509 + } else { 510 + this.create(row.text); 511 + } 512 + } 489 513 }, 490 514 491 515 _onundelete: function() { ··· 496 520 _oncancel: function(row, e) { 497 521 e.kill(); 498 522 499 - // TODO: Capture edited text and offer "undo". 523 + var text = this._readText(row.node); 524 + if (text && text.length && (text != this._originalText)) { 525 + this._drawUneditRows(text); 526 + } 500 527 501 528 this._removeRow(row); 502 529 503 530 this.setInvisible(false); 531 + }, 532 + 533 + _readText: function(row) { 534 + var textarea; 535 + try { 536 + textarea = JX.DOM.find( 537 + row, 538 + 'textarea', 539 + 'differential-inline-comment-edit-textarea'); 540 + } catch (ex) { 541 + return null; 542 + } 543 + 544 + return textarea.value; 504 545 }, 505 546 506 547 _onsubmitresponse: function(row, response) {