From 4938295e758004d86584fe8d048032cc2aad3af7 Mon Sep 17 00:00:00 2001 From: Adam Antal Date: Thu, 14 Dec 2023 15:26:13 +0100 Subject: [PATCH 01/11] Throw an error if a text string isn't defined with description of string --- src/core/utils/text.tsx | 8 +++++++- src/tests/unit/text.test.tsx | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/core/utils/text.tsx b/src/core/utils/text.tsx index 569e8c84b6..fb7e8bc57d 100644 --- a/src/core/utils/text.tsx +++ b/src/core/utils/text.tsx @@ -108,8 +108,14 @@ export const useText = (): UseTextFunction => { const { data } = useSelector((state: RootState) => state.text); return (key: string, { placeholders, count } = { count: 0 }) => { + if (!data) { + throw new Error(`The translation store is broken.`); + } + if (!data[key]) { + throw new Error(`The translation for ${key} is not defined.`); + } const textDefinition = constructTextDefinitionFromRawTextTextEntry( - data?.[key] ?? key + data[key] ); const textPlaceholders = { ...(placeholders ?? {}) }; diff --git a/src/tests/unit/text.test.tsx b/src/tests/unit/text.test.tsx index 445dd40b5b..af0768d4e9 100644 --- a/src/tests/unit/text.test.tsx +++ b/src/tests/unit/text.test.tsx @@ -76,3 +76,15 @@ test("Should handle plural text definitions", () => { ); }); }); + +test("Should throw an error if the text definition is not found", () => { + const { result } = renderHook(() => useText(), { wrapper: Wrapper }); + // We name it t, because that is how we normally use it in the code. + const t = result.current; + + act(() => { + expect(() => t("nonExistingText")).toThrowError( + "The translation for nonExistingText is not defined." + ); + }); +}); From b612606bf7194aa1c5e32c38c84873dd087678b1 Mon Sep 17 00:00:00 2001 From: Adam Antal Date: Fri, 15 Dec 2023 13:43:48 +0100 Subject: [PATCH 02/11] Add globalTextArgs.ts with error message translations & add to all apps --- src/apps/advanced-search/AdvancedSearch.dev.tsx | 2 ++ .../advanced-search/AdvancedSearch.entry.tsx | 2 ++ .../CreatePatron.dev.tsx | 2 ++ .../CreatePatron.entry.tsx | 2 ++ src/apps/dashboard/dashboard.dev.tsx | 2 ++ src/apps/dashboard/dashboard.entry.tsx | 4 +++- src/apps/demo-modal/demo-modal.dev.tsx | 6 +++++- src/apps/demo-modal/demo-modal.entry.tsx | 3 ++- .../FavoritesListMaterialComponent.dev.tsx | 2 ++ .../FavoritesListMaterialComponent.entry.tsx | 6 ++++-- src/apps/favorites-list/FavoritesList.dev.tsx | 2 ++ src/apps/favorites-list/FavoritesList.entry.tsx | 2 ++ src/apps/fee-list/FeeList.dev.tsx | 2 ++ src/apps/fee-list/FeeList.entry.tsx | 2 ++ src/apps/hello-world/hello-world.dev.tsx | 6 +++++- src/apps/hello-world/hello-world.entry.tsx | 5 ++++- src/apps/loan-list/list/loan-list.dev.tsx | 2 ++ src/apps/loan-list/list/loan-list.entry.tsx | 2 ++ src/apps/material/material.dev.tsx | 2 ++ src/apps/material/material.entry.tsx | 2 ++ src/apps/menu/menu.dev.tsx | 2 ++ src/apps/menu/menu.entry.tsx | 2 ++ src/apps/patron-page/PatronPage.dev.tsx | 2 ++ src/apps/patron-page/PatronPage.entry.tsx | 2 ++ src/apps/recommender/Recommender.dev.tsx | 2 ++ src/apps/recommender/Recommender.entry.tsx | 2 ++ .../list/reservation-list.dev.tsx | 2 ++ .../list/reservation-list.entry.tsx | 2 ++ src/apps/search-header/search-header.dev.tsx | 2 ++ src/apps/search-header/search-header.entry.tsx | 2 ++ src/apps/search-result/search-result.dev.tsx | 2 ++ src/apps/search-result/search-result.entry.tsx | 2 ++ .../something-similar/SomethingSimilar.dev.tsx | 2 ++ .../SomethingSimilar.entry.tsx | 5 ++++- .../availability-label.dev.tsx | 2 ++ .../blocked-modal/BlockedModal.tsx | 4 ++++ .../button-favourite/button-favourite.dev.tsx | 4 ++-- src/components/cover/cover.dev.tsx | 2 ++ .../error-boundary-alert/ErrorBoundaryAlert.tsx | 2 +- .../find-on-shelf/FindOnShelfModal.dev.tsx | 2 ++ src/components/hello/hello.dev.tsx | 2 ++ .../message/modal-message/ModalMessage.dev.tsx | 2 ++ src/components/multiselect/Multiselect.dev.tsx | 2 ++ src/components/search-bar/search-bar.dev.tsx | 2 ++ src/core/storybook/globalTextArgs.ts | 17 +++++++++++++++++ 45 files changed, 119 insertions(+), 11 deletions(-) create mode 100644 src/core/storybook/globalTextArgs.ts diff --git a/src/apps/advanced-search/AdvancedSearch.dev.tsx b/src/apps/advanced-search/AdvancedSearch.dev.tsx index c99f62d85e..e8aa86b857 100644 --- a/src/apps/advanced-search/AdvancedSearch.dev.tsx +++ b/src/apps/advanced-search/AdvancedSearch.dev.tsx @@ -1,6 +1,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import React from "react"; import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; import AdvancedSearchEntry, { AdvancedSearchEntryProps } from "./AdvancedSearch.entry"; @@ -10,6 +11,7 @@ export default { component: AdvancedSearchEntry, argTypes: { ...serviceUrlArgs, + ...globalTextArgs, pageSizeDesktop: { name: "Number of search result items on desktop", defaultValue: 50, diff --git a/src/apps/advanced-search/AdvancedSearch.entry.tsx b/src/apps/advanced-search/AdvancedSearch.entry.tsx index 04ec8a28fc..18f840a942 100644 --- a/src/apps/advanced-search/AdvancedSearch.entry.tsx +++ b/src/apps/advanced-search/AdvancedSearch.entry.tsx @@ -6,6 +6,7 @@ import { withText } from "../../core/utils/text"; import { withUrls } from "../../core/utils/url"; import GlobalUrlEntryPropsInterface from "../../core/utils/types/global-url-props"; import AdvancedSearch from "./AdvancedSearch"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; interface AdvancedSearchEntryTextProps { addToFavoritesAriaLabelText: string; @@ -79,6 +80,7 @@ interface AdvancedSearchEntryConfigProps { export interface AdvancedSearchEntryProps extends GlobalUrlEntryPropsInterface, + GlobalEntryTextProps, AdvancedSearchEntryConfigProps, AdvancedSearchEntryTextProps { pageSizeDesktop?: number; diff --git a/src/apps/create-patron-user-info/CreatePatron.dev.tsx b/src/apps/create-patron-user-info/CreatePatron.dev.tsx index fe73273eab..a1343a94a0 100644 --- a/src/apps/create-patron-user-info/CreatePatron.dev.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.dev.tsx @@ -3,6 +3,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import CreatePatron from "./CreatePatron.entry"; import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import pincodeArgs from "../../core/storybook/pincodeArgs"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Create patron", @@ -10,6 +11,7 @@ export default { argTypes: { ...serviceUrlArgs, ...pincodeArgs, + ...globalTextArgs, blacklistedPickupBranchesConfig: { defaultValue: "FBS-751032,FBS-751031,FBS-751009,FBS-751027,FBS-751024", control: { type: "text" } diff --git a/src/apps/create-patron-user-info/CreatePatron.entry.tsx b/src/apps/create-patron-user-info/CreatePatron.entry.tsx index 4174257c1d..7ac889631d 100644 --- a/src/apps/create-patron-user-info/CreatePatron.entry.tsx +++ b/src/apps/create-patron-user-info/CreatePatron.entry.tsx @@ -4,6 +4,7 @@ import { withText } from "../../core/utils/text"; import { withUrls } from "../../core/utils/url"; import CreatePatron from "./CreatePatron"; import { getToken, hasToken } from "../../core/token"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; interface CreatePatronConfigProps { agencyConfig: string; @@ -49,6 +50,7 @@ interface CreatePatronTextProps { export interface CreatePatronProps extends CreatePatronConfigProps, + GlobalEntryTextProps, CreatePatronUrlProps, CreatePatronTextProps {} diff --git a/src/apps/dashboard/dashboard.dev.tsx b/src/apps/dashboard/dashboard.dev.tsx index bcbe1541b2..6ea43e433e 100644 --- a/src/apps/dashboard/dashboard.dev.tsx +++ b/src/apps/dashboard/dashboard.dev.tsx @@ -11,6 +11,7 @@ import materialDetailsModalArgs from "../../core/storybook/materialDetailsModalA import deleteReservationModalArgs from "../../core/storybook/deleteReservationModalArgs"; import acceptModalArgs from "../../core/storybook/acceptFeesModalArgs"; import reservationListArgs from "../../core/storybook/reservationListArgs"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Dashboard", @@ -25,6 +26,7 @@ export default { ...materialDetailsModalArgs, ...deleteReservationModalArgs, ...reservationListArgs, + ...globalTextArgs, // Urls physicalLoansUrl: { defaultValue: "/user/me/loans", diff --git a/src/apps/dashboard/dashboard.entry.tsx b/src/apps/dashboard/dashboard.entry.tsx index 26afd0907c..3a59c38834 100644 --- a/src/apps/dashboard/dashboard.entry.tsx +++ b/src/apps/dashboard/dashboard.entry.tsx @@ -12,6 +12,7 @@ import { GroupModalReservationsProps } from "../../core/storybook/reservationGro import { DeleteReservationModalArgs } from "../../core/storybook/deleteReservationModalArgs"; import { AcceptFeesModalEntryTextProps } from "../../core/storybook/acceptFeesModalArgs"; import { RenewalArgs } from "../../core/storybook/renewalArgs"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface DashBoardProps { // Url @@ -70,7 +71,8 @@ const DashboardEntry: FC< GroupModalReservationsProps & RenewalArgs & ReservationMaterialDetailsProps & - MaterialDetailsModalProps + MaterialDetailsModalProps & + GlobalEntryTextProps > = ({ pageSizeDesktop, pageSizeMobile }) => { const pageSize = pageSizeGlobal( { diff --git a/src/apps/demo-modal/demo-modal.dev.tsx b/src/apps/demo-modal/demo-modal.dev.tsx index 8eb8725f53..f5cfad655c 100644 --- a/src/apps/demo-modal/demo-modal.dev.tsx +++ b/src/apps/demo-modal/demo-modal.dev.tsx @@ -2,6 +2,9 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import React from "react"; import { withQuery } from "@storybook/addon-queryparams"; import DemoModal, { DemoModalEntryProps } from "./demo-modal.entry"; +import globalTextArgs, { + GlobalEntryTextProps +} from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Demo modal", @@ -13,6 +16,7 @@ export default { } }, argTypes: { + ...globalTextArgs, ariaLabelModalOneText: { defaultValue: "Luk dialog et" }, @@ -26,5 +30,5 @@ export default { } as ComponentMeta; export const App: ComponentStory = ( - props: DemoModalEntryProps + props: DemoModalEntryProps & GlobalEntryTextProps ) => ; diff --git a/src/apps/demo-modal/demo-modal.entry.tsx b/src/apps/demo-modal/demo-modal.entry.tsx index 07c3d3343a..93ecb96dc2 100644 --- a/src/apps/demo-modal/demo-modal.entry.tsx +++ b/src/apps/demo-modal/demo-modal.entry.tsx @@ -1,6 +1,7 @@ import React from "react"; import { withText } from "../../core/utils/text"; import DemoModal from "./demo-modal"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface DemoModalEntryProps { ariaLabelModalOneText: string; @@ -8,7 +9,7 @@ export interface DemoModalEntryProps { screenReaderModalDescriptionText: string; } -const DemoModalEntry: React.FC = ( +const DemoModalEntry: React.FC = ( props: DemoModalEntryProps ) => ; diff --git a/src/apps/favorites-list-material-component/FavoritesListMaterialComponent.dev.tsx b/src/apps/favorites-list-material-component/FavoritesListMaterialComponent.dev.tsx index 02e4b73ab3..41334bc63f 100644 --- a/src/apps/favorites-list-material-component/FavoritesListMaterialComponent.dev.tsx +++ b/src/apps/favorites-list-material-component/FavoritesListMaterialComponent.dev.tsx @@ -3,6 +3,7 @@ import React from "react"; import { withQuery } from "@storybook/addon-queryparams"; import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import FavoritesListMaterialComponent from "./FavoritesListMaterialComponent.entry"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Favorites list material component", @@ -10,6 +11,7 @@ export default { decorators: [withQuery], argTypes: { ...serviceUrlArgs, + ...globalTextArgs, favoritesListMaterialComponentTitleText: { control: { type: "text" diff --git a/src/apps/favorites-list-material-component/FavoritesListMaterialComponent.entry.tsx b/src/apps/favorites-list-material-component/FavoritesListMaterialComponent.entry.tsx index d009b0729e..4c33b61de9 100644 --- a/src/apps/favorites-list-material-component/FavoritesListMaterialComponent.entry.tsx +++ b/src/apps/favorites-list-material-component/FavoritesListMaterialComponent.entry.tsx @@ -3,7 +3,7 @@ import FavoritesListMaterialComponent from "./FavoritesListMaterialComponent"; import { withText } from "../../core/utils/text"; import { withConfig } from "../../core/utils/config"; import { withUrls } from "../../core/utils/url"; -import { FaustId } from "../../core/utils/types/ids"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface FavoritesListMaterialComponentProps { fbsBaseUrl: string; @@ -23,7 +23,9 @@ export interface FavoritesListMaterialComponentProps { removeFromFavoritesAriaLabelText: string; } -const SomethingSimilarEntry: FC = () => { +const SomethingSimilarEntry: FC< + FavoritesListMaterialComponentProps & GlobalEntryTextProps +> = () => { return ; }; diff --git a/src/apps/favorites-list/FavoritesList.dev.tsx b/src/apps/favorites-list/FavoritesList.dev.tsx index e7cf9ff239..a8fd5f055f 100644 --- a/src/apps/favorites-list/FavoritesList.dev.tsx +++ b/src/apps/favorites-list/FavoritesList.dev.tsx @@ -5,12 +5,14 @@ import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import FavoritesListEntry, { FavoritesListEntryProps } from "./FavoritesList.entry"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Favorite list", component: FavoritesListEntry, argTypes: { ...serviceUrlArgs, + ...globalTextArgs, pageSizeDesktop: { name: "Number of favorite items on desktop", defaultValue: 50, diff --git a/src/apps/favorites-list/FavoritesList.entry.tsx b/src/apps/favorites-list/FavoritesList.entry.tsx index 0cb3ac5010..3ab4ed19da 100644 --- a/src/apps/favorites-list/FavoritesList.entry.tsx +++ b/src/apps/favorites-list/FavoritesList.entry.tsx @@ -5,6 +5,7 @@ import { withText } from "../../core/utils/text"; import { withUrls } from "../../core/utils/url"; import FavoritesList from "./FavoritesList"; import GlobalUrlEntryPropsInterface from "../../core/utils/types/global-url-props"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; interface FavoritesListConfigEntryProps { blacklistedAvailabilityBranchesConfig: string; @@ -27,6 +28,7 @@ interface FavoritesListTextEntryProps { export interface FavoritesListEntryProps extends FavoritesListConfigEntryProps, FavoritesListTextEntryProps, + GlobalEntryTextProps, GlobalUrlEntryPropsInterface { pageSizeDesktop?: number; pageSizeMobile?: number; diff --git a/src/apps/fee-list/FeeList.dev.tsx b/src/apps/fee-list/FeeList.dev.tsx index c363d92b1a..fad6aefb74 100644 --- a/src/apps/fee-list/FeeList.dev.tsx +++ b/src/apps/fee-list/FeeList.dev.tsx @@ -5,6 +5,7 @@ import blockedArgs from "../../core/storybook/blockedArgs"; import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import FeeList from "./FeeList.entry"; import { getModalIds } from "../../core/utils/helpers/modal-helpers"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Fee list", @@ -12,6 +13,7 @@ export default { argTypes: { ...serviceUrlArgs, ...blockedArgs, + ...globalTextArgs, feeListHeadlineText: { defaultValue: "Fees & Replacement costs", control: { type: "text" } diff --git a/src/apps/fee-list/FeeList.entry.tsx b/src/apps/fee-list/FeeList.entry.tsx index 05d17eda3e..8f6047de2b 100644 --- a/src/apps/fee-list/FeeList.entry.tsx +++ b/src/apps/fee-list/FeeList.entry.tsx @@ -6,6 +6,7 @@ import { withUrls } from "../../core/utils/url"; import FeeList from "./FeeList"; import GlobalUrlEntryPropsInterface from "../../core/utils/types/global-url-props"; import { withConfig } from "../../core/utils/config"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface IntermedateListEntryConfigProps { expirationWarningDaysBeforeConfig: string; @@ -49,6 +50,7 @@ const FeeListEntry: FC< FeeListProps & BlockedPatronEntryTextProps & IntermedateListEntryConfigProps & + GlobalEntryTextProps & GlobalUrlEntryPropsInterface > = () => ; diff --git a/src/apps/hello-world/hello-world.dev.tsx b/src/apps/hello-world/hello-world.dev.tsx index 2aa7812376..dc41ae2be0 100644 --- a/src/apps/hello-world/hello-world.dev.tsx +++ b/src/apps/hello-world/hello-world.dev.tsx @@ -1,11 +1,15 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import React from "react"; import HelloWorld, { HelloWorldEntryProps } from "./hello-world.entry"; +import globalTextArgs, { + GlobalEntryTextProps +} from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Hello World", component: HelloWorld, argTypes: { + ...globalTextArgs, titleText: { defaultValue: "Greetings", control: { type: "text" } @@ -22,5 +26,5 @@ export default { } as ComponentMeta; export const App: ComponentStory = ( - args: HelloWorldEntryProps + args: HelloWorldEntryProps & GlobalEntryTextProps ) => ; diff --git a/src/apps/hello-world/hello-world.entry.tsx b/src/apps/hello-world/hello-world.entry.tsx index 36e6d69185..813e321b27 100644 --- a/src/apps/hello-world/hello-world.entry.tsx +++ b/src/apps/hello-world/hello-world.entry.tsx @@ -1,6 +1,7 @@ import React from "react"; import { withText } from "../../core/utils/text"; import HelloWorld from "./hello-world"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface HelloWorldEntryProps { titleText: string; @@ -8,6 +9,8 @@ export interface HelloWorldEntryProps { whatText: string; } -const HelloWorldEntry: React.FC = () => ; +const HelloWorldEntry: React.FC< + HelloWorldEntryProps & GlobalEntryTextProps +> = () => ; export default withText(HelloWorldEntry); diff --git a/src/apps/loan-list/list/loan-list.dev.tsx b/src/apps/loan-list/list/loan-list.dev.tsx index cda58523ff..4e8ea5e9d1 100644 --- a/src/apps/loan-list/list/loan-list.dev.tsx +++ b/src/apps/loan-list/list/loan-list.dev.tsx @@ -3,6 +3,7 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import React from "react"; import serviceUrlArgs from "../../../core/storybook/serviceUrlArgs"; import blockedArgs from "../../../core/storybook/blockedArgs"; +import globalTextArgs from "../../../core/storybook/globalTextArgs"; import LoanList from "./loan-list.entry"; import groupModalArgs from "../../../core/storybook/groupModalArgs"; import loanGroupModalArgs from "../../../core/storybook/loanGroupModalArgs"; @@ -17,6 +18,7 @@ export default { argTypes: { ...serviceUrlArgs, ...groupModalArgs, + ...globalTextArgs, ...loanGroupModalArgs, ...renewalArgs, ...acceptModalArgs, diff --git a/src/apps/loan-list/list/loan-list.entry.tsx b/src/apps/loan-list/list/loan-list.entry.tsx index 0967eb30e0..561f60ab18 100644 --- a/src/apps/loan-list/list/loan-list.entry.tsx +++ b/src/apps/loan-list/list/loan-list.entry.tsx @@ -12,6 +12,7 @@ import { GroupModalLoansProps } from "../../../core/storybook/loanGroupModalArgs import { RenewalArgs } from "../../../core/storybook/renewalArgs"; import { MaterialDetailsModalProps } from "../../../core/storybook/materialDetailsModalArgs"; import { AcceptFeesModalEntryTextProps } from "../../../core/storybook/acceptFeesModalArgs"; +import { GlobalEntryTextProps } from "../../../core/storybook/globalTextArgs"; export interface LoanListEntryConfigProps { expirationWarningDaysBeforeConfig: string; @@ -58,6 +59,7 @@ export interface LoanListEntryWithPageSizeProps extends BlockedPatronEntryTextProps, LoanListEntryTextProps, LoanListEntryConfigProps, + GlobalEntryTextProps, GroupModalProps, GroupModalLoansProps, RenewalArgs, diff --git a/src/apps/material/material.dev.tsx b/src/apps/material/material.dev.tsx index 48bb23d025..80d8b4b342 100644 --- a/src/apps/material/material.dev.tsx +++ b/src/apps/material/material.dev.tsx @@ -2,12 +2,14 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import React from "react"; import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import MaterialEntry, { MaterialEntryProps } from "./material.entry"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Material", component: MaterialEntry, argTypes: { ...serviceUrlArgs, + ...globalTextArgs, searchUrl: { name: "Path to the search result page", defaultValue: "/search", diff --git a/src/apps/material/material.entry.tsx b/src/apps/material/material.entry.tsx index 1295ffa494..793e206c3c 100644 --- a/src/apps/material/material.entry.tsx +++ b/src/apps/material/material.entry.tsx @@ -6,6 +6,7 @@ import { WorkId } from "../../core/utils/types/ids"; import { withUrls } from "../../core/utils/url"; import Material from "./material"; import GlobalUrlEntryPropsInterface from "../../core/utils/types/global-url-props"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; interface MaterialEntryTextProps { addToFavoritesAriaLabelText: string; @@ -187,6 +188,7 @@ interface MaterialEntryConfigProps { export interface MaterialEntryProps extends GlobalUrlEntryPropsInterface, MaterialEntryTextProps, + GlobalEntryTextProps, MaterialEntryConfigProps { wid: WorkId; } diff --git a/src/apps/menu/menu.dev.tsx b/src/apps/menu/menu.dev.tsx index 2fe1605d5e..9d039c62fa 100644 --- a/src/apps/menu/menu.dev.tsx +++ b/src/apps/menu/menu.dev.tsx @@ -10,6 +10,7 @@ import reservationMaterialDetailsProps from "../../core/storybook/reservationMat import materialDetailsModalArgs from "../../core/storybook/materialDetailsModalArgs"; import deleteReservationModalArgs from "../../core/storybook/deleteReservationModalArgs"; import StoryHeader from "../../components/search-bar/story-header.dev.inc"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Header", @@ -23,6 +24,7 @@ export default { ...reservationGroupModalArgs, ...deleteReservationModalArgs, ...materialDetailsModalArgs, + ...globalTextArgs, materialAndAuthorText: { control: { type: "text" diff --git a/src/apps/menu/menu.entry.tsx b/src/apps/menu/menu.entry.tsx index 7fd1f1c777..ada9517096 100644 --- a/src/apps/menu/menu.entry.tsx +++ b/src/apps/menu/menu.entry.tsx @@ -12,6 +12,7 @@ import { MaterialDetailsModalProps } from "../../core/storybook/materialDetailsM import { ReservationMaterialDetailsProps } from "../../core/storybook/reservationMaterialDetailsArgs"; import { DeleteReservationModalArgs } from "../../core/storybook/deleteReservationModalArgs"; import { RenewalArgs } from "../../core/storybook/renewalArgs"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface MenuProps { menuUserProfileUrlText: string; @@ -55,6 +56,7 @@ export interface MenuEntryProps DeleteReservationModalArgs, GroupModalReservationsProps, MaterialDetailsModalProps, + GlobalEntryTextProps, ReservationMaterialDetailsProps {} const MenuEntry: FC = ({ pageSizeDesktop, pageSizeMobile }) => { diff --git a/src/apps/patron-page/PatronPage.dev.tsx b/src/apps/patron-page/PatronPage.dev.tsx index 5977cb7329..95b31f8831 100644 --- a/src/apps/patron-page/PatronPage.dev.tsx +++ b/src/apps/patron-page/PatronPage.dev.tsx @@ -4,6 +4,7 @@ import PatronPage from "./PatronPage.entry"; import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import pincodeArgs from "../../core/storybook/pincodeArgs"; import blockedArgs from "../../core/storybook/blockedArgs"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Patron page", @@ -12,6 +13,7 @@ export default { ...serviceUrlArgs, ...pincodeArgs, ...blockedArgs, + ...globalTextArgs, // Config pauseReservationStartDateConfig: { defaultValue: "2022-06-30", diff --git a/src/apps/patron-page/PatronPage.entry.tsx b/src/apps/patron-page/PatronPage.entry.tsx index 11a14c75b7..006ec2d70a 100644 --- a/src/apps/patron-page/PatronPage.entry.tsx +++ b/src/apps/patron-page/PatronPage.entry.tsx @@ -6,6 +6,7 @@ import PatronPage from "./PatronPage"; import { BlockedPatronEntryTextProps } from "../../core/storybook/blockedArgs"; import withIsPatronBlockedHoc from "../../core/utils/withIsPatronBlockedHoc"; import GlobalUrlEntryPropsInterface from "../../core/utils/types/global-url-props"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; interface PatronPageConfigProps { blacklistedPickupBranchesConfig: string; @@ -81,6 +82,7 @@ export interface PatronPageProps BlockedPatronEntryTextProps, PatronPageTextProps, PatronPageUrlProps, + GlobalEntryTextProps, GlobalUrlEntryPropsInterface {} const PatronPageEntry: FC = () => ; diff --git a/src/apps/recommender/Recommender.dev.tsx b/src/apps/recommender/Recommender.dev.tsx index ff65612926..3e9cd4cb06 100644 --- a/src/apps/recommender/Recommender.dev.tsx +++ b/src/apps/recommender/Recommender.dev.tsx @@ -2,12 +2,14 @@ import { ComponentMeta, ComponentStory } from "@storybook/react"; import React from "react"; import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import Recommender from "./Recommender.entry"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Recommender", component: Recommender, argTypes: { ...serviceUrlArgs, + ...globalTextArgs, emptyRecommenderSearchConfig: { defaultValue: "Mimbo jimbo", control: { type: "text" } diff --git a/src/apps/recommender/Recommender.entry.tsx b/src/apps/recommender/Recommender.entry.tsx index a5333a399c..b86499dff8 100644 --- a/src/apps/recommender/Recommender.entry.tsx +++ b/src/apps/recommender/Recommender.entry.tsx @@ -5,6 +5,7 @@ import { withConfig } from "../../core/utils/config"; import { withUrls } from "../../core/utils/url"; import GuardedApp from "../../components/guarded-app"; import GlobalUrlEntryPropsInterface from "../../core/utils/types/global-url-props"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface RecommenderProps { emptyRecommenderSearchConfig: string; @@ -20,6 +21,7 @@ export interface RecommenderProps { export interface ReccommenderPropsInterface extends GlobalUrlEntryPropsInterface, + GlobalEntryTextProps, RecommenderProps { q?: string; pageSizeDesktop?: number; diff --git a/src/apps/reservation-list/list/reservation-list.dev.tsx b/src/apps/reservation-list/list/reservation-list.dev.tsx index 4f6f3ff491..cd88f49061 100644 --- a/src/apps/reservation-list/list/reservation-list.dev.tsx +++ b/src/apps/reservation-list/list/reservation-list.dev.tsx @@ -8,6 +8,7 @@ import reservationMaterialDetailsProps from "../../../core/storybook/reservation import deleteReservationModalArgs from "../../../core/storybook/deleteReservationModalArgs"; import reservationListArgs from "../../../core/storybook/reservationListArgs"; import { getModalIds } from "../../../core/utils/helpers/modal-helpers"; +import globalTextArgs from "../../../core/storybook/globalTextArgs"; export default { title: "Apps / Reservation list", @@ -19,6 +20,7 @@ export default { ...reservationMaterialDetailsProps, ...blockedArgs, ...reservationListArgs, + ...globalTextArgs, blacklistedSearchBranchesConfig: { name: "Blacklisted branches", defaultValue: "FBS-751032,FBS-751031,FBS-751009,FBS-751027,FBS-751024", diff --git a/src/apps/reservation-list/list/reservation-list.entry.tsx b/src/apps/reservation-list/list/reservation-list.entry.tsx index b378a3668e..1e813b3b37 100644 --- a/src/apps/reservation-list/list/reservation-list.entry.tsx +++ b/src/apps/reservation-list/list/reservation-list.entry.tsx @@ -9,6 +9,7 @@ import { BlockedPatronEntryTextProps } from "../../../core/storybook/blockedArgs import GlobalUrlEntryPropsInterface from "../../../core/utils/types/global-url-props"; import { ReservationMaterialDetailsProps } from "../../../core/storybook/reservationMaterialDetailsArgs"; import { DeleteReservationModalArgs } from "../../../core/storybook/deleteReservationModalArgs"; +import { GlobalEntryTextProps } from "../../../core/storybook/globalTextArgs"; export interface ReservationListUrlProps { expirationWarningDaysBeforeConfig: string; @@ -77,6 +78,7 @@ export interface ReservationListEntryWithPageSizeProps ReservationListUrlProps, DeleteReservationModalArgs, ReservationMaterialDetailsProps, + GlobalEntryTextProps, GlobalUrlEntryPropsInterface { pageSizeDesktop?: number; pageSizeMobile?: number; diff --git a/src/apps/search-header/search-header.dev.tsx b/src/apps/search-header/search-header.dev.tsx index 38fd82cae3..f7390f0034 100644 --- a/src/apps/search-header/search-header.dev.tsx +++ b/src/apps/search-header/search-header.dev.tsx @@ -5,12 +5,14 @@ import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import SearchHeaderEntry, { SearchHeaderEntryProps } from "./search-header.entry"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Header", component: SearchHeaderEntry, argTypes: { ...serviceUrlArgs, + ...globalTextArgs, alertErrorCloseText: { name: "Alert error close text", defaultValue: "close", diff --git a/src/apps/search-header/search-header.entry.tsx b/src/apps/search-header/search-header.entry.tsx index c4fb2fa9e8..7d5d869a47 100644 --- a/src/apps/search-header/search-header.entry.tsx +++ b/src/apps/search-header/search-header.entry.tsx @@ -3,6 +3,7 @@ import { withText } from "../../core/utils/text"; import { withUrls } from "../../core/utils/url"; import SearchHeader from "./search-header"; import GlobalUrlEntryPropsInterface from "../../core/utils/types/global-url-props"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface SearchHeaderTextProps { alertErrorCloseText: string; @@ -30,6 +31,7 @@ export interface SearchHeaderTextProps { export interface SearchHeaderEntryProps extends SearchHeaderTextProps, + GlobalEntryTextProps, GlobalUrlEntryPropsInterface {} const SearchHeaderEntry: React.FC = () => { diff --git a/src/apps/search-result/search-result.dev.tsx b/src/apps/search-result/search-result.dev.tsx index 926d477a32..426a4bdcfd 100644 --- a/src/apps/search-result/search-result.dev.tsx +++ b/src/apps/search-result/search-result.dev.tsx @@ -4,12 +4,14 @@ import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import SearchResultEntry, { SearchResultEntryProps } from "./search-result.entry"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Search Result", component: SearchResultEntry, argTypes: { ...serviceUrlArgs, + ...globalTextArgs, q: { name: "Search string", defaultValue: "harry", diff --git a/src/apps/search-result/search-result.entry.tsx b/src/apps/search-result/search-result.entry.tsx index f67649694b..356265fadd 100644 --- a/src/apps/search-result/search-result.entry.tsx +++ b/src/apps/search-result/search-result.entry.tsx @@ -6,6 +6,7 @@ import { withText } from "../../core/utils/text"; import { withUrls } from "../../core/utils/url"; import SearchResult from "./search-result"; import GlobalUrlEntryPropsInterface from "../../core/utils/types/global-url-props"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; interface SearchResultEntryTextProps { addMoreFiltersText: string; @@ -52,6 +53,7 @@ interface SearchResultEntryConfigProps { export interface SearchResultEntryProps extends GlobalUrlEntryPropsInterface, SearchResultEntryConfigProps, + GlobalEntryTextProps, SearchResultEntryTextProps { q?: string; pageSizeDesktop?: number; diff --git a/src/apps/something-similar/SomethingSimilar.dev.tsx b/src/apps/something-similar/SomethingSimilar.dev.tsx index d2b7174756..5520f34e25 100644 --- a/src/apps/something-similar/SomethingSimilar.dev.tsx +++ b/src/apps/something-similar/SomethingSimilar.dev.tsx @@ -3,6 +3,7 @@ import React from "react"; import { withQuery } from "@storybook/addon-queryparams"; import serviceUrlArgs from "../../core/storybook/serviceUrlArgs"; import SomethingSimilar from "./SomethingSimilar.entry"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; export default { title: "Apps / Something similar", @@ -10,6 +11,7 @@ export default { decorators: [withQuery], argTypes: { ...serviceUrlArgs, + ...globalTextArgs, somethingSimilarTitleText: { control: { type: "text" diff --git a/src/apps/something-similar/SomethingSimilar.entry.tsx b/src/apps/something-similar/SomethingSimilar.entry.tsx index 445ba00796..48ef884233 100644 --- a/src/apps/something-similar/SomethingSimilar.entry.tsx +++ b/src/apps/something-similar/SomethingSimilar.entry.tsx @@ -4,6 +4,7 @@ import { withText } from "../../core/utils/text"; import { withConfig } from "../../core/utils/config"; import { withUrls } from "../../core/utils/url"; import { FaustId } from "../../core/utils/types/ids"; +import { GlobalEntryTextProps } from "../../core/storybook/globalTextArgs"; export interface SomethingSimilarProps { fbsBaseUrl: string; @@ -24,7 +25,9 @@ export interface SomethingSimilarProps { faust: FaustId; } -const SomethingSimilarEntry: FC = ({ faust }) => { +const SomethingSimilarEntry: FC< + SomethingSimilarProps & GlobalEntryTextProps +> = ({ faust }) => { return ; }; diff --git a/src/components/availability-label/availability-label.dev.tsx b/src/components/availability-label/availability-label.dev.tsx index 27277e7f70..fd3a631898 100644 --- a/src/components/availability-label/availability-label.dev.tsx +++ b/src/components/availability-label/availability-label.dev.tsx @@ -9,6 +9,7 @@ import { AvailabilityLabelProps, AvailabilityLabel } from "./availability-label"; +import globalTextArgs from "../../core/storybook/globalTextArgs"; // The configuration below addresses the different variables, // their default values, and how they translate into storybook @@ -18,6 +19,7 @@ export default { component: AvailabilityLabel, argTypes: { ...serviceUrlArgs, + ...globalTextArgs, faustIds: { name: "Faust Ids", control: { type: "array" } diff --git a/src/components/blocked-patron/blocked-modal/BlockedModal.tsx b/src/components/blocked-patron/blocked-modal/BlockedModal.tsx index 6d2cd58c88..6073368fee 100644 --- a/src/components/blocked-patron/blocked-modal/BlockedModal.tsx +++ b/src/components/blocked-patron/blocked-modal/BlockedModal.tsx @@ -17,6 +17,10 @@ const BlockedModal: FC = ({ blockedStatus }) => { const { blockedModal } = getModalIds(); + if (!blockedStatus || blockedStatus === "") { + return null; + } + return ( = ({ {t("alertErrorMessageText")}