Commit 4f96511b authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch 'fix-pipeline-count-on-mr-tab' into 'master'

Fix pipeline count on merge request tab

See merge request gitlab-org/gitlab!65536
parents 920e7f26 014927f0
...@@ -14,14 +14,10 @@ export default () => { ...@@ -14,14 +14,10 @@ export default () => {
if (pipelineTableViewEl) { if (pipelineTableViewEl) {
// Update MR and Commits tabs // Update MR and Commits tabs
pipelineTableViewEl.addEventListener('update-pipelines-count', (event) => { pipelineTableViewEl.addEventListener('update-pipelines-count', (event) => {
if ( if (event.detail.pipelineCount) {
event.detail.pipelines &&
event.detail.pipelines.count &&
event.detail.pipelines.count.all
) {
const badge = document.querySelector('.js-pipelines-mr-count'); const badge = document.querySelector('.js-pipelines-mr-count');
badge.textContent = event.detail.pipelines.count.all; badge.textContent = event.detail.pipelineCount;
} }
}); });
......
...@@ -133,16 +133,16 @@ export default { ...@@ -133,16 +133,16 @@ export default {
this.store.storePagination(resp.headers); this.store.storePagination(resp.headers);
this.setCommonData(pipelines); this.setCommonData(pipelines);
if (resp.headers?.['x-total']) {
const updatePipelinesEvent = new CustomEvent('update-pipelines-count', { const updatePipelinesEvent = new CustomEvent('update-pipelines-count', {
detail: { detail: { pipelineCount: resp.headers['x-total'] },
pipelines: resp.data,
},
}); });
// notifiy to update the count in tabs // notifiy to update the count in tabs
if (this.$el.parentElement) { if (this.$el.parentElement) {
this.$el.parentElement.dispatchEvent(updatePipelinesEvent); this.$el.parentElement.dispatchEvent(updatePipelinesEvent);
} }
}
}, },
/** /**
* When the user clicks on the "Run pipeline" button * When the user clicks on the "Run pipeline" button
......
...@@ -66,7 +66,7 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -66,7 +66,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
describe('with pipelines', () => { describe('with pipelines', () => {
beforeEach(async () => { beforeEach(async () => {
mock.onGet('endpoint.json').reply(200, [pipeline]); mock.onGet('endpoint.json').reply(200, [pipeline], { 'x-total': 10 });
createComponent(); createComponent();
...@@ -110,7 +110,7 @@ describe('Pipelines table in Commits and Merge requests', () => { ...@@ -110,7 +110,7 @@ describe('Pipelines table in Commits and Merge requests', () => {
document.body.appendChild(element); document.body.appendChild(element);
element.addEventListener('update-pipelines-count', (event) => { element.addEventListener('update-pipelines-count', (event) => {
expect(event.detail.pipelines).toEqual([pipeline]); expect(event.detail.pipelineCount).toEqual(10);
done(); 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