Files
gerrit/polygerrit-ui/app/elements/admin/gr-repo-command/gr-repo-command.js
David Ostrovsky aa04f13bdf gr-repo-command: Add support for tooltips
Project core and plugins actions exposing label and title. Label
supposed to be used as button name and title is supposed to be used
as button tooltip. Support for tooltip is added in this change. To make
minimal invasive change, we preserve title that was already taken as the
name of the button and add new tooltip attribute.

Alternative approach would be to consistently use label and title, like
it is done on change screen. However that approach may break some users,
that rely on current naming convention.

Note that this also fixed the problem for plugin authors. For example in
custom element in project screen, tooltip can be used as following:

    <gr-repo-command
        title="[[action.label]]"
        tooltip="[[action.title]]"
        on-command-tap="_handleCommandTap">
    </gr-repo-command>

Bug: Issue 9638
Change-Id: Ib1b54eb7cd4ba544402d293b9fce9bb176b01065
2018-08-29 20:12:43 +02:00

40 lines
1004 B
JavaScript

/**
* @license
* Copyright (C) 2017 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-repo-command',
properties: {
title: String,
disabled: Boolean,
tooltip: String,
},
/**
* Fired when command button is tapped.
*
* @event command-tap
*/
_onCommandTap() {
this.dispatchEvent(new CustomEvent('command-tap', {bubbles: true}));
},
});
})();