Skip to content
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

Reader / Player #1596

Open
wants to merge 58 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
e0f5660
Add `Reader` + Story
kasperbirch1 Nov 19, 2024
b22cd7b
Add "full screen" modal
kasperbirch1 Nov 19, 2024
d0cf8b2
Implement "Try E-Book" Reader for E-Book Materials
kasperbirch1 Nov 19, 2024
0cc6502
Move `MaterialButtonReaderTeaser` logic to `MaterialButtonOnlineExter…
kasperbirch1 Nov 19, 2024
0c672c1
Make `MaterialButtonReaderTeaser` follow the same structure as `Mater…
kasperbirch1 Nov 20, 2024
ad50bec
Introduce `MaterialSecondaryButton`
kasperbirch1 Nov 20, 2024
f746243
Render `ReaderModal` only when required
kasperbirch1 Nov 20, 2024
2271e65
Remove `window.location.reload();` from `Reader`
kasperbirch1 Nov 20, 2024
c1ab716
Move `window.closeModal` logic into `ReaderModal`
kasperbirch1 Nov 20, 2024
fcddcb3
Initial setup of `Reader app
kasperbirch1 Nov 22, 2024
f8e7202
Remove / Move `Reader` component
kasperbirch1 Nov 22, 2024
62e31b6
Remove `ReaderModal` and Introduce `MaterialSecondaryLink`
kasperbirch1 Nov 22, 2024
1b2229e
Remove `MaterialButtonReaderTeaser`
kasperbirch1 Nov 22, 2024
3b75c58
Add `Player` Component + Story
kasperbirch1 Nov 25, 2024
4f90ab8
Add `Player` teaser functionality to `Material` app
kasperbirch1 Nov 25, 2024
5d688f4
Move `Reader` and `Player` to the same component folder
kasperbirch1 Nov 26, 2024
e90237e
Rename `hasReaderTeaser` and `hasPlayerTeaser`
kasperbirch1 Nov 26, 2024
9a4335a
Refactor `onlineMaterialTeaserText` string
kasperbirch1 Nov 26, 2024
db4a2a4
Remove unnecessary div with inline style
kasperbirch1 Nov 26, 2024
4f91c51
Rename `orderid` to lowercase
kasperbirch1 Nov 27, 2024
af58830
Relocate `Reader` / `Player` teaser buttons to `MaterialButtonOnlineP…
kasperbirch1 Dec 2, 2024
a1f8f6d
Rename `MaterialButtonOnlinePublizon` + Fix typos
kasperbirch1 Dec 3, 2024
8669c48
Add `.modal--center` modifier class to `PlayerModal` for centering
kasperbirch1 Dec 3, 2024
bd60ac0
Remove `readerModalDescriptionText`
kasperbirch1 Dec 6, 2024
f40bccd
Add Todo: Fix infinite loop in MaterialDetailsModal
kasperbirch1 Nov 28, 2024
94c6cd2
Add `useGetWorkUrlFromIdentifier` to support material linking from loans
kasperbirch1 Nov 28, 2024
31a1ec8
WIP: Refactor `MaterialButtonsOnlineInternal`
kasperbirch1 Dec 6, 2024
b0ce8a9
Render all `PlayerModal`s in `material.tsx`
kasperbirch1 Dec 10, 2024
60d47fa
Refactor `getReaderPlayerType`
kasperbirch1 Dec 10, 2024
7285a34
Clean up
kasperbirch1 Dec 10, 2024
c1a59fa
Change `useReaderPlayerButtons` to `useReaderPlayer`
kasperbirch1 Dec 10, 2024
c3a9bcf
Change `useReaderPlayerButtons` to `useReaderPlayer` Part 2
kasperbirch1 Dec 10, 2024
e2d8ca7
Ensure `patrons/patronid/loans/v2` does not cause Cypress tests to fail
kasperbirch1 Dec 11, 2024
c85f6be
Refactor `useReaderPlayer` to fetch loans only if the user is logged in
kasperbirch1 Dec 11, 2024
febec20
Convert `orderid` to lowercase
kasperbirch1 Dec 11, 2024
85d98ce
Hide "Teaser" buttons on materials that are already loaned
kasperbirch1 Dec 11, 2024
821dc1c
This branch will consolidate all features related to Reader/Player fu…
kasperbirch1 Dec 13, 2024
71100af
Merge pull request #1555 from danskernesdigitalebibliotek/DDFBRA-183-…
kasperbirch1 Dec 13, 2024
bb1131d
Merge pull request #1565 from danskernesdigitalebibliotek/DDFBRA-236-…
kasperbirch1 Dec 13, 2024
4cad8a0
Merge pull request #1573 from danskernesdigitalebibliotek/DDFBRA-251-…
kasperbirch1 Dec 13, 2024
5c41d4a
Implement `isVisible` feature flag for reader/player logic
kasperbirch1 Dec 16, 2024
4273f66
Reintroduce `MaterialAvailabilityText` for online manifestations
kasperbirch1 Dec 17, 2024
7a8734d
Link Jira ticket to "TODO" in `material-details-modal.tsx`
kasperbirch1 Jan 2, 2025
954d438
Enhance clarity of `availabilityTextMap` construction
kasperbirch1 Jan 2, 2025
a55d372
Improve naming for clarity in `shouldShowMaterialAvailabilityText`
kasperbirch1 Jan 2, 2025
5ac5d52
Refactor `useReaderPlayer` to simplify logic and improve null checks
kasperbirch1 Jan 6, 2025
225e123
Rename `useGetWorkUrlFromIdentifier` to `useGetWorkUrlFromPublizonIde…
kasperbirch1 Jan 6, 2025
fb1068b
Rename file `useGetWorkUrlFromIdentifier` to `useGetWorkUrlFromPubliz…
kasperbirch1 Jan 6, 2025
cf0afe8
Use `error` instead of `warn`
kasperbirch1 Jan 6, 2025
009b0e3
Only show `MaterialButtonOnlineExternal` if the manifestation is not …
kasperbirch1 Jan 7, 2025
c1349b1
Use `Link` for `MaterialSecondaryLink`
kasperbirch1 Jan 7, 2025
7df08b5
add `!isVisible("readerPlayer")` check to ensure proper fallback beha…
kasperbirch1 Jan 7, 2025
eb30703
Refactor `featureFlag` to adopt object-based approach for improved ex…
kasperbirch1 Jan 7, 2025
5e1cd13
Improve `Reader` and `Player` Stories
kasperbirch1 Jan 7, 2025
91342b9
Add comments to clarify usage of non-standard HTML attributes in Read…
kasperbirch1 Jan 7, 2025
073821a
Trigger new build
kasperbirch1 Jan 7, 2025
602b221
Test Fix Lint Javascript
kasperbirch1 Jan 7, 2025
d08cbca
Rebase to fix Linting Issues in .js files
kasperbirch1 Jan 7, 2025
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
2 changes: 2 additions & 0 deletions src/apps/loan-list/modal/material-details-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Todo: Fix infinite loop in MaterialDetailsModal
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
// Please see https://reload.atlassian.net/browse/DDFBRA-303
import React, { FC, ReactNode } from "react";
import Modal from "../../../core/utils/modal";
import { useText } from "../../../core/utils/text";
Expand Down
65 changes: 48 additions & 17 deletions src/apps/loan-list/modal/material-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { RequestStatus } from "../../../core/utils/types/request";
import { RenewedLoanV2 } from "../../../core/fbs/model";
import RenewalModalMessage from "../../../components/renewal/RenewalModalMessage";
import { formatDate } from "../../../core/utils/helpers/date";
import useGetWorkUrlFromPublizonIdentifier from "../../../core/utils/useGetWorkUrlFromPublizonIdentifier";
import featureFlag from "../../../core/utils/featureFlag";

interface MaterialDetailsProps {
loan: LoanType | null;
Expand All @@ -33,14 +35,14 @@ const MaterialDetails: FC<MaterialDetailsProps & MaterialProps> = ({
material,
modalId
}) => {
const { workUrl } = useGetWorkUrlFromPublizonIdentifier(loan?.identifier);
const [renewingStatus, setRenewingStatus] = useState<RequestStatus>("idle");
const [renewingResponse, setRenewingResponse] = useState<
RenewedLoanV2[] | null
>(null);

const t = useText();
const u = useUrls();
const ereolenMyPageUrl = u("ereolenMyPageUrl");
const viewFeesAndCompensationRatesUrl = u("viewFeesAndCompensationRatesUrl");

if (!loan) {
Expand Down Expand Up @@ -119,20 +121,34 @@ const MaterialDetails: FC<MaterialDetailsProps & MaterialProps> = ({
renewalStatusList={renewalStatusList}
/>
)}
{isDigital(loan) && (
{featureFlag.isActive("readerPlayer") &&
isDigital(loan) &&
workUrl ? (
<div className="modal-details__buttons modal-details__buttons--hide-on-mobile">
<Link
href={ereolenMyPageUrl}
href={workUrl}
className="btn-primary btn-filled btn-small arrow__hover--right-small"
>
{t("materialDetailsGoToEreolenText")}
<img
src={ExternalLinkIcon}
className="btn-icon invert"
alt=""
/>
{t("materialDetailsGoToMaterialText")}
</Link>
</div>
) : (
// Todo: Delete this else block after the readerPlayer feature flag is removed
kasperbirch1 marked this conversation as resolved.
Show resolved Hide resolved
isDigital(loan) && (
<div className="modal-details__buttons modal-details__buttons--hide-on-mobile">
<Link
href={new URL("https://ereolen.dk/user/me")}
className="btn-primary btn-filled btn-small arrow__hover--right-small"
>
Gå til eReolen
<img
src={ExternalLinkIcon}
className="btn-icon invert"
alt=""
/>
</Link>
</div>
)
)}
{dueDate && materialIsOverdue(dueDate) && (
<div className="modal-details__warning">
Expand Down Expand Up @@ -186,20 +202,35 @@ const MaterialDetails: FC<MaterialDetailsProps & MaterialProps> = ({
renewalStatusList={renewalStatusList}
/>
)}
{isDigital(loan) && (
{featureFlag.isActive("readerPlayer") &&
isDigital(loan) &&
workUrl ? (
<div className="modal-details__buttons">
<Link
href={ereolenMyPageUrl}
href={workUrl}
className="btn-primary btn-filled btn-small arrow__hover--right-small modal-details__buttons__full-width"
>
{t("materialDetailsGoToEreolenText")}
<img
src={ExternalLinkIcon}
className="btn-icon invert"
alt=""
/>
{t("materialDetailsGoToMaterialText")}
</Link>
</div>
) : (
// Todo: Delete this else block after the readerPlayer feature flag is removed
!featureFlag.isActive("readerPlayer") &&
isDigital(loan) && (
kasperbirch1 marked this conversation as resolved.
Show resolved Hide resolved
<div className="modal-details__buttons">
<Link
href={new URL("https://ereolen.dk/user/me")}
className="btn-primary btn-filled btn-small arrow__hover--right-small modal-details__buttons__full-width"
>
Gå til eReolen test
<img
src={ExternalLinkIcon}
className="btn-icon invert"
alt=""
/>
</Link>
</div>
)
)}
</div>
)}
Expand Down
9 changes: 8 additions & 1 deletion src/apps/material/material.entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs";
interface MaterialEntryTextProps {
alreadyReservedText: string;
approveReservationText: string;
audiobookText: string;
kasperbirch1 marked this conversation as resolved.
Show resolved Hide resolved
blockedButtonText: string;
cantReserveText: string;
cantViewReviewText: string;
Expand Down Expand Up @@ -43,6 +44,7 @@ interface MaterialEntryTextProps {
detailsListTypeText: string;
detailsOfTheMaterialText: string;
detailsText: string;
ebookText: string;
editionsText: string;
editionText: string;
etAlText: string;
Expand Down Expand Up @@ -100,6 +102,9 @@ interface MaterialEntryTextProps {
okButtonText: string;
onlineLimitMonthAudiobookInfoText: string;
onlineLimitMonthEbookInfoText: string;
onlineMaterialPlayerText: string;
onlineMaterialReaderText: string;
onlineMaterialTeaserText: string;
openOrderAuthenticationErrorText: string;
openOrderErrorMissingPincodeText: string;
openOrderInvalidOrderText: string;
Expand Down Expand Up @@ -144,13 +149,15 @@ interface MaterialEntryTextProps {
outOfText: string;
periodicalSelectEditionText: string;
periodicalSelectYearText: string;
reservationDetailsPickUpAtTitleText: string;
playerModalCloseButtonText: string;
playerModalDescriptionText: string;
queueText: string;
ratingIsText: string;
readArticleText: string;
receiveEmailWhenMaterialReadyText: string;
receiveSmsWhenMaterialReadyText: string;
reservableFromAnotherLibraryText: string;
reservationDetailsPickUpAtTitleText: string;
reservationErrorsDescriptionText: string;
reservationErrorsTitleText: string;
reservationModalCloseModalAriaLabelText: string;
Expand Down
35 changes: 35 additions & 0 deletions src/apps/material/material.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ const meta: Meta<typeof MaterialEntry> = {
description: "Edition/Week",
control: { type: "text" }
},
playerModalCloseButtonText: {
description: "Close",
control: { type: "text" }
},
playerModalDescriptionText: {
description: "Player modal description text",
control: { type: "text" }
},
reserveBookText: {
description: "Reserve",
control: { type: "text" }
Expand Down Expand Up @@ -143,6 +151,10 @@ const meta: Meta<typeof MaterialEntry> = {
description: "Details",
control: { type: "text" }
},
ebookText: {
description: "Ebook",
control: { type: "text" }
},
reviewsText: {
description: "Reviews",
control: { type: "text" }
Expand Down Expand Up @@ -291,10 +303,26 @@ const meta: Meta<typeof MaterialEntry> = {
description: "Online limit info text",
control: { type: "text" }
},
onlineMaterialPlayerText: {
description: "Material button online player text",
control: { type: "text" }
},
onlineMaterialReaderText: {
description: "Material button online reader text",
control: { type: "text" }
},
onlineMaterialTeaserText: {
description: "Material button online teaser text",
control: { type: "text" }
},
approveReservationText: {
description: "Approve reservation",
control: { type: "text" }
},
audiobookText: {
description: "Audiobook",
control: { type: "text" }
},
shiftText: {
description: "Change",
control: { type: "text" }
Expand Down Expand Up @@ -692,6 +720,7 @@ const meta: Meta<typeof MaterialEntry> = {
...serviceUrlArgs,
...globalTextArgs,
...globalConfigArgs,
audiobookText: "Audiobook",
searchUrl: "/search",
materialUrl: "/work/:workid",
wid: "work-of:870970-basis:52557240",
Expand All @@ -708,6 +737,8 @@ const meta: Meta<typeof MaterialEntry> = {
materialHeaderAuthorByText: "By",
periodicalSelectYearText: "Year",
periodicalSelectEditionText: "Edition",
playerModalDescriptionText: "Modal for player",
playerModalCloseButtonText: "Close",
reserveBookText: "Reserve book",
reserveText: "Reserve",
reserveWithMaterialTypeText: "Reserve @materialType",
Expand All @@ -728,6 +759,7 @@ const meta: Meta<typeof MaterialEntry> = {
editionsText: "Editions",
fictionNonfictionText: "Fictional",
detailsText: "Details",
ebookText: "E-book",
reviewsText: "Reviews",
detailsListTypeText: "Type",
detailsListLanguageText: "Language",
Expand Down Expand Up @@ -771,6 +803,9 @@ const meta: Meta<typeof MaterialEntry> = {
"You have borrowed @count out of @limit possible e-books this month",
onlineLimitMonthAudiobookInfoText:
"You have borrowed @count out of @limit possible audio-books this month",
onlineMaterialPlayerText: "Listen to @materialType",
onlineMaterialReaderText: "Read @materialType",
onlineMaterialTeaserText: "Try @materialType",
approveReservationText: "Approve reservation",
shiftText: "Change",
reservationDetailsPickUpAtTitleText: "Pick up at",
Expand Down
16 changes: 15 additions & 1 deletion src/apps/material/material.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import {
} from "./helper";
import MaterialDisclosure from "./MaterialDisclosure";
import ReservationFindOnShelfModals from "./ReservationFindOnShelfModals";
import PlayerModal from "../../components/material/player-modal/PlayerModal";
import useReaderPlayer from "../../core/utils/useReaderPlayer";
import featureFlag from "../../core/utils/featureFlag";

export interface MaterialProps {
wid: WorkId;
Expand All @@ -54,6 +57,11 @@ const Material: React.FC<MaterialProps> = ({ wid }) => {
const { data: userData } = usePatronData();
const [isUserBlocked, setIsUserBlocked] = useState<boolean | null>(null);
const { track } = useStatistics();
const {
type: readerPlayerType,
identifier,
orderId
} = useReaderPlayer(selectedManifestations);

useEffect(() => {
setIsUserBlocked(!!(userData?.patron && isBlocked(userData.patron)));
Expand Down Expand Up @@ -170,7 +178,6 @@ const Material: React.FC<MaterialProps> = ({ wid }) => {
setSelectedPeriodical={setSelectedPeriodical}
/>
))}

{infomediaIds.length > 0 && !isAnonymous() && !isUserBlocked && (
<InfomediaModal
selectedManifestations={selectedManifestations}
Expand All @@ -193,6 +200,13 @@ const Material: React.FC<MaterialProps> = ({ wid }) => {
setSelectedPeriodical={setSelectedPeriodical}
/>
)}
{featureFlag.isActive("readerPlayer") &&
readerPlayerType === "player" && (
<>
{identifier && <PlayerModal identifier={identifier} />}
{orderId && <PlayerModal orderId={orderId} />}
</>
)}
</MaterialHeader>
<MaterialDescription pid={pid} work={work} />
{/* Since we cannot trust the editions for global manifestations */}
Expand Down
11 changes: 11 additions & 0 deletions src/apps/reader/Reader.entry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import { withConfig } from "../../core/utils/config";
import { withUrls } from "../../core/utils/url";
import { withText } from "../../core/utils/text";
import Reader, { ReaderType } from "../../components/reader-player/Reader";

const ReaderEntry: React.FC<ReaderType> = ({ identifier, orderid }) => {
return <Reader identifier={identifier} orderid={orderid} />;
};

export default withConfig(withUrls(withText(ReaderEntry)));
4 changes: 4 additions & 0 deletions src/apps/reader/Reader.mount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import addMount from "../../core/addMount";
import Reader from "./Reader.entry";

addMount({ appName: "reader", app: Reader });
5 changes: 4 additions & 1 deletion src/components/Buttons/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type ButtonProps = {
id?: string;
classNames?: string;
dataCy?: string;
ariaDescribedBy?: string;
};

export const Button: React.FC<ButtonProps> = ({
Expand All @@ -31,7 +32,8 @@ export const Button: React.FC<ButtonProps> = ({
iconClassNames,
id,
classNames,
dataCy
dataCy,
ariaDescribedBy
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
}) => {
return (
<button
Expand All @@ -43,6 +45,7 @@ export const Button: React.FC<ButtonProps> = ({
disabled={disabled}
onClick={onClick}
id={id}
aria-describedby={ariaDescribedBy}
>
{label}
<ButtonIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useText } from "../../../../core/utils/text";
import MaterialAvailabilityTextParagraph from "../generic/MaterialAvailabilityTextParagraph";
import { ManifestationMaterialType } from "../../../../core/utils/types/material-type";
import { AvailabilityTextMap, getAvailabilityText } from "./helper";
import { playerTypes, readerTypes } from "../../../reader-player/helper";

interface MaterialAvailabilityTextOnlineProps {
isbns: string[];
Expand Down Expand Up @@ -43,16 +44,26 @@ const MaterialAvailabilityTextOnline: React.FC<
} = libraryProfileData;

const availabilityTextMap: AvailabilityTextMap = {
[ManifestationMaterialType.ebook]: {
text: "onlineLimitMonthEbookInfoText",
count: totalEbookLoans,
limit: maxConcurrentEbookLoansPerBorrower
},
[ManifestationMaterialType.audioBook]: {
text: "onlineLimitMonthAudiobookInfoText",
count: totalAudioLoans,
limit: maxConcurrentAudioLoansPerBorrower
},
...readerTypes.reduce((acc, type) => {
return {
...acc,
[type]: {
text: "onlineLimitMonthEbookInfoText",
count: totalEbookLoans,
limit: maxConcurrentEbookLoansPerBorrower
}
};
}, {}),
...playerTypes.reduce((acc, type) => {
return {
...acc,
[type]: {
text: "onlineLimitMonthAudiobookInfoText",
count: totalAudioLoans,
limit: maxConcurrentAudioLoansPerBorrower
}
};
}, {}),
materialIsIncluded: {
text: "materialIsIncludedText"
}
Expand Down
Loading
Loading