Commit 5c8a8409 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'sh-disable-pager-on-small-counts' into 'master'

Fix erroneous "No activities found" message

Closes #27118

See merge request gitlab-org/gitlab!18434
parents 860a9a27 c7faf45c
...@@ -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