Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 07e160b

Browse files
author
epriestley
committed
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
1 parent 7fa4740 commit 07e160b

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

resources/celerity/map.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'core.pkg.js' => '632fb8f5',
1414
'dark-console.pkg.js' => '187792c2',
1515
'differential.pkg.css' => '2d70b7b9',
16-
'differential.pkg.js' => 'e6da9e6f',
16+
'differential.pkg.js' => '22ec6f26',
1717
'diffusion.pkg.css' => '42c75c37',
1818
'diffusion.pkg.js' => 'a98c0bf7',
1919
'maniphest.pkg.css' => '35995d6d',
@@ -381,7 +381,7 @@
381381
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
382382
'rsrc/js/application/diff/DiffChangeset.js' => 'a49dc31e',
383383
'rsrc/js/application/diff/DiffChangesetList.js' => '6992b85c',
384-
'rsrc/js/application/diff/DiffInline.js' => 'e6b9b4f3',
384+
'rsrc/js/application/diff/DiffInline.js' => 'db754a7b',
385385
'rsrc/js/application/diff/DiffPathView.js' => '8207abf9',
386386
'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b',
387387
'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17',
@@ -778,7 +778,7 @@
778778
'phabricator-dashboard-css' => '5a205b9d',
779779
'phabricator-diff-changeset' => 'a49dc31e',
780780
'phabricator-diff-changeset-list' => '6992b85c',
781-
'phabricator-diff-inline' => 'e6b9b4f3',
781+
'phabricator-diff-inline' => 'db754a7b',
782782
'phabricator-diff-path-view' => '8207abf9',
783783
'phabricator-diff-tree-view' => '5d83623b',
784784
'phabricator-drag-and-drop-file-upload' => '4370900d',
@@ -2113,6 +2113,9 @@
21132113
'javelin-uri',
21142114
'phabricator-notification',
21152115
),
2116+
'db754a7b' => array(
2117+
'javelin-dom',
2118+
),
21162119
'e150bd50' => array(
21172120
'javelin-behavior',
21182121
'javelin-stratcom',
@@ -2132,9 +2135,6 @@
21322135
'javelin-dom',
21332136
'phabricator-draggable-list',
21342137
),
2135-
'e6b9b4f3' => array(
2136-
'javelin-dom',
2137-
),
21382138
'e8240b50' => array(
21392139
'javelin-behavior',
21402140
'javelin-stratcom',

src/infrastructure/diff/PhabricatorInlineCommentController.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ public function processRequest() {
211211
}
212212

213213
$this->saveComment($inline);
214+
215+
if (strlen($text)) {
216+
$this->purgeVersionedDrafts($inline);
217+
}
218+
219+
PhabricatorInlineComment::loadAndAttachVersionedDrafts(
220+
$viewer,
221+
array($inline));
214222
}
215223

216224
$edit_dialog = $this->buildEditDialog($inline)

src/infrastructure/diff/view/PHUIDiffInlineCommentEditView.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private function newTextarea() {
109109
$viewer = $this->getViewer();
110110
$inline = $this->getInlineComment();
111111

112-
$text = $inline->getContent();
112+
$text = $inline->getContentForEdit($viewer);
113113

114114
return id(new PhabricatorRemarkupControl())
115115
->setViewer($viewer)

src/infrastructure/diff/view/PHUIDiffInlineCommentView.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,14 @@ protected function getInlineCommentMetadata() {
7575
break;
7676
}
7777

78-
$original_text = $inline->getContentForEdit($viewer);
79-
8078
return array(
8179
'id' => $inline->getID(),
8280
'phid' => $inline->getPHID(),
8381
'changesetID' => $inline->getChangesetID(),
8482
'number' => $inline->getLineNumber(),
8583
'length' => $inline->getLineLength(),
8684
'isNewFile' => (bool)$inline->getIsNewFile(),
87-
'original' => $original_text,
85+
'original' => $inline->getContent(),
8886
'replyToCommentPHID' => $inline->getReplyToCommentPHID(),
8987
'isDraft' => $inline->isDraft(),
9088
'isFixed' => $is_fixed,

webroot/rsrc/js/application/diff/DiffInline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ JX.install('DiffInline', {
9696
// which we're currently editing. This flow is a little clumsy, but
9797
// reasonable until some future change moves away from "send down
9898
// the inline, then immediately click edit".
99-
this.edit(this._originalText, true);
99+
this.edit(null, true);
100100
} else {
101101
this.setInvisible(false);
102102
}

0 commit comments

Comments
 (0)