diff --git a/app/assets/javascripts/related_issues/constants.js b/app/assets/javascripts/related_issues/constants.js index 821f6b525c594915fb1c8e58aa0e1a33d45fc473..2a4ce70511bf682b426e3c3baf7539cf78524f8c 100644 --- a/app/assets/javascripts/related_issues/constants.js +++ b/app/assets/javascripts/related_issues/constants.js @@ -1,5 +1,5 @@ import { __, sprintf } from '~/locale'; -import { TYPE_ISSUE } from '~/issues/constants'; +import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants'; export const issuableTypesMap = { ISSUE: 'issue', @@ -32,7 +32,7 @@ export const autoCompleteTextMap = { { emphasisStart: '<', emphasisEnd: '>' }, false, ), - [issuableTypesMap.EPIC]: sprintf( + [TYPE_EPIC]: sprintf( __(' or %{emphasisStart}&epic id%{emphasisEnd}'), { emphasisStart: '<', emphasisEnd: '>' }, false, @@ -45,7 +45,7 @@ export const autoCompleteTextMap = { }, false: { [TYPE_ISSUE]: '', - [issuableTypesMap.EPIC]: '', + [TYPE_EPIC]: '', [issuableTypesMap.MERGE_REQUEST]: __(' or references'), }, }; @@ -53,24 +53,24 @@ export const autoCompleteTextMap = { export const inputPlaceholderTextMap = { [TYPE_ISSUE]: __('Paste issue link'), [issuableTypesMap.INCIDENT]: __('Paste link'), - [issuableTypesMap.EPIC]: __('Paste epic link'), + [TYPE_EPIC]: __('Paste epic link'), [issuableTypesMap.MERGE_REQUEST]: __('Enter merge request URLs'), }; export const inputPlaceholderConfidentialTextMap = { [TYPE_ISSUE]: __('Paste confidential issue link'), - [issuableTypesMap.EPIC]: __('Paste confidential epic link'), + [TYPE_EPIC]: __('Paste confidential epic link'), [issuableTypesMap.MERGE_REQUEST]: __('Enter merge request URLs'), }; export const relatedIssuesRemoveErrorMap = { [TYPE_ISSUE]: __('An error occurred while removing issues.'), - [issuableTypesMap.EPIC]: __('An error occurred while removing epics.'), + [TYPE_EPIC]: __('An error occurred while removing epics.'), }; export const pathIndeterminateErrorMap = { [TYPE_ISSUE]: __('We could not determine the path to remove the issue'), - [issuableTypesMap.EPIC]: __('We could not determine the path to remove the epic'), + [TYPE_EPIC]: __('We could not determine the path to remove the epic'), }; export const itemAddFailureTypesMap = { @@ -80,7 +80,7 @@ export const itemAddFailureTypesMap = { export const addRelatedIssueErrorMap = { [TYPE_ISSUE]: __('Issue cannot be found.'), - [issuableTypesMap.EPIC]: __('Epic cannot be found.'), + [TYPE_EPIC]: __('Epic cannot be found.'), }; export const addRelatedItemErrorMap = { @@ -97,7 +97,7 @@ export const addRelatedItemErrorMap = { export const issuableIconMap = { [TYPE_ISSUE]: 'issues', [issuableTypesMap.INCIDENT]: 'issues', - [issuableTypesMap.EPIC]: 'epic', + [TYPE_EPIC]: 'epic', }; export const PathIdSeparator = { @@ -108,28 +108,28 @@ export const PathIdSeparator = { export const issuablesBlockHeaderTextMap = { [TYPE_ISSUE]: __('Linked items'), [issuableTypesMap.INCIDENT]: __('Linked incidents or issues'), - [issuableTypesMap.EPIC]: __('Linked epics'), + [TYPE_EPIC]: __('Linked epics'), }; export const issuablesBlockHelpTextMap = { [TYPE_ISSUE]: __('Learn more about linking issues'), [issuableTypesMap.INCIDENT]: __('Learn more about linking issues and incidents'), - [issuableTypesMap.EPIC]: __('Learn more about linking epics'), + [TYPE_EPIC]: __('Learn more about linking epics'), }; export const issuablesBlockAddButtonTextMap = { [TYPE_ISSUE]: __('Add a related issue'), - [issuableTypesMap.EPIC]: __('Add a related epic'), + [TYPE_EPIC]: __('Add a related epic'), }; export const issuablesFormCategoryHeaderTextMap = { [TYPE_ISSUE]: __('The current issue'), [issuableTypesMap.INCIDENT]: __('The current incident'), - [issuableTypesMap.EPIC]: __('The current epic'), + [TYPE_EPIC]: __('The current epic'), }; export const issuablesFormInputTextMap = { [TYPE_ISSUE]: __('the following issues'), [issuableTypesMap.INCIDENT]: __('the following incidents or issues'), - [issuableTypesMap.EPIC]: __('the following epics'), + [TYPE_EPIC]: __('the following epics'), }; diff --git a/ee/app/assets/javascripts/linked_epics/linked_epics_bundle.js b/ee/app/assets/javascripts/linked_epics/linked_epics_bundle.js index d9169fb961ae2e2d5aa70b0bc2fef5fe4941c22f..365e9a07fa3b65a860d43cda8abbef97248e36a8 100644 --- a/ee/app/assets/javascripts/linked_epics/linked_epics_bundle.js +++ b/ee/app/assets/javascripts/linked_epics/linked_epics_bundle.js @@ -1,7 +1,8 @@ import Vue from 'vue'; +import { TYPE_EPIC } from '~/issues/constants'; import { parseBoolean } from '~/lib/utils/common_utils'; import RelatedEpicsRoot from '~/related_issues/components/related_issues_root.vue'; -import { PathIdSeparator, issuableTypesMap } from '~/related_issues/constants'; +import { PathIdSeparator } from '~/related_issues/constants'; export default function initRelatedEpics() { const relatedEpicsRootEl = document.querySelector('#js-related-epics'); @@ -29,7 +30,7 @@ export default function initRelatedEpics() { canAdmin: parseBoolean(canAddRelatedEpics), showCategorizedIssues: parseBoolean(showCategorizedEpics), pathIdSeparator: PathIdSeparator.Epic, - issuableType: issuableTypesMap.EPIC, + issuableType: TYPE_EPIC, autoCompleteIssues: false, }, }), diff --git a/ee/app/assets/javascripts/related_items_tree/components/related_items_tree_app.vue b/ee/app/assets/javascripts/related_items_tree/components/related_items_tree_app.vue index 2d6a22c3f48244c4c6b8f3485e70c7e4cd4f25cb..c9fa5feba51cd4e67857e3d807ae2b6e39174610 100644 --- a/ee/app/assets/javascripts/related_items_tree/components/related_items_tree_app.vue +++ b/ee/app/assets/javascripts/related_items_tree/components/related_items_tree_app.vue @@ -1,11 +1,10 @@ <script> import { GlLoadingIcon, GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { mapState, mapActions, mapGetters } from 'vuex'; -import { TYPE_ISSUE } from '~/issues/constants'; +import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants'; import { __, sprintf } from '~/locale'; import AddItemForm from '~/related_issues/components/add_issuable_form.vue'; import SlotSwitch from '~/vue_shared/components/slot_switch.vue'; -import { issuableTypesMap } from '~/related_issues/constants'; import { ITEM_TABS, OVERFLOW_AFTER, i18nConfidentialParent } from '../constants'; import CreateEpicForm from './create_epic_form.vue'; import CreateIssueForm from './create_issue_form.vue'; @@ -107,7 +106,7 @@ export default { ]; }, enableEpicsAutoComplete() { - return this.issuableType === issuableTypesMap.EPIC && this.autoCompleteEpics; + return this.issuableType === TYPE_EPIC && this.autoCompleteEpics; }, enableIssuesAutoComplete() { return this.issuableType === TYPE_ISSUE && this.autoCompleteIssues; diff --git a/ee/app/assets/javascripts/related_items_tree/components/related_items_tree_header.vue b/ee/app/assets/javascripts/related_items_tree/components/related_items_tree_header.vue index 2ca64a7ae429d7646aeafa6813ef32deab1f16e9..4b5073a3badb6514bf7831920e0bde680373bac6 100644 --- a/ee/app/assets/javascripts/related_items_tree/components/related_items_tree_header.vue +++ b/ee/app/assets/javascripts/related_items_tree/components/related_items_tree_header.vue @@ -1,8 +1,7 @@ <script> import { GlAlert, GlPopover, GlIcon, GlButton } from '@gitlab/ui'; import { mapState, mapActions } from 'vuex'; -import { TYPE_ISSUE } from '~/issues/constants'; -import { issuableTypesMap } from '~/related_issues/constants'; +import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants'; import { __ } from '~/locale'; import { i18n, treeTitle, ParentType } from '../constants'; import EpicHealthStatus from './epic_health_status.vue'; @@ -77,7 +76,7 @@ export default { }, showAddEpicForm() { this.toggleAddItemForm({ - issuableType: issuableTypesMap.EPIC, + issuableType: TYPE_EPIC, toggleState: true, }); }, diff --git a/ee/app/assets/javascripts/related_items_tree/store/getters.js b/ee/app/assets/javascripts/related_items_tree/store/getters.js index 2bb094277ccbd1e477214a32659d36f44de5a16c..f08311be02103f80465c721784108e586de1d2ab 100644 --- a/ee/app/assets/javascripts/related_items_tree/store/getters.js +++ b/ee/app/assets/javascripts/related_items_tree/store/getters.js @@ -1,4 +1,5 @@ -import { issuableTypesMap, PathIdSeparator } from '~/related_issues/constants'; +import { TYPE_EPIC } from '~/issues/constants'; +import { PathIdSeparator } from '~/related_issues/constants'; import { processIssueTypeIssueSources } from '../utils/epic_utils'; export const autoCompleteSources = () => gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources; @@ -26,4 +27,4 @@ export const itemAutoCompleteSources = (state, getters) => { export const itemPathIdSeparator = (state, getters) => getters.isEpic ? PathIdSeparator.Epic : PathIdSeparator.Issue; -export const isEpic = (state) => state.issuableType === issuableTypesMap.EPIC; +export const isEpic = (state) => state.issuableType === TYPE_EPIC; diff --git a/ee/app/assets/javascripts/related_items_tree/store/mutations.js b/ee/app/assets/javascripts/related_items_tree/store/mutations.js index b6dea98896e79233a8d2675bfe6117d45f72c873..7e5587c97c3fea451f4ace14a645e31b0f0d9ae9 100644 --- a/ee/app/assets/javascripts/related_items_tree/store/mutations.js +++ b/ee/app/assets/javascripts/related_items_tree/store/mutations.js @@ -1,6 +1,5 @@ import Vue from 'vue'; -import { TYPE_ISSUE } from '~/issues/constants'; -import { issuableTypesMap } from '~/related_issues/constants'; +import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants'; import * as types from './mutation_types'; export default { @@ -167,7 +166,7 @@ export default { state.showCreateEpicForm = toggleState; state.showAddItemForm = false; state.showCreateIssueForm = false; - state.issuableType = issuableTypesMap.EPIC; + state.issuableType = TYPE_EPIC; }, [types.TOGGLE_CREATE_ISSUE_FORM](state, { toggleState }) { diff --git a/ee/spec/frontend/related_items_tree/components/related_items_tree_app_spec.js b/ee/spec/frontend/related_items_tree/components/related_items_tree_app_spec.js index eb2aea5d60664001ab8897c6260d29f8c95aade2..294ccea26453606b7b522a1351b0cdf7d0a06b44 100644 --- a/ee/spec/frontend/related_items_tree/components/related_items_tree_app_spec.js +++ b/ee/spec/frontend/related_items_tree/components/related_items_tree_app_spec.js @@ -15,11 +15,10 @@ import RelatedItemsTreeBody from 'ee/related_items_tree/components/related_items import RelatedItemsRoadmapApp from 'ee/related_items_tree/components/related_items_roadmap_app.vue'; import createDefaultStore from 'ee/related_items_tree/store'; -import { TYPE_ISSUE } from '~/issues/constants'; +import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { ITEM_TABS } from 'ee/related_items_tree/constants'; -import { issuableTypesMap } from '~/related_issues/constants'; import { mockInitialConfig, mockParentItem, mockEpics, mockIssues } from '../mock_data'; @@ -238,7 +237,7 @@ describe('RelatedItemsTreeApp', () => { it('renders item add/create form container element', async () => { wrapper.vm.$store.dispatch('toggleAddItemForm', { toggleState: true, - issuableType: issuableTypesMap.EPIC, + issuableType: TYPE_EPIC, }); await nextTick(); @@ -250,9 +249,9 @@ describe('RelatedItemsTreeApp', () => { }); it.each` - issuableType | autoCompleteIssues | autoCompleteEpics | expectedAutoCompleteIssues | expectedAutoCompleteEpics - ${TYPE_ISSUE} | ${true} | ${true} | ${true} | ${false} - ${issuableTypesMap.EPIC} | ${true} | ${true} | ${false} | ${true} + issuableType | autoCompleteIssues | autoCompleteEpics | expectedAutoCompleteIssues | expectedAutoCompleteEpics + ${TYPE_ISSUE} | ${true} | ${true} | ${true} | ${false} + ${TYPE_EPIC} | ${true} | ${true} | ${false} | ${true} `( 'enables $issuableType autocomplete only when "issuableType" is "$issuableType" and autocomplete for it is supported', async ({ diff --git a/ee/spec/frontend/related_items_tree/components/related_items_tree_header_spec.js b/ee/spec/frontend/related_items_tree/components/related_items_tree_header_spec.js index 289347dab82554aa07d3ebdc4f36dc9053698d4f..10f009a2ed686f7ce43a030fdc4f6e6b964bc820 100644 --- a/ee/spec/frontend/related_items_tree/components/related_items_tree_header_spec.js +++ b/ee/spec/frontend/related_items_tree/components/related_items_tree_header_spec.js @@ -9,8 +9,7 @@ import RelatedItemsTreeHeader from 'ee/related_items_tree/components/related_ite import createDefaultStore from 'ee/related_items_tree/store'; import * as epicUtils from 'ee/related_items_tree/utils/epic_utils'; -import { TYPE_ISSUE } from '~/issues/constants'; -import { issuableTypesMap } from '~/related_issues/constants'; +import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants'; import { mockInitialConfig, mockParentItem, mockQueryResponse } from '../mock_data'; Vue.use(Vuex); @@ -111,7 +110,7 @@ describe('RelatedItemsTree', () => { const payload = toggleAddItemForm.mock.calls[0][1]; expect(payload).toEqual({ - issuableType: issuableTypesMap.EPIC, + issuableType: TYPE_EPIC, toggleState: true, }); }); diff --git a/ee/spec/frontend/related_items_tree/store/actions_spec.js b/ee/spec/frontend/related_items_tree/store/actions_spec.js index 058fbe4cdcf6035a45954d1451717a261948277b..d3015df12106e76cb2e5b83e94e164dff7089480 100644 --- a/ee/spec/frontend/related_items_tree/store/actions_spec.js +++ b/ee/spec/frontend/related_items_tree/store/actions_spec.js @@ -17,13 +17,10 @@ import Tracking from '~/tracking'; import testAction from 'helpers/vuex_action_helper'; import { TEST_HOST } from 'spec/test_constants'; import { createAlert } from '~/flash'; +import { TYPE_EPIC } from '~/issues/constants'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_INTERNAL_SERVER_ERROR, HTTP_STATUS_OK } from '~/lib/utils/http_status'; -import { - issuableTypesMap, - itemAddFailureTypesMap, - PathIdSeparator, -} from '~/related_issues/constants'; +import { itemAddFailureTypesMap, PathIdSeparator } from '~/related_issues/constants'; import { mockInitialConfig, @@ -930,7 +927,7 @@ describe('RelatedItemTree', () => { describe('receiveAddItemSuccess', () => { it('should set `state.itemAddInProgress` to false and dispatches actions `setPendingReferences`, `setItemInputValue` and `toggleAddItemForm`', () => { - state.issuableType = issuableTypesMap.EPIC; + state.issuableType = TYPE_EPIC; state.isEpic = true; const mockEpicsWithoutPerm = mockEpics.map((item) => ({ @@ -1025,7 +1022,7 @@ describe('RelatedItemTree', () => { }); it('should dispatch `requestAddItem` and `receiveAddItemSuccess` actions on request success', () => { - state.issuableType = issuableTypesMap.EPIC; + state.issuableType = TYPE_EPIC; state.epicsEndpoint = '/foo/bar'; state.pendingReferences = ['foo']; state.isEpic = true; @@ -1079,7 +1076,7 @@ describe('RelatedItemTree', () => { }); it('should dispatch `requestAddItem` and `receiveAddItemFailure` actions on request failure', () => { - state.issuableType = issuableTypesMap.EPIC; + state.issuableType = TYPE_EPIC; state.epicsEndpoint = '/foo/bar'; state.pendingReferences = ['foo']; @@ -1122,7 +1119,7 @@ describe('RelatedItemTree', () => { state.parentItem = { fullPath: createdEpic.group.fullPath, }; - state.issuableType = issuableTypesMap.EPIC; + state.issuableType = TYPE_EPIC; state.isEpic = true; testAction( @@ -1188,7 +1185,7 @@ describe('RelatedItemTree', () => { beforeEach(() => { mock = new MockAdapter(axios); state.parentItem = mockParentItem; - state.issuableType = issuableTypesMap.EPIC; + state.issuableType = TYPE_EPIC; }); afterEach(() => { @@ -1779,7 +1776,7 @@ describe('RelatedItemTree', () => { beforeEach(() => { mock = new MockAdapter(axios); state.parentItem = mockParentItem; - state.issuableType = issuableTypesMap.EPIC; + state.issuableType = TYPE_EPIC; }); afterEach(() => { diff --git a/ee/spec/frontend/related_items_tree/store/getters_spec.js b/ee/spec/frontend/related_items_tree/store/getters_spec.js index 450f17f43b867e7f3c4fe7c7d312b71fe0a54af7..6440082d82c42b4633f6233239b64c2b2d0729b0 100644 --- a/ee/spec/frontend/related_items_tree/store/getters_spec.js +++ b/ee/spec/frontend/related_items_tree/store/getters_spec.js @@ -1,7 +1,6 @@ import * as getters from 'ee/related_items_tree/store/getters'; import createDefaultState from 'ee/related_items_tree/store/state'; -import { TYPE_ISSUE } from '~/issues/constants'; -import { issuableTypesMap } from '~/related_issues/constants'; +import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants'; import { mockEpic1, mockEpic2 } from '../mock_data'; @@ -64,7 +63,7 @@ describe('RelatedItemsTree', () => { autoCompleteSources: 'foo', isEpic: true, }; - state.issuableType = issuableTypesMap.Epic; + state.issuableType = TYPE_EPIC; state.autoCompleteEpics = true; expect(getters.itemAutoCompleteSources(state, mockGetter)).toBe('foo'); @@ -127,10 +126,10 @@ describe('RelatedItemsTree', () => { describe('isEpic', () => { it.each` - issuableType | expectedValue - ${null} | ${false} - ${TYPE_ISSUE} | ${false} - ${issuableTypesMap.EPIC} | ${true} + issuableType | expectedValue + ${null} | ${false} + ${TYPE_ISSUE} | ${false} + ${TYPE_EPIC} | ${true} `( 'for issuableType = issuableType is $expectedValue', ({ issuableType, expectedValue }) => { diff --git a/spec/frontend/issuable/related_issues/components/add_issuable_form_spec.js b/spec/frontend/issuable/related_issues/components/add_issuable_form_spec.js index e1546f74a59d67683c3dfd9d9e5ded81bee7a5c1..72fcab63ba70bcafdb1d36797e7ccb98c61b9817 100644 --- a/spec/frontend/issuable/related_issues/components/add_issuable_form_spec.js +++ b/spec/frontend/issuable/related_issues/components/add_issuable_form_spec.js @@ -1,10 +1,10 @@ import { GlFormGroup } from '@gitlab/ui'; import { mount, shallowMount } from '@vue/test-utils'; import { nextTick } from 'vue'; -import { TYPE_ISSUE } from '~/issues/constants'; +import { TYPE_EPIC, TYPE_ISSUE } from '~/issues/constants'; import AddIssuableForm from '~/related_issues/components/add_issuable_form.vue'; import IssueToken from '~/related_issues/components/issue_token.vue'; -import { issuableTypesMap, linkedIssueTypesMap, PathIdSeparator } from '~/related_issues/constants'; +import { linkedIssueTypesMap, PathIdSeparator } from '~/related_issues/constants'; const issuable1 = { id: 200, @@ -143,7 +143,7 @@ describe('AddIssuableForm', () => { wrapper = shallowMount(AddIssuableForm, { propsData: { inputValue: '', - issuableType: issuableTypesMap.EPIC, + issuableType: TYPE_EPIC, pathIdSeparator, pendingReferences: [], }, @@ -157,9 +157,9 @@ describe('AddIssuableForm', () => { describe('categorized issuables', () => { it.each` - issuableType | pathIdSeparator | contextHeader | contextFooter - ${TYPE_ISSUE} | ${PathIdSeparator.Issue} | ${'The current issue'} | ${'the following issues'} - ${issuableTypesMap.EPIC} | ${PathIdSeparator.Epic} | ${'The current epic'} | ${'the following epics'} + issuableType | pathIdSeparator | contextHeader | contextFooter + ${TYPE_ISSUE} | ${PathIdSeparator.Issue} | ${'The current issue'} | ${'the following issues'} + ${TYPE_EPIC} | ${PathIdSeparator.Epic} | ${'The current epic'} | ${'the following epics'} `( 'show header text as "$contextHeader" and footer text as "$contextFooter" issuableType is set to $issuableType', ({ issuableType, contextHeader, contextFooter }) => {