Commit 08a41adf authored by Fatih Acet's avatar Fatih Acet

Merge branch 'winh-resuse-PathIdSeparator' into 'master'

Reuse PathIdSeparator constants

See merge request gitlab-org/gitlab!19299
parents 01ba510d bb8eae40
<script> <script>
import { mapState, mapGetters } from 'vuex'; import { mapState, mapGetters } from 'vuex';
import { PathIdSeparator } from 'ee/related_issues/constants';
import IssuableBody from '~/issue_show/components/app.vue'; import IssuableBody from '~/issue_show/components/app.vue';
import IssuableSidebar from '~/issuable_sidebar/components/sidebar_app.vue'; import IssuableSidebar from '~/issuable_sidebar/components/sidebar_app.vue';
import RelatedItems from 'ee/related_issues/components/related_issues_root.vue'; import RelatedItems from 'ee/related_issues/components/related_issues_root.vue';
...@@ -8,7 +10,7 @@ import RelatedItems from 'ee/related_issues/components/related_issues_root.vue'; ...@@ -8,7 +10,7 @@ import RelatedItems from 'ee/related_issues/components/related_issues_root.vue';
import EpicSidebar from './epic_sidebar.vue'; import EpicSidebar from './epic_sidebar.vue';
export default { export default {
epicsPathIdSeparator: '&', PathIdSeparator,
components: { components: {
IssuableBody, IssuableBody,
IssuableSidebar, IssuableSidebar,
...@@ -78,7 +80,7 @@ export default { ...@@ -78,7 +80,7 @@ export default {
:can-admin="canAdmin" :can-admin="canAdmin"
:can-reorder="canAdmin" :can-reorder="canAdmin"
:allow-auto-complete="false" :allow-auto-complete="false"
:path-id-separator="$options.epicsPathIdSeparator" :path-id-separator="$options.PathIdSeparator.Epic"
:title="__('Epics')" :title="__('Epics')"
issuable-type="epic" issuable-type="epic"
css-class="js-related-epics-block" css-class="js-related-epics-block"
......
...@@ -34,6 +34,7 @@ import { ...@@ -34,6 +34,7 @@ import {
pathIndeterminateErrorMap, pathIndeterminateErrorMap,
addRelatedIssueErrorMap, addRelatedIssueErrorMap,
issuableTypesMap, issuableTypesMap,
PathIdSeparator,
} from '../constants'; } from '../constants';
export default { export default {
...@@ -79,7 +80,7 @@ export default { ...@@ -79,7 +80,7 @@ export default {
pathIdSeparator: { pathIdSeparator: {
type: String, type: String,
required: false, required: false,
default: '#', default: PathIdSeparator.Issue,
}, },
cssClass: { cssClass: {
type: String, type: String,
......
...@@ -59,3 +59,8 @@ export const issuableQaClassMap = { ...@@ -59,3 +59,8 @@ export const issuableQaClassMap = {
[issuableTypesMap.ISSUE]: 'qa-add-issues-button', [issuableTypesMap.ISSUE]: 'qa-add-issues-button',
[issuableTypesMap.EPIC]: 'qa-add-epics-button', [issuableTypesMap.EPIC]: 'qa-add-epics-button',
}; };
export const PathIdSeparator = {
Epic: '&',
Issue: '#',
};
...@@ -14,10 +14,9 @@ import TreeItemRemoveModal from './tree_item_remove_modal.vue'; ...@@ -14,10 +14,9 @@ import TreeItemRemoveModal from './tree_item_remove_modal.vue';
import RelatedItemsTreeHeader from './related_items_tree_header.vue'; import RelatedItemsTreeHeader from './related_items_tree_header.vue';
import RelatedItemsTreeBody from './related_items_tree_body.vue'; import RelatedItemsTreeBody from './related_items_tree_body.vue';
import { PathIdSeparator, OVERFLOW_AFTER } from '../constants'; import { OVERFLOW_AFTER } from '../constants';
export default { export default {
PathIdSeparator,
OVERFLOW_AFTER, OVERFLOW_AFTER,
components: { components: {
GlLoadingIcon, GlLoadingIcon,
......
...@@ -12,11 +12,6 @@ export const ChildState = { ...@@ -12,11 +12,6 @@ export const ChildState = {
Closed: 'closed', Closed: 'closed',
}; };
export const PathIdSeparator = {
Epic: '&',
Issue: '#',
};
export const idProp = { export const idProp = {
Epic: 'id', Epic: 'id',
Issue: 'epicIssueId', Issue: 'epicIssueId',
......
import { issuableTypesMap } from 'ee/related_issues/constants'; import { issuableTypesMap, PathIdSeparator } from 'ee/related_issues/constants';
import { ChildType, PathIdSeparator } from '../constants'; import { ChildType } from '../constants';
export const autoCompleteSources = () => gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources; export const autoCompleteSources = () => gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources;
......
import createGqClient from '~/lib/graphql'; import createGqClient from '~/lib/graphql';
import { ChildType, PathIdSeparator } from '../constants'; import { PathIdSeparator } from 'ee/related_issues/constants';
import { ChildType } from '../constants';
export const gqClient = createGqClient(); export const gqClient = createGqClient();
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { issuableTypesMap } from 'ee/related_issues/constants'; import { issuableTypesMap, PathIdSeparator } from 'ee/related_issues/constants';
import RelatedIssuableInput from 'ee/related_issues/components/related_issuable_input.vue'; import RelatedIssuableInput from 'ee/related_issues/components/related_issuable_input.vue';
jest.mock('ee_else_ce/gfm_auto_complete', () => ({ jest.mock('ee_else_ce/gfm_auto_complete', () => ({
...@@ -20,7 +20,7 @@ describe('RelatedIssuableInput', () => { ...@@ -20,7 +20,7 @@ describe('RelatedIssuableInput', () => {
propsData = { propsData = {
inputValue: '', inputValue: '',
references: [], references: [],
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
issuableType: issuableTypesMap.issue, issuableType: issuableTypesMap.issue,
autoCompleteSources: { autoCompleteSources: {
issues: `${TEST_HOST}/h5bp/html5-boilerplate/-/autocomplete_sources/issues`, issues: `${TEST_HOST}/h5bp/html5-boilerplate/-/autocomplete_sources/issues`,
......
import * as epicUtils from 'ee/related_items_tree/utils/epic_utils'; import * as epicUtils from 'ee/related_items_tree/utils/epic_utils';
import { ChildType, PathIdSeparator } from 'ee/related_items_tree/constants'; import { PathIdSeparator } from 'ee/related_issues/constants';
import { ChildType } from 'ee/related_items_tree/constants';
import { import {
mockQueryResponse, mockQueryResponse,
......
import Vue from 'vue'; import Vue from 'vue';
import { PathIdSeparator } from 'ee/related_issues/constants';
import addIssuableForm from 'ee/related_issues/components/add_issuable_form.vue'; import addIssuableForm from 'ee/related_issues/components/add_issuable_form.vue';
const issuable1 = { const issuable1 = {
...@@ -19,7 +20,7 @@ const issuable2 = { ...@@ -19,7 +20,7 @@ const issuable2 = {
state: 'opened', state: 'opened',
}; };
const pathIdSeparator = '#'; const pathIdSeparator = PathIdSeparator.Issue;
describe('AddIssuableForm', () => { describe('AddIssuableForm', () => {
let AddIssuableForm; let AddIssuableForm;
......
import Vue from 'vue'; import Vue from 'vue';
import { PathIdSeparator } from 'ee/related_issues/constants';
import issueToken from 'ee/related_issues/components/issue_token.vue'; import issueToken from 'ee/related_issues/components/issue_token.vue';
describe('IssueToken', () => { describe('IssueToken', () => {
const idKey = 200; const idKey = 200;
const displayReference = 'foo/bar#123'; const displayReference = 'foo/bar#123';
const title = 'some title'; const title = 'some title';
const pathIdSeparator = '#'; const pathIdSeparator = PathIdSeparator.Issue;
const eventNamespace = 'pendingIssuable'; const eventNamespace = 'pendingIssuable';
let IssueToken; let IssueToken;
let vm; let vm;
......
...@@ -7,6 +7,7 @@ import { ...@@ -7,6 +7,7 @@ import {
issuable4, issuable4,
issuable5, issuable5,
} from 'spec/vue_shared/components/issue/related_issuable_mock_data'; } from 'spec/vue_shared/components/issue/related_issuable_mock_data';
import { PathIdSeparator } from 'ee/related_issues/constants';
describe('RelatedIssuesBlock', () => { describe('RelatedIssuesBlock', () => {
let RelatedIssuesBlock; let RelatedIssuesBlock;
...@@ -26,7 +27,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -26,7 +27,7 @@ describe('RelatedIssuesBlock', () => {
beforeEach(() => { beforeEach(() => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
issuableType: 'issue', issuableType: 'issue',
}, },
}).$mount(); }).$mount();
...@@ -49,7 +50,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -49,7 +50,7 @@ describe('RelatedIssuesBlock', () => {
beforeEach(() => { beforeEach(() => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
isFetching: true, isFetching: true,
issuableType: 'issue', issuableType: 'issue',
}, },
...@@ -69,7 +70,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -69,7 +70,7 @@ describe('RelatedIssuesBlock', () => {
beforeEach(() => { beforeEach(() => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
canAdmin: true, canAdmin: true,
issuableType: 'issue', issuableType: 'issue',
}, },
...@@ -85,7 +86,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -85,7 +86,7 @@ describe('RelatedIssuesBlock', () => {
beforeEach(() => { beforeEach(() => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
isFormVisible: true, isFormVisible: true,
issuableType: 'issue', issuableType: 'issue',
}, },
...@@ -101,7 +102,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -101,7 +102,7 @@ describe('RelatedIssuesBlock', () => {
beforeEach(() => { beforeEach(() => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
relatedIssues: [issuable1, issuable2], relatedIssues: [issuable1, issuable2],
issuableType: 'issue', issuableType: 'issue',
}, },
...@@ -117,7 +118,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -117,7 +118,7 @@ describe('RelatedIssuesBlock', () => {
beforeEach(() => { beforeEach(() => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
relatedIssues: [issuable1, issuable2, issuable3, issuable4, issuable5], relatedIssues: [issuable1, issuable2, issuable3, issuable4, issuable5],
issuableType: 'issue', issuableType: 'issue',
}, },
...@@ -167,7 +168,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -167,7 +168,7 @@ describe('RelatedIssuesBlock', () => {
it(`issuableType=${issuableType} is passed`, () => { it(`issuableType=${issuableType} is passed`, () => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
issuableType, issuableType,
}, },
}).$mount(); }).$mount();
...@@ -183,7 +184,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -183,7 +184,7 @@ describe('RelatedIssuesBlock', () => {
it('issuableType is epic', () => { it('issuableType is epic', () => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
issuableType: 'issue', issuableType: 'issue',
}, },
}).$mount(); }).$mount();
...@@ -196,7 +197,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -196,7 +197,7 @@ describe('RelatedIssuesBlock', () => {
it('issuableType is issue', () => { it('issuableType is issue', () => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
issuableType: 'epic', issuableType: 'epic',
}, },
}).$mount(); }).$mount();
...@@ -217,7 +218,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -217,7 +218,7 @@ describe('RelatedIssuesBlock', () => {
it('issuableType is epic', () => { it('issuableType is epic', () => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
issuableType: 'epic', issuableType: 'epic',
relatedIssues, relatedIssues,
}, },
...@@ -233,7 +234,7 @@ describe('RelatedIssuesBlock', () => { ...@@ -233,7 +234,7 @@ describe('RelatedIssuesBlock', () => {
it('issuableType is issue', () => { it('issuableType is issue', () => {
vm = new RelatedIssuesBlock({ vm = new RelatedIssuesBlock({
propsData: { propsData: {
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
issuableType: 'issue', issuableType: 'issue',
relatedIssues, relatedIssues,
}, },
......
...@@ -13,12 +13,13 @@ import StateTooltip from 'ee/related_items_tree/components/state_tooltip.vue'; ...@@ -13,12 +13,13 @@ import StateTooltip from 'ee/related_items_tree/components/state_tooltip.vue';
import createDefaultStore from 'ee/related_items_tree/store'; import createDefaultStore from 'ee/related_items_tree/store';
import * as epicUtils from 'ee/related_items_tree/utils/epic_utils'; import * as epicUtils from 'ee/related_items_tree/utils/epic_utils';
import { ChildType, ChildState } from 'ee/related_items_tree/constants'; import { ChildType, ChildState } from 'ee/related_items_tree/constants';
import { PathIdSeparator } from 'ee/related_issues/constants';
import { mockParentItem, mockInitialConfig, mockQueryResponse, mockIssue1 } from '../mock_data'; import { mockParentItem, mockInitialConfig, mockQueryResponse, mockIssue1 } from '../mock_data';
const mockItem = Object.assign({}, mockIssue1, { const mockItem = Object.assign({}, mockIssue1, {
type: ChildType.Issue, type: ChildType.Issue,
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
assignees: epicUtils.extractIssueAssignees(mockIssue1.assignees), assignees: epicUtils.extractIssueAssignees(mockIssue1.assignees),
}); });
......
...@@ -6,12 +6,13 @@ import TreeItemRemoveModal from 'ee/related_items_tree/components/tree_item_remo ...@@ -6,12 +6,13 @@ import TreeItemRemoveModal from 'ee/related_items_tree/components/tree_item_remo
import createDefaultStore from 'ee/related_items_tree/store'; import createDefaultStore from 'ee/related_items_tree/store';
import * as epicUtils from 'ee/related_items_tree/utils/epic_utils'; import * as epicUtils from 'ee/related_items_tree/utils/epic_utils';
import { ChildType } from 'ee/related_items_tree/constants'; import { ChildType } from 'ee/related_items_tree/constants';
import { PathIdSeparator } from 'ee/related_issues/constants';
import { mockParentItem, mockQueryResponse, mockIssue1 } from '../mock_data'; import { mockParentItem, mockQueryResponse, mockIssue1 } from '../mock_data';
const mockItem = Object.assign({}, mockIssue1, { const mockItem = Object.assign({}, mockIssue1, {
type: ChildType.Issue, type: ChildType.Issue,
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
assignees: epicUtils.extractIssueAssignees(mockIssue1.assignees), assignees: epicUtils.extractIssueAssignees(mockIssue1.assignees),
}); });
......
...@@ -10,12 +10,13 @@ import TreeRoot from 'ee/related_items_tree/components/tree_root.vue'; ...@@ -10,12 +10,13 @@ import TreeRoot from 'ee/related_items_tree/components/tree_root.vue';
import createDefaultStore from 'ee/related_items_tree/store'; import createDefaultStore from 'ee/related_items_tree/store';
import * as epicUtils from 'ee/related_items_tree/utils/epic_utils'; import * as epicUtils from 'ee/related_items_tree/utils/epic_utils';
import { ChildType } from 'ee/related_items_tree/constants'; import { ChildType } from 'ee/related_items_tree/constants';
import { PathIdSeparator } from 'ee/related_issues/constants';
import { mockParentItem, mockQueryResponse, mockEpic1 } from '../mock_data'; import { mockParentItem, mockQueryResponse, mockEpic1 } from '../mock_data';
const mockItem = Object.assign({}, mockEpic1, { const mockItem = Object.assign({}, mockEpic1, {
type: ChildType.Epic, type: ChildType.Epic,
pathIdSeparator: '&', pathIdSeparator: PathIdSeparator.Epic,
}); });
const createComponent = (parentItem = mockParentItem, item = mockItem) => { const createComponent = (parentItem = mockParentItem, item = mockItem) => {
......
...@@ -5,8 +5,8 @@ import * as actions from 'ee/related_items_tree/store/actions'; ...@@ -5,8 +5,8 @@ import * as actions from 'ee/related_items_tree/store/actions';
import * as types from 'ee/related_items_tree/store/mutation_types'; import * as types from 'ee/related_items_tree/store/mutation_types';
import * as epicUtils from 'ee/related_items_tree/utils/epic_utils'; import * as epicUtils from 'ee/related_items_tree/utils/epic_utils';
import { ChildType, ChildState, PathIdSeparator } from 'ee/related_items_tree/constants'; import { ChildType, ChildState } from 'ee/related_items_tree/constants';
import { issuableTypesMap } from 'ee/related_issues/constants'; import { issuableTypesMap, PathIdSeparator } from 'ee/related_issues/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import testAction from 'spec/helpers/vuex_action_helper'; import testAction from 'spec/helpers/vuex_action_helper';
...@@ -970,7 +970,7 @@ describe('RelatedItemTree', () => { ...@@ -970,7 +970,7 @@ describe('RelatedItemTree', () => {
const createdEpic = Object.assign({}, mockEpics[0], { const createdEpic = Object.assign({}, mockEpics[0], {
id: `gid://gitlab/Epic/${mockEpics[0].id}`, id: `gid://gitlab/Epic/${mockEpics[0].id}`,
reference: `${mockEpics[0].group.fullPath}${mockEpics[0].reference}`, reference: `${mockEpics[0].group.fullPath}${mockEpics[0].reference}`,
pathIdSeparator: '&', pathIdSeparator: PathIdSeparator.Epic,
}); });
state.epicsBeginAtIndex = 0; state.epicsBeginAtIndex = 0;
state.parentItem = { state.parentItem = {
......
import Vue from 'vue'; import Vue from 'vue';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
import { mount, createLocalVue } from '@vue/test-utils'; import { mount, createLocalVue } from '@vue/test-utils';
import { PathIdSeparator } from 'ee/related_issues/constants';
import RelatedIssuableItem from '~/vue_shared/components/issue/related_issuable_item.vue'; import RelatedIssuableItem from '~/vue_shared/components/issue/related_issuable_item.vue';
import { import {
defaultAssignees, defaultAssignees,
...@@ -12,7 +13,7 @@ describe('RelatedIssuableItem', () => { ...@@ -12,7 +13,7 @@ describe('RelatedIssuableItem', () => {
const props = { const props = {
idKey: 1, idKey: 1,
displayReference: 'gitlab-org/gitlab-test#1', displayReference: 'gitlab-org/gitlab-test#1',
pathIdSeparator: '#', pathIdSeparator: PathIdSeparator.Issue,
path: `${gl.TEST_HOST}/path`, path: `${gl.TEST_HOST}/path`,
title: 'title', title: 'title',
confidential: true, confidential: true,
......
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