2017-10-10 07:06:42 -04:00
|
|
|
/* eslint-disable func-names, prefer-arrow-callback, no-return-assign */
|
2017-09-20 16:35:49 -04:00
|
|
|
import { visitUrl } from './lib/utils/url_utility';
|
|
|
|
import { convertPermissionToBoolean } 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() {
|
|
|
|
$('.top-block').on('click', '.download', function (e) {
|
2017-03-11 02:30:44 -05:00
|
|
|
return e.stopPropagation();
|
|
|
|
});
|
2017-10-10 07:06:42 -04:00
|
|
|
return $('.tree-holder').on('click', 'tr[data-link] a', function (e) {
|
2017-03-11 02:30:44 -05:00
|
|
|
return e.stopImmediatePropagation();
|
|
|
|
});
|
2017-10-10 07:06:42 -04:00
|
|
|
}
|
|
|
|
// eslint-disable-next-line class-methods-use-this
|
|
|
|
setupEntryClick() {
|
|
|
|
return $('.tree-holder').on('click', 'tr[data-link]', function () {
|
2017-09-20 16:35:49 -04:00
|
|
|
visitUrl(this.dataset.link, convertPermissionToBoolean(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')
|
|
|
|
.on('mouseenter', (e) => {
|
|
|
|
$(e.currentTarget).find('.js-artifact-tree-tooltip').tooltip('show');
|
|
|
|
})
|
|
|
|
.on('mouseleave', (e) => {
|
|
|
|
$(e.currentTarget).find('.js-artifact-tree-tooltip').tooltip('hide');
|
|
|
|
});
|
2017-10-10 07:06:42 -04:00
|
|
|
}
|
|
|
|
}
|