Merge changes from topic 'pg-change-editing'

* changes:
  Hide reviewed checkbox when edit is loaded
  Add _editLoaded property to gr-change-view
This commit is contained in:
Kasper Nilsson
2017-08-09 21:18:55 +00:00
committed by Gerrit Code Review
6 changed files with 61 additions and 3 deletions

View File

@@ -516,6 +516,7 @@ limitations under the License.
project-config="[[_projectConfig]]"
selected-index="{{viewState.selectedFileIndex}}"
diff-view-mode="{{viewState.diffMode}}"
edit-loaded="[[_editLoaded]]"
num-files-shown="{{_numFilesShown}}"
file-list-increment="{{_numFilesShown}}"></gr-file-list>
</section>

View File

@@ -182,6 +182,10 @@
},
_updateCheckTimerHandle: Number,
_sortedRevisions: Array,
_editLoaded: {
type: Boolean,
computed: '_computeEditLoaded(_patchRange.*)',
},
},
behaviors: [
@@ -1319,5 +1323,10 @@
_computeHeaderClass(change) {
return change.work_in_progress ? 'header wip' : 'header';
},
_computeEditLoaded(patchRangeRecord) {
const patchRange = patchRangeRecord.base || {};
return this.patchNumEquals(patchRange.patchNum, this.EDIT_NAME);
},
});
})();

View File

@@ -1288,6 +1288,14 @@ limitations under the License.
assert.isTrue(element.$.relatedChanges.reload.calledOnce);
});
test('_computeEditLoaded', () => {
const callCompute = range => element._computeEditLoaded({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('_upgradeUrl calls', () => {
let upgradeStub;
const mockChange = {project: 'test'};

View File

@@ -168,6 +168,9 @@ limitations under the License.
.mobile {
display: none;
}
#container.editLoaded .hideOnEdit {
display: none;
}
@media screen and (max-width: 50em) {
.desktop {
display: none;
@@ -245,7 +248,10 @@ limitations under the License.
</label>
</div>
</header>
<div on-tap="_handleFileListTap">
<div
id="container"
class$="[[_computeContainerClass(editLoaded)]]"
on-tap="_handleFileListTap">
<template is="dom-repeat"
items="[[_shownFiles]]"
id="files"
@@ -253,7 +259,7 @@ limitations under the License.
initial-count="[[fileListIncrement]]"
target-framerate="1">
<div class="file-row row" data-path$="[[file.__path]]" tabindex="-1">
<div class="reviewed" hidden$="[[!_loggedIn]]" hidden>
<div class="reviewed hideOnEdit" hidden$="[[!_loggedIn]]" hidden>
<input
type="checkbox"
checked="[[file.isReviewed]]"

View File

@@ -14,6 +14,8 @@
(function() {
'use strict';
const ERR_EDIT_LOADED = 'You cannot change the review status of an edit.';
// Maximum length for patch set descriptions.
const PATCH_DESC_MAX_LENGTH = 500;
const WARN_SHOW_ALL_THRESHOLD = 1000;
@@ -58,6 +60,7 @@
notify: true,
observer: '_updateDiffPreferences',
},
editLoaded: Boolean,
_files: {
type: Array,
observer: '_filesChanged',
@@ -387,6 +390,10 @@
},
_reviewFile(path) {
if (this.editLoaded) {
this.fire('show-alert', {message: ERR_EDIT_LOADED});
return;
}
const index = this._reviewed.indexOf(path);
const reviewed = index !== -1;
if (reviewed) {
@@ -942,5 +949,9 @@
this.classList.toggle('loading', loading && this._files.length);
}, LOADING_DEBOUNCE_INTERVAL);
},
_computeContainerClass(editLoaded) {
return editLoaded ? 'editLoaded' : '';
},
});
})();

View File

@@ -1282,7 +1282,30 @@ limitations under the License.
element._handleEscKey(mockEvent);
assert.isFalse(element._displayLine);
});
});
suite('editLoaded behavior', () => {
const isVisible = el => {
assert.ok(el);
return getComputedStyle(el).getPropertyValue('display') !== 'none';
};
test('reviewed checkbox', () => {
const alertStub = sandbox.stub();
element.addEventListener('show-alert', alertStub);
element.editLoaded = false;
// Reviewed checkbox should be shown.
assert.isTrue(isVisible(element.$$('.reviewed')));
MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
assert.isFalse(alertStub.called);
element.editLoaded = true;
flushAsynchronousOperations();
assert.isFalse(isVisible(element.$$('.reviewed')));
MockInteractions.pressAndReleaseKeyOn(element, 82, null, 'r');
assert.isTrue(alertStub.called);
});
});
});
a11ySuite('basic');
</script>