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