Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6d6143a7
Commit
6d6143a7
authored
Jul 08, 2020
by
Scott Stern
Committed by
Nicolò Maria Mezzopera
Jul 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pagination when total items is not in the header response
parent
ff9bcb08
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
34 deletions
+84
-34
app/assets/javascripts/issuables_list/components/issuables_list_app.vue
...ascripts/issuables_list/components/issuables_list_app.vue
+25
-5
spec/frontend/issuables_list/components/issuables_list_app_spec.js
...tend/issuables_list/components/issuables_list_app_spec.js
+59
-29
No files found.
app/assets/javascripts/issuables_list/components/issuables_list_app.vue
View file @
6d6143a7
...
@@ -118,6 +118,29 @@ export default {
...
@@ -118,6 +118,29 @@ export default {
baseUrl
()
{
baseUrl
()
{
return
window
.
location
.
href
.
replace
(
/
(\?
.*
)?(
#.*
)?
$/
,
''
);
return
window
.
location
.
href
.
replace
(
/
(\?
.*
)?(
#.*
)?
$/
,
''
);
},
},
paginationNext
()
{
return
this
.
page
+
1
;
},
paginationPrev
()
{
return
this
.
page
-
1
;
},
paginationProps
()
{
const
paginationProps
=
{
value
:
this
.
page
};
if
(
this
.
totalItems
)
{
return
{
...
paginationProps
,
perPage
:
this
.
itemsPerPage
,
totalItems
:
this
.
totalItems
,
};
}
return
{
...
paginationProps
,
prevPage
:
this
.
paginationPrev
,
nextPage
:
this
.
paginationNext
,
};
},
},
},
watch
:
{
watch
:
{
selection
()
{
selection
()
{
...
@@ -272,11 +295,8 @@ export default {
...
@@ -272,11 +295,8 @@ export default {
</ul>
</ul>
<div
class=
"mt-3"
>
<div
class=
"mt-3"
>
<gl-pagination
<gl-pagination
v-if=
"totalItems"
v-bind=
"paginationProps"
:value=
"page"
class=
"gl-justify-content-center"
:per-page=
"itemsPerPage"
:total-items=
"totalItems"
class=
"justify-content-center"
@
input=
"onPaginate"
@
input=
"onPaginate"
/>
/>
</div>
</div>
...
...
spec/frontend/issuables_list/components/issuables_list_app_spec.js
View file @
6d6143a7
...
@@ -454,43 +454,73 @@ describe('Issuables list component', () => {
...
@@ -454,43 +454,73 @@ describe('Issuables list component', () => {
describe
(
'
when paginates
'
,
()
=>
{
describe
(
'
when paginates
'
,
()
=>
{
const
newPage
=
3
;
const
newPage
=
3
;
beforeEach
(()
=>
{
describe
(
'
when total-items is defined in response headers
'
,
()
=>
{
window
.
history
.
pushState
=
jest
.
fn
();
beforeEach
(()
=>
{
setupApiMock
(()
=>
[
window
.
history
.
pushState
=
jest
.
fn
();
200
,
setupApiMock
(()
=>
[
MOCK_ISSUES
.
slice
(
0
,
PAGE_SIZE
),
200
,
{
MOCK_ISSUES
.
slice
(
0
,
PAGE_SIZE
),
'
x-total
'
:
100
,
{
'
x-page
'
:
2
,
'
x-total
'
:
100
,
},
'
x-page
'
:
2
,
]);
},
]);
factory
();
factory
();
return
waitForPromises
();
return
waitForPromises
();
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
// reset to original value
// reset to original value
window
.
history
.
pushState
.
mockRestore
();
window
.
history
.
pushState
.
mockRestore
();
});
});
it
(
'
calls window.history.pushState one time
'
,
()
=>
{
// Trigger pagination
wrapper
.
find
(
GlPagination
).
vm
.
$emit
(
'
input
'
,
newPage
);
expect
(
window
.
history
.
pushState
).
toHaveBeenCalledTimes
(
1
);
});
it
(
'
calls window.history.pushState one time
'
,
()
=>
{
it
(
'
sets params in the url
'
,
()
=>
{
// Trigger pagination
// Trigger pagination
wrapper
.
find
(
GlPagination
).
vm
.
$emit
(
'
input
'
,
newPage
);
wrapper
.
find
(
GlPagination
).
vm
.
$emit
(
'
input
'
,
newPage
);
expect
(
window
.
history
.
pushState
).
toHaveBeenCalledTimes
(
1
);
expect
(
window
.
history
.
pushState
).
toHaveBeenCalledWith
(
{},
''
,
`
${
TEST_LOCATION
}
?state=opened&order_by=priority&sort=asc&page=
${
newPage
}
`
,
);
});
});
});
it
(
'
sets params in the url
'
,
()
=>
{
describe
(
'
when total-items is not defined in the headers
'
,
()
=>
{
// Trigger pagination
const
page
=
2
;
wrapper
.
find
(
GlPagination
).
vm
.
$emit
(
'
input
'
,
newPage
);
const
prevPage
=
page
-
1
;
const
nextPage
=
page
+
1
;
expect
(
window
.
history
.
pushState
).
toHaveBeenCalledWith
(
beforeEach
(()
=>
{
{},
setupApiMock
(()
=>
[
''
,
200
,
`
${
TEST_LOCATION
}
?state=opened&order_by=priority&sort=asc&page=
${
newPage
}
`
,
MOCK_ISSUES
.
slice
(
0
,
PAGE_SIZE
),
);
{
'
x-page
'
:
page
,
},
]);
factory
();
return
waitForPromises
();
});
it
(
'
finds the correct props applied to GlPagination
'
,
()
=>
{
expect
(
wrapper
.
find
(
GlPagination
).
props
()).
toMatchObject
({
nextPage
,
prevPage
,
value
:
page
,
});
});
});
});
});
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment