Commit b0cf4817 authored by Axel García's avatar Axel García

Improve epic form bundle

This improves both the data source and the data
selection, removing helper functions on the
component
parent 2b98addb
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
GlFormGroup, GlFormGroup,
GlFormInput, GlFormInput,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { visitUrl, joinPaths } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import LabelsSelectVue from '~/vue_shared/components/sidebar/labels_select_vue/labels_select_root.vue'; import LabelsSelectVue from '~/vue_shared/components/sidebar/labels_select_vue/labels_select_root.vue';
...@@ -34,6 +34,14 @@ export default { ...@@ -34,6 +34,14 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
labelsFetchPath: {
type: String,
required: true,
},
labelsManagePath: {
type: String,
required: true,
},
markdownPreviewPath: { markdownPreviewPath: {
type: String, type: String,
required: false, required: false,
...@@ -62,9 +70,6 @@ export default { ...@@ -62,9 +70,6 @@ export default {
}, },
}, },
methods: { methods: {
groupUrl(path) {
return joinPaths('/groups', this.groupPath, '/-/', path);
},
save() { save() {
this.loading = true; this.loading = true;
...@@ -180,11 +185,9 @@ export default { ...@@ -180,11 +185,9 @@ export default {
:allow-multiselect="true" :allow-multiselect="true"
:allow-scoped-labels="false" :allow-scoped-labels="false"
:selected-labels="labels" :selected-labels="labels"
:labels-fetch-path=" :labels-fetch-path="labelsFetchPath"
groupUrl('labels.json?include_ancestor_groups=true&only_group_labels=true') :labels-manage-path="labelsManagePath"
" :labels-filter-base-path="groupEpicsPath"
:labels-manage-path="groupUrl('labels')"
:labels-filter-base-path="groupUrl('epics')"
:labels-list-title="__('Select label')" :labels-list-title="__('Select label')"
:dropdown-button-text="__('Choose labels')" :dropdown-button-text="__('Choose labels')"
variant="embedded" variant="embedded"
......
...@@ -16,16 +16,27 @@ export function initEpicForm() { ...@@ -16,16 +16,27 @@ export function initEpicForm() {
return null; return null;
} }
const {
groupPath,
groupEpicsPath,
labelsFetchPath,
labelsManagePath,
markdownDocsPath,
markdownPreviewPath,
} = el.dataset;
return new Vue({ return new Vue({
el, el,
apolloProvider, apolloProvider,
render(createElement) { render(createElement) {
return createElement(EpicForm, { return createElement(EpicForm, {
props: { props: {
groupPath: el.dataset.groupFullPath, groupPath,
groupEpicsPath: el.dataset.groupEpicsPath, groupEpicsPath,
markdownPreviewPath: el.dataset.markdownPreviewPath, labelsFetchPath,
markdownDocsPath: el.dataset.markdownDocsPath, labelsManagePath,
markdownDocsPath,
markdownPreviewPath,
}, },
}); });
}, },
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
- breadcrumb_title _("New") - breadcrumb_title _("New")
- page_title _("New epic") - page_title _("New epic")
.js-epic-new{ data: { group_full_path: @group.full_path, group_epics_path: group_epics_path(@group), markdown_preview_path: preview_markdown_path(@group), markdown_docs_path: help_page_path('user/markdown') } } .js-epic-new{ data: { group_path: @group.full_path, group_epics_path: group_epics_path(@group), labels_fetch_path: group_labels_path(@group, format: :json, only_group_labels: true, include_ancestor_groups: true), labels_manage_path: group_labels_path(@group), markdown_preview_path: preview_markdown_path(@group), markdown_docs_path: help_page_path('user/markdown') } }
...@@ -20,6 +20,8 @@ describe('ee/epic/components/epic_form.vue', () => { ...@@ -20,6 +20,8 @@ describe('ee/epic/components/epic_form.vue', () => {
propsData: { propsData: {
groupPath: TEST_GROUP_PATH, groupPath: TEST_GROUP_PATH,
groupEpicsPath: TEST_HOST, groupEpicsPath: TEST_HOST,
labelsFetchPath: TEST_HOST,
labelsManagePath: TEST_HOST,
}, },
stubs: { stubs: {
ApolloMutation, ApolloMutation,
......
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