mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-08 22:01:03 +01:00
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
This commit is contained in:
parent
2aa146ffac
commit
772afc5ed8
3 changed files with 69 additions and 30 deletions
|
@ -12,8 +12,8 @@ return array(
|
|||
'core.pkg.css' => 'ee5f28cd',
|
||||
'core.pkg.js' => '8c5f913d',
|
||||
'darkconsole.pkg.js' => '1f9a31bc',
|
||||
'differential.pkg.css' => '7b1c772c',
|
||||
'differential.pkg.js' => 'f1b636fb',
|
||||
'differential.pkg.css' => '4ff77743',
|
||||
'differential.pkg.js' => '85543704',
|
||||
'diffusion.pkg.css' => 'b93d9b8c',
|
||||
'diffusion.pkg.js' => '84c8f8fd',
|
||||
'favicon.ico' => '30672e08',
|
||||
|
@ -66,7 +66,7 @@ return array(
|
|||
'rsrc/css/application/differential/add-comment.css' => 'c47f8c40',
|
||||
'rsrc/css/application/differential/changeset-view.css' => '69a3c268',
|
||||
'rsrc/css/application/differential/core.css' => '5b7b8ff4',
|
||||
'rsrc/css/application/differential/phui-inline-comment.css' => 'e0a2b52e',
|
||||
'rsrc/css/application/differential/phui-inline-comment.css' => 'ffd1a542',
|
||||
'rsrc/css/application/differential/revision-comment.css' => '14b8565a',
|
||||
'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
|
||||
'rsrc/css/application/differential/revision-list.css' => 'f3c47d33',
|
||||
|
@ -392,7 +392,7 @@ return array(
|
|||
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63',
|
||||
'rsrc/js/application/diff/DiffChangeset.js' => 'c5742feb',
|
||||
'rsrc/js/application/diff/DiffChangesetList.js' => 'f1101e6e',
|
||||
'rsrc/js/application/diff/DiffInline.js' => 'bdf6b568',
|
||||
'rsrc/js/application/diff/DiffInline.js' => 'a81c29d4',
|
||||
'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832',
|
||||
'rsrc/js/application/differential/behavior-comment-preview.js' => 'b064af76',
|
||||
'rsrc/js/application/differential/behavior-diff-radios.js' => 'e1ff79b1',
|
||||
|
@ -781,7 +781,7 @@ return array(
|
|||
'phabricator-dashboard-css' => 'fe5b1869',
|
||||
'phabricator-diff-changeset' => 'c5742feb',
|
||||
'phabricator-diff-changeset-list' => 'f1101e6e',
|
||||
'phabricator-diff-inline' => 'bdf6b568',
|
||||
'phabricator-diff-inline' => 'a81c29d4',
|
||||
'phabricator-drag-and-drop-file-upload' => '58dea2fa',
|
||||
'phabricator-draggable-list' => 'bea6e7f4',
|
||||
'phabricator-fatal-config-template-css' => '8f18fa41',
|
||||
|
@ -864,7 +864,7 @@ return array(
|
|||
'phui-image-mask-css' => 'a8498f9c',
|
||||
'phui-info-panel-css' => '27ea50a1',
|
||||
'phui-info-view-css' => '6e217679',
|
||||
'phui-inline-comment-view-css' => 'e0a2b52e',
|
||||
'phui-inline-comment-view-css' => 'ffd1a542',
|
||||
'phui-invisible-character-view-css' => '6993d9f0',
|
||||
'phui-lightbox-css' => '0a035e40',
|
||||
'phui-list-view-css' => '12eb8ce6',
|
||||
|
@ -1718,6 +1718,9 @@ return array(
|
|||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
),
|
||||
'a81c29d4' => array(
|
||||
'javelin-dom',
|
||||
),
|
||||
'a8beebea' => array(
|
||||
'phui-oi-list-view-css',
|
||||
),
|
||||
|
@ -1872,9 +1875,6 @@ return array(
|
|||
'javelin-util',
|
||||
'javelin-request',
|
||||
),
|
||||
'bdf6b568' => array(
|
||||
'javelin-dom',
|
||||
),
|
||||
'bea6e7f4' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
|
|
|
@ -318,11 +318,10 @@
|
|||
|
||||
.differential-inline-undo {
|
||||
padding: 8px;
|
||||
margin: 8px 12px;
|
||||
margin: 4px 12px;
|
||||
text-align: center;
|
||||
background: {$sh-yellowbackground};
|
||||
border: 1px solid {$sh-yellowborder};
|
||||
margin: 4px 0;
|
||||
color: {$darkgreytext};
|
||||
font: {$basefont};
|
||||
font-size: {$normalfontsize};
|
||||
|
@ -396,7 +395,6 @@
|
|||
background: {$lightgreybackground};
|
||||
padding: 2px 16px;
|
||||
color: {$lightgreytext};
|
||||
font-size: {$smallerfontsize};
|
||||
display: none;
|
||||
font: {$basefont};
|
||||
white-space: nowrap;
|
||||
|
|
|
@ -25,6 +25,7 @@ JX.install('DiffInline', {
|
|||
_isNewFile: null,
|
||||
_undoRow: null,
|
||||
_replyToCommentPHID: null,
|
||||
_originalText: null,
|
||||
|
||||
_isDeleted: false,
|
||||
_isInvisible: false,
|
||||
|
@ -57,6 +58,7 @@ JX.install('DiffInline', {
|
|||
|
||||
this._number = data.number;
|
||||
this._length = data.length;
|
||||
this._originalText = data.original;
|
||||
this._isNewFile =
|
||||
(this.getDisplaySide() == 'right') ||
|
||||
(data.left != data.right);
|
||||
|
@ -165,6 +167,8 @@ JX.install('DiffInline', {
|
|||
this._phid = null;
|
||||
this._hidden = false;
|
||||
|
||||
this._originalText = null;
|
||||
|
||||
return row;
|
||||
},
|
||||
|
||||
|
@ -231,10 +235,10 @@ JX.install('DiffInline', {
|
|||
this._didUpdate();
|
||||
},
|
||||
|
||||
create: function() {
|
||||
create: function(text) {
|
||||
var uri = this._getInlineURI();
|
||||
var handler = JX.bind(this, this._oncreateresponse);
|
||||
var data = this._newRequestData('new');
|
||||
var data = this._newRequestData('new', text);
|
||||
|
||||
this.setLoading(true);
|
||||
|
||||
|
@ -248,10 +252,10 @@ JX.install('DiffInline', {
|
|||
return changeset.newInlineReply(this);
|
||||
},
|
||||
|
||||
edit: function() {
|
||||
edit: function(text) {
|
||||
var uri = this._getInlineURI();
|
||||
var handler = JX.bind(this, this._oneditresponse);
|
||||
var data = this._newRequestData('edit');
|
||||
var data = this._newRequestData('edit', text || null);
|
||||
|
||||
this.setLoading(true);
|
||||
|
||||
|
@ -336,7 +340,7 @@ JX.install('DiffInline', {
|
|||
return this;
|
||||
},
|
||||
|
||||
_newRequestData: function(operation) {
|
||||
_newRequestData: function(operation, text) {
|
||||
return {
|
||||
op: operation,
|
||||
id: this._id,
|
||||
|
@ -347,6 +351,7 @@ JX.install('DiffInline', {
|
|||
is_new: this.isNewFile(),
|
||||
changesetID: this.getChangesetID(),
|
||||
replyToCommentPHID: this.getReplyToCommentPHID() || '',
|
||||
text: text || ''
|
||||
};
|
||||
},
|
||||
|
||||
|
@ -366,7 +371,7 @@ JX.install('DiffInline', {
|
|||
},
|
||||
|
||||
_ondeleteresponse: function() {
|
||||
this._drawUndoRows();
|
||||
this._drawUndeleteRows();
|
||||
|
||||
this.setLoading(false);
|
||||
this.setDeleted(true);
|
||||
|
@ -374,7 +379,15 @@ JX.install('DiffInline', {
|
|||
this._didUpdate();
|
||||
},
|
||||
|
||||
_drawUndoRows: function() {
|
||||
_drawUndeleteRows: function() {
|
||||
return this._drawUndoRows('undelete', this._row);
|
||||
},
|
||||
|
||||
_drawUneditRows: function(text) {
|
||||
return this._drawUndoRows('unedit', null, text);
|
||||
},
|
||||
|
||||
_drawUndoRows: function(mode, cursor, text) {
|
||||
var templates = this.getChangeset().getUndoTemplates();
|
||||
|
||||
var template;
|
||||
|
@ -385,14 +398,14 @@ JX.install('DiffInline', {
|
|||
}
|
||||
template = JX.$H(template).getNode();
|
||||
|
||||
this._undoRow = this._drawRows(template, this._row, 'undo');
|
||||
this._undoRow = this._drawRows(template, cursor, mode, text);
|
||||
},
|
||||
|
||||
_drawEditRows: function(rows) {
|
||||
return this._drawRows(rows, null, 'edit');
|
||||
},
|
||||
|
||||
_drawRows: function(rows, cursor, type) {
|
||||
_drawRows: function(rows, cursor, type, text) {
|
||||
var first_row = JX.DOM.scry(rows, 'tr')[0];
|
||||
var first_meta;
|
||||
var row = first_row;
|
||||
|
@ -410,6 +423,7 @@ JX.install('DiffInline', {
|
|||
var row_meta = {
|
||||
node: row,
|
||||
type: type,
|
||||
text: text || null,
|
||||
listeners: []
|
||||
};
|
||||
|
||||
|
@ -476,16 +490,26 @@ JX.install('DiffInline', {
|
|||
|
||||
this._removeRow(row);
|
||||
|
||||
var uri = this._getInlineURI();
|
||||
var data = this._newRequestData('undelete');
|
||||
var handler = JX.bind(this, this._onundelete);
|
||||
if (row.type == 'undelete') {
|
||||
var uri = this._getInlineURI();
|
||||
var data = this._newRequestData('undelete');
|
||||
var handler = JX.bind(this, this._onundelete);
|
||||
|
||||
this.setDeleted(false);
|
||||
this.setLoading(true);
|
||||
this.setDeleted(false);
|
||||
this.setLoading(true);
|
||||
|
||||
new JX.Request(uri, handler)
|
||||
.setData(data)
|
||||
.send();
|
||||
new JX.Request(uri, handler)
|
||||
.setData(data)
|
||||
.send();
|
||||
}
|
||||
|
||||
if (row.type == 'unedit') {
|
||||
if (this.getID()) {
|
||||
this.edit(row.text);
|
||||
} else {
|
||||
this.create(row.text);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_onundelete: function() {
|
||||
|
@ -496,13 +520,30 @@ JX.install('DiffInline', {
|
|||
_oncancel: function(row, e) {
|
||||
e.kill();
|
||||
|
||||
// TODO: Capture edited text and offer "undo".
|
||||
var text = this._readText(row.node);
|
||||
if (text && text.length && (text != this._originalText)) {
|
||||
this._drawUneditRows(text);
|
||||
}
|
||||
|
||||
this._removeRow(row);
|
||||
|
||||
this.setInvisible(false);
|
||||
},
|
||||
|
||||
_readText: function(row) {
|
||||
var textarea;
|
||||
try {
|
||||
textarea = JX.DOM.find(
|
||||
row,
|
||||
'textarea',
|
||||
'differential-inline-comment-edit-textarea');
|
||||
} catch (ex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return textarea.value;
|
||||
},
|
||||
|
||||
_onsubmitresponse: function(row, response) {
|
||||
this._removeRow(row);
|
||||
|
||||
|
|
Loading…
Reference in a new issue