/* eslint-disable no-new */ /* global Flash */ import '~/flash'; import playIconSvg from 'icons/_icon_play.svg'; import eventHub from '../event_hub'; import loadingIconComponent from '../../vue_shared/components/loading_icon.vue'; export default { props: { actions: { type: Array, required: true, }, service: { type: Object, required: true, }, }, components: { loadingIconComponent, }, data() { return { playIconSvg, isLoading: false, }; }, methods: { onClickAction(endpoint) { this.isLoading = true; $(this.$refs.tooltip).tooltip('destroy'); this.service.postAction(endpoint) .then(() => { this.isLoading = false; eventHub.$emit('refreshPipelines'); }) .catch(() => { this.isLoading = false; new Flash('An error occured while making the request.'); }); }, isActionDisabled(action) { if (action.playable === undefined) { return false; } return !action.playable; }, }, template: `