Commit 414e0631 authored by Mark Florian's avatar Mark Florian

Merge branch '222763-frontend-use-scopedpath-for-iterations' into 'master'

Use scopedPath for the iterations list

See merge request gitlab-org/gitlab!39862
parents e947074b 959bb18f
...@@ -153,7 +153,7 @@ export default { ...@@ -153,7 +153,7 @@ export default {
</gl-alert> </gl-alert>
</div> </div>
<div v-else> <div v-else>
<iterations-list :iterations="iterations" /> <iterations-list :iterations="iterations" :namespace-type="namespaceType" />
<gl-pagination <gl-pagination
v-if="prevPage || nextPage" v-if="prevPage || nextPage"
:value="pagination.currentPage" :value="pagination.currentPage"
......
<script> <script>
import { GlLink } from '@gitlab/ui'; import { GlLink } from '@gitlab/ui';
import { Namespace } from 'ee/iterations/constants';
import { formatDate } from '~/lib/utils/datetime_utility'; import { formatDate } from '~/lib/utils/datetime_utility';
export default { export default {
...@@ -12,6 +13,12 @@ export default { ...@@ -12,6 +13,12 @@ export default {
required: false, required: false,
default: () => [], default: () => [],
}, },
namespaceType: {
type: String,
required: false,
default: Namespace.Group,
validator: value => Object.values(Namespace).includes(value),
},
}, },
methods: { methods: {
formatDate(date) { formatDate(date) {
...@@ -26,9 +33,9 @@ export default { ...@@ -26,9 +33,9 @@ export default {
<ul v-if="iterations.length > 0" class="content-list"> <ul v-if="iterations.length > 0" class="content-list">
<li v-for="iteration in iterations" :key="iteration.id" class="milestone"> <li v-for="iteration in iterations" :key="iteration.id" class="milestone">
<div class="gl-mb-3"> <div class="gl-mb-3">
<gl-link :href="iteration.webPath" <gl-link :href="iteration.scopedPath || iteration.webPath">
><strong>{{ iteration.title }}</strong></gl-link <strong>{{ iteration.title }}</strong>
> </gl-link>
</div> </div>
<div class="text-secondary gl-mb-3"> <div class="text-secondary gl-mb-3">
{{ formatDate(iteration.startDate) }}{{ formatDate(iteration.dueDate) }} {{ formatDate(iteration.startDate) }}{{ formatDate(iteration.dueDate) }}
......
fragment Iteration on Iteration { fragment Iteration on Iteration {
dueDate dueDate
id id
scopedPath
startDate startDate
state state
title title
......
import { GlLink } from '@gitlab/ui';
import IterationsList from 'ee/iterations/components/iterations_list.vue'; import IterationsList from 'ee/iterations/components/iterations_list.vue';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import timezoneMock from 'timezone-mock'; import timezoneMock from 'timezone-mock';
...@@ -5,6 +6,8 @@ import timezoneMock from 'timezone-mock'; ...@@ -5,6 +6,8 @@ import timezoneMock from 'timezone-mock';
describe('Iterations list', () => { describe('Iterations list', () => {
let wrapper; let wrapper;
const findGlLink = () => wrapper.find(GlLink);
const mountComponent = (propsData = { iterations: [] }) => { const mountComponent = (propsData = { iterations: [] }) => {
wrapper = shallowMount(IterationsList, { wrapper = shallowMount(IterationsList, {
propsData, propsData,
...@@ -29,6 +32,8 @@ describe('Iterations list', () => { ...@@ -29,6 +32,8 @@ describe('Iterations list', () => {
title: 'Iteration #1', title: 'Iteration #1',
startDate: '2020-05-27', startDate: '2020-05-27',
dueDate: '2020-06-04', dueDate: '2020-06-04',
scopedPath: null,
webPath: '/groups/gitlab-org/-/iterations/1',
}; };
it('shows iteration', () => { it('shows iteration', () => {
...@@ -50,5 +55,32 @@ describe('Iterations list', () => { ...@@ -50,5 +55,32 @@ describe('Iterations list', () => {
expect(wrapper.html()).toHaveText('May 27, 2020'); expect(wrapper.html()).toHaveText('May 27, 2020');
expect(wrapper.html()).toHaveText('Jun 4, 2020'); expect(wrapper.html()).toHaveText('Jun 4, 2020');
}); });
describe('when within group', () => {
it('links to iteration report within group', () => {
mountComponent({
iterations: [iteration],
});
expect(findGlLink().attributes('href')).toBe(iteration.webPath);
});
});
describe('when within project', () => {
it('links to iteration report within project', () => {
const scopedPath = '/gitlab-org/gitlab-test/-/iterations/inherited/1';
mountComponent({
iterations: [
{
...iteration,
scopedPath,
},
],
});
expect(findGlLink().attributes('href')).toBe(scopedPath);
});
});
}); });
}); });
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