All files / ee/app/assets/javascripts/analytics/cycle_analytics/components/create_value_stream_form stage_field_actions.vue

0% Statements 0/7
0% Branches 0/8
0% Functions 0/7
0% Lines 0/7

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 92                                                                                                                                                                                       
<script>
import { GlButton, GlButtonGroup, GlTooltipDirective } from '@gitlab/ui';
import { __ } from '~/locale';
import { STAGE_SORT_DIRECTION } from './constants';
 
export default {
  i18n: {
    moveDownLabel: __('Move down'),
    moveUpLabel: __('Move up'),
  },
  name: 'StageFieldActions',
  components: {
    GlButton,
    GlButtonGroup,
  },
  directives: {
    GlTooltip: GlTooltipDirective,
  },
  props: {
    index: {
      type: Number,
      required: true,
    },
    stageCount: {
      type: Number,
      required: true,
    },
    canRemove: {
      type: Boolean,
      required: false,
      default: false,
    },
  },
  computed: {
    lastStageIndex() {
      return this.stageCount - 1;
    },
    isFirstActiveStage() {
      return this.index === 0;
    },
    isLastActiveStage() {
      return this.index === this.lastStageIndex;
    },
    hideActionEvent() {
      return this.canRemove ? 'remove' : 'hide';
    },
    hideActionTooltip() {
      return this.canRemove ? __('Remove') : __('Hide');
    },
    hideActionIcon() {
      return this.canRemove ? 'remove' : 'eye-slash';
    },
    hideActionTestId() {
      return `stage-action-${this.canRemove ? 'remove' : 'hide'}-${this.index}`;
    },
  },
  STAGE_SORT_DIRECTION,
};
</script>
<template>
  <div>
    <gl-button-group class="gl-pr-2">
      <gl-button
        v-gl-tooltip
        :data-testid="`stage-action-move-down-${index}`"
        :disabled="isLastActiveStage"
        icon="arrow-down"
        :title="$options.i18n.moveDownLabel"
        :aria-label="$options.i18n.moveDownLabel"
        @click="$emit('move', { index, direction: $options.STAGE_SORT_DIRECTION.DOWN })"
      />
      <gl-button
        v-gl-tooltip
        :data-testid="`stage-action-move-up-${index}`"
        :disabled="isFirstActiveStage"
        icon="arrow-up"
        :title="$options.i18n.moveUpLabel"
        :aria-label="$options.i18n.moveUpLabel"
        @click="$emit('move', { index, direction: $options.STAGE_SORT_DIRECTION.UP })"
      />
    </gl-button-group>
    <gl-button
      v-gl-tooltip
      :title="hideActionTooltip"
      :aria-label="hideActionTooltip"
      :data-testid="hideActionTestId"
      :icon="hideActionIcon"
      @click="$emit(hideActionEvent, index)"
    />
  </div>
</template>