Files
gerrit/polygerrit-ui/app/elements/shared/gr-change-star/gr-change-star.js
Becky Siegel 200061e281 Add keyboard shortcut for star toggle
This change adds a keyboard shortcut to star a CL from the change view,
to match GWT UI features. The 's' key toggles the the CL star.

Bug: Issue 5192
Change-Id: I6f471ac2638815b78cb374326b0e37eaad0fa30d
2017-01-06 10:57:47 -08:00

45 lines
1.2 KiB
JavaScript

// Copyright (C) 2016 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
(function() {
'use strict';
Polymer({
is: 'gr-change-star',
properties: {
change: {
type: Object,
notify: true,
},
_xhrPromise: Object, // Used for testing.
},
_computeStarClass: function(starred) {
var classes = ['starButton'];
if (starred) {
classes.push('starButton-active');
}
return classes.join(' ');
},
toggleStar: function() {
var newVal = !this.change.starred;
this.set('change.starred', newVal);
this._xhrPromise = this.$.restAPI.saveChangeStarred(this.change._number,
newVal);
},
});
})();