All files / app/assets/javascripts/user_lists/components new_user_list.vue

100% Statements 2/2
100% Branches 2/2
100% Functions 1/1
100% Lines 2/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    1x                                   9x                                                              
<script>
import { GlAlert } from '@gitlab/ui';
// eslint-disable-next-line no-restricted-imports
import { mapActions, mapState } from 'vuex';
import { s__ } from '~/locale';
import UserListForm from './user_list_form.vue';
 
export default {
  components: {
    GlAlert,
    UserListForm,
  },
  inject: ['userListsDocsPath', 'featureFlagsPath'],
  translations: {
    pageTitle: s__('UserLists|New list'),
    createButtonLabel: s__('UserLists|Create'),
  },
  computed: {
    ...mapState(['userList', 'errorMessage']),
    isError() {
      return Array.isArray(this.errorMessage) && this.errorMessage.length > 0;
    },
  },
  methods: {
    ...mapActions(['createUserList', 'dismissErrorAlert']),
  },
};
</script>
<template>
  <div>
    <gl-alert v-if="isError" variant="danger" @dismiss="dismissErrorAlert">
      <ul class="gl-mb-0">
        <li v-for="(message, index) in errorMessage" :key="index">
          {{ message }}
        </li>
      </ul>
    </gl-alert>
 
    <h3 class="gl-font-weight-bold gl-pb-5 gl-border-b-solid gl-border-gray-100 gl-border-1">
      {{ $options.translations.pageTitle }}
    </h3>
 
    <user-list-form
      :cancel-path="featureFlagsPath"
      :save-button-label="$options.translations.createButtonLabel"
      :user-lists-docs-path="userListsDocsPath"
      :user-list="userList"
      @submit="createUserList"
    />
  </div>
</template>