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

csv_import_export_buttons.vue « components « issuable « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 872e1d4269ddea636b17e5280283ad8fc6b99b1d (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<script>
import { GlDisclosureDropdownItem, GlModalDirective } from '@gitlab/ui';
import { TYPE_ISSUE } from '~/issues/constants';
import { __ } from '~/locale';
import CsvExportModal from './csv_export_modal.vue';
import CsvImportModal from './csv_import_modal.vue';

export default {
  components: {
    GlDisclosureDropdownItem,
    CsvExportModal,
    CsvImportModal,
  },
  directives: {
    GlModal: GlModalDirective,
  },
  inject: {
    issuableType: {
      default: TYPE_ISSUE,
    },
    showExportButton: {
      default: false,
    },
    showImportButton: {
      default: false,
    },
    canEdit: {
      default: false,
    },
    projectImportJiraPath: {
      default: null,
    },
  },
  props: {
    exportCsvPath: {
      type: String,
      required: false,
      default: '',
    },
    issuableCount: {
      type: Number,
      required: false,
      default: undefined,
    },
  },
  data() {
    return {
      dropdownItems: {
        exportAsCSV: {
          text: __('Export as CSV'),
        },
        importCSV: {
          text: __('Import CSV'),
        },
        importFromJIRA: {
          text: __('Import from Jira'),
          href: this.projectImportJiraPath,
        },
      },
    };
  },
  computed: {
    exportModalId() {
      return `${this.issuableType}-export-modal`;
    },
    importModalId() {
      return `${this.issuableType}-import-modal`;
    },
  },
};
</script>

<template>
  <ul class="gl-display-contents">
    <gl-disclosure-dropdown-item
      v-if="showExportButton"
      v-gl-modal="exportModalId"
      data-testid="export-as-csv-button"
      data-qa-selector="export_as_csv_button"
      :item="dropdownItems.exportAsCSV"
    />
    <gl-disclosure-dropdown-item
      v-if="showImportButton"
      v-gl-modal="importModalId"
      data-testid="import-from-csv-button"
      :item="dropdownItems.importCSV"
    />
    <gl-disclosure-dropdown-item
      v-if="showImportButton && canEdit"
      data-testid="import-from-jira-link"
      data-qa-selector="import_from_jira_link"
      :item="dropdownItems.importFromJIRA"
    />

    <csv-export-modal
      v-if="showExportButton"
      :modal-id="exportModalId"
      :export-csv-path="exportCsvPath"
      :issuable-count="issuableCount"
    />
    <csv-import-modal v-if="showImportButton" :modal-id="importModalId" />
  </ul>
</template>