mirror of https://github.com/rancher/ui.git
54 lines
1.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
import { alias } from '@ember/object/computed';
|
|
import { inject as service } from '@ember/service';
|
|
import Component from '@ember/component';
|
|
import Tooltip from 'shared/mixins/tooltip';
|
|
import StrippedName from 'shared/mixins/stripped-name';
|
|
import layout from './template';
|
|
|
|
export default Component.extend(Tooltip, StrippedName, {
|
|
layout,
|
|
resourceActions: service('resource-actions'),
|
|
needs: ['application'],
|
|
model: alias('tooltipService.tooltipOpts.model'),
|
|
actionsOpen: alias('resourceActions.open'),
|
|
inTooltip: false,
|
|
layoutName: 'tooltip-action-menu',
|
|
|
|
init: function() {
|
|
if (this.get('tooltipTemplate')) {
|
|
this.set('layoutName', this.get('tooltipTemplate'));
|
|
}
|
|
this._super(...arguments);
|
|
// Just so openChanged is ready to go, otherwise you have to chain on('init') on openChanged
|
|
// which because of the context menu click on container dot can cause some issues with checking
|
|
// flags and such. This was the least compliated way to ensure that openChanged would recognize changes
|
|
this.set('actionsOpen', false);
|
|
},
|
|
|
|
mouseEnter: function() {
|
|
this._super();
|
|
this.set('inTooltip', true);
|
|
|
|
// Must get the property before it will be observed for openChanged
|
|
// https://github.com/emberjs/ember.js/issues/10821
|
|
this.get('actionsOpen');
|
|
},
|
|
|
|
mouseLeave: function() {
|
|
this.set('inTooltip', false);
|
|
if ( !this.get('actionsOpen') )
|
|
{
|
|
this.get('tooltipService').leave();
|
|
}
|
|
},
|
|
|
|
openChanged: function() {
|
|
this.set('tooltipService.requireClick', this.get('actionsOpen'));
|
|
if ( !this.get('actionsOpen') && !this.get('inTooltip') )
|
|
{
|
|
this.get('tooltipService').leave();
|
|
}
|
|
}.observes('actionsOpen'),
|
|
|
|
});
|