All files / app/assets/javascripts/boards/components new_board_button.vue

100% Statements 11/11
100% Branches 4/4
100% Functions 4/4
100% Lines 11/11

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  1x 1x 1x 1x 1x 1x                           4x     2x         1x 1x           25x                        
<script>
import { GlButton, GlModalDirective } from '@gitlab/ui';
import { formType } from '~/boards/constants';
import eventHub from '~/boards/eventhub';
import { s__ } from '~/locale';
import Tracking from '~/tracking';
import GitlabExperiment from '~/experimentation/components/gitlab_experiment.vue';
 
export default {
  components: {
    GlButton,
    GitlabExperiment,
  },
  directives: {
    GlModalDirective,
  },
  mixins: [Tracking.mixin()],
  inject: ['multipleIssueBoardsAvailable', 'canAdminBoard'],
  computed: {
    canShowCreateButton() {
      return this.canAdminBoard && this.multipleIssueBoardsAvailable;
    },
    createButtonText() {
      return s__('Boards|New board');
    },
  },
  methods: {
    showDialog() {
      this.track('click_button', { label: 'create_board' });
      eventHub.$emit('showBoardModal', formType.new);
    },
  },
};
</script>
 
<template>
  <gitlab-experiment name="prominent_create_board_btn">
    <template #control> </template>
    <template #candidate>
      <div v-if="canShowCreateButton" class="gl-ml-1 gl-mr-3 gl-display-flex gl-align-items-center">
        <gl-button data-qa-selector="new_board_button" @click.prevent="showDialog">
          {{ createButtonText }}
        </gl-button>
      </div>
    </template>
  </gitlab-experiment>
</template>