2019-09-24 09:06:04 +00:00
|
|
|
/* eslint-disable func-names */
|
2018-03-09 20:18:59 +00:00
|
|
|
|
|
|
|
import $ from 'jquery';
|
2017-09-20 20:35:49 +00:00
|
|
|
import { visitUrl } from './lib/utils/url_utility';
|
2018-11-21 15:13:04 +00:00
|
|
|
import { parseBoolean } from './lib/utils/common_utils';
|
2020-10-02 18:08:56 +00:00
|
|
|
import { hide, initTooltips, show } from '~/tooltips';
|
2016-07-24 20:45:11 +00:00
|
|
|
|
2017-10-10 11:06:42 +00:00
|
|
|
export default class BuildArtifacts {
|
|
|
|
constructor() {
|
2017-03-11 07:30:44 +00:00
|
|
|
this.disablePropagation();
|
|
|
|
this.setupEntryClick();
|
2017-09-20 20:35:49 +00:00
|
|
|
this.setupTooltips();
|
2017-03-11 07:30:44 +00:00
|
|
|
}
|
2020-10-02 18:08:56 +00:00
|
|
|
|
2017-10-10 11:06:42 +00:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
disablePropagation() {
|
2019-09-24 09:06:04 +00:00
|
|
|
$('.top-block').on('click', '.download', e => {
|
|
|
|
e.stopPropagation();
|
2017-03-11 07:30:44 +00:00
|
|
|
});
|
2019-09-24 09:06:04 +00:00
|
|
|
return $('.tree-holder').on('click', 'tr[data-link] a', e => {
|
|
|
|
e.stopImmediatePropagation();
|
2017-03-11 07:30:44 +00:00
|
|
|
});
|
2017-10-10 11:06:42 +00:00
|
|
|
}
|
2020-10-02 18:08:56 +00:00
|
|
|
|
2017-10-10 11:06:42 +00:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
setupEntryClick() {
|
2018-10-24 19:17:03 +00:00
|
|
|
return $('.tree-holder').on('click', 'tr[data-link]', function() {
|
2018-11-21 15:13:04 +00:00
|
|
|
visitUrl(this.dataset.link, parseBoolean(this.dataset.externalLink));
|
2017-03-11 07:30:44 +00:00
|
|
|
});
|
2017-10-10 11:06:42 +00:00
|
|
|
}
|
2020-10-02 18:08:56 +00:00
|
|
|
|
2017-10-10 11:06:42 +00:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
setupTooltips() {
|
2020-10-02 18:08:56 +00:00
|
|
|
initTooltips({
|
2017-09-20 20:35:49 +00:00
|
|
|
placement: 'bottom',
|
|
|
|
// Stop the tooltip from hiding when we stop hovering the element directly
|
|
|
|
// We handle all the showing/hiding below
|
|
|
|
trigger: 'manual',
|
|
|
|
});
|
|
|
|
|
|
|
|
// We want the tooltip to show if you hover anywhere on the row
|
|
|
|
// But be placed below and in the middle of the file name
|
|
|
|
$('.js-artifact-tree-row')
|
2018-10-24 19:17:03 +00:00
|
|
|
.on('mouseenter', e => {
|
2020-10-02 18:08:56 +00:00
|
|
|
const $el = $(e.currentTarget).find('.js-artifact-tree-tooltip');
|
|
|
|
|
|
|
|
show($el);
|
2017-09-20 20:35:49 +00:00
|
|
|
})
|
2018-10-24 19:17:03 +00:00
|
|
|
.on('mouseleave', e => {
|
2020-10-02 18:08:56 +00:00
|
|
|
const $el = $(e.currentTarget).find('.js-artifact-tree-tooltip');
|
|
|
|
|
|
|
|
hide($el);
|
2017-09-20 20:35:49 +00:00
|
|
|
});
|
2017-10-10 11:06:42 +00:00
|
|
|
}
|
|
|
|
}
|