Hide reviewed checkbox when edit is loaded

Modifying the reviewed state of an edit patchset is an illogical action,
and should be disabled.

This change utilizes the _editLoaded property of gr-change-view to
conditionally hide the reviewed checkbox from the file list. In
addition, attempts to modify the reviewed state (e.g. with a hotkey)
are treated as a no-op, and the user is shown a toast.

TODO: Further utilize this approach to conditionally show buttons for
modifying an edit patchset. Will be done in a later change.

Bug: Issue 4437
Change-Id: Iee33d7ebbe0a7182cb91ca6168813154775d9ab4
This commit is contained in:
Kasper Nilsson
2017-08-07 10:58:19 -07:00
parent 9c8cfe5619
commit 5b57a36857
4 changed files with 44 additions and 3 deletions

View File

@@ -1267,7 +1267,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>