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

issuable_form.vue « components « create « issuable « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 64f0ec3fbc7c21204b9766f55691989ff84d87f4 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<script>
import { GlForm, GlFormInput, GlFormCheckbox, GlFormGroup } from '@gitlab/ui';
import LabelsSelect from '~/sidebar/components/labels/labels_select_vue/labels_select_root.vue';
import { VARIANT_EMBEDDED } from '~/sidebar/components/labels/labels_select_widget/constants';
import MarkdownEditor from '~/vue_shared/components/markdown/markdown_editor.vue';
import { __, sprintf } from '~/locale';
import { issuableTypeText } from '~/issues/constants';

export default {
  VARIANT_EMBEDDED,
  components: {
    GlForm,
    GlFormInput,
    GlFormCheckbox,
    GlFormGroup,
    MarkdownEditor,
    LabelsSelect,
  },
  props: {
    descriptionPreviewPath: {
      type: String,
      required: true,
    },
    descriptionHelpPath: {
      type: String,
      required: true,
    },
    labelsFetchPath: {
      type: String,
      required: true,
    },
    labelsManagePath: {
      type: String,
      required: true,
    },
    issuableType: {
      type: String,
      required: true,
    },
  },
  descriptionFormFieldProps: {
    ariaLabel: __('Description'),
    class: 'rspec-issuable-form-description',
    placeholder: __('Write a comment or drag your files here…'),
    dataTestid: 'issuable-form-description-field',
    id: 'issuable-description',
    name: 'issuable-description',
  },
  data() {
    return {
      issuableTitle: '',
      issuableDescription: '',
      issuableConfidential: false,
      selectedLabels: [],
    };
  },
  computed: {
    confidentialityText() {
      return sprintf(
        __(
          'This %{issuableType} is confidential and should only be visible to team members with at least Reporter access.',
        ),
        { issuableType: issuableTypeText[this.issuableType] },
      );
    },
  },
  methods: {
    handleUpdateSelectedLabels(labels) {
      if (labels.length) {
        this.selectedLabels = labels;
      }
    },
  },
};
</script>

<template>
  <gl-form class="common-note-form gfm-form" @submit.stop.prevent>
    <div data-testid="issuable-title" class="row">
      <label for="issuable-title" class="col-12 gl-mb-0">{{ __('Title') }}</label>
      <div class="col-12">
        <gl-form-group :description="__('Maximum of 255 characters')">
          <gl-form-input
            id="issuable-title"
            v-model="issuableTitle"
            maxlength="255"
            :autofocus="true"
            :placeholder="__('Title')"
          />
        </gl-form-group>
      </div>
    </div>
    <div data-testid="issuable-description" class="form-group row">
      <label for="issuable-description" class="col-12">{{ __('Description') }}</label>
      <div class="col-12">
        <markdown-editor
          v-model="issuableDescription"
          :render-markdown-path="descriptionPreviewPath"
          :markdown-docs-path="descriptionHelpPath"
          :form-field-props="$options.descriptionFormFieldProps"
        />
      </div>
    </div>
    <div data-testid="issuable-confidential" class="form-group row">
      <div class="col-12">
        <gl-form-group :label="__('Confidentiality')" label-for="issuable-confidential">
          <gl-form-checkbox id="issuable-confidential" v-model="issuableConfidential">
            {{ confidentialityText }}
          </gl-form-checkbox>
        </gl-form-group>
      </div>
    </div>
    <div data-testid="issuable-labels" class="form-group row">
      <label for="issuable-labels" class="col-12">{{ __('Labels') }}</label>
      <div class="col-12">
        <div class="issuable-form-select-holder">
          <labels-select
            :allow-label-edit="true"
            :allow-label-create="true"
            :allow-multiselect="true"
            :allow-scoped-labels="true"
            :labels-fetch-path="labelsFetchPath"
            :labels-manage-path="labelsManagePath"
            :selected-labels="selectedLabels"
            :labels-list-title="__('Select label')"
            :footer-create-label-title="__('Create project label')"
            :footer-manage-label-title="__('Manage project labels')"
            :variant="$options.VARIANT_EMBEDDED"
            @updateSelectedLabels="handleUpdateSelectedLabels"
          />
        </div>
      </div>
    </div>
    <div data-testid="issuable-create-actions" class="footer-block gl-display-flex gl-mt-6">
      <slot
        name="actions"
        :issuable-title="issuableTitle"
        :issuable-description="issuableDescription"
        :issuable-confidential="issuableConfidential"
        :selected-labels="selectedLabels"
      ></slot>
    </div>
  </gl-form>
</template>