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

DDFBRA-183 - Anonymous and logged in user can try ebook #1555

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 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
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: 6 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,7 @@ interface MaterialEntryTextProps {
okButtonText: string;
onlineLimitMonthAudiobookInfoText: string;
onlineLimitMonthEbookInfoText: string;
onlineMaterialTeaserText: string;
openOrderAuthenticationErrorText: string;
openOrderErrorMissingPincodeText: string;
openOrderInvalidOrderText: string;
Expand Down Expand Up @@ -144,13 +147,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
25 changes: 25 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,18 @@ const meta: Meta<typeof MaterialEntry> = {
description: "Online limit info 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 +712,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 +729,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 +751,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 +795,7 @@ 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",
onlineMaterialTeaserText: "Try @materialType",
approveReservationText: "Approve reservation",
shiftText: "Change",
reservationDetailsPickUpAtTitleText: "Pick up at",
Expand Down
8 changes: 8 additions & 0 deletions src/apps/material/material.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ import {
getBestMaterialTypeForWork,
getDetailsListData,
getInfomediaIds,
getManifestationIsbn,
getManifestationsOrderByTypeAndYear,
isParallelReservation
} from "./helper";
import MaterialDisclosure from "./MaterialDisclosure";
import ReservationFindOnShelfModals from "./ReservationFindOnShelfModals";
import PlayerModal from "../../components/material/player-modal/PlayerModal";
import { hasPlayerManifestation } from "../../components/reader-player/helper";

export interface MaterialProps {
wid: WorkId;
Expand Down Expand Up @@ -193,6 +196,11 @@ const Material: React.FC<MaterialProps> = ({ wid }) => {
setSelectedPeriodical={setSelectedPeriodical}
/>
)}
{hasPlayerManifestation(selectedManifestations) && (
<PlayerModal
identifier={getManifestationIsbn(selectedManifestations[0])}
/>
)}
</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
}) => {
return (
<button
Expand All @@ -43,6 +45,7 @@ export const Button: React.FC<ButtonProps> = ({
disabled={disabled}
onClick={onClick}
id={id}
aria-describedby={ariaDescribedBy}
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
>
{label}
<ButtonIcon
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React, { FC } from "react";
import { Button } from "../../../Buttons/Button";
import { ButtonSize } from "../../../../core/utils/types/button";

interface MaterialSecondaryButtonProps {
label: string;
size: ButtonSize;
onClick: () => void;
dataCy?: string;
ariaDescribedBy: string;
}

const MaterialSecondaryButton: FC<MaterialSecondaryButtonProps> = ({
label,
size,
onClick,
dataCy,
ariaDescribedBy
}) => {
// If element is currently focused on, we would like to let users open it using enter
const handleKeyUp = (key: string) => {
if (key === "Enter") {
onClick();
}
};

if (size !== "small") {
return (
<Button
label={label}
buttonType="none"
variant="outline"
disabled={false}
collapsible={false}
size="large"
onClick={onClick}
dataCy={dataCy}
ariaDescribedBy={ariaDescribedBy}
kasperbirch1 marked this conversation as resolved.
Show resolved Hide resolved
/>
);
}

return (
<button
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
className="link-tag text-small-caption material-manifestation-item__find capitalize-all btn-ui"
aria-describedby={ariaDescribedBy}
kasperbirch1 marked this conversation as resolved.
Show resolved Hide resolved
onClick={onClick}
onKeyUp={(e) => handleKeyUp(e.key)}
tabIndex={0}
type="button"
data-cy={dataCy}
>
{label}
</button>
);
};

export default MaterialSecondaryButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { FC } from "react";
import { ButtonSize } from "../../../../core/utils/types/button";
import LinkButton from "../../../Buttons/LinkButton";

interface MaterialSecondaryLinkProps {
label: string;
size: ButtonSize;
url: URL;
dataCy?: string;
}

const MaterialSecondaryLink: FC<MaterialSecondaryLinkProps> = ({
label,
size,
url,
dataCy
}) => {
if (size !== "small") {
return (
<LinkButton
url={url}
buttonType="none"
variant="outline"
size="large"
dataCy={dataCy}
>
{label}
</LinkButton>
);
}

return (
<a
href={url.toString()}
className="link-tag text-small-caption material-manifestation-item__find capitalize-all btn-ui"
data-cy={dataCy}
>
{label}
</a>
);
};

export default MaterialSecondaryLink;
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: Remember to clean this up for all paths that refer to eReolen
import React, { useState, FC, useEffect } from "react";
import {
AccessUrl,
Expand Down Expand Up @@ -90,6 +91,7 @@ const MaterialButtonOnlineExternal: FC<MaterialButtonOnlineExternalProps> = ({
return t("seeOnlineText");
}
};

return (
<LinkButton
url={translatedUrl}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import MaterialButtonOnlineDigitalArticle from "./MaterialButtonOnlineDigitalArt
import MaterialButtonOnlineExternal from "./MaterialButtonOnlineExternal";
import MaterialButtonOnlineInfomediaArticle from "./MaterialButtonOnlineInfomediaArticle";
import { ManifestationMaterialType } from "../../../../core/utils/types/material-type";
import MaterialButtonsOnlineInternal from "./MaterialButtonsOnlineInternal";

export interface MaterialButtonsOnlineProps {
manifestations: Manifestation[];
Expand All @@ -38,6 +39,11 @@ const MaterialButtonsOnline: FC<MaterialButtonsOnlineProps> = ({
});
};

// Todo: Move logic for Player / Reader buttons / Links to here.
// if (condition) {
// return <MaterialButtonsOnlineInternal manifestations={manifestations} />;
// }

// Find 'Ereol' object or default to the first 'access' object
const accessElement =
manifestations[0].access.find((item) => item.__typename === "Ereol") ||
Expand All @@ -58,15 +64,23 @@ const MaterialButtonsOnline: FC<MaterialButtonsOnlineProps> = ({
}

return (
<MaterialButtonOnlineExternal
externalUrl={externalUrl}
origin={origin}
size={size}
trackOnlineView={trackOnlineView}
manifestations={manifestations}
dataCy={`${dataCy}-external`}
ariaLabelledBy={ariaLabelledBy}
/>
<>
<MaterialButtonOnlineExternal
externalUrl={externalUrl}
origin={origin}
size={size}
trackOnlineView={trackOnlineView}
manifestations={manifestations}
dataCy={`${dataCy}-external`}
ariaLabelledBy={ariaLabelledBy}
/>
{/* Todo: MaterialButtonsOnlineInternal should be in the todo at line 44 */}
<MaterialButtonsOnlineInternal
size={size}
manifestations={manifestations}
dataCy={`${dataCy}-publizon`}
/>
</>
);
}

Expand Down
Loading
Loading