Replace editLoaded with editMode

Done for clarity and differentiation with `editPatchsetLoaded`.

Bug: Issue 4437
Change-Id: I05432b202921cad7f906a1cbe9ed68aaeac164cb
This commit is contained in:
Kasper Nilsson
2018-01-23 17:15:38 -08:00
parent eb389b9185
commit 808838e915
14 changed files with 59 additions and 59 deletions

View File

@@ -320,8 +320,8 @@
type: Boolean,
value: false,
},
// editLoaded == "is edit mode enabled in the file list".
editLoaded: {
// editMode == "is edit mode enabled in the file list".
editMode: {
type: Boolean,
value: false,
},
@@ -342,7 +342,7 @@
observers: [
'_actionsChanged(actions.*, revisionActions.*, _additionalActions.*, ' +
'editPatchsetLoaded, editLoaded, editBasedOnCurrentPatchSet, change)',
'editPatchsetLoaded, editMode, editBasedOnCurrentPatchSet, change)',
'_changeChanged(change)',
],
@@ -489,7 +489,7 @@
},
_actionsChanged(actionsChangeRecord, revisionActionsChangeRecord,
additionalActionsChangeRecord, editPatchsetLoaded, editLoaded,
additionalActionsChangeRecord, editPatchsetLoaded, editMode,
editBasedOnCurrentPatchSet, change) {
const additionalActions = (additionalActionsChangeRecord &&
additionalActionsChangeRecord.base) || [];
@@ -549,7 +549,7 @@
// Only show edit button if there is no edit patchset loaded and the
// file list is not in edit mode.
if (editPatchsetLoaded || editLoaded) {
if (editPatchsetLoaded || editMode) {
if (changeActions.edit) {
delete this.actions.edit;
this.notifyPath('actions.edit');

View File

@@ -401,7 +401,7 @@ limitations under the License.
suite('change edits', () => {
test('shows confirm dialog for delete edit', () => {
element.set('editLoaded', true);
element.set('editMode', true);
element.set('editPatchsetLoaded', true);
const fireActionStub = sandbox.stub(element, '_fireAction');
element._handleDeleteEditTap();
@@ -415,7 +415,7 @@ limitations under the License.
});
test('hide publishEdit and rebaseEdit if change is not open', () => {
element.set('editLoaded', true);
element.set('editMode', true);
element.set('editPatchsetLoaded', true);
element.change = {status: 'MERGED'};
flushAsynchronousOperations();
@@ -426,7 +426,7 @@ limitations under the License.
});
test('edit patchset is loaded, needs rebase', () => {
element.set('editLoaded', true);
element.set('editMode', true);
element.set('editPatchsetLoaded', true);
element.change = {status: 'NEW'};
element.editBasedOnCurrentPatchSet = false;
@@ -439,7 +439,7 @@ limitations under the License.
});
test('edit patchset is loaded, does not need rebase', () => {
element.set('editLoaded', true);
element.set('editMode', true);
element.set('editPatchsetLoaded', true);
element.change = {status: 'NEW'};
element.editBasedOnCurrentPatchSet = true;
@@ -452,7 +452,7 @@ limitations under the License.
});
test('edit mode is loaded, no edit patchset', () => {
element.set('editLoaded', true);
element.set('editMode', true);
element.set('editPatchsetLoaded', false);
element.change = {status: 'NEW'};
flushAsynchronousOperations();
@@ -464,7 +464,7 @@ limitations under the License.
});
test('normal patch set', () => {
element.set('editLoaded', false);
element.set('editMode', false);
element.set('editPatchsetLoaded', false);
element.change = {status: 'NEW'};
flushAsynchronousOperations();
@@ -477,11 +477,11 @@ limitations under the License.
test('edit action', done => {
element.addEventListener('edit-tap', () => { done(); });
element.set('editLoaded', true);
element.set('editMode', true);
flushAsynchronousOperations();
assert.isNotOk(element.$$('gr-button[data-action-key="edit"]'));
element.set('editLoaded', false);
element.set('editMode', false);
flushAsynchronousOperations();
const editButton = element.$$('gr-button[data-action-key="edit"]');

View File

@@ -365,7 +365,7 @@ limitations under the License.
reply-button-label="[[_replyButtonLabel]]"
commit-message="[[_latestCommitMessage]]"
edit-patchset-loaded="[[hasEditPatchsetLoaded(_patchRange)]]"
edit-loaded="[[_editLoaded]]"
edit-mode="[[_editMode]]"
edit-based-on-current-patch-set="[[hasEditBasedOnCurrentPatchSet(_allPatchSets)]]"
on-reload-change="_handleReloadChange"
on-edit-tap="_handleEditTap"
@@ -478,7 +478,7 @@ limitations under the License.
change-comments="[[_changeComments]]"
commit-info="[[_commitInfo]]"
change-url="[[_computeChangeUrl(_change)]]"
edit-loaded="[[_editLoaded]]"
edit-mode="[[_editMode]]"
logged-in="[[_loggedIn]]"
server-config="[[_serverConfig]]"
shown-file-count="[[_shownFileCount]]"
@@ -503,7 +503,7 @@ limitations under the License.
project-config="[[_projectConfig]]"
selected-index="{{viewState.selectedFileIndex}}"
diff-view-mode="[[viewState.diffMode]]"
edit-loaded="[[_editLoaded]]"
edit-mode="[[_editMode]]"
num-files-shown="{{_numFilesShown}}"
files-expanded="{{_filesExpanded}}"
file-list-increment="{{_numFilesShown}}"

View File

@@ -207,9 +207,9 @@
},
/** @type {?number} */
_updateCheckTimerHandle: Number,
_editLoaded: {
_editMode: {
type: Boolean,
computed: '_computeEditLoaded(_patchRange.*, params.*)',
computed: '_computeEditMode(_patchRange.*, params.*)',
},
_showRelatedToggle: {
type: Boolean,
@@ -1381,7 +1381,7 @@
return change.work_in_progress ? 'header wip' : 'header';
},
_computeEditLoaded(patchRangeRecord, paramsRecord) {
_computeEditMode(patchRangeRecord, paramsRecord) {
if (paramsRecord.base && paramsRecord.base.edit) { return true; }
const patchRange = patchRangeRecord.base || {};

View File

@@ -1335,9 +1335,9 @@ limitations under the License.
assert.isTrue(element.$.relatedChanges.reload.calledOnce);
});
test('_computeEditLoaded', () => {
test('_computeEditMode', () => {
const callCompute = (range, params) =>
element._computeEditLoaded({base: range}, {base: params});
element._computeEditMode({base: range}, {base: params});
assert.isFalse(callCompute({}, {}));
assert.isTrue(callCompute({}, {edit: true}));
assert.isFalse(callCompute({basePatchNum: 'PARENT', patchNum: 1}, {}));

View File

@@ -118,16 +118,16 @@ limitations under the License.
.fileViewActions > *:not(:last-child) {
margin-right: 5px;
}
.editLoaded .hideOnEdit {
.editMode .hideOnEdit {
display: none;
}
.showOnEdit {
display: none;
}
.editLoaded .showOnEdit {
.editMode .showOnEdit {
display: initial;
}
.editLoaded .showOnEdit.flexContainer {
.editMode .showOnEdit.flexContainer {
align-items: center;
display: flex;
}
@@ -144,7 +144,7 @@ limitations under the License.
}
}
</style>
<div class$="patchInfo-header [[_computeEditLoadedClass(editLoaded)]] [[_computePatchInfoClass(patchNum, allPatchSets)]]">
<div class$="patchInfo-header [[_computeEditModeClass(editMode)]] [[_computePatchInfoClass(patchNum, allPatchSets)]]">
<div class="patchInfo-left">
<h3 class="label">Files</h3>
<div class="patchInfoContent">

View File

@@ -29,7 +29,7 @@
changeUrl: String,
changeComments: Object,
commitInfo: Object,
editLoaded: Boolean,
editMode: Boolean,
loggedIn: Boolean,
serverConfig: Object,
shownFileCount: Number,
@@ -201,8 +201,8 @@
this.fire('open-download-dialog');
},
_computeEditLoadedClass(editLoaded) {
return editLoaded ? 'editLoaded' : '';
_computeEditModeClass(editMode) {
return editMode ? 'editMode' : '';
},
_computePatchInfoClass(patchNum, allPatchSets) {

View File

@@ -273,7 +273,7 @@ limitations under the License.
assert.equal(element._computePatchInfoClass('4', allPatchSets), '');
});
suite('editLoaded behavior', () => {
suite('editMode behavior', () => {
setup(() => {
element.loggedIn = true;
element.diffPrefs = {};
@@ -285,14 +285,14 @@ limitations under the License.
};
test('patch specific elements', () => {
element.editLoaded = true;
element.editMode = true;
sandbox.stub(element, 'computeLatestPatchNum').returns('2');
flushAsynchronousOperations();
assert.isFalse(isVisible(element.$.diffPrefsContainer));
assert.isFalse(isVisible(element.$$('.descriptionContainer')));
element.editLoaded = false;
element.editMode = false;
flushAsynchronousOperations();
assert.isTrue(isVisible(element.$$('.descriptionContainer')));
@@ -300,11 +300,11 @@ limitations under the License.
});
test('edit-controls visibility', () => {
element.editLoaded = true;
element.editMode = true;
flushAsynchronousOperations();
assert.isTrue(isVisible(element.$.editControls.parentElement));
element.editLoaded = false;
element.editMode = false;
flushAsynchronousOperations();
assert.isFalse(isVisible(element.$.editControls.parentElement));
});

View File

@@ -50,13 +50,13 @@ limitations under the License.
:host(.loading) .row {
opacity: .5;
};
:host(.editLoaded) .hideOnEdit {
:host(.editMode) .hideOnEdit {
display: none;
}
.showOnEdit {
display: none;
}
:host(.editLoaded) .showOnEdit {
:host(.editMode) .showOnEdit {
display: initial;
}
.controlRow {

View File

@@ -63,9 +63,9 @@
notify: true,
observer: '_updateDiffPreferences',
},
editLoaded: {
editMode: {
type: Boolean,
observer: '_editLoadedChanged',
observer: '_editModeChanged',
},
filesExpanded: {
type: String,
@@ -377,7 +377,7 @@
},
_reviewFile(path) {
if (this.editLoaded) {
if (this.editMode) {
this.fire('show-alert', {message: ERR_EDIT_LOADED});
return;
}
@@ -402,7 +402,7 @@
},
_getReviewedFiles() {
if (this.editLoaded) { return Promise.resolve([]); }
if (this.editMode) { return Promise.resolve([]); }
return this.$.restAPI.getReviewedFiles(this.changeNum,
this.patchRange.patchNum);
},
@@ -935,8 +935,8 @@
}, LOADING_DEBOUNCE_INTERVAL);
},
_editLoadedChanged(editLoaded) {
this.classList.toggle('editLoaded', editLoaded);
_editModeChanged(editMode) {
this.classList.toggle('editMode', editMode);
},
_computeReviewedClass(isReviewed) {

View File

@@ -1280,18 +1280,18 @@ limitations under the License.
assert.isFalse(element._displayLine);
});
suite('editLoaded behavior', () => {
suite('editMode behavior', () => {
test('reviewed checkbox', () => {
const alertStub = sandbox.stub();
const saveReviewStub = sandbox.stub(element, '_saveReviewedState');
element.addEventListener('show-alert', alertStub);
element.editLoaded = false;
element.editMode = false;
MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
assert.isFalse(alertStub.called);
assert.isTrue(saveReviewStub.calledOnce);
element.editLoaded = true;
element.editMode = true;
flushAsynchronousOperations();
MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
@@ -1301,7 +1301,7 @@ limitations under the License.
test('_getReviewedFiles does not call API', () => {
const apiSpy = sandbox.spy(element.$.restAPI, 'getReviewedFiles');
element.editLoaded = true;
element.editMode = true;
return element._getReviewedFiles().then(files => {
assert.equal(files.length, 0);
assert.isFalse(apiSpy.called);
@@ -1310,7 +1310,7 @@ limitations under the License.
});
test('editing actions', () => {
element.editLoaded = true;
element.editMode = true;
const editControls =
Polymer.dom(element.root).querySelectorAll('.row:not(.header)')
.map(row => row.querySelector('gr-edit-file-controls'));

View File

@@ -116,7 +116,7 @@ limitations under the License.
display: block;
overflow: auto;
}
.editLoaded .hideOnEdit {
.editMode .hideOnEdit {
display: none;
}
.blameLoader {
@@ -188,7 +188,7 @@ limitations under the License.
}
</style>
<gr-fixed-panel
class$="[[_computeContainerClass(_editLoaded)]]"
class$="[[_computeContainerClass(_editMode)]]"
floating-disabled="[[_panelFloatingDisabled]]"
keep-on-scroll
ready-for-measure="[[!_loading]]">

View File

@@ -132,9 +132,9 @@
type: Boolean,
value: () => { return window.PANEL_FLOATING_DISABLED; },
},
_editLoaded: {
_editMode: {
type: Boolean,
computed: '_computeEditLoaded(_patchRange.*)',
computed: '_computeEditMode(_patchRange.*)',
},
_isBlameSupported: {
type: Boolean,
@@ -244,7 +244,7 @@
},
_setReviewed(reviewed) {
if (this._editLoaded) { return; }
if (this._editMode) { return; }
this.$.reviewed.checked = reviewed;
this._saveReviewedState(reviewed).catch(err => {
this.fire('show-alert', {message: ERR_REVIEW_STATUS});
@@ -882,16 +882,16 @@
/**
* @param {!Object} patchRangeRecord
*/
_computeEditLoaded(patchRangeRecord) {
_computeEditMode(patchRangeRecord) {
const patchRange = patchRangeRecord.base || {};
return this.patchNumEquals(patchRange.patchNum, this.EDIT_NAME);
},
/**
* @param {boolean} editLoaded
* @param {boolean} editMode
*/
_computeContainerClass(editLoaded) {
return editLoaded ? 'editLoaded' : '';
_computeContainerClass(editMode) {
return editMode ? 'editMode' : '';
},
_computeBlameToggleLabel(loaded, loading) {

View File

@@ -551,7 +551,7 @@ limitations under the License.
element._patchRange = {patchNum: element.EDIT_NAME};
flushAsynchronousOperations();
assert.isTrue(element._editLoaded);
assert.isTrue(element._editMode);
element._setReviewed();
assert.isFalse(saveReviewedStub.called);
});
@@ -868,15 +868,15 @@ limitations under the License.
});
});
test('_computeEditLoaded', () => {
const callCompute = range => element._computeEditLoaded({base: range});
test('_computeEditMode', () => {
const callCompute = range => element._computeEditMode({base: range});
assert.isFalse(callCompute({}));
assert.isFalse(callCompute({basePatchNum: 'PARENT', patchNum: 1}));
assert.isFalse(callCompute({basePatchNum: 'edit', patchNum: 1}));
assert.isTrue(callCompute({basePatchNum: 1, patchNum: 'edit'}));
});
suite('editLoaded behavior', () => {
suite('editMode behavior', () => {
setup(() => {
element._loggedIn = true;
});