Welcome to mirror list, hosted at ThFree Co, Russian Federation.

board_new_issue.vue « components « boards « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8b9fafca306647774c119b051779e0fe2c7f5a6f (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
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
79
<script>
import { mapActions, mapGetters, mapState } from 'vuex';
import { getMilestone } from 'ee_else_ce/boards/boards_util';
import BoardNewIssueMixin from 'ee_else_ce/boards/mixins/board_new_issue';

import { toggleFormEventPrefix } from '../constants';
import eventHub from '../eventhub';

import BoardNewItem from './board_new_item.vue';
import ProjectSelect from './project_select.vue';

export default {
  name: 'BoardNewIssue',
  components: {
    BoardNewItem,
    ProjectSelect,
  },
  mixins: [BoardNewIssueMixin],
  inject: ['groupId', 'fullPath', 'isGroupBoard'],
  props: {
    list: {
      type: Object,
      required: true,
    },
  },
  computed: {
    ...mapState(['selectedProject']),
    ...mapGetters(['getBoardItemsByList']),
    formEventPrefix() {
      return toggleFormEventPrefix.issue;
    },
    disableSubmit() {
      return this.isGroupBoard ? !this.selectedProject.name : false;
    },
    projectPath() {
      return this.isGroupBoard ? this.selectedProject.fullPath : this.fullPath;
    },
  },
  methods: {
    ...mapActions(['addListNewIssue']),
    submit({ title }) {
      const labels = this.list.label ? [this.list.label] : [];
      const assignees = this.list.assignee ? [this.list.assignee] : [];
      const milestone = getMilestone(this.list);
      const firstItemId = this.getBoardItemsByList(this.list.id)[0]?.id;

      return this.addListNewIssue({
        list: this.list,
        issueInput: {
          title,
          labelIds: labels?.map((l) => l.id),
          assigneeIds: assignees?.map((a) => a?.id),
          milestoneId: milestone?.id,
          projectPath: this.projectPath,
          moveAfterId: firstItemId,
        },
      }).then(() => {
        this.cancel();
      });
    },
    cancel() {
      eventHub.$emit(`${this.formEventPrefix}${this.list.id}`);
    },
  },
};
</script>

<template>
  <board-new-item
    :list="list"
    :form-event-prefix="formEventPrefix"
    :submit-button-title="__('Create issue')"
    :disable-submit="disableSubmit"
    @form-submit="submit"
    @form-cancel="cancel"
  >
    <project-select v-if="isGroupBoard" :group-id="groupId" :list="list" />
  </board-new-item>
</template>