Toggle left diff on Shift+A
Feature: Issue 3926 Change-Id: Ia52334f2aefeae4b3f115e5779da3b61af25ba11
This commit is contained in:
@@ -496,10 +496,10 @@
|
||||
|
||||
switch (e.keyCode) {
|
||||
case 65: // 'a'
|
||||
if (!this._loggedIn) { return; }
|
||||
|
||||
e.preventDefault();
|
||||
this._openReplyDialog();
|
||||
if (this._loggedIn && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
this._openReplyDialog();
|
||||
}
|
||||
break;
|
||||
case 85: // 'u'
|
||||
e.preventDefault();
|
||||
|
@@ -46,17 +46,20 @@ limitations under the License.
|
||||
test('keyboard shortcuts', function() {
|
||||
var showStub = sinon.stub(page, 'show');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 85); // 'u'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 85); // 'U'
|
||||
assert(showStub.lastCall.calledWithExactly('/'),
|
||||
'Should navigate to /');
|
||||
showStub.restore();
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 65); // 'a'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 65); // 'A'
|
||||
var overlayEl = element.$.replyOverlay;
|
||||
assert.isFalse(overlayEl.opened);
|
||||
element._loggedIn = true;
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 65); // 'a'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 65, 'shift'); // 'A'
|
||||
assert.isFalse(overlayEl.opened);
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 65); // 'A'
|
||||
assert.isTrue(overlayEl.opened);
|
||||
overlayEl.close();
|
||||
assert.isFalse(overlayEl.opened);
|
||||
|
@@ -303,6 +303,14 @@
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 65: // 'a'
|
||||
if (e.shiftKey) { // Hide left diff.
|
||||
e.preventDefault();
|
||||
this._forEachDiff(function(diff) {
|
||||
diff.toggleLeftDiff();
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
@@ -77,6 +77,15 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('toggle left diff via shortcut', function() {
|
||||
var toggleLeftDiffStub = sinon.stub();
|
||||
sinon.stub(element, 'diffs', {get: function() {
|
||||
return [{toggleLeftDiff: toggleLeftDiffStub}];
|
||||
}});
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 65, 'shift'); // 'A'
|
||||
assert.isTrue(toggleLeftDiffStub.calledOnce);
|
||||
});
|
||||
|
||||
test('keyboard shortcuts', function() {
|
||||
var toggleInlineDiffsStub = sinon.stub(element, '_toggleInlineDiffs');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 73, 'shift'); // 'I'
|
||||
@@ -102,25 +111,25 @@ limitations under the License.
|
||||
assert.isTrue(elementItems[0].hasAttribute('selected'));
|
||||
assert.isFalse(elementItems[1].hasAttribute('selected'));
|
||||
assert.isFalse(elementItems[2].hasAttribute('selected'));
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'J'
|
||||
assert.equal(element.selectedIndex, 1);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'j'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 74); // 'J'
|
||||
|
||||
var showStub = sinon.stub(page, 'show');
|
||||
assert.equal(element.selectedIndex, 2);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'enter'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 13); // 'ENTER'
|
||||
assert(showStub.lastCall.calledWith('/c/42/2/myfile.txt'),
|
||||
'Should navigate to /c/42/2/myfile.txt');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'K'
|
||||
assert.equal(element.selectedIndex, 1);
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 79); // 'o'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 79); // 'O'
|
||||
assert(showStub.lastCall.calledWith('/c/42/2/file_added_in_rev2.txt'),
|
||||
'Should navigate to /c/42/2/file_added_in_rev2.txt');
|
||||
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'k'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'K'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'K'
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 75); // 'K'
|
||||
assert.equal(element.selectedIndex, 0);
|
||||
|
||||
showStub.restore();
|
||||
|
@@ -219,6 +219,13 @@ limitations under the License.
|
||||
</td>
|
||||
<td>Select right pane</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="key modifier">Shift</span>
|
||||
<span class="key">a</span>
|
||||
</td>
|
||||
<td>Hide/show left diff</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="key">c</span>
|
||||
@@ -275,6 +282,13 @@ limitations under the License.
|
||||
</td>
|
||||
<td>Select right pane</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="key modifier">Shift</span>
|
||||
<span class="key">a</span>
|
||||
</td>
|
||||
<td>Hide/show left diff</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="key">c</span>
|
||||
|
@@ -230,7 +230,13 @@
|
||||
}
|
||||
break;
|
||||
case 65: // 'a'
|
||||
if (!this._loggedIn) { return; }
|
||||
if (e.shiftKey) { // Hide left diff.
|
||||
e.preventDefault();
|
||||
this.$.diff.toggleLeftDiff();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!this._loggedIn) { break; }
|
||||
|
||||
this.set('changeViewState.showReplyDialog', true);
|
||||
/* falls through */ // required by JSHint
|
||||
|
@@ -47,6 +47,13 @@ limitations under the License.
|
||||
element = fixture('basic');
|
||||
});
|
||||
|
||||
test('toggle left diff with a hotkey', function() {
|
||||
var toggleLeftDiffStub = sinon.stub(element.$.diff, 'toggleLeftDiff');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 65, 'shift'); // 'a'
|
||||
assert.isTrue(toggleLeftDiffStub.calledOnce);
|
||||
toggleLeftDiffStub.restore();
|
||||
});
|
||||
|
||||
test('keyboard shortcuts', function() {
|
||||
element._changeNum = '42';
|
||||
element._patchRange = {
|
||||
|
@@ -32,6 +32,10 @@ limitations under the License.
|
||||
--light-add-highlight-color: #efe;
|
||||
--dark-add-highlight-color: #d4ffd4;
|
||||
}
|
||||
:host.no-left .sideBySide ::content .left,
|
||||
:host.no-left .sideBySide ::content .left + td {
|
||||
display: none;
|
||||
}
|
||||
.diffContainer {
|
||||
border-bottom: 1px solid #eee;
|
||||
border-top: 1px solid #eee;
|
||||
|
@@ -137,6 +137,10 @@
|
||||
return this.$.highlights.isRangeSelected();
|
||||
},
|
||||
|
||||
toggleLeftDiff: function() {
|
||||
this.toggleClass('no-left');
|
||||
},
|
||||
|
||||
_getCommentThreads: function() {
|
||||
return Polymer.dom(this.root).querySelectorAll('gr-diff-comment-thread');
|
||||
},
|
||||
|
@@ -44,6 +44,13 @@ limitations under the License.
|
||||
element = fixture('basic');
|
||||
});
|
||||
|
||||
test('toggleLeftDiff', function() {
|
||||
element.toggleLeftDiff();
|
||||
assert.isTrue(element.classList.contains('no-left'));
|
||||
element.toggleLeftDiff();
|
||||
assert.isFalse(element.classList.contains('no-left'));
|
||||
});
|
||||
|
||||
test('get drafts', function(done) {
|
||||
element.patchRange = {basePatchNum: 0, patchNum: 0};
|
||||
|
||||
|
Reference in New Issue
Block a user