All files / app/assets/javascripts/jira_connect/branches/pages index.vue

100% Statements 4/4
33.33% Branches 1/3
100% Functions 3/3
100% Lines 4/4

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 631x                                     4x           4x                   1x                                                      
<!-- eslint-disable vue/multi-word-component-names -->
<script>
import { GlEmptyState } from '@gitlab/ui';
import { sprintf } from '~/locale';
import NewBranchForm from '../components/new_branch_form.vue';
import {
  I18N_PAGE_TITLE_WITH_BRANCH_NAME,
  I18N_PAGE_TITLE_DEFAULT,
  I18N_NEW_BRANCH_SUCCESS_TITLE,
  I18N_NEW_BRANCH_SUCCESS_MESSAGE,
} from '../constants';
 
export default {
  components: {
    GlEmptyState,
    NewBranchForm,
  },
  inject: ['initialBranchName', 'successStateSvgPath'],
  data() {
    return {
      showForm: true,
    };
  },
  computed: {
    pageTitle() {
      return this.initialBranchName
        ? sprintf(this.$options.i18n.I18N_PAGE_TITLE_WITH_BRANCH_NAME, {
            jiraIssue: this.initialBranchName,
          })
        : this.$options.i18n.I18N_PAGE_TITLE_DEFAULT;
    },
  },
  methods: {
    onNewBranchFormSuccess() {
      // light-weight toggle to hide the form and show the success state
      this.showForm = false;
    },
  },
  i18n: {
    I18N_PAGE_TITLE_WITH_BRANCH_NAME,
    I18N_PAGE_TITLE_DEFAULT,
    I18N_NEW_BRANCH_SUCCESS_TITLE,
    I18N_NEW_BRANCH_SUCCESS_MESSAGE,
  },
};
</script>
<template>
  <div>
    <div class="gl-border-1 gl-border-b-solid gl-border-gray-100 gl-mb-5 gl-mt-7">
      <h1 data-testid="page-title" class="page-title gl-font-size-h-display">{{ pageTitle }}</h1>
    </div>
 
    <new-branch-form v-if="showForm" @success="onNewBranchFormSuccess" />
    <gl-empty-state
      v-else
      :title="$options.i18n.I18N_NEW_BRANCH_SUCCESS_TITLE"
      :description="$options.i18n.I18N_NEW_BRANCH_SUCCESS_MESSAGE"
      :svg-path="successStateSvgPath"
      :svg-height="null"
    />
  </div>
</template>