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

Remove direct reads of form state from main Inline client code

Summary:
Ref T13559. Instead of directly reading form state, make all callers use the "active" state instead. The state reads the form.

No functional changes, just clarifying responsiblites.

Test Plan: Created inlines, etc. See followup changes.

Maniphest Tasks: T13559

Differential Revision: https://secure.phabricator.com/D21647
This commit is contained in:
epriestley 2021-03-23 12:11:21 -07:00
parent cb00cb99e2
commit 0f04d9e584
2 changed files with 10 additions and 32 deletions

View file

@ -13,7 +13,7 @@ return array(
'core.pkg.js' => 'ab3502fe', 'core.pkg.js' => 'ab3502fe',
'dark-console.pkg.js' => '187792c2', 'dark-console.pkg.js' => '187792c2',
'differential.pkg.css' => 'ffb69e3d', 'differential.pkg.css' => 'ffb69e3d',
'differential.pkg.js' => '68a2e7be', 'differential.pkg.js' => '442567d7',
'diffusion.pkg.css' => '42c75c37', 'diffusion.pkg.css' => '42c75c37',
'diffusion.pkg.js' => '78c9885d', 'diffusion.pkg.js' => '78c9885d',
'maniphest.pkg.css' => '35995d6d', 'maniphest.pkg.css' => '35995d6d',
@ -385,7 +385,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' => 'd7d3ba75', 'rsrc/js/application/diff/DiffChangeset.js' => 'd7d3ba75',
'rsrc/js/application/diff/DiffChangesetList.js' => 'cc2c5de5', 'rsrc/js/application/diff/DiffChangesetList.js' => 'cc2c5de5',
'rsrc/js/application/diff/DiffInline.js' => 'a5f196da', 'rsrc/js/application/diff/DiffInline.js' => 'fdebbba6',
'rsrc/js/application/diff/DiffInlineContentState.js' => '68e6339d', 'rsrc/js/application/diff/DiffInlineContentState.js' => '68e6339d',
'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',
@ -788,7 +788,7 @@ return array(
'phabricator-dashboard-css' => '5a205b9d', 'phabricator-dashboard-css' => '5a205b9d',
'phabricator-diff-changeset' => 'd7d3ba75', 'phabricator-diff-changeset' => 'd7d3ba75',
'phabricator-diff-changeset-list' => 'cc2c5de5', 'phabricator-diff-changeset-list' => 'cc2c5de5',
'phabricator-diff-inline' => 'a5f196da', 'phabricator-diff-inline' => 'fdebbba6',
'phabricator-diff-inline-content-state' => '68e6339d', 'phabricator-diff-inline-content-state' => '68e6339d',
'phabricator-diff-path-view' => '8207abf9', 'phabricator-diff-path-view' => '8207abf9',
'phabricator-diff-tree-view' => '5d83623b', 'phabricator-diff-tree-view' => '5d83623b',
@ -1871,10 +1871,6 @@ return array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
), ),
'a5f196da' => array(
'javelin-dom',
'phabricator-diff-inline-content-state',
),
'a77e2cbd' => array( 'a77e2cbd' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',
@ -2235,6 +2231,10 @@ return array(
'fdc13e4e' => array( 'fdc13e4e' => array(
'javelin-install', 'javelin-install',
), ),
'fdebbba6' => array(
'javelin-dom',
'phabricator-diff-inline-content-state',
),
'ff688a7a' => array( 'ff688a7a' => array(
'owners-path-editor', 'owners-path-editor',
'javelin-behavior', 'javelin-behavior',

View file

@ -612,7 +612,7 @@ JX.install('DiffInline', {
// read and preserve the text so "Undo" restores it. // read and preserve the text so "Undo" restores it.
var state = null; var state = null;
if (this._editRow) { if (this._editRow) {
state = this._readFormState(this._editRow); state = this._getActiveContentState().getWireFormat();
JX.DOM.remove(this._editRow); JX.DOM.remove(this._editRow);
this._editRow = null; this._editRow = null;
} }
@ -856,7 +856,7 @@ JX.install('DiffInline', {
}, },
cancel: function() { cancel: function() {
var state = this._readFormState(this._editRow); var state = this._getActiveContentState().getWireFormat();
JX.DOM.remove(this._editRow); JX.DOM.remove(this._editRow);
this._editRow = null; this._editRow = null;
@ -909,28 +909,6 @@ JX.install('DiffInline', {
} }
}, },
_readFormState: function(row) {
var state = this._newContentState();
var node;
try {
node = JX.DOM.find(row, 'textarea', 'inline-content-text');
state.text = node.value;
} catch (ex) {
// Ignore.
}
node = this._getSuggestionNode(row);
if (node) {
state.suggestionText = node.value;
}
state.hasSuggestion = this._getActiveContentState().getHasSuggestion();
return state;
},
_getSuggestionNode: function(row) { _getSuggestionNode: function(row) {
try { try {
return JX.DOM.find(row, 'textarea', 'inline-content-suggestion'); return JX.DOM.find(row, 'textarea', 'inline-content-suggestion');
@ -1043,7 +1021,7 @@ JX.install('DiffInline', {
return null; return null;
} }
var state = this._readFormState(this._editRow); var state = this._getActiveContentState().getWireFormat();
if (this._isVoidContentState(state)) { if (this._isVoidContentState(state)) {
return null; return null;
} }