-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pagination to the "Pending Owner Invites" page #5185
Changes from 15 commits
0809f82
8c60753
712abe1
cd92237
9855ff5
6eb4a45
c664493
c99229b
539fb30
6a44750
78d249b
95f9b64
80db2b4
18ad7b9
fee2365
2409f0e
eb93218
1b140b5
11fafa7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{#if @pagination.nextPage}} | ||
<nav local-class='seek-pagination' aria-label="Pagination navigation"> | ||
<LinkTo @query={{hash [email protected]}} local-class="next" rel="next" title="Goes to next page" data-test-pagination-next> | ||
Next Page | ||
</LinkTo> | ||
</nav> | ||
{{/if}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.seek-pagination { | ||
text-align: center; | ||
font-size: 90%; | ||
margin-bottom: 20px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
import { reads } from 'macro-decorators'; | ||
|
||
import { pagination } from '../../utils/seek-pagination'; | ||
|
||
export default class PendingInvitesController extends Controller { | ||
@reads('model.meta.next_page') nextPage; | ||
@pagination() pagination; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.list { | ||
background: white; | ||
margin-bottom: 2rem; | ||
} | ||
|
||
.row { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import macro from 'macro-decorators'; | ||
|
||
export function pagination() { | ||
return macro(function () { | ||
let { nextPage, totalItems } = this; | ||
|
||
return { | ||
nextPage, | ||
totalItems, | ||
}; | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,9 @@ pub fn list(req: &mut dyn RequestExt) -> EndpointResult { | |
let user_id = auth.user_id(); | ||
|
||
let PrivateListResponse { | ||
invitations, users, .. | ||
invitations, | ||
users, | ||
meta, | ||
} = prepare_list(req, auth, ListFilter::InviteeId(user_id))?; | ||
|
||
// The schema for the private endpoints is converted to the schema used by v1 endpoints. | ||
|
@@ -47,6 +49,7 @@ pub fn list(req: &mut dyn RequestExt) -> EndpointResult { | |
Ok(req.json(&json!({ | ||
"crate_owner_invitations": crate_owner_invitations, | ||
"users": users, | ||
"meta": meta, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adds There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry that I just noticed this now, but #3763 introduced a new endpoint for the invitations ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good! Lets do that! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whatever you prefer. feel free to keep it open and then rebase it once the other stuff is done :) |
||
}))) | ||
} | ||
|
||
|
@@ -147,15 +150,12 @@ fn prepare_list( | |
raw_invitations.pop(); | ||
|
||
if let Some(last) = raw_invitations.last() { | ||
let mut params = IndexMap::new(); | ||
params.insert( | ||
"seek".into(), | ||
crate::controllers::helpers::pagination::encode_seek(( | ||
last.crate_id, | ||
last.invited_user_id, | ||
))?, | ||
); | ||
Some(req.query_with_params(params)) | ||
let seek_key = crate::controllers::helpers::pagination::encode_seek(( | ||
last.crate_id, | ||
last.invited_user_id, | ||
))?; | ||
|
||
Some(seek_key) | ||
EstebanBorai marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else { | ||
None | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is causing some trouble when retrieving crates by its ID, given that crates IDs are actually strings with the name of such crate.