Commit 014927f0 authored by Lee Tickett's avatar Lee Tickett

Fix pipeline count on merge request tab

When a merge request has more than one page of pipelines the count
will revert to the max number of pipelines per page.

Changelog: fixed
parent 99f5cbd3
...@@ -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