Commit 78c720ae authored by Coung Ngo's avatar Coung Ngo

Add "Set Up Jira Integration" page

If Jira integration is not set up for Jira Import,
show a message to the user to direct them to the
Jira integration page
parent 73c43e5b
<script> <script>
import getJiraProjects from '../queries/getJiraProjects.query.graphql'; import getJiraProjects from '../queries/getJiraProjects.query.graphql';
import JiraImportSetup from './jira_import_setup.vue';
export default { export default {
name: 'JiraImportApp', name: 'JiraImportApp',
components: {
JiraImportSetup,
},
props: { props: {
isJiraConfigured: {
type: Boolean,
required: true,
},
projectPath: { projectPath: {
type: String, type: String,
required: true, required: true,
}, },
setupIllustration: {
type: String,
required: true,
},
}, },
apollo: { apollo: {
getJiraImports: { getJiraImports: {
...@@ -18,11 +30,17 @@ export default { ...@@ -18,11 +30,17 @@ export default {
}; };
}, },
update: data => data.project.jiraImports, update: data => data.project.jiraImports,
skip() {
return !this.isJiraConfigured;
},
}, },
}, },
}; };
</script> </script>
<template> <template>
<div></div> <div>
<jira-import-setup v-if="!isJiraConfigured" :illustration="setupIllustration" />
<div v-else></div>
</div>
</template> </template>
<script>
export default {
name: 'JiraImportSetup',
props: {
illustration: {
type: String,
required: true,
},
},
};
</script>
<template>
<div class="empty-state">
<div class="svg-content">
<img :src="illustration" :alt="__('Set up Jira Integration illustration')" />
</div>
<div class="text-content d-flex flex-column align-items-center">
<p>{{ __('You will first need to set up Jira Integration to use this feature.') }}</p>
<a class="btn btn-success" href="../services/jira/edit">
{{ __('Set up Jira Integration') }}
</a>
</div>
</div>
</template>
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 { parseBoolean } from '~/lib/utils/common_utils';
import App from './components/jira_import_app.vue'; import App from './components/jira_import_app.vue';
Vue.use(VueApollo); Vue.use(VueApollo);
...@@ -23,7 +24,9 @@ export default function mountJiraImportApp() { ...@@ -23,7 +24,9 @@ export default function mountJiraImportApp() {
render(createComponent) { render(createComponent) {
return createComponent(App, { return createComponent(App, {
props: { props: {
isJiraConfigured: parseBoolean(el.dataset.isJiraConfigured),
projectPath: el.dataset.projectPath, projectPath: el.dataset.projectPath,
setupIllustration: el.dataset.setupIllustration,
}, },
}); });
}, },
......
...@@ -7,6 +7,7 @@ module Projects ...@@ -7,6 +7,7 @@ module Projects
before_action :jira_integration_configured? before_action :jira_integration_configured?
def show def show
@is_jira_configured = @project.jira_service.present?
return if Feature.enabled?(:jira_issue_import_vue, @project) return if Feature.enabled?(:jira_issue_import_vue, @project)
unless @project.latest_jira_import&.in_progress? unless @project.latest_jira_import&.in_progress?
...@@ -45,6 +46,7 @@ module Projects ...@@ -45,6 +46,7 @@ module Projects
end end
def jira_integration_configured? def jira_integration_configured?
return if Feature.enabled?(:jira_issue_import_vue, @project)
return if @project.jira_service return if @project.jira_service
flash[:notice] = _("Configure the Jira integration first on your project's %{strong_start} Settings > Integrations > Jira%{strong_end} page." % flash[:notice] = _("Configure the Jira integration first on your project's %{strong_start} Settings > Integrations > Jira%{strong_end} page." %
......
- if Feature.enabled?(:jira_issue_import_vue, @project) - if Feature.enabled?(:jira_issue_import_vue, @project)
.js-jira-import-root{ data: { project_path: @project.full_path } } .js-jira-import-root{ data: { project_path: @project.full_path,
is_jira_configured: @is_jira_configured.to_s,
setup_illustration: image_path('illustrations/manual_action.svg') } }
- else - else
- title = _('Jira Issue Import') - title = _('Jira Issue Import')
- page_title title - page_title title
......
...@@ -18324,6 +18324,12 @@ msgstr "" ...@@ -18324,6 +18324,12 @@ msgstr ""
msgid "Set up CI/CD" msgid "Set up CI/CD"
msgstr "" msgstr ""
msgid "Set up Jira Integration"
msgstr ""
msgid "Set up Jira Integration illustration"
msgstr ""
msgid "Set up a %{type} Runner automatically" msgid "Set up a %{type} Runner automatically"
msgstr "" msgstr ""
...@@ -23583,6 +23589,9 @@ msgstr "" ...@@ -23583,6 +23589,9 @@ msgstr ""
msgid "You will be removed from existing projects/groups" msgid "You will be removed from existing projects/groups"
msgstr "" msgstr ""
msgid "You will first need to set up Jira Integration to use this feature."
msgstr ""
msgid "You will lose all changes you've made to this file. This action cannot be undone." msgid "You will lose all changes you've made to this file. This action cannot be undone."
msgstr "" msgstr ""
......
import { shallowMount } from '@vue/test-utils';
import JiraImportApp from '~/jira_import/components/jira_import_app.vue';
import JiraImportSetup from '~/jira_import/components/jira_import_setup.vue';
describe('JiraImportApp', () => {
let wrapper;
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('set up Jira integration page', () => {
it('is shown when Jira integration is not configured', () => {
wrapper = shallowMount(JiraImportApp, {
propsData: {
isJiraConfigured: false,
projectPath: 'gitlab-org/gitlab-test',
setupIllustration: 'illustration.svg',
},
});
expect(wrapper.find(JiraImportSetup).exists()).toBe(true);
});
it('is not shown when Jira integration is configured', () => {
wrapper = shallowMount(JiraImportApp, {
propsData: {
isJiraConfigured: true,
projectPath: 'gitlab-org/gitlab-test',
setupIllustration: 'illustration.svg',
},
});
expect(wrapper.find(JiraImportSetup).exists()).toBe(false);
});
});
});
import { shallowMount } from '@vue/test-utils';
import JiraImportSetup from '~/jira_import/components/jira_import_setup.vue';
describe('JiraImportSetup', () => {
let wrapper;
beforeEach(() => {
wrapper = shallowMount(JiraImportSetup, {
propsData: {
illustration: 'illustration.svg',
},
});
});
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
it('displays a message to the user', () => {
const message = 'You will first need to set up Jira Integration to use this feature.';
expect(wrapper.find('p').text()).toBe(message);
});
it('contains button to set up Jira integration', () => {
expect(wrapper.find('a').text()).toBe('Set up Jira Integration');
});
});
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