Commit 3cdd8109 authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '287868-expired-iterations-don-t-appear-in-the-sidebar' into 'master'

Fixed not showing iterations when it has past

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