2019-09-24 05:06:04 -04:00
|
|
|
/* eslint-disable func-names */
|
2018-03-09 15:18:59 -05:00
|
|
|
|
|
|
|
import $ from 'jquery';
|
2021-02-01 10:08:56 -05:00
|
|
|
import { hide, initTooltips, show } from '~/tooltips';
|
2017-09-20 16:35:49 -04:00
|
|
|
import { visitUrl } from './lib/utils/url_utility';
|
2018-11-21 10:13:04 -05:00
|
|
|
import { parseBoolean } from './lib/utils/common_utils';
|
2016-07-24 16:45:11 -04:00
|
|
|
|
2017-10-10 07:06:42 -04:00
|
|
|
export default class BuildArtifacts {
|
|
|
|
constructor() {
|
2017-03-11 02:30:44 -05:00
|
|
|
this.disablePropagation();
|
|
|
|
this.setupEntryClick();
|
2017-09-20 16:35:49 -04:00
|
|
|
this.setupTooltips();
|
2017-03-11 02:30:44 -05:00
|
|
|
}
|
2020-10-02 14:08:56 -04:00
|
|
|
|
2017-10-10 07:06:42 -04:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
disablePropagation() {
|
2020-12-23 16:10:24 -05:00
|
|
|
$('.top-block').on('click', '.download', (e) => {
|
2019-09-24 05:06:04 -04:00
|
|
|
e.stopPropagation();
|
2017-03-11 02:30:44 -05:00
|
|
|
});
|
2020-12-23 16:10:24 -05:00
|
|
|
return $('.tree-holder').on('click', 'tr[data-link] a', (e) => {
|
2019-09-24 05:06:04 -04:00
|
|
|
e.stopImmediatePropagation();
|
2017-03-11 02:30:44 -05:00
|
|
|
});
|
2017-10-10 07:06:42 -04:00
|
|
|
}
|
2020-10-02 14:08:56 -04:00
|
|
|
|
2017-10-10 07:06:42 -04:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
setupEntryClick() {
|
2020-12-23 07:10:26 -05:00
|
|
|
return $('.tree-holder').on('click', 'tr[data-link]', function () {
|
2018-11-21 10:13:04 -05:00
|
|
|
visitUrl(this.dataset.link, parseBoolean(this.dataset.externalLink));
|
2017-03-11 02:30:44 -05:00
|
|
|
});
|
2017-10-10 07:06:42 -04:00
|
|
|
}
|
2020-10-02 14:08:56 -04:00
|
|
|
|
2017-10-10 07:06:42 -04:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
setupTooltips() {
|
2020-10-02 14:08:56 -04:00
|
|
|
initTooltips({
|
2017-09-20 16:35:49 -04: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')
|
2020-12-23 16:10:24 -05:00
|
|
|
.on('mouseenter', (e) => {
|
2020-10-02 14:08:56 -04:00
|
|
|
const $el = $(e.currentTarget).find('.js-artifact-tree-tooltip');
|
|
|
|
|
|
|
|
show($el);
|
2017-09-20 16:35:49 -04:00
|
|
|
})
|
2020-12-23 16:10:24 -05:00
|
|
|
.on('mouseleave', (e) => {
|
2020-10-02 14:08:56 -04:00
|
|
|
const $el = $(e.currentTarget).find('.js-artifact-tree-tooltip');
|
|
|
|
|
|
|
|
hide($el);
|
2017-09-20 16:35:49 -04:00
|
|
|
});
|
2017-10-10 07:06:42 -04:00
|
|
|
}
|
|
|
|
}
|