Commit 529eede8 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch 'issue-task-status-fix' into 'master'

Stop showing task status if no tasks are present

Closes #33880

See merge request !12303
parents bf57a7e8 5dc253f1
...@@ -51,6 +51,11 @@ export default { ...@@ -51,6 +51,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
initialTaskStatus: {
type: String,
required: false,
default: '',
},
updatedAt: { updatedAt: {
type: String, type: String,
required: false, required: false,
...@@ -105,6 +110,7 @@ export default { ...@@ -105,6 +110,7 @@ export default {
updatedAt: this.updatedAt, updatedAt: this.updatedAt,
updatedByName: this.updatedByName, updatedByName: this.updatedByName,
updatedByPath: this.updatedByPath, updatedByPath: this.updatedByPath,
taskStatus: this.initialTaskStatus,
}); });
return { return {
......
...@@ -37,18 +37,7 @@ ...@@ -37,18 +37,7 @@
}); });
}, },
taskStatus() { taskStatus() {
const taskRegexMatches = this.taskStatus.match(/(\d+) of (\d+)/); this.updateTaskStatusText();
const $issuableHeader = $('.issuable-meta');
const $tasks = $('#task_status', $issuableHeader);
const $tasksShort = $('#task_status_short', $issuableHeader);
if (taskRegexMatches) {
$tasks.text(this.taskStatus);
$tasksShort.text(`${taskRegexMatches[1]}/${taskRegexMatches[2]} task${taskRegexMatches[2] > 1 ? 's' : ''}`);
} else {
$tasks.text('');
$tasksShort.text('');
}
}, },
}, },
methods: { methods: {
...@@ -64,9 +53,24 @@ ...@@ -64,9 +53,24 @@
}); });
} }
}, },
updateTaskStatusText() {
const taskRegexMatches = this.taskStatus.match(/(\d+) of ((?!0)\d+)/);
const $issuableHeader = $('.issuable-meta');
const $tasks = $('#task_status', $issuableHeader);
const $tasksShort = $('#task_status_short', $issuableHeader);
if (taskRegexMatches) {
$tasks.text(this.taskStatus);
$tasksShort.text(`${taskRegexMatches[1]}/${taskRegexMatches[2]} task${taskRegexMatches[2] > 1 ? 's' : ''}`);
} else {
$tasks.text('');
$tasksShort.text('');
}
},
}, },
mounted() { mounted() {
this.renderGFM(); this.renderGFM();
this.updateTaskStatusText();
}, },
}; };
</script> </script>
......
...@@ -45,6 +45,7 @@ document.addEventListener('DOMContentLoaded', () => { ...@@ -45,6 +45,7 @@ document.addEventListener('DOMContentLoaded', () => {
updatedAt: this.updatedAt, updatedAt: this.updatedAt,
updatedByName: this.updatedByName, updatedByName: this.updatedByName,
updatedByPath: this.updatedByPath, updatedByPath: this.updatedByPath,
initialTaskStatus: this.initialTaskStatus,
}, },
}); });
}, },
......
export default class Store { export default class Store {
constructor({ constructor(initialState) {
titleHtml, this.state = initialState;
titleText,
descriptionHtml,
descriptionText,
updatedAt,
updatedByName,
updatedByPath,
}) {
this.state = {
titleHtml,
titleText,
descriptionHtml,
descriptionText,
taskStatus: '',
updatedAt,
updatedByName,
updatedByPath,
};
this.formState = { this.formState = {
title: '', title: '',
confidential: false, confidential: false,
......
...@@ -138,8 +138,8 @@ module IssuablesHelper ...@@ -138,8 +138,8 @@ module IssuablesHelper
end end
output << "&ensp;".html_safe output << "&ensp;".html_safe
output << content_tag(:span, issuable.task_status, id: "task_status", class: "hidden-xs hidden-sm") output << content_tag(:span, (issuable.task_status if issuable.tasks?), id: "task_status", class: "hidden-xs hidden-sm")
output << content_tag(:span, issuable.task_status_short, id: "task_status_short", class: "hidden-md hidden-lg") output << content_tag(:span, (issuable.task_status_short if issuable.tasks?), id: "task_status_short", class: "hidden-md hidden-lg")
output output
end end
...@@ -216,7 +216,8 @@ module IssuablesHelper ...@@ -216,7 +216,8 @@ module IssuablesHelper
initialTitleHtml: markdown_field(issuable, :title), initialTitleHtml: markdown_field(issuable, :title),
initialTitleText: issuable.title, initialTitleText: issuable.title,
initialDescriptionHtml: markdown_field(issuable, :description), initialDescriptionHtml: markdown_field(issuable, :description),
initialDescriptionText: issuable.description initialDescriptionText: issuable.description,
initialTaskStatus: issuable.task_status
} }
data.merge!(updated_at_by(issuable)) data.merge!(updated_at_by(issuable))
......
...@@ -95,6 +95,18 @@ describe('Description component', () => { ...@@ -95,6 +95,18 @@ describe('Description component', () => {
done(); done();
}); });
}); });
it('clears task status text when no tasks are present', (done) => {
vm.taskStatus = '0 of 0';
setTimeout(() => {
expect(
document.querySelector('.issuable-meta #task_status').textContent.trim(),
).toBe('');
done();
});
});
}); });
it('applies syntax highlighting and math when description changed', (done) => { it('applies syntax highlighting and math when description changed', (done) => {
......
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