summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/user_lists/components/new_user_list.vue
blob: 522e077fb25ed6be517d051cca4cf754c32d3a63 (plain)
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
<script>
import { mapActions, mapState } from 'vuex';
import { GlAlert } from '@gitlab/ui';
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>