1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

When cancelling an unsaved editing inline after a reload, don't cancel into an empty state

Summary:
Ref T13513. Overloading "original text" to get "edit-on-load" comments into the right state has some undesirable side effects.

Instead, provide the text when the editor opens. This fixes a cancel interaction.

Test Plan:
  - Create an inline, type text, don't save.
  - Reload page.
  - Cancel.
  - Before: cancelled into empty state.
  - After: cancelled into deleted+undo state.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21219
This commit is contained in:
epriestley 2020-05-04 13:55:43 -07:00
parent 7fa47408a3
commit 07e160bde1
5 changed files with 17 additions and 11 deletions

View file

@ -13,7 +13,7 @@ return array(
'core.pkg.js' => '632fb8f5', 'core.pkg.js' => '632fb8f5',
'dark-console.pkg.js' => '187792c2', 'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => '2d70b7b9', 'differential.pkg.css' => '2d70b7b9',
'differential.pkg.js' => 'e6da9e6f', 'differential.pkg.js' => '22ec6f26',
'diffusion.pkg.css' => '42c75c37', 'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => 'a98c0bf7', 'diffusion.pkg.js' => 'a98c0bf7',
'maniphest.pkg.css' => '35995d6d', 'maniphest.pkg.css' => '35995d6d',
@ -381,7 +381,7 @@ return array(
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
'rsrc/js/application/diff/DiffChangeset.js' => 'a49dc31e', 'rsrc/js/application/diff/DiffChangeset.js' => 'a49dc31e',
'rsrc/js/application/diff/DiffChangesetList.js' => '6992b85c', 'rsrc/js/application/diff/DiffChangesetList.js' => '6992b85c',
'rsrc/js/application/diff/DiffInline.js' => 'e6b9b4f3', 'rsrc/js/application/diff/DiffInline.js' => 'db754a7b',
'rsrc/js/application/diff/DiffPathView.js' => '8207abf9', 'rsrc/js/application/diff/DiffPathView.js' => '8207abf9',
'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b', 'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b',
'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17', 'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17',
@ -778,7 +778,7 @@ return array(
'phabricator-dashboard-css' => '5a205b9d', 'phabricator-dashboard-css' => '5a205b9d',
'phabricator-diff-changeset' => 'a49dc31e', 'phabricator-diff-changeset' => 'a49dc31e',
'phabricator-diff-changeset-list' => '6992b85c', 'phabricator-diff-changeset-list' => '6992b85c',
'phabricator-diff-inline' => 'e6b9b4f3', 'phabricator-diff-inline' => 'db754a7b',
'phabricator-diff-path-view' => '8207abf9', 'phabricator-diff-path-view' => '8207abf9',
'phabricator-diff-tree-view' => '5d83623b', 'phabricator-diff-tree-view' => '5d83623b',
'phabricator-drag-and-drop-file-upload' => '4370900d', 'phabricator-drag-and-drop-file-upload' => '4370900d',
@ -2113,6 +2113,9 @@ return array(
'javelin-uri', 'javelin-uri',
'phabricator-notification', 'phabricator-notification',
), ),
'db754a7b' => array(
'javelin-dom',
),
'e150bd50' => array( 'e150bd50' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -2132,9 +2135,6 @@ return array(
'javelin-dom', 'javelin-dom',
'phabricator-draggable-list', 'phabricator-draggable-list',
), ),
'e6b9b4f3' => array(
'javelin-dom',
),
'e8240b50' => array( 'e8240b50' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',

View file

@ -211,6 +211,14 @@ abstract class PhabricatorInlineCommentController
} }
$this->saveComment($inline); $this->saveComment($inline);
if (strlen($text)) {
$this->purgeVersionedDrafts($inline);
}
PhabricatorInlineComment::loadAndAttachVersionedDrafts(
$viewer,
array($inline));
} }
$edit_dialog = $this->buildEditDialog($inline) $edit_dialog = $this->buildEditDialog($inline)

View file

@ -109,7 +109,7 @@ final class PHUIDiffInlineCommentEditView
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$inline = $this->getInlineComment(); $inline = $this->getInlineComment();
$text = $inline->getContent(); $text = $inline->getContentForEdit($viewer);
return id(new PhabricatorRemarkupControl()) return id(new PhabricatorRemarkupControl())
->setViewer($viewer) ->setViewer($viewer)

View file

@ -75,8 +75,6 @@ abstract class PHUIDiffInlineCommentView extends AphrontView {
break; break;
} }
$original_text = $inline->getContentForEdit($viewer);
return array( return array(
'id' => $inline->getID(), 'id' => $inline->getID(),
'phid' => $inline->getPHID(), 'phid' => $inline->getPHID(),
@ -84,7 +82,7 @@ abstract class PHUIDiffInlineCommentView extends AphrontView {
'number' => $inline->getLineNumber(), 'number' => $inline->getLineNumber(),
'length' => $inline->getLineLength(), 'length' => $inline->getLineLength(),
'isNewFile' => (bool)$inline->getIsNewFile(), 'isNewFile' => (bool)$inline->getIsNewFile(),
'original' => $original_text, 'original' => $inline->getContent(),
'replyToCommentPHID' => $inline->getReplyToCommentPHID(), 'replyToCommentPHID' => $inline->getReplyToCommentPHID(),
'isDraft' => $inline->isDraft(), 'isDraft' => $inline->isDraft(),
'isFixed' => $is_fixed, 'isFixed' => $is_fixed,

View file

@ -96,7 +96,7 @@ JX.install('DiffInline', {
// which we're currently editing. This flow is a little clumsy, but // which we're currently editing. This flow is a little clumsy, but
// reasonable until some future change moves away from "send down // reasonable until some future change moves away from "send down
// the inline, then immediately click edit". // the inline, then immediately click edit".
this.edit(this._originalText, true); this.edit(null, true);
} else { } else {
this.setInvisible(false); this.setInvisible(false);
} }