-
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
12 changed files
with
557 additions
and
334 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
Oops, something went wrong.