Commit d56e9bc5 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch 'cngo-organise-issues-new-code' into 'master'

Organise code into ~/issues/new

See merge request gitlab-org/gitlab!76348
parents 6c8c11ed ff379f1d
...@@ -4,8 +4,7 @@ import $ from 'jquery'; ...@@ -4,8 +4,7 @@ import $ from 'jquery';
import IssuableForm from 'ee_else_ce/issuable/issuable_form'; import IssuableForm from 'ee_else_ce/issuable/issuable_form';
import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation'; import ShortcutsNavigation from '~/behaviors/shortcuts/shortcuts_navigation';
import GLForm from '~/gl_form'; import GLForm from '~/gl_form';
import initSuggestions from '~/issues/suggestions'; import { initTitleSuggestions, initTypePopover } from '~/issues/new';
import initIssuableTypeSelector from '~/issues/type_selector';
import LabelsSelect from '~/labels/labels_select'; import LabelsSelect from '~/labels/labels_select';
import MilestoneSelect from '~/milestones/milestone_select'; import MilestoneSelect from '~/milestones/milestone_select';
import IssuableTemplateSelectors from '~/issuable/issuable_template_selectors'; import IssuableTemplateSelectors from '~/issuable/issuable_template_selectors';
...@@ -20,6 +19,6 @@ export default () => { ...@@ -20,6 +19,6 @@ export default () => {
warnTemplateOverride: true, warnTemplateOverride: true,
}); });
initSuggestions(); initTitleSuggestions();
initIssuableTypeSelector(); initTypePopover();
}; };
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
import { GlTooltipDirective, GlIcon } from '@gitlab/ui'; import { GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import query from '../queries/issues.query.graphql'; import query from '../queries/issues.query.graphql';
import Suggestion from './item.vue'; import TitleSuggestionsItem from './title_suggestions_item.vue';
export default { export default {
components: { components: {
Suggestion,
GlIcon, GlIcon,
TitleSuggestionsItem,
}, },
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
</script> </script>
<template> <template>
<div v-show="showSuggestions" class="form-group row issuable-suggestions"> <div v-show="showSuggestions" class="form-group row">
<div v-once class="col-form-label col-sm-2 pt-0"> <div v-once class="col-form-label col-sm-2 pt-0">
{{ __('Similar issues') }} {{ __('Similar issues') }}
<gl-icon <gl-icon
...@@ -86,7 +86,7 @@ export default { ...@@ -86,7 +86,7 @@ export default {
'gl-mb-3': index !== issues.length - 1, 'gl-mb-3': index !== issues.length - 1,
}" }"
> >
<suggestion :suggestion="suggestion" /> <title-suggestions-item :suggestion="suggestion" />
</li> </li>
</ul> </ul>
</div> </div>
......
...@@ -19,9 +19,9 @@ export default { ...@@ -19,9 +19,9 @@ export default {
<template> <template>
<span id="popovercontainer"> <span id="popovercontainer">
<gl-icon id="issuable-type-info" name="question-o" class="gl-ml-5 gl-text-gray-500" /> <gl-icon id="issue-type-info" name="question-o" class="gl-ml-5 gl-text-gray-500" />
<gl-popover <gl-popover
target="issuable-type-info" target="issue-type-info"
container="popovercontainer" container="popovercontainer"
:title="$options.i18n.issueTypes" :title="$options.i18n.issueTypes"
triggers="focus hover" triggers="focus hover"
......
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql'; import createDefaultClient from '~/lib/graphql';
import App from './components/app.vue'; import TitleSuggestions from './components/title_suggestions.vue';
import TypePopover from './components/type_popover.vue';
Vue.use(VueApollo); export function initTitleSuggestions() {
Vue.use(VueApollo);
export default function initIssuableSuggestions() {
const el = document.getElementById('js-suggestions'); const el = document.getElementById('js-suggestions');
const issueTitle = document.getElementById('issue_title'); const issueTitle = document.getElementById('issue_title');
const { projectPath } = el.dataset;
if (!el) {
return undefined;
}
const apolloProvider = new VueApollo({ const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(), defaultClient: createDefaultClient(),
}); });
...@@ -26,13 +31,26 @@ export default function initIssuableSuggestions() { ...@@ -26,13 +31,26 @@ export default function initIssuableSuggestions() {
this.search = issueTitle.value; this.search = issueTitle.value;
}); });
}, },
render(h) { render(createElement) {
return h(App, { return createElement(TitleSuggestions, {
props: { props: {
projectPath, projectPath: el.dataset.projectPath,
search: this.search, search: this.search,
}, },
}); });
}, },
}); });
} }
export function initTypePopover() {
const el = document.getElementById('js-type-popover');
if (!el) {
return undefined;
}
return new Vue({
el,
render: (createElement) => createElement(TypePopover),
});
}
import Vue from 'vue';
import InfoPopover from './components/info_popover.vue';
export default function initIssuableTypeSelector() {
const el = document.getElementById('js-type-popover');
return new Vue({
el,
components: {
InfoPopover,
},
render(h) {
return h(InfoPopover);
},
});
}
...@@ -869,10 +869,6 @@ ...@@ -869,10 +869,6 @@
} }
} }
.issuable-suggestions svg {
vertical-align: sub;
}
.suggestion-footer { .suggestion-footer {
font-size: 12px; font-size: 12px;
line-height: 15px; line-height: 15px;
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Issuable type info popover renders 1`] = ` exports[`Issue type info popover renders 1`] = `
<span <span
id="popovercontainer" id="popovercontainer"
> >
<gl-icon-stub <gl-icon-stub
class="gl-ml-5 gl-text-gray-500" class="gl-ml-5 gl-text-gray-500"
id="issuable-type-info" id="issue-type-info"
name="question-o" name="question-o"
size="16" size="16"
/> />
...@@ -14,7 +14,7 @@ exports[`Issuable type info popover renders 1`] = ` ...@@ -14,7 +14,7 @@ exports[`Issuable type info popover renders 1`] = `
<gl-popover-stub <gl-popover-stub
container="popovercontainer" container="popovercontainer"
cssclasses="" cssclasses=""
target="issuable-type-info" target="issue-type-info"
title="Issue types" title="Issue types"
triggers="focus hover" triggers="focus hover"
> >
......
import { GlTooltip, GlLink, GlIcon } from '@gitlab/ui'; import { GlTooltip, GlLink, GlIcon } from '@gitlab/ui';
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 Suggestion from '~/issues/suggestions/components/item.vue'; import TitleSuggestionsItem from '~/issues/new/components/title_suggestions_item.vue';
import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue'; import UserAvatarImage from '~/vue_shared/components/user_avatar/user_avatar_image.vue';
import mockData from '../mock_data'; import mockData from '../mock_data';
describe('Issuable suggestions suggestion component', () => { describe('Issue title suggestions item component', () => {
let wrapper; let wrapper;
function createComponent(suggestion = {}) { function createComponent(suggestion = {}) {
wrapper = shallowMount(Suggestion, { wrapper = shallowMount(TitleSuggestionsItem, {
propsData: { propsData: {
suggestion: { suggestion: {
...mockData(), ...mockData(),
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import App from '~/issues/suggestions/components/app.vue'; import TitleSuggestions from '~/issues/new/components/title_suggestions.vue';
import Suggestion from '~/issues/suggestions/components/item.vue'; import TitleSuggestionsItem from '~/issues/new/components/title_suggestions_item.vue';
describe('Issuable suggestions app component', () => { describe('Issue title suggestions component', () => {
let wrapper; let wrapper;
function createComponent(search = 'search') { function createComponent(search = 'search') {
wrapper = shallowMount(App, { wrapper = shallowMount(TitleSuggestions, {
propsData: { propsData: {
search, search,
projectPath: 'project', projectPath: 'project',
...@@ -77,7 +77,7 @@ describe('Issuable suggestions app component', () => { ...@@ -77,7 +77,7 @@ describe('Issuable suggestions app component', () => {
wrapper.setData(data); wrapper.setData(data);
return wrapper.vm.$nextTick(() => { return wrapper.vm.$nextTick(() => {
expect(wrapper.findAll(Suggestion).length).toBe(2); expect(wrapper.findAll(TitleSuggestionsItem).length).toBe(2);
}); });
}); });
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import InfoPopover from '~/issues/type_selector/components/info_popover.vue'; import TypePopover from '~/issues/new/components/type_popover.vue';
describe('Issuable type info popover', () => { describe('Issue type info popover', () => {
let wrapper; let wrapper;
function createComponent() { function createComponent() {
wrapper = shallowMount(InfoPopover); wrapper = shallowMount(TypePopover);
} }
afterEach(() => { afterEach(() => {
......
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