From e28e09493fc55e5d9e366e36820350471841ed66 Mon Sep 17 00:00:00 2001 From: Vasilii Burlacu Date: Wed, 10 Mar 2021 01:04:16 +0200 Subject: [PATCH] #1617 - Fetch store name from the GraphQL server at compile time (#3019) * #1617 - Fetch store name from the GraphQL server at compile time * format the code with prettier * remove unnecessary declarations * Simplify the process of finding the available store Co-authored-by: Stephen * Simplify the assignment of current store name Co-authored-by: Stephen * Fix destructure syntax * prettier * availableStore -> availableStores * Use runtime store name fetch in a new TitleWithStore component. Signed-off-by: sirugh * StoreTitle * Fix tests * Fix error view rendering when data was still returned Signed-off-by: sirugh * fix test snap Signed-off-by: sirugh Co-authored-by: Stephen Co-authored-by: Stephen Co-authored-by: Revanth Kumar Annavarapu <35203638+revanth0212@users.noreply.github.com> Co-authored-by: Devagouda <40405790+dpatil-magento@users.noreply.github.com> --- .../i18n/fr_FR.json | 10 ++--- .../useCategoryContent.spec.js.snap | 2 - .../Category/useCategoryContent.js | 6 --- .../lib/queries/getStoreConfigData.graphql | 1 + packages/venia-concept/template.html | 2 - packages/venia-concept/webpack.config.js | 13 ++++++- packages/venia-ui/i18n/en_US.json | 10 ++--- .../RootComponents/CMS/__tests__/cms.spec.js | 6 +-- .../venia-ui/lib/RootComponents/CMS/cms.js | 4 +- .../Category/__tests__/category.spec.js | 2 +- .../__tests__/categoryContent.spec.js | 2 +- .../Category/categoryContent.js | 5 +-- .../__snapshots__/product.spec.js.snap | 12 +++--- .../lib/RootComponents/Product/product.js | 7 +--- .../__tests__/accountInformationPage.spec.js | 2 +- .../accountInformationPage.js | 17 ++++----- .../__tests__/addressBookPage.spec.js | 2 +- .../AddressBookPage/addressBookPage.js | 6 +-- .../__tests__/__snapshots__/app.spec.js.snap | 8 +--- .../lib/components/App/__tests__/app.spec.js | 2 +- packages/venia-ui/lib/components/App/app.js | 6 +-- .../__snapshots__/cartPage.spec.js.snap | 2 + .../CartPage/__tests__/cartPage.spec.js | 29 ++++----------- .../lib/components/CartPage/cartPage.js | 17 ++++----- .../__tests__/orderConfirmationPage.spec.js | 2 +- .../orderConfirmationPage.js | 17 ++++----- .../__tests__/checkoutPage.spec.js | 2 +- .../components/CheckoutPage/checkoutPage.js | 17 ++++----- .../__tests__/communicationsPage.spec.js | 2 +- .../CommunicationsPage/communicationsPage.js | 15 +++----- .../venia-ui/lib/components/Head/index.js | 37 ++++++++++++++++++- .../__snapshots__/resetPassword.spec.js.snap | 24 ++++++------ .../__tests__/resetPassword.spec.js | 2 +- .../MyAccount/ResetPassword/resetPassword.js | 7 +--- .../__tests__/orderHistoryPage.spec.js | 2 +- .../OrderHistoryPage/orderHistoryPage.js | 7 +--- .../__tests__/savedPaymentsPage.spec.js | 2 +- .../SavedPaymentsPage/savedPaymentsPage.js | 4 +- .../modify-site-footer/index.md | 6 +-- 39 files changed, 156 insertions(+), 163 deletions(-) diff --git a/packages/extensions/venia-sample-language-packs/i18n/fr_FR.json b/packages/extensions/venia-sample-language-packs/i18n/fr_FR.json index 3b225139c3..b12d23ce99 100644 --- a/packages/extensions/venia-sample-language-packs/i18n/fr_FR.json +++ b/packages/extensions/venia-sample-language-packs/i18n/fr_FR.json @@ -5,7 +5,7 @@ "accountInformationPage.accountInformation": "Informations sur le compte", "accountInformationPage.editAccount": "Modifier les informations du compte", "accountInformationPage.errorTryAgain": "Un problème est survenu. Veuillez actualiser et réessayer.", - "accountInformationPage.titleAccount": "Information sur le compte - {name}", + "accountInformationPage.titleAccount": "Information sur le compte", "accountMenu.accountInfoLink": "Information sur le compte", "accountMenu.addressBookLink": "Carnet d'adresses", "accountMenu.communicationsLink": "Les communications", @@ -39,7 +39,7 @@ "cartPage.emptyCart": "Il n'y a aucun article dans votre panier.", "cartPage.heading": "Panier", "cartPage.signIn": "Se connecter", - "cartPage.title": "Panier - {name}", + "cartPage.title": "Panier", "cartTrigger.ariaLabel": "Basculer le mini-panier. Vous avez {count} articles dans votre panier.", "categoryContent.filter": "Filtre", "categoryContent.itemsSortedBy": "Articles triés par ", @@ -88,8 +88,8 @@ "checkoutPage.stockStatusMessage": "Un article de votre panier est actuellement en rupture de stock et doit être retiré pour pouvoir passer à la caisse. Veuillez retourner à votre panier pour retirer l'article.", "checkoutPage.subscribe": "Abonnez-vous aux nouvelles et mises à jour", "checkoutPage.thankYou": "Nous vous remercions de votre commande!", - "checkoutPage.titleCheckout": "Paiement - {name}", - "checkoutPage.titleReceipt": "Le reçu - {name}", + "checkoutPage.titleCheckout": "Paiement", + "checkoutPage.titleReceipt": "Le reçu", "cms.shopByCategory": "Acheter par catégorie", "cmsBlock.noBlocks": "Il n'y a aucun bloc à afficher", "communicationsPage.changesText": "Sauvegarder les modifications", @@ -99,7 +99,7 @@ "communicationsPage.preferencesText": "Vos préférences ont été mises à jour.", "communicationsPage.savingText": "Économie", "communicationsPage.subscribeText": "Restez à la pointe de la mode; abonnez-vous à la newsletter mensuelle de Venia.", - "communicationsPage.title": "Les Communications - {name}", + "communicationsPage.title": "Les Communications", "completedView.errorLoading": "Erreur lors du chargement de la méthode d'expédition sélectionnée. Veuillez sélectionner à nouveau.", "completedView.shippingMethod": "Méthode d'expédition", "Contact Us": "Nous contacter", diff --git a/packages/peregrine/lib/talons/RootComponents/Category/__tests__/__snapshots__/useCategoryContent.spec.js.snap b/packages/peregrine/lib/talons/RootComponents/Category/__tests__/__snapshots__/useCategoryContent.spec.js.snap index d1cdad66db..9ccf94613f 100644 --- a/packages/peregrine/lib/talons/RootComponents/Category/__tests__/__snapshots__/useCategoryContent.spec.js.snap +++ b/packages/peregrine/lib/talons/RootComponents/Category/__tests__/__snapshots__/useCategoryContent.spec.js.snap @@ -19,7 +19,6 @@ Object { null, ], "loadFilters": false, - "pageTitle": "Venia", "totalPagesFromData": null, } `; @@ -46,7 +45,6 @@ Object { }, ], "loadFilters": false, - "pageTitle": "Jewelry - Venia", "totalPagesFromData": 1, } `; diff --git a/packages/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js b/packages/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js index 481889a646..5e43bf2b4e 100644 --- a/packages/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js +++ b/packages/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js @@ -21,7 +21,6 @@ const DRAWER_NAME = 'filter'; * @returns {func} result.handleOpenFilters - A callback function that actually opens the filter drawer. * @returns {object} result.items - The items in this category. * @returns {bool} result.loadFilters - Whether or not the user has signalled their intent to interact with the filters. - * @returns {string} result.pageTitle - The text to put in the browser tab for this page. */ export const useCategoryContent = props => { const { categoryId, data, pageSize = 6 } = props; @@ -68,10 +67,6 @@ export const useCategoryContent = props => { : null; const categoryName = data ? data.category.name : null; const categoryDescription = data ? data.category.description : null; - // Note: STORE_NAME is injected by Webpack at build time. - const pageTitle = categoryName - ? `${categoryName} - ${STORE_NAME}` - : STORE_NAME; return { categoryName, @@ -81,7 +76,6 @@ export const useCategoryContent = props => { handleOpenFilters, items, loadFilters, - pageTitle, totalPagesFromData }; }; diff --git a/packages/pwa-buildpack/lib/queries/getStoreConfigData.graphql b/packages/pwa-buildpack/lib/queries/getStoreConfigData.graphql index 67b9d5a0b9..3fa0ba80c0 100644 --- a/packages/pwa-buildpack/lib/queries/getStoreConfigData.graphql +++ b/packages/pwa-buildpack/lib/queries/getStoreConfigData.graphql @@ -5,5 +5,6 @@ query { code locale secure_base_media_url + store_name } } diff --git a/packages/venia-concept/template.html b/packages/venia-concept/template.html index 08e105b941..5978a51b69 100644 --- a/packages/venia-concept/template.html +++ b/packages/venia-concept/template.html @@ -7,8 +7,6 @@ - <%= STORE_NAME %> -