Commit 1668fc85 authored by Donald Cook's avatar Donald Cook Committed by Natalia Tepluhina

Fixed not showing iterations when it has past

parent 5704c69e
...@@ -58,7 +58,7 @@ export default { ...@@ -58,7 +58,7 @@ export default {
}; };
}, },
update(data) { update(data) {
return data?.project?.issue?.iteration?.id; return data?.project?.issue?.iteration;
}, },
}, },
iterations: { iterations: {
...@@ -95,13 +95,13 @@ export default { ...@@ -95,13 +95,13 @@ export default {
return this.iterations.find(({ id }) => id === this.currentIteration); return this.iterations.find(({ id }) => id === this.currentIteration);
}, },
iterationTitle() { iterationTitle() {
return this.iteration?.title; return this.currentIteration?.title;
}, },
iterationUrl() { iterationUrl() {
return this.iteration?.webUrl; return this.currentIteration?.webUrl;
}, },
showNoIterationContent() { showNoIterationContent() {
return !this.editing && !this.currentIteration; return !this.editing && !this.currentIteration?.id;
}, },
}, },
mounted() { mounted() {
...@@ -121,7 +121,7 @@ export default { ...@@ -121,7 +121,7 @@ export default {
}); });
}, },
setIteration(iterationId) { setIteration(iterationId) {
if (iterationId === this.currentIteration) return; if (iterationId === this.currentIteration?.id) return;
this.editing = false; this.editing = false;
...@@ -137,8 +137,6 @@ export default { ...@@ -137,8 +137,6 @@ export default {
.then(({ data }) => { .then(({ data }) => {
if (data.issueSetIteration?.errors?.length) { if (data.issueSetIteration?.errors?.length) {
createFlash(data.issueSetIteration.errors[0]); createFlash(data.issueSetIteration.errors[0]);
} else {
this.currentIteration = data.issueSetIteration?.issue?.iteration?.id;
} }
}) })
.catch(() => { .catch(() => {
...@@ -155,7 +153,9 @@ export default { ...@@ -155,7 +153,9 @@ export default {
} }
}, },
isIterationChecked(iterationId = undefined) { isIterationChecked(iterationId = undefined) {
return iterationId === this.currentIteration || (!this.currentIteration && !iterationId); return (
iterationId === this.currentIteration?.id || (!this.currentIteration?.id && !iterationId)
);
}, },
}, },
}; };
......
query issueSprint($fullPath: ID!, $iid: String!) { query issueSprint($fullPath: ID!, $iid: String!) {
project(fullPath: $fullPath) { project(fullPath: $fullPath) {
issue(iid: $iid) { issue(iid: $iid) {
id
iteration { iteration {
id id
title title
webUrl
} }
} }
} }
......
...@@ -2,6 +2,7 @@ mutation updateIssueConfidential($projectPath: ID!, $iid: String!, $iterationId: ...@@ -2,6 +2,7 @@ mutation updateIssueConfidential($projectPath: ID!, $iid: String!, $iterationId:
issueSetIteration(input: { projectPath: $projectPath, iid: $iid, iterationId: $iterationId }) { issueSetIteration(input: { projectPath: $projectPath, iid: $iid, iterationId: $iterationId }) {
errors errors
issue { issue {
id
iteration { iteration {
title title
id id
......
...@@ -58,7 +58,10 @@ describe('IterationSelect', () => { ...@@ -58,7 +58,10 @@ describe('IterationSelect', () => {
describe('when not editing', () => { describe('when not editing', () => {
it('shows the current iteration', () => { it('shows the current iteration', () => {
createComponent({ createComponent({
data: { iterations: [{ id: 'id', title: 'title' }], currentIteration: 'id' }, data: {
iterations: [{ id: 'id', title: 'title' }],
currentIteration: { id: 'id', title: 'title' },
},
}); });
expect(wrapper.find('[data-testid="select-iteration"]').text()).toBe('title'); expect(wrapper.find('[data-testid="select-iteration"]').text()).toBe('title');
...@@ -68,7 +71,7 @@ describe('IterationSelect', () => { ...@@ -68,7 +71,7 @@ describe('IterationSelect', () => {
createComponent({ createComponent({
data: { data: {
iterations: [{ id: 'id', title: 'title', webUrl: 'webUrl' }], iterations: [{ id: 'id', title: 'title', webUrl: 'webUrl' }],
currentIteration: 'id', currentIteration: { id: 'id', title: 'title', webUrl: 'webUrl' },
}, },
}); });
...@@ -132,7 +135,9 @@ describe('IterationSelect', () => { ...@@ -132,7 +135,9 @@ describe('IterationSelect', () => {
const title = 'title'; const title = 'title';
beforeEach(() => { beforeEach(() => {
createComponent({ data: { iterations: [{ id, title }], currentIteration: id } }); createComponent({
data: { iterations: [{ id, title }], currentIteration: { id, title } },
});
}); });
it('renders title $title', () => { it('renders title $title', () => {
...@@ -174,7 +179,10 @@ describe('IterationSelect', () => { ...@@ -174,7 +179,10 @@ describe('IterationSelect', () => {
describe('when currentIteration is equal to iteration id', () => { describe('when currentIteration is equal to iteration id', () => {
it('does not call setIssueIteration mutation', () => { it('does not call setIssueIteration mutation', () => {
createComponent({ createComponent({
data: { iterations: [{ id: 'id', title: 'title' }], currentIteration: 'id' }, data: {
iterations: [{ id: 'id', title: 'title' }],
currentIteration: { id: 'id', title: 'title' },
},
}); });
wrapper wrapper
...@@ -340,11 +348,11 @@ describe('IterationSelect', () => { ...@@ -340,11 +348,11 @@ describe('IterationSelect', () => {
it.each([ it.each([
[{}, undefined], [{}, undefined],
[{ project: { issue: {} } }, undefined], [{ project: { issue: {} } }, undefined],
[{ project: { issue: { iteration: {} } } }, undefined], [{ project: { issue: { iteration: {} } } }, {}],
])('when %j as an argument it returns %j', (data, value) => { ])('when %j as an argument it returns %j', (data, value) => {
const { update } = wrapper.vm.$options.apollo.currentIteration; const { update } = wrapper.vm.$options.apollo.currentIteration;
expect(update(data)).toBe(value); expect(update(data)).toEqual(value);
}); });
}); });
...@@ -354,7 +362,9 @@ describe('IterationSelect', () => { ...@@ -354,7 +362,9 @@ describe('IterationSelect', () => {
const { update } = wrapper.vm.$options.apollo.currentIteration; const { update } = wrapper.vm.$options.apollo.currentIteration;
expect(update({ project: { issue: { iteration: { id: '123' } } } })).toEqual('123'); expect(update({ project: { issue: { iteration: { id: '123' } } } })).toEqual({
id: '123',
});
}); });
}); });
}); });
......
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