Skip to content

fix: use new endpoint for crate owner invites #5389

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/components/seek-pagination.hbs
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}}
5 changes: 5 additions & 0 deletions app/components/seek-pagination.module.css
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;
}
10 changes: 10 additions & 0 deletions app/controllers/me/pending-invites.js
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;
}
8 changes: 6 additions & 2 deletions app/routes/me/pending-invites.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import AuthenticatedRoute from '../-authenticated-route';
export default class PendingInvitesRoute extends AuthenticatedRoute {
@service store;

model() {
return this.store.findAll('crate-owner-invite');
queryParams = {
seek: { refreshModel: true },
};

model(params) {
return this.store.query('crate-owner-invite', params);
}
}
2 changes: 2 additions & 0 deletions app/templates/me/pending-invites.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
<p local-class="row" data-test-empty-state>You don't seem to have any pending invitations.</p>
{{/each}}
</div>

<SeekPagination @pagination={{this.pagination}} />
12 changes: 12 additions & 0 deletions app/utils/seek-pagination.js
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 () {
const { nextPage } = this;
const nextPageParams = new URLSearchParams(nextPage);

return {
nextPage: nextPageParams.get('seek'),
};
});
}
11 changes: 9 additions & 2 deletions mirage/route-handlers/me.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,20 @@ export function register(server) {
return { ok: true };
});

server.get('/api/v1/me/crate_owner_invitations', function (schema) {
server.get('/api/private/crate_owner_invitations', function (schema, request) {
let { user } = getSession(schema);
if (!user) {
return new Response(403, {}, { errors: [{ detail: 'must be logged in to perform that action' }] });
}

return schema.crateOwnerInvitations.where({ inviteeId: user.id });
const { start, end } = pageParams(request);
const invites = schema.crateOwnerInvitations.where({ inviteeId: user.id });

let response = this.serialize(invites.slice(start, end));

response.meta = { total: invites.length };

return response;
});

server.put('/api/v1/me/crate_owner_invitations/:crate_id', (schema, request) => {
Expand Down