All files / app/assets/javascripts/vue_merge_request_widget/components/deployment deployment_action_button.vue

0% Statements 0/2
0% Branches 0/5
0% Functions 0/2
0% Lines 0/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91                                                                                                                                                                                     
<script>
import { GlTooltipDirective, GlButton } from '@gitlab/ui';
import { RUNNING, WILL_DEPLOY } from './constants';
 
export default {
  name: 'DeploymentActionButton',
  components: {
    GlButton,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    actionsConfiguration: {
      type: Object,
      required: true,
    },
    actionInProgress: {
      type: String,
      required: false,
      default: null,
    },
    buttonTitle: {
      type: String,
      required: false,
      default: '',
    },
    computedDeploymentStatus: {
      type: String,
      required: true,
    },
    containerClasses: {
      type: String,
      required: false,
      default: '',
    },
    icon: {
      type: String,
      required: true,
    },
  },
  computed: {
    isActionInProgress() {
      return Boolean(
        this.computedDeploymentStatus === RUNNING ||
          this.computedDeploymentStatus === WILL_DEPLOY ||
          this.actionInProgress,
      );
    },
    isLoading() {
      return (
        this.actionInProgress === this.actionsConfiguration.actionName ||
        this.computedDeploymentStatus === WILL_DEPLOY
      );
    },
  },
};
</script>
 
<template>
  <gl-button
    v-if="isLoading || isActionInProgress"
    category="primary"
    size="small"
    :title="buttonTitle"
    :aria-label="buttonTitle"
    :loading="isLoading"
    :disabled="isActionInProgress"
    :class="`inline gl-ml-3 ${containerClasses}`"
    :icon="icon"
    @click="$emit('click')"
  >
    <slot> </slot>
  </gl-button>
  <gl-button
    v-else
    v-gl-tooltip.hover
    category="primary"
    size="small"
    :title="buttonTitle"
    :aria-label="buttonTitle"
    :loading="isLoading"
    :disabled="isActionInProgress"
    :class="`inline gl-ml-3 ${containerClasses}`"
    :icon="icon"
    @click="$emit('click')"
  >
    <slot> </slot>
  </gl-button>
</template>