Merge "Add keyboard shortcut for star toggle"
This commit is contained in:
@@ -241,7 +241,8 @@ limitations under the License.
|
||||
<div class="container" hidden$="{{_loading}}">
|
||||
<div class="header">
|
||||
<span class="header-title">
|
||||
<gr-change-star change="{{_change}}" hidden$="[[!_loggedIn]]"></gr-change-star>
|
||||
<gr-change-star id="changeStar"
|
||||
change="{{_change}}" hidden$="[[!_loggedIn]]"></gr-change-star>
|
||||
<a href$="[[_computeChangePermalink(_change._number)]]">[[_change._number]]</a><!--
|
||||
--><span class="changeStatus">[[_computeChangeStatus(_change, _patchRange.patchNum)]]</span><!--
|
||||
-->:
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
'shift+r': '_handleCapitalRKey',
|
||||
'a': '_handleAKey',
|
||||
'd': '_handleDKey',
|
||||
's': '_handleSKey',
|
||||
'u': '_handleUKey',
|
||||
},
|
||||
|
||||
@@ -636,6 +637,14 @@
|
||||
this._switchToMostRecentPatchNum();
|
||||
},
|
||||
|
||||
_handleSKey: function(e) {
|
||||
if (this.shouldSuppressKeyboardShortcut(e) ||
|
||||
this.modifierPressed(e)) { return; }
|
||||
|
||||
e.preventDefault();
|
||||
this.$.changeStar.toggleStar();
|
||||
},
|
||||
|
||||
_handleUKey: function(e) {
|
||||
if (this.shouldSuppressKeyboardShortcut(e)) { return; }
|
||||
|
||||
|
||||
@@ -51,6 +51,12 @@ limitations under the License.
|
||||
});
|
||||
|
||||
suite('keyboard shortcuts', function() {
|
||||
test('S should toggle the CL star', function() {
|
||||
var starStub = sandbox.stub(element.$.changeStar, 'toggleStar');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 83, null, 's');
|
||||
assert(starStub.called);
|
||||
});
|
||||
|
||||
test('U should navigate to / if no backPage set', function() {
|
||||
var showStub = sandbox.stub(page, 'show');
|
||||
MockInteractions.pressAndReleaseKeyOn(element, 85, null, 'u');
|
||||
|
||||
@@ -42,7 +42,7 @@ limitations under the License.
|
||||
fill: #ffac33;
|
||||
}
|
||||
</style>
|
||||
<button class$="[[_computeStarClass(change.starred)]]" on-tap="_handleStarTap">
|
||||
<button class$="[[_computeStarClass(change.starred)]]" on-tap="toggleStar">
|
||||
<!-- Public Domain image from the Noun Project: https://thenounproject.com/search/?q=star&i=25969 -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><path d="M26.439,95.601c-5.608,2.949-9.286,0.276-8.216-5.968l4.5-26.237L3.662,44.816c-4.537-4.423-3.132-8.746,3.137-9.657 l26.343-3.829L44.923,7.46c2.804-5.682,7.35-5.682,10.154,0l11.78,23.87l26.343,3.829c6.27,0.911,7.674,5.234,3.138,9.657 L77.277,63.397l4.501,26.237c1.07,6.244-2.608,8.916-8.216,5.968L50,83.215L26.439,95.601z"></path></svg>
|
||||
</button>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
return classes.join(' ');
|
||||
},
|
||||
|
||||
_handleStarTap: function() {
|
||||
toggleStar: function() {
|
||||
var newVal = !this.change.starred;
|
||||
this.set('change.starred', newVal);
|
||||
this._xhrPromise = this.$.restAPI.saveChangeStarred(this.change._number,
|
||||
|
||||
Reference in New Issue
Block a user