All files / ee/app/assets/javascripts/hand_raise_leads/hand_raise_lead/components hand_raise_lead_button.vue

100% Statements 7/7
100% Branches 1/1
100% Functions 4/4
100% Lines 7/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          3x                                                       11x       1x               2x 2x 1x       2x                                                    
<script>
import { GlButton, GlModalDirective } from '@gitlab/ui';
import { uniqueId } from 'lodash';
import Tracking from '~/tracking';
import { PQL_BUTTON_TEXT } from '../constants';
import HandRaiseLeadModal from './hand_raise_lead_modal.vue';
 
export default {
  name: 'HandRaiseLeadButton',
  components: {
    GlButton,
    HandRaiseLeadModal,
  },
  directives: {
    GlModal: GlModalDirective,
  },
  mixins: [Tracking.mixin()],
  inject: {
    createHandRaiseLeadPath: {},
    user: {
      default: {},
    },
    buttonAttributes: {
      default: {},
    },
    buttonText: {
      default: PQL_BUTTON_TEXT,
    },
    ctaTracking: {
      default: {},
    },
  },
  data() {
    return { isLoading: false, modalId: uniqueId('hand-raise-lead-modal-') };
  },
  computed: {
    tracking() {
      return {
        label: 'hand_raise_lead_form',
        experiment: this.ctaTracking.experiment,
      };
    },
  },
  methods: {
    trackBtnClick() {
      const { action, ...options } = this.ctaTracking;
      if (action) {
        this.track(action, options);
      }
    },
    updateLoading(value) {
      this.isLoading = value;
    },
  },
};
</script>
 
<template>
  <div>
    <gl-button
      v-gl-modal="modalId"
      v-bind="buttonAttributes"
      :loading="isLoading"
      @click="trackBtnClick"
    >
      {{ buttonText }}
    </gl-button>
 
    <hand-raise-lead-modal
      :user="user"
      :submit-path="createHandRaiseLeadPath"
      :cta-tracking="ctaTracking"
      :modal-id="modalId"
      @loading="updateLoading"
    />
  </div>
</template>