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

When a user clicks "Cancel" on an inline comment to leave the "Editing" state, save the state change

Summary:
Ref T13513. Now that the "currently being edited" state of inlines is saved on the server side, clear the flag when the user clicks "Cancel" to leave the "editing" state on the client.

This also serves to delete empty comments.

Test Plan:
  - Clicked a line number to create a new comment. Then:
    - Clicked "Cancel". Reloaded page, saw no more comment.
    - Typed text, saved. Reloaded page, saw non-editing draft. Clicked "Edit", reloaded page, saw editing draft. Clicked "Cancel", reloaded page, saw non-editing draft.
    - Typed text, saved. Clicked "Edit", deleted text, saved. Reloaded page, saw no more comment.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21187
This commit is contained in:
epriestley 2020-04-29 11:25:43 -07:00
parent b48a22bf50
commit b2ce0844b6
3 changed files with 33 additions and 7 deletions

View file

@ -13,7 +13,7 @@ return array(
'core.pkg.js' => '632fb8f5',
'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => '2d70b7b9',
'differential.pkg.js' => 'b289f75d',
'differential.pkg.js' => 'b35de23a',
'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => 'a98c0bf7',
'maniphest.pkg.css' => '35995d6d',
@ -381,7 +381,7 @@ return array(
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8',
'rsrc/js/application/diff/DiffChangeset.js' => '9a713ba5',
'rsrc/js/application/diff/DiffChangesetList.js' => '10726e6a',
'rsrc/js/application/diff/DiffInline.js' => '7b0bdd6d',
'rsrc/js/application/diff/DiffInline.js' => '02791ed9',
'rsrc/js/application/diff/DiffPathView.js' => '8207abf9',
'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b',
'rsrc/js/application/diff/behavior-preview-link.js' => 'f51e9c17',
@ -778,7 +778,7 @@ return array(
'phabricator-dashboard-css' => '5a205b9d',
'phabricator-diff-changeset' => '9a713ba5',
'phabricator-diff-changeset-list' => '10726e6a',
'phabricator-diff-inline' => '7b0bdd6d',
'phabricator-diff-inline' => '02791ed9',
'phabricator-diff-path-view' => '8207abf9',
'phabricator-diff-tree-view' => '5d83623b',
'phabricator-drag-and-drop-file-upload' => '4370900d',
@ -944,6 +944,9 @@ return array(
'javelin-leader',
'javelin-json',
),
'02791ed9' => array(
'javelin-dom',
),
'02cb4398' => array(
'javelin-behavior',
'javelin-dom',
@ -1616,9 +1619,6 @@ return array(
'phabricator-drag-and-drop-file-upload',
'phabricator-textareautils',
),
'7b0bdd6d' => array(
'javelin-dom',
),
'7b139193' => array(
'javelin-behavior',
'javelin-stratcom',

View file

@ -215,6 +215,19 @@ abstract class PhabricatorInlineCommentController
$view = $this->buildScaffoldForView($edit_dialog);
return $this->newInlineResponse($inline, $view);
case 'cancel':
$inline = $this->loadCommentForEdit($this->getCommentID());
$inline->setIsEditing(false);
$content = $inline->getContent();
if (!strlen($content)) {
$this->deleteComment($inline);
} else {
$this->saveComment($inline);
}
return $this->buildEmptyResponse();
case 'new':
case 'reply':
default:

View file

@ -647,12 +647,25 @@ JX.install('DiffInline', {
}
this.setEditing(false);
this.setInvisible(false);
var uri = this._getInlineURI();
var data = this._newRequestData('cancel');
var handler = JX.bind(this, this._onCancelResponse);
this.setLoading(true);
new JX.Request(uri, handler)
.setData(data)
.send();
this._didUpdate(true);
},
_onCancelResponse: function(response) {
this.setLoading(false);
},
_readText: function(row) {
var textarea;
try {