-
Notifications
You must be signed in to change notification settings - Fork 8
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
WIP: DDFBRA-251 - User can open their loaned e materials #1573
Merged
kasperbirch1
merged 12 commits into
reader-player-feature
from
DDFBRA-251-logged-in-user-can-open-their-loaned-e-material
Dec 13, 2024
Merged
WIP: DDFBRA-251 - User can open their loaned e materials #1573
kasperbirch1
merged 12 commits into
reader-player-feature
from
DDFBRA-251-logged-in-user-can-open-their-loaned-e-material
Dec 13, 2024
Conversation
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
kasperbirch1
force-pushed
the
DDFBRA-251-logged-in-user-can-open-their-loaned-e-material
branch
from
December 10, 2024 14:23
6a06120
to
f11511b
Compare
While investigating https://reload.atlassian.net/browse/DDFBRA-236, I identified an infinite loop in `MaterialDetailsModal`. This issue appears when the modal is opened via "user/loans" and potentially all places it is used
Since all data from loans comes from Publizon, we don’t have a `workId`, which is required to link to the material. Therefore, I use the `useComplexSearchWithPaginationQuery` to find the work using the ISBN (identifier) and construct the `workId` into a URL, e.g., `/work/work-of:870970-basis:62986115`. Additionally, if it finds the material type, it adds that as a parameter.
This commit ensures that users who already have a digital loan (OrderId) at Publizon will see a button labeled either "Read" or "Listen to @materialType." ### Changes Made: 1. Added `orderId` to `LoanType` and included it in the return of `mapPublizonLoanToLoanType`. 2. Introduced a new hook, `useReaderPlayerButtons`, which accepts `selectedManifestations` and returns an `orderId` if the identifier for the `selectedManifestations` exists in the Publizon loans retrieved from `useLoans`. ### Known Issues: This is a WIP because an issue with `FocusTrap` still needs to be resolved. Currently, `FocusTrap` is temporarily set to `active={false}` to avoid blocking further testing.
This change was required to avoid removing the `FocusTrap` from the modal, as it states: "Your focus-trap must have at least one container with at least one tabbable node in it at all times." I spent some time attempting to use `createPortal` to manage a single modal in `material.tsx`, but this approach does not work because the modal is only rendered after it is opened. The solution is to include both modals in `material.tsx` and utilize the existing `useReaderPlayerButtons` hook to determine whether the modal should render. This necessitated a small refactor to handle scenarios where there are no `manifestations`. Additionally, I made a minor cleanup, but further improvements are still needed.
Eliminate redundant code, prevent duplicate invocations of `getMaterialTypes`, and consolidate the logic into a single function for determining the type. Use the `type` from `useReaderPlayerButtons` to control when player logic is enabled.
It is now also used to determine the modals, so a more generic name is appropriate.
kasperbirch1
force-pushed
the
DDFBRA-236-logged-in-user-can-go-from-digital-loans-to-material-to-listen-read
branch
from
December 11, 2024 08:40
c02d269
to
94c6cd2
Compare
kasperbirch1
force-pushed
the
DDFBRA-251-logged-in-user-can-open-their-loaned-e-material
branch
from
December 11, 2024 08:40
f11511b
to
c3a9bcf
Compare
Perhaps there should be some logic in `useLoans` or `useReaderPlayer` to prevent them from being called if no user is logged in.
This change optimizes the `useReaderPlayer` hook to fetch data from Publizon only if the user is logged in. The hook now uses `useGetV1UserLoans` instead of `useLoans`, ensuring that only the necessary data is fetched. This update also makes the hook more reusable for the "Go-project" and prevents the need to add translation strings for `expirationWarningDaysBeforeConfig` in the Material app. Additionally, this update prevents the Cypress test from failing by ensuring the API's is called only when the user is logged in.
kasperbirch1
added a commit
to danskernesdigitalebibliotek/dpl-cms
that referenced
this pull request
Dec 11, 2024
as the reader page in Drupal doesn't support camelCase. See this commit: danskernesdigitalebibliotek/dpl-cms@1279f27 ("Rename orderid to lowercase ")
There is no reason to try borrowing a material that the user has already loaned.
kasperbirch1
added a commit
to danskernesdigitalebibliotek/dpl-cms
that referenced
this pull request
Dec 12, 2024
kasperbirch1
added a commit
to danskernesdigitalebibliotek/dpl-cms
that referenced
this pull request
Dec 12, 2024
kasperbirch1
added a commit
to danskernesdigitalebibliotek/dpl-cms
that referenced
this pull request
Dec 12, 2024
kasperbirch1
changed the base branch from
DDFBRA-236-logged-in-user-can-go-from-digital-loans-to-material-to-listen-read
to
reader-player-feature
December 13, 2024 10:52
kasperbirch1
deleted the
DDFBRA-251-logged-in-user-can-open-their-loaned-e-material
branch
December 13, 2024 10:56
Merged
kasperbirch1
added a commit
that referenced
this pull request
Dec 17, 2024
…logged-in-user-can-open-their-loaned-e-material WIP: DDFBRA-251 - User can open their loaned e materials
kasperbirch1
added a commit
that referenced
this pull request
Jan 7, 2025
…logged-in-user-can-open-their-loaned-e-material WIP: DDFBRA-251 - User can open their loaned e materials
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to issue
https://reload.atlassian.net/browse/DDFBRA-251
Description
This pull request ensures that users who already have a digital loan (OrderId) at Publizon will see a button labeled either "Read" or "Listen to @materialType."
Changes Made:
orderId
toLoanType
and included it in the return ofmapPublizonLoanToLoanType
.useReaderPlayer
, which acceptsselectedManifestations
and returns anorderId
if the identifier for theselectedManifestations
exists in the Publizon loans retrieved fromuseLoans
.### Known Issues:This is a WIP because an issue with
FocusTrap
still needs to be resolved. Currently,FocusTrap
is temporarily set toactive={false}
to avoid blocking further testing.