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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue')
-rw-r--r--app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue123
1 files changed, 119 insertions, 4 deletions
diff --git a/app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue b/app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue
index af4e9acf4ba..22a767cfaae 100644
--- a/app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue
+++ b/app/assets/javascripts/integrations/edit/components/jira_trigger_fields.vue
@@ -1,7 +1,16 @@
<script>
-import { GlFormGroup, GlFormCheckbox, GlFormRadio } from '@gitlab/ui';
+import {
+ GlFormGroup,
+ GlFormCheckbox,
+ GlFormRadio,
+ GlFormInput,
+ GlLink,
+ GlSprintf,
+} from '@gitlab/ui';
import { mapGetters } from 'vuex';
+import { helpPagePath } from '~/helpers/help_page_helper';
import { s__ } from '~/locale';
+import eventHub from '../event_hub';
const commentDetailOptions = [
{
@@ -18,12 +27,41 @@ const commentDetailOptions = [
},
];
+const ISSUE_TRANSITION_AUTO = 'auto';
+const ISSUE_TRANSITION_CUSTOM = 'custom';
+
+const issueTransitionOptions = [
+ {
+ value: ISSUE_TRANSITION_AUTO,
+ label: s__('JiraService|Move to Done'),
+ help: s__(
+ 'JiraService|Automatically transitions Jira issues to the "Done" category. %{linkStart}Learn more%{linkEnd}',
+ ),
+ link: helpPagePath('user/project/integrations/jira.html', {
+ anchor: 'automatic-issue-transitions',
+ }),
+ },
+ {
+ value: ISSUE_TRANSITION_CUSTOM,
+ label: s__('JiraService|Use custom transitions'),
+ help: s__(
+ 'JiraService|Set a custom final state by using transition IDs. %{linkStart}Learn about transition IDs%{linkEnd}',
+ ),
+ link: helpPagePath('user/project/integrations/jira.html', {
+ anchor: 'custom-issue-transitions',
+ }),
+ },
+];
+
export default {
name: 'JiraTriggerFields',
components: {
GlFormGroup,
GlFormCheckbox,
GlFormRadio,
+ GlFormInput,
+ GlLink,
+ GlSprintf,
},
props: {
initialTriggerCommit: {
@@ -43,21 +81,52 @@ export default {
required: false,
default: 'standard',
},
+ initialJiraIssueTransitionId: {
+ type: String,
+ required: false,
+ default: '',
+ },
},
data() {
return {
+ validated: false,
triggerCommit: this.initialTriggerCommit,
triggerMergeRequest: this.initialTriggerMergeRequest,
enableComments: this.initialEnableComments,
commentDetail: this.initialCommentDetail,
+ jiraIssueTransitionId: this.initialJiraIssueTransitionId,
+ issueTransitionMode: this.initialJiraIssueTransitionId.length
+ ? ISSUE_TRANSITION_CUSTOM
+ : ISSUE_TRANSITION_AUTO,
commentDetailOptions,
+ issueTransitionOptions,
};
},
computed: {
...mapGetters(['isInheriting']),
- showEnableComments() {
+ showTriggerSettings() {
return this.triggerCommit || this.triggerMergeRequest;
},
+ validIssueTransitionId() {
+ return !this.validated || this.jiraIssueTransitionId.length > 0;
+ },
+ },
+ created() {
+ eventHub.$on('validateForm', this.validateForm);
+ },
+ beforeDestroy() {
+ eventHub.$off('validateForm', this.validateForm);
+ },
+ methods: {
+ validateForm() {
+ this.validated = true;
+ },
+ showCustomIssueTransitions(currentOption) {
+ return (
+ this.issueTransitionMode === ISSUE_TRANSITION_CUSTOM &&
+ currentOption === ISSUE_TRANSITION_CUSTOM
+ );
+ },
},
};
</script>
@@ -89,7 +158,7 @@ export default {
</gl-form-group>
<gl-form-group
- v-show="showEnableComments"
+ v-show="showTriggerSettings"
:label="s__('Integrations|Comment settings:')"
label-for="service[comment_on_event_enabled]"
class="gl-pl-6"
@@ -106,7 +175,7 @@ export default {
</gl-form-group>
<gl-form-group
- v-show="showEnableComments && enableComments"
+ v-show="showTriggerSettings && enableComments"
:label="s__('Integrations|Comment detail:')"
label-for="service[comment_detail]"
class="gl-pl-9"
@@ -126,5 +195,51 @@ export default {
</template>
</gl-form-radio>
</gl-form-group>
+
+ <gl-form-group
+ v-show="showTriggerSettings"
+ :label="s__('JiraService|Transition Jira issues to their final state:')"
+ class="gl-pl-6"
+ data-testid="issue-transition-settings"
+ >
+ <input type="hidden" name="service[jira_issue_transition_id]" value="" />
+
+ <gl-form-radio
+ v-for="issueTransitionOption in issueTransitionOptions"
+ :key="issueTransitionOption.value"
+ v-model="issueTransitionMode"
+ :value="issueTransitionOption.value"
+ :disabled="isInheriting"
+ :data-qa-selector="`service_issue_transition_mode_${issueTransitionOption.value}`"
+ >
+ {{ issueTransitionOption.label }}
+
+ <template v-if="showCustomIssueTransitions(issueTransitionOption.value)">
+ <gl-form-input
+ v-model="jiraIssueTransitionId"
+ name="service[jira_issue_transition_id]"
+ type="text"
+ class="gl-my-3"
+ data-qa-selector="service_jira_issue_transition_id_field"
+ :placeholder="s__('JiraService|For example, 12, 24')"
+ :disabled="isInheriting"
+ :required="true"
+ :state="validIssueTransitionId"
+ />
+
+ <span class="invalid-feedback">
+ {{ s__('This field is required.') }}
+ </span>
+ </template>
+
+ <template #help>
+ <gl-sprintf :message="issueTransitionOption.help">
+ <template #link="{ content }">
+ <gl-link :href="issueTransitionOption.link" target="_blank">{{ content }}</gl-link>
+ </template>
+ </gl-sprintf>
+ </template>
+ </gl-form-radio>
+ </gl-form-group>
</div>
</template>