Commit c7faf45c authored by Stan Hu's avatar Stan Hu Committed by Kushal Pandya

Fix erroneous "No activities found" message

If the number of activities on the page were less than the limit (20),
the pager would display the set of activities but also insert a "No
activities found" banner underneath. This was happening because the
pager attempted to load more data because it thought it needed to
display more information in the window.

This commit fixes the problem by disabling the pager if the number of
activities received is less than the total limit.

Closes https://gitlab.com/gitlab-org/gitlab/issues/27118
parent 722dca57
...@@ -56,6 +56,10 @@ export default { ...@@ -56,6 +56,10 @@ export default {
$('.content_list').append(html); $('.content_list').append(html);
if (count > 0) { if (count > 0) {
this.offset += count; this.offset += count;
if (count < this.limit) {
this.disable = true;
}
} else { } else {
this.disable = true; this.disable = true;
} }
......
---
title: Fix erroneous "No activities found" message
merge_request: 18434
author:
type: fixed
...@@ -63,9 +63,9 @@ describe('pager', () => { ...@@ -63,9 +63,9 @@ describe('pager', () => {
describe('getOld', () => { describe('getOld', () => {
const urlRegex = /(.*)some_list(.*)$/; const urlRegex = /(.*)some_list(.*)$/;
function mockSuccess() { function mockSuccess(count = 0) {
axiosMock.onGet(urlRegex).reply(200, { axiosMock.onGet(urlRegex).reply(200, {
count: 0, count,
html: '', html: '',
}); });
} }
...@@ -142,5 +142,21 @@ describe('pager', () => { ...@@ -142,5 +142,21 @@ describe('pager', () => {
done(); done();
}); });
}); });
it('disables if return count is less than limit', done => {
Pager.offset = 0;
Pager.limit = 20;
mockSuccess(1);
spyOn(Pager.loading, 'hide');
Pager.getOld();
setTimeout(() => {
expect(Pager.loading.hide).toHaveBeenCalled();
expect(Pager.disable).toBe(true);
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