2019-09-24 05:06:04 -04:00
|
|
|
/* eslint-disable func-names */
|
2018-03-09 15:18:59 -05:00
|
|
|
|
|
|
|
import $ from 'jquery';
|
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
|
|
|
}
|
2017-10-10 07:06:42 -04:00
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
disablePropagation() {
|
2019-09-24 05:06:04 -04:00
|
|
|
$('.top-block').on('click', '.download', e => {
|
|
|
|
e.stopPropagation();
|
2017-03-11 02:30:44 -05:00
|
|
|
});
|
2019-09-24 05:06:04 -04:00
|
|
|
return $('.tree-holder').on('click', 'tr[data-link] a', e => {
|
|
|
|
e.stopImmediatePropagation();
|
2017-03-11 02:30:44 -05:00
|
|
|
});
|
2017-10-10 07:06:42 -04:00
|
|
|
}
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
setupEntryClick() {
|
2018-10-24 15:17:03 -04: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
|
|
|
}
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
setupTooltips() {
|
2017-09-20 16:35:49 -04:00
|
|
|
$('.js-artifact-tree-tooltip').tooltip({
|
|
|
|
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 15:17:03 -04:00
|
|
|
.on('mouseenter', e => {
|
|
|
|
$(e.currentTarget)
|
|
|
|
.find('.js-artifact-tree-tooltip')
|
|
|
|
.tooltip('show');
|
2017-09-20 16:35:49 -04:00
|
|
|
})
|
2018-10-24 15:17:03 -04:00
|
|
|
.on('mouseleave', e => {
|
|
|
|
$(e.currentTarget)
|
|
|
|
.find('.js-artifact-tree-tooltip')
|
|
|
|
.tooltip('hide');
|
2017-09-20 16:35:49 -04:00
|
|
|
});
|
2017-10-10 07:06:42 -04:00
|
|
|
}
|
|
|
|
}
|