1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-29 10:12:41 +01:00

Warn and prevent 1-up/2-up switch in Differential if the user is editing an inline

Summary:
See PHI180. Currently, if you begin creating or editing an inline and then swap display modes (for example, with "View Unified"), your edit is lost.

Persisting the editor state is complicated and this is very rare, so just prevent the action and warn the user instead.

Also make the warning persist for a little longer since a few of the messages, including this one, take a couple seconds to read now.

Test Plan:
  - Edited a comment, tried to swap display modes, got a warning.
  - Swapped display modes normally with no comment being edited.

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18774
This commit is contained in:
epriestley 2017-11-15 09:21:52 -08:00
parent a1f12b4ac7
commit 3700bcb638
3 changed files with 28 additions and 8 deletions

View file

@ -13,7 +13,7 @@ return array(
'core.pkg.js' => '4c79d74f',
'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '45951e9e',
'differential.pkg.js' => 'ae6460e0',
'differential.pkg.js' => '500a75c5',
'diffusion.pkg.css' => 'a2d17c7d',
'diffusion.pkg.js' => '6134c5a1',
'favicon.ico' => '30672e08',
@ -396,7 +396,7 @@ return array(
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375',
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63',
'rsrc/js/application/diff/DiffChangeset.js' => '99abf4cd',
'rsrc/js/application/diff/DiffChangesetList.js' => '8f1cd52c',
'rsrc/js/application/diff/DiffChangesetList.js' => '3b77efdd',
'rsrc/js/application/diff/DiffInline.js' => 'e83d28f3',
'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832',
'rsrc/js/application/differential/behavior-comment-preview.js' => '51c5ad07',
@ -775,7 +775,7 @@ return array(
'phabricator-darkmessage' => 'c48cccdd',
'phabricator-dashboard-css' => 'fe5b1869',
'phabricator-diff-changeset' => '99abf4cd',
'phabricator-diff-changeset-list' => '8f1cd52c',
'phabricator-diff-changeset-list' => '3b77efdd',
'phabricator-diff-inline' => 'e83d28f3',
'phabricator-drag-and-drop-file-upload' => '58dea2fa',
'phabricator-draggable-list' => 'bea6e7f4',
@ -1137,6 +1137,10 @@ return array(
'javelin-dom',
'javelin-magical-init',
),
'3b77efdd' => array(
'javelin-install',
'phuix-button-view',
),
'3cb0b2fc' => array(
'javelin-behavior',
'javelin-dom',
@ -1610,10 +1614,6 @@ return array(
'8e1baf68' => array(
'phui-button-css',
),
'8f1cd52c' => array(
'javelin-install',
'phuix-button-view',
),
'8f29b364' => array(
'javelin-behavior',
'javelin-stratcom',

View file

@ -301,6 +301,9 @@ final class DifferentialChangesetListView extends AphrontView {
'Hide or show all inline comments.' =>
pht('Hide or show all inline comments.'),
'Finish editing inline comments before changing display modes.' =>
pht('Finish editing inline comments before changing display modes.'),
),
));

View file

@ -465,7 +465,7 @@ JX.install('DiffChangesetList', {
new JX.Notification()
.setContent(message)
.alterClassName('jx-notification-alert', true)
.setDuration(1000)
.setDuration(3000)
.show();
},
@ -691,6 +691,7 @@ JX.install('DiffChangesetList', {
'div',
'differential-changeset');
var changeset_list = this;
var changeset = this.getChangesetForNode(node);
var menu = new JX.PHUIXDropdownMenu(button);
@ -738,6 +739,22 @@ JX.install('DiffChangesetList', {
var up_item = new JX.PHUIXActionView()
.setHandler(function(e) {
if (changeset.isLoaded()) {
// Don't let the user swap display modes if a comment is being
// edited, since they might lose their work. See PHI180.
var inlines = changeset.getInlines();
for (var ii = 0; ii < inlines.length; ii++) {
if (inlines[ii].isEditing()) {
changeset_list._warnUser(
pht(
'Finish editing inline comments before changing display ' +
'modes.'));
e.prevent();
menu.close();
return;
}
}
var renderer = changeset.getRenderer();
if (renderer == '1up') {
renderer = '2up';