debian-mirror-gitlab/app/assets/javascripts/pipelines/components/graph/action_component.vue

73 lines
1.4 KiB
Vue
Raw Normal View History

2017-08-17 22:00:37 +05:30
<script>
2018-05-09 12:01:36 +05:30
import $ from 'jquery';
import tooltip from '../../../vue_shared/directives/tooltip';
import Icon from '../../../vue_shared/components/icon.vue';
import { dasherize } from '../../../lib/utils/text_utility';
import eventHub from '../../event_hub';
/**
* Renders either a cancel, retry or play icon pointing to the given path.
*/
export default {
components: {
Icon,
},
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
directives: {
tooltip,
},
2018-03-17 18:26:18 +05:30
2018-05-09 12:01:36 +05:30
props: {
tooltipText: {
type: String,
required: true,
},
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
link: {
type: String,
required: true,
},
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
actionIcon: {
type: String,
required: true,
},
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
buttonDisabled: {
type: String,
required: false,
default: null,
},
},
computed: {
cssClass() {
const actionIconDash = dasherize(this.actionIcon);
return `${actionIconDash} js-icon-${actionIconDash}`;
},
isDisabled() {
return this.buttonDisabled === this.link;
2017-08-17 22:00:37 +05:30
},
2018-05-09 12:01:36 +05:30
},
2017-08-17 22:00:37 +05:30
2018-05-09 12:01:36 +05:30
methods: {
onClickAction() {
$(this.$el).tooltip('hide');
eventHub.$emit('graphAction', this.link);
2017-08-17 22:00:37 +05:30
},
2018-05-09 12:01:36 +05:30
},
};
2017-08-17 22:00:37 +05:30
</script>
<template>
2018-05-09 12:01:36 +05:30
<button
type="button"
@click="onClickAction"
2017-09-10 17:25:29 +05:30
v-tooltip
2017-08-17 22:00:37 +05:30
:title="tooltipText"
2018-05-09 12:01:36 +05:30
class="btn btn-blank btn-transparent ci-action-icon-container ci-action-icon-wrapper"
2018-03-17 18:26:18 +05:30
:class="cssClass"
data-container="body"
2018-05-09 12:01:36 +05:30
:disabled="isDisabled"
2018-03-17 18:26:18 +05:30
>
<icon :name="actionIcon" />
2018-05-09 12:01:36 +05:30
</button>
2017-08-17 22:00:37 +05:30
</template>