-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js+service: [#855] 4) integrate request flow with frontend [+]
This concludes the 2nd flow of the membership request feature. Remaining flows are - 'waiting for decision' flow - 'making a decision' flow This PR needs to be complemented by: - one in invenio-requests (done) - one in invenio-rdm-records (to do)
- Loading branch information
Showing
13 changed files
with
559 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
invenio_communities/assets/semantic-ui/js/invenio_communities/api/RequestLinksExtractor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// This file is part of Invenio-communities | ||
// Copyright (C) 2024 Northwestern University. | ||
// | ||
// Invenio-communities is free software; you can redistribute it and/or modify it | ||
// under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
export class RequestLinksExtractor { | ||
#urls; | ||
|
||
constructor(request) { | ||
if (!request?.links) { | ||
throw TypeError("Request resource links are undefined"); | ||
} | ||
this.#urls = request.links; | ||
} | ||
|
||
url(key) { | ||
const urlOfKey = this.#urls[key]; | ||
if (!urlOfKey) { | ||
throw TypeError(`"${key}" link missing from resource.`); | ||
} | ||
return urlOfKey; | ||
} | ||
|
||
get userDiscussionUrl() { | ||
const result = this.url("self_html"); | ||
return result.replace("/requests/", "/me/requests/"); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
invenio_communities/assets/semantic-ui/js/invenio_communities/api/membershipRequests/api.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// This file is part of Invenio-communities | ||
// Copyright (C) 2022 CERN. | ||
// Copyright (C) 2024 Northwestern University. | ||
// | ||
// Invenio-communities is free software; you can redistribute it and/or modify it | ||
// under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
import { CommunityLinksExtractor } from "../CommunityLinksExtractor"; | ||
import { http } from "react-invenio-forms"; | ||
|
||
/** | ||
* API Client for community membership requests. | ||
* | ||
* It mostly uses the API links passed to it from initial community. | ||
* | ||
*/ | ||
export class CommunityMembershipRequestsApi { | ||
constructor(community) { | ||
this.community = community; | ||
this.linksExtractor = new CommunityLinksExtractor(community); | ||
} | ||
|
||
requestMembership = async (payload) => { | ||
return await http.post(this.linksExtractor.url("membership_requests"), payload); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,7 +371,7 @@ def create_user(UserFixture, app, db): | |
is essential for many tests. | ||
""" | ||
|
||
def _create_user(data): | ||
def _create_user(data=None): | ||
"""Create user.""" | ||
default_data = dict( | ||
email="[email protected]", | ||
|
@@ -391,6 +391,7 @@ def _create_user(data): | |
active=True, | ||
confirmed=True, | ||
) | ||
data = data or {} | ||
actual_data = dict(default_data, **data) | ||
u = UserFixture(**actual_data) | ||
u.create(app, db) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.