Commit ad5add29 authored by Rajat Jain's avatar Rajat Jain

Pass issuable-type in AddIssuableForm

Pass a prop called issuable-type from EpicShowApp down to
AddIssuableForm in a backward compatible way. Right now, the
issuable-type can take two values: 'epic' and 'issue' which is
needed mostly for the display purposes in the Input field which asks,
"Paste issue link" or "Paste epic link".
parent a8e2ca00
...@@ -328,6 +328,7 @@ export default { ...@@ -328,6 +328,7 @@ export default {
:allow-auto-complete="false" :allow-auto-complete="false"
:path-id-separator="$options.epicsPathIdSeparator" :path-id-separator="$options.epicsPathIdSeparator"
:title="__('Epics')" :title="__('Epics')"
:issuable-type="__('epic')"
css-class="js-related-epics-block" css-class="js-related-epics-block"
/> />
<related-issues-root <related-issues-root
...@@ -336,6 +337,7 @@ export default { ...@@ -336,6 +337,7 @@ export default {
:can-reorder="canAdmin" :can-reorder="canAdmin"
:allow-auto-complete="false" :allow-auto-complete="false"
:title="__('Issues')" :title="__('Issues')"
:issuable-type="__('issue')"
css-class="js-related-issues-block" css-class="js-related-issues-block"
path-id-separator="#" path-id-separator="#"
/> />
......
...@@ -3,6 +3,7 @@ import $ from 'jquery'; ...@@ -3,6 +3,7 @@ import $ from 'jquery';
import GfmAutoComplete from '~/gfm_auto_complete'; import GfmAutoComplete from '~/gfm_auto_complete';
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import issueToken from './issue_token.vue'; import issueToken from './issue_token.vue';
import { autoCompleteTextMap, inputPlaceholderTextMap } from '../constants';
export default { export default {
name: 'AddIssuableForm', name: 'AddIssuableForm',
...@@ -34,6 +35,11 @@ export default { ...@@ -34,6 +35,11 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
issuableType: {
type: String,
required: false,
default: 'issue',
},
}, },
data() { data() {
...@@ -45,7 +51,9 @@ export default { ...@@ -45,7 +51,9 @@ export default {
computed: { computed: {
inputPlaceholder() { inputPlaceholder() {
return `Paste issue link${this.allowAutoComplete ? ' or <#issue id>' : ''}`; const { issuableType, allowAutoComplete } = this;
const allowAutoCompleteText = autoCompleteTextMap[allowAutoComplete][issuableType];
return `${inputPlaceholderTextMap[issuableType]}${allowAutoCompleteText}`;
}, },
isSubmitButtonDisabled() { isSubmitButtonDisabled() {
return ( return (
......
...@@ -78,6 +78,10 @@ export default { ...@@ -78,6 +78,10 @@ export default {
required: false, required: false,
default: 'Related issues', default: 'Related issues',
}, },
issuableType: {
type: String,
required: true,
},
}, },
computed: { computed: {
hasRelatedIssues() { hasRelatedIssues() {
...@@ -183,6 +187,7 @@ export default { ...@@ -183,6 +187,7 @@ export default {
> >
<add-issuable-form <add-issuable-form
:is-submitting="isSubmitting" :is-submitting="isSubmitting"
:issuable-type="issuableType"
:input-value="inputValue" :input-value="inputValue"
:pending-references="pendingReferences" :pending-references="pendingReferences"
:auto-complete-sources="autoCompleteSources" :auto-complete-sources="autoCompleteSources"
......
...@@ -28,6 +28,11 @@ import Flash from '~/flash'; ...@@ -28,6 +28,11 @@ import Flash from '~/flash';
import RelatedIssuesBlock from './related_issues_block.vue'; import RelatedIssuesBlock from './related_issues_block.vue';
import RelatedIssuesStore from '../stores/related_issues_store'; import RelatedIssuesStore from '../stores/related_issues_store';
import RelatedIssuesService from '../services/related_issues_service'; import RelatedIssuesService from '../services/related_issues_service';
import {
relatedIssuesRemoveErrorMap,
pathIndeterminateErrorMap,
addRelatedIssueErrorMap,
} from '../constants';
const SPACE_FACTOR = 1; const SPACE_FACTOR = 1;
...@@ -61,6 +66,11 @@ export default { ...@@ -61,6 +66,11 @@ export default {
required: false, required: false,
default: 'Related issues', default: 'Related issues',
}, },
issuableType: {
type: String,
required: false,
default: 'issue',
},
allowAutoComplete: { allowAutoComplete: {
type: Boolean, type: Boolean,
required: false, required: false,
...@@ -110,11 +120,11 @@ export default { ...@@ -110,11 +120,11 @@ export default {
}) })
.catch(res => { .catch(res => {
if (res && res.status !== 404) { if (res && res.status !== 404) {
Flash('An error occurred while removing issues.'); Flash(relatedIssuesRemoveErrorMap[this.issuableType]);
} }
}); });
} else { } else {
Flash('We could not determine the path to remove the issue'); Flash(pathIndeterminateErrorMap[this.issuableType]);
} }
}, },
onToggleAddRelatedIssuesForm() { onToggleAddRelatedIssuesForm() {
...@@ -142,7 +152,7 @@ export default { ...@@ -142,7 +152,7 @@ export default {
}) })
.catch(res => { .catch(res => {
this.isSubmitting = false; this.isSubmitting = false;
let errorMessage = "We can't find an issue that matches what you are looking for."; let errorMessage = addRelatedIssueErrorMap[this.issuableType];
if (res.data && res.data.message) { if (res.data && res.data.message) {
errorMessage = res.data.message; errorMessage = res.data.message;
} }
...@@ -239,6 +249,7 @@ export default { ...@@ -239,6 +249,7 @@ export default {
:input-value="inputValue" :input-value="inputValue"
:auto-complete-sources="autoCompleteSources" :auto-complete-sources="autoCompleteSources"
:title="title" :title="title"
:issuable-type="issuableType"
:path-id-separator="pathIdSeparator" :path-id-separator="pathIdSeparator"
@saveReorder="saveIssueOrder" @saveReorder="saveIssueOrder"
@toggleAddRelatedIssuesForm="onToggleAddRelatedIssuesForm" @toggleAddRelatedIssuesForm="onToggleAddRelatedIssuesForm"
......
import { __ } from '~/locale';
export const autoCompleteTextMap = {
true: {
issue: __(' or <#issue id>'),
epic: __(' or <#epic id>'),
},
false: {
issue: '',
epic: '',
},
};
export const inputPlaceholderTextMap = {
issue: __('Paste issue link'),
epic: __('Paste epic link'),
};
export const relatedIssuesRemoveErrorMap = {
issue: __('An error occurred while removing issues.'),
epic: __('An error occurred while removing epics.'),
};
export const pathIndeterminateErrorMap = {
issue: __('We could not determine the path to remove the issue'),
epic: __('We could not determine the path to remove the epic'),
};
export const addRelatedIssueErrorMap = {
issue: __("We can't find an issue that matches what you are looking for."),
epic: __("We can't find an epic that matches what you are looking for."),
};
---
title: Pass issuable-type in AddIssuableForm
merge_request: 9111
author:
type: other
...@@ -22,6 +22,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -22,6 +22,7 @@ describe('RelatedIssuesBlock', () => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: '#',
issuableType: 'issue',
}, },
}).$mount(); }).$mount();
}); });
...@@ -45,6 +46,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -45,6 +46,7 @@ describe('RelatedIssuesBlock', () => {
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: '#',
isFetching: true, isFetching: true,
issuableType: 'issue',
}, },
}).$mount(); }).$mount();
}); });
...@@ -64,6 +66,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -64,6 +66,7 @@ describe('RelatedIssuesBlock', () => {
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: '#',
canAdmin: true, canAdmin: true,
issuableType: 'issue',
}, },
}).$mount(); }).$mount();
}); });
...@@ -79,6 +82,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -79,6 +82,7 @@ describe('RelatedIssuesBlock', () => {
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: '#',
isFormVisible: true, isFormVisible: true,
issuableType: 'issue',
}, },
}).$mount(); }).$mount();
}); });
...@@ -94,6 +98,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -94,6 +98,7 @@ describe('RelatedIssuesBlock', () => {
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: '#',
relatedIssues: [issuable1, issuable2], relatedIssues: [issuable1, issuable2],
issuableType: 'issue',
}, },
}).$mount(); }).$mount();
}); });
...@@ -109,6 +114,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -109,6 +114,7 @@ describe('RelatedIssuesBlock', () => {
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: '#',
relatedIssues: [issuable1, issuable2, issuable3, issuable4, issuable5], relatedIssues: [issuable1, issuable2, issuable3, issuable4, issuable5],
issuableType: 'issue',
}, },
}).$mount(); }).$mount();
}); });
......
...@@ -35,6 +35,12 @@ msgstr[1] "" ...@@ -35,6 +35,12 @@ msgstr[1] ""
msgid " or " msgid " or "
msgstr "" msgstr ""
msgid " or <#epic id>"
msgstr ""
msgid " or <#issue id>"
msgstr ""
msgid "\"%{query}\" in projects" msgid "\"%{query}\" in projects"
msgstr "" msgstr ""
...@@ -763,6 +769,12 @@ msgstr "" ...@@ -763,6 +769,12 @@ msgstr ""
msgid "An error occurred while removing approver" msgid "An error occurred while removing approver"
msgstr "" msgstr ""
msgid "An error occurred while removing epics."
msgstr ""
msgid "An error occurred while removing issues."
msgstr ""
msgid "An error occurred while rendering KaTeX" msgid "An error occurred while rendering KaTeX"
msgstr "" msgstr ""
...@@ -6362,6 +6374,12 @@ msgstr "" ...@@ -6362,6 +6374,12 @@ msgstr ""
msgid "Password" msgid "Password"
msgstr "" msgstr ""
msgid "Paste epic link"
msgstr ""
msgid "Paste issue link"
msgstr ""
msgid "Paste your public SSH key, which is usually contained in the file '~/.ssh/id_rsa.pub' and begins with 'ssh-rsa'. Don't use your private SSH key." msgid "Paste your public SSH key, which is usually contained in the file '~/.ssh/id_rsa.pub' and begins with 'ssh-rsa'. Don't use your private SSH key."
msgstr "" msgstr ""
...@@ -9939,6 +9957,18 @@ msgstr "" ...@@ -9939,6 +9957,18 @@ msgstr ""
msgid "Want to see the data? Please ask an administrator for access." msgid "Want to see the data? Please ask an administrator for access."
msgstr "" msgstr ""
msgid "We can't find an epic that matches what you are looking for."
msgstr ""
msgid "We can't find an issue that matches what you are looking for."
msgstr ""
msgid "We could not determine the path to remove the epic"
msgstr ""
msgid "We could not determine the path to remove the issue"
msgstr ""
msgid "We detected potential spam in the %{humanized_resource_name}. Please solve the reCAPTCHA to proceed." msgid "We detected potential spam in the %{humanized_resource_name}. Please solve the reCAPTCHA to proceed."
msgstr "" msgstr ""
...@@ -10652,6 +10682,9 @@ msgstr[1] "" ...@@ -10652,6 +10682,9 @@ msgstr[1] ""
msgid "enabled" msgid "enabled"
msgstr "" msgstr ""
msgid "epic"
msgstr ""
msgid "error" msgid "error"
msgstr "" msgstr ""
...@@ -10708,6 +10741,9 @@ msgstr "" ...@@ -10708,6 +10741,9 @@ msgstr ""
msgid "is out of the hierarchy of the Group owning the template" msgid "is out of the hierarchy of the Group owning the template"
msgstr "" msgstr ""
msgid "issue"
msgstr ""
msgid "issue boards" msgid "issue boards"
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment