From c410f120886b1634b0f62705736a54e7e9056294 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 24 Aug 2021 12:15:34 +0300 Subject: [PATCH 01/16] Web: Files: show new ads by timeout --- .../Client/src/components/Article/Body/Banner.js | 9 +++++++-- products/ASC.Files/Client/src/helpers/constants.js | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/products/ASC.Files/Client/src/components/Article/Body/Banner.js b/products/ASC.Files/Client/src/components/Article/Body/Banner.js index 4558f5749de..87713d7608f 100644 --- a/products/ASC.Files/Client/src/components/Article/Body/Banner.js +++ b/products/ASC.Files/Client/src/components/Article/Body/Banner.js @@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react"; import { useTranslation } from "react-i18next"; import CampaignsBanner from "@appserver/components/campaigns-banner"; +import { ADS_TIMEOUT } from "../../../helpers/constants"; const Banner = () => { const campaigns = (localStorage.getItem("campaigns") || "") @@ -11,7 +12,9 @@ const Banner = () => { const defaultBannerName = "Cloud"; const [bannerName, setBannerName] = useState(defaultBannerName); - useEffect(() => { + const updateBanner = () => { + console.log("update banner"); + let index = Number(localStorage.getItem("bannerIndex") || 0); const campaign = campaigns[index]; @@ -23,7 +26,7 @@ const Banner = () => { localStorage.setItem("bannerIndex", index); setBannerName(campaign); - }, []); + }; const { t, i18n, ready } = useTranslation(`CampaignPersonal${bannerName}`, { useSuspense: false, @@ -37,6 +40,8 @@ const Banner = () => { return <>; } + setTimeout(updateBanner, ADS_TIMEOUT); + return ( Date: Tue, 24 Aug 2021 21:52:01 +0300 Subject: [PATCH 02/16] Web: added firebase storage --- packages/asc-web-common/utils/firebase.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/asc-web-common/utils/firebase.js b/packages/asc-web-common/utils/firebase.js index c655b865d74..b7dfe158541 100644 --- a/packages/asc-web-common/utils/firebase.js +++ b/packages/asc-web-common/utils/firebase.js @@ -1,9 +1,12 @@ import firebase from "firebase/app"; import "firebase/remote-config"; +import "firebase/storage"; class FirebaseHelper { remoteConfig = null; firebaseConfig = null; + firebaseStorage = null; + constructor(settings) { this.firebaseConfig = settings; @@ -15,6 +18,8 @@ class FirebaseHelper { firebase.app(); } + this.firebaseStorage = firebase.storage(); + this.remoteConfig = firebase.remoteConfig(); this.remoteConfig.settings = { @@ -87,6 +92,14 @@ class FirebaseHelper { return await Promise.resolve(campaigns); } + + async getCampaignsImages(banner) { + const storageRef = this.firebaseStorage.ref(); + const tangRef = storageRef.child( + `campaigns/images/campaigns.${banner}.png` + ); + return await tangRef.getDownloadURL(); + } } export default FirebaseHelper; From 725091a9fd23dec5c2f7f6f831bb0e3b88335710 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 25 Aug 2021 15:26:34 +0300 Subject: [PATCH 03/16] Web: Files: get banner image from firebase storage --- .../src/components/Article/Body/Banner.js | 19 ++++++++++++++----- .../src/components/Article/Body/index.js | 4 +++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/products/ASC.Files/Client/src/components/Article/Body/Banner.js b/products/ASC.Files/Client/src/components/Article/Body/Banner.js index 87713d7608f..521399d711c 100644 --- a/products/ASC.Files/Client/src/components/Article/Body/Banner.js +++ b/products/ASC.Files/Client/src/components/Article/Body/Banner.js @@ -4,15 +4,16 @@ import { useTranslation } from "react-i18next"; import CampaignsBanner from "@appserver/components/campaigns-banner"; import { ADS_TIMEOUT } from "../../../helpers/constants"; -const Banner = () => { +const Banner = ({ FirebaseHelper }) => { const campaigns = (localStorage.getItem("campaigns") || "") .split(",") .filter((campaign) => campaign.length > 0); const defaultBannerName = "Cloud"; const [bannerName, setBannerName] = useState(defaultBannerName); + const [bannerImage, setBannerImage] = useState(""); - const updateBanner = () => { + const updateBanner = async () => { console.log("update banner"); let index = Number(localStorage.getItem("bannerIndex") || 0); @@ -26,8 +27,18 @@ const Banner = () => { localStorage.setItem("bannerIndex", index); setBannerName(campaign); + + const image = await FirebaseHelper.getCampaignsImages( + campaign.toLowerCase() + ); + setBannerImage(image); }; + useEffect(() => { + updateBanner(); + setInterval(updateBanner, ADS_TIMEOUT); + }, []); + const { t, i18n, ready } = useTranslation(`CampaignPersonal${bannerName}`, { useSuspense: false, }); @@ -40,13 +51,11 @@ const Banner = () => { return <>; } - setTimeout(updateBanner, ADS_TIMEOUT); - return ( diff --git a/products/ASC.Files/Client/src/components/Article/Body/index.js b/products/ASC.Files/Client/src/components/Article/Body/index.js index bbe69f9f008..f3104e5a842 100644 --- a/products/ASC.Files/Client/src/components/Article/Body/index.js +++ b/products/ASC.Files/Client/src/components/Article/Body/index.js @@ -82,6 +82,7 @@ class ArticleBodyContent extends React.Component { enableThirdParty, isVisitor, personal, + FirebaseHelper, } = this.props; const campaigns = (localStorage.getItem("campaigns") || "") @@ -103,7 +104,7 @@ class ArticleBodyContent extends React.Component { {enableThirdParty && !isVisitor && } {(isDesktop || isTablet) && personal && campaigns.length > 0 && ( - + )} ); @@ -152,6 +153,7 @@ export default inject( homepage: config.homepage, personal, + FirebaseHelper: auth.settingsStore.firebaseHelper, }; } )(observer(withRouter(ArticleBodyContent))); From 24e13fb79d888b7a9c3d462384d826e8b759a4b9 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 7 Sep 2021 12:47:53 +0300 Subject: [PATCH 04/16] Web: deleted campaigns locales --- public/locales/de/CampaignPersonalCloud.json | 6 ------ public/locales/de/CampaignPersonalDesktop.json | 6 ------ public/locales/de/CampaignPersonalEducation.json | 6 ------ public/locales/de/CampaignPersonalEnterprise.json | 6 ------ public/locales/de/CampaignPersonalIntegration.json | 6 ------ public/locales/en/CampaignPersonalCloud.json | 6 ------ public/locales/en/CampaignPersonalDesktop.json | 6 ------ public/locales/en/CampaignPersonalEducation.json | 6 ------ public/locales/en/CampaignPersonalEnterprise.json | 6 ------ public/locales/en/CampaignPersonalIntegration.json | 6 ------ public/locales/fr/CampaignPersonalCloud.json | 6 ------ public/locales/fr/CampaignPersonalDesktop.json | 6 ------ public/locales/fr/CampaignPersonalEducation.json | 6 ------ public/locales/fr/CampaignPersonalEnterprise.json | 6 ------ public/locales/fr/CampaignPersonalIntegration.json | 6 ------ public/locales/it/CampaignPersonalCloud.json | 6 ------ public/locales/it/CampaignPersonalDesktop.json | 6 ------ public/locales/it/CampaignPersonalEducation.json | 6 ------ public/locales/it/CampaignPersonalEnterprise.json | 6 ------ public/locales/it/CampaignPersonalIntegration.json | 6 ------ public/locales/lo/CampaignPersonalCloud.json | 6 ------ public/locales/lo/CampaignPersonalDesktop.json | 6 ------ public/locales/lo/CampaignPersonalEducation.json | 6 ------ public/locales/lo/CampaignPersonalEnterprise.json | 6 ------ public/locales/lo/CampaignPersonalIntegration.json | 6 ------ public/locales/pt-BR/CampaignPersonalCloud.json | 6 ------ public/locales/pt-BR/CampaignPersonalDesktop.json | 6 ------ public/locales/pt-BR/CampaignPersonalEducation.json | 6 ------ public/locales/pt-BR/CampaignPersonalEnterprise.json | 6 ------ public/locales/pt-BR/CampaignPersonalIntegration.json | 6 ------ public/locales/ro/CampaignPersonalCloud.json | 6 ------ public/locales/ro/CampaignPersonalDesktop.json | 6 ------ public/locales/ro/CampaignPersonalEducation.json | 6 ------ public/locales/ro/CampaignPersonalEnterprise.json | 6 ------ public/locales/ro/CampaignPersonalIntegration.json | 6 ------ public/locales/ru/CampaignPersonalCloud.json | 6 ------ public/locales/ru/CampaignPersonalDesktop.json | 6 ------ public/locales/ru/CampaignPersonalEducation.json | 6 ------ public/locales/ru/CampaignPersonalEnterprise.json | 6 ------ public/locales/ru/CampaignPersonalIntegration.json | 6 ------ public/locales/sk/CampaignPersonalCloud.json | 6 ------ public/locales/sk/CampaignPersonalDesktop.json | 6 ------ public/locales/sk/CampaignPersonalEducation.json | 6 ------ public/locales/sk/CampaignPersonalEnterprise.json | 6 ------ public/locales/sk/CampaignPersonalIntegration.json | 6 ------ 45 files changed, 270 deletions(-) delete mode 100644 public/locales/de/CampaignPersonalCloud.json delete mode 100644 public/locales/de/CampaignPersonalDesktop.json delete mode 100644 public/locales/de/CampaignPersonalEducation.json delete mode 100644 public/locales/de/CampaignPersonalEnterprise.json delete mode 100644 public/locales/de/CampaignPersonalIntegration.json delete mode 100644 public/locales/en/CampaignPersonalCloud.json delete mode 100644 public/locales/en/CampaignPersonalDesktop.json delete mode 100644 public/locales/en/CampaignPersonalEducation.json delete mode 100644 public/locales/en/CampaignPersonalEnterprise.json delete mode 100644 public/locales/en/CampaignPersonalIntegration.json delete mode 100644 public/locales/fr/CampaignPersonalCloud.json delete mode 100644 public/locales/fr/CampaignPersonalDesktop.json delete mode 100644 public/locales/fr/CampaignPersonalEducation.json delete mode 100644 public/locales/fr/CampaignPersonalEnterprise.json delete mode 100644 public/locales/fr/CampaignPersonalIntegration.json delete mode 100644 public/locales/it/CampaignPersonalCloud.json delete mode 100644 public/locales/it/CampaignPersonalDesktop.json delete mode 100644 public/locales/it/CampaignPersonalEducation.json delete mode 100644 public/locales/it/CampaignPersonalEnterprise.json delete mode 100644 public/locales/it/CampaignPersonalIntegration.json delete mode 100644 public/locales/lo/CampaignPersonalCloud.json delete mode 100644 public/locales/lo/CampaignPersonalDesktop.json delete mode 100644 public/locales/lo/CampaignPersonalEducation.json delete mode 100644 public/locales/lo/CampaignPersonalEnterprise.json delete mode 100644 public/locales/lo/CampaignPersonalIntegration.json delete mode 100644 public/locales/pt-BR/CampaignPersonalCloud.json delete mode 100644 public/locales/pt-BR/CampaignPersonalDesktop.json delete mode 100644 public/locales/pt-BR/CampaignPersonalEducation.json delete mode 100644 public/locales/pt-BR/CampaignPersonalEnterprise.json delete mode 100644 public/locales/pt-BR/CampaignPersonalIntegration.json delete mode 100644 public/locales/ro/CampaignPersonalCloud.json delete mode 100644 public/locales/ro/CampaignPersonalDesktop.json delete mode 100644 public/locales/ro/CampaignPersonalEducation.json delete mode 100644 public/locales/ro/CampaignPersonalEnterprise.json delete mode 100644 public/locales/ro/CampaignPersonalIntegration.json delete mode 100644 public/locales/ru/CampaignPersonalCloud.json delete mode 100644 public/locales/ru/CampaignPersonalDesktop.json delete mode 100644 public/locales/ru/CampaignPersonalEducation.json delete mode 100644 public/locales/ru/CampaignPersonalEnterprise.json delete mode 100644 public/locales/ru/CampaignPersonalIntegration.json delete mode 100644 public/locales/sk/CampaignPersonalCloud.json delete mode 100644 public/locales/sk/CampaignPersonalDesktop.json delete mode 100644 public/locales/sk/CampaignPersonalEducation.json delete mode 100644 public/locales/sk/CampaignPersonalEnterprise.json delete mode 100644 public/locales/sk/CampaignPersonalIntegration.json diff --git a/public/locales/de/CampaignPersonalCloud.json b/public/locales/de/CampaignPersonalCloud.json deleted file mode 100644 index 8feac73ba1a..00000000000 --- a/public/locales/de/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE für Business", - "SubHeader": "Dokumente, Projekte, Kunden & E-Mails", - "ButtonLabel": "Kostenlos testen", - "Link": "https://www.onlyoffice.com/de/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/de/CampaignPersonalDesktop.json b/public/locales/de/CampaignPersonalDesktop.json deleted file mode 100644 index f6acf1d7059..00000000000 --- a/public/locales/de/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE für PC", - "SubHeader": "Gratis Alternative zu MS Office", - "ButtonLabel": "Herunterladen", - "Link": "https://www.onlyoffice.com/de/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/de/CampaignPersonalEducation.json b/public/locales/de/CampaignPersonalEducation.json deleted file mode 100644 index eda8be68c2e..00000000000 --- a/public/locales/de/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE für Schulen", - "SubHeader": "Endecken Sie alle Rabatte", - "ButtonLabel": "Mehr erfahren", - "Link": "https://www.onlyoffice.com/de/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/de/CampaignPersonalEnterprise.json b/public/locales/de/CampaignPersonalEnterprise.json deleted file mode 100644 index cee960017cf..00000000000 --- a/public/locales/de/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE On-Premises", - "SubHeader": "Schützen Sie Ihre Dokumente", - "ButtonLabel": "Jetzt erhalten", - "Link": "https://www.onlyoffice.com/de/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/de/CampaignPersonalIntegration.json b/public/locales/de/CampaignPersonalIntegration.json deleted file mode 100644 index 71495459cc4..00000000000 --- a/public/locales/de/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE Integration", - "SubHeader": "Editoren für Ihre Plattform", - "ButtonLabel": "Jetzt integrieren", - "Link": "https://www.onlyoffice.com/de/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} diff --git a/public/locales/en/CampaignPersonalCloud.json b/public/locales/en/CampaignPersonalCloud.json deleted file mode 100644 index 4ad7c5f06f3..00000000000 --- a/public/locales/en/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for business", - "SubHeader": "Docs, projects, clients & emails", - "ButtonLabel": "Start free trial", - "Link": "https://www.onlyoffice.com/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/en/CampaignPersonalDesktop.json b/public/locales/en/CampaignPersonalDesktop.json deleted file mode 100644 index 2162ac26074..00000000000 --- a/public/locales/en/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for PC", - "SubHeader": "Get a free alternative to MS Office", - "ButtonLabel": "Download", - "Link": "https://www.onlyoffice.com/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/en/CampaignPersonalEducation.json b/public/locales/en/CampaignPersonalEducation.json deleted file mode 100644 index 9bb6588eba1..00000000000 --- a/public/locales/en/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for schools", - "SubHeader": "Learn about education discounts", - "ButtonLabel": "Learn more", - "Link": "https://www.onlyoffice.com/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/en/CampaignPersonalEnterprise.json b/public/locales/en/CampaignPersonalEnterprise.json deleted file mode 100644 index 25ce985a869..00000000000 --- a/public/locales/en/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE on-premises", - "SubHeader": "Keep your docs and projects safe", - "ButtonLabel": "Get it now", - "Link": "https://www.onlyoffice.com/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/en/CampaignPersonalIntegration.json b/public/locales/en/CampaignPersonalIntegration.json deleted file mode 100644 index 4e35e4aa51e..00000000000 --- a/public/locales/en/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for integration", - "SubHeader": "Use online editors with your platform", - "ButtonLabel": "Integrate now", - "Link": "https://www.onlyoffice.com/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} diff --git a/public/locales/fr/CampaignPersonalCloud.json b/public/locales/fr/CampaignPersonalCloud.json deleted file mode 100644 index ad24274f8bd..00000000000 --- a/public/locales/fr/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE pour les entreprises", - "SubHeader": "Documents, projets, clients et mails.", - "ButtonLabel": "Commencer l’essai gratuit", - "Link": "https://www.onlyoffice.com/fr/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/fr/CampaignPersonalDesktop.json b/public/locales/fr/CampaignPersonalDesktop.json deleted file mode 100644 index 691819bf9ba..00000000000 --- a/public/locales/fr/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE pour le PC", - "SubHeader": "Alternative gratuite à MS Office", - "ButtonLabel": "Télécharger", - "Link": "https://www.onlyoffice.com/fr/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/fr/CampaignPersonalEducation.json b/public/locales/fr/CampaignPersonalEducation.json deleted file mode 100644 index bc552e1f0c6..00000000000 --- a/public/locales/fr/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE éducation", - "SubHeader": "Voir toutes les offres", - "ButtonLabel": "En savoir plus", - "Link": "https://www.onlyoffice.com/fr/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/fr/CampaignPersonalEnterprise.json b/public/locales/fr/CampaignPersonalEnterprise.json deleted file mode 100644 index 059b4a62759..00000000000 --- a/public/locales/fr/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "Solution auto-hébergée", - "SubHeader": "Vos docs en toute sécurité", - "ButtonLabel": "Obtenir maintenant", - "Link": "https://www.onlyoffice.com/fr/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/fr/CampaignPersonalIntegration.json b/public/locales/fr/CampaignPersonalIntegration.json deleted file mode 100644 index 881af54e26e..00000000000 --- a/public/locales/fr/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE intégration", - "SubHeader": "Éditeurs pour votre plateforme", - "ButtonLabel": "Intégrer maintenant", - "Link": "https://www.onlyoffice.com/fr/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} diff --git a/public/locales/it/CampaignPersonalCloud.json b/public/locales/it/CampaignPersonalCloud.json deleted file mode 100644 index f865288cba6..00000000000 --- a/public/locales/it/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE per business", - "SubHeader": "Documenti, progetti, clienti ed e-mail", - "ButtonLabel": "Inizia la prova gratuita", - "Link": "https://www.onlyoffice.com/it/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/it/CampaignPersonalDesktop.json b/public/locales/it/CampaignPersonalDesktop.json deleted file mode 100644 index fcbda34d926..00000000000 --- a/public/locales/it/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE per PC", - "SubHeader": "Alternativa gratuita a MS Office", - "ButtonLabel": "Scarica", - "Link": "https://www.onlyoffice.com/it/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/it/CampaignPersonalEducation.json b/public/locales/it/CampaignPersonalEducation.json deleted file mode 100644 index beb16f35949..00000000000 --- a/public/locales/it/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE per scuole", - "SubHeader": "Informazioni sugli sconti", - "ButtonLabel": "Per saperne di più", - "Link": "https://www.onlyoffice.com/it/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/it/CampaignPersonalEnterprise.json b/public/locales/it/CampaignPersonalEnterprise.json deleted file mode 100644 index 3bc94f101c4..00000000000 --- a/public/locales/it/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE sul server", - "SubHeader": "Mantieni documenti al sicuro", - "ButtonLabel": "Scaricalo ora", - "Link": "https://www.onlyoffice.com/it/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/it/CampaignPersonalIntegration.json b/public/locales/it/CampaignPersonalIntegration.json deleted file mode 100644 index 53a1af3194e..00000000000 --- a/public/locales/it/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE integrazioni", - "SubHeader": "Editor per la tua piattaforma", - "ButtonLabel": "Connetti ora", - "Link": "https://www.onlyoffice.com/it/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} diff --git a/public/locales/lo/CampaignPersonalCloud.json b/public/locales/lo/CampaignPersonalCloud.json deleted file mode 100644 index 4ad7c5f06f3..00000000000 --- a/public/locales/lo/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for business", - "SubHeader": "Docs, projects, clients & emails", - "ButtonLabel": "Start free trial", - "Link": "https://www.onlyoffice.com/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/lo/CampaignPersonalDesktop.json b/public/locales/lo/CampaignPersonalDesktop.json deleted file mode 100644 index 2162ac26074..00000000000 --- a/public/locales/lo/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for PC", - "SubHeader": "Get a free alternative to MS Office", - "ButtonLabel": "Download", - "Link": "https://www.onlyoffice.com/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/lo/CampaignPersonalEducation.json b/public/locales/lo/CampaignPersonalEducation.json deleted file mode 100644 index 9bb6588eba1..00000000000 --- a/public/locales/lo/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for schools", - "SubHeader": "Learn about education discounts", - "ButtonLabel": "Learn more", - "Link": "https://www.onlyoffice.com/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/lo/CampaignPersonalEnterprise.json b/public/locales/lo/CampaignPersonalEnterprise.json deleted file mode 100644 index 25ce985a869..00000000000 --- a/public/locales/lo/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE on-premises", - "SubHeader": "Keep your docs and projects safe", - "ButtonLabel": "Get it now", - "Link": "https://www.onlyoffice.com/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/lo/CampaignPersonalIntegration.json b/public/locales/lo/CampaignPersonalIntegration.json deleted file mode 100644 index 4e35e4aa51e..00000000000 --- a/public/locales/lo/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for integration", - "SubHeader": "Use online editors with your platform", - "ButtonLabel": "Integrate now", - "Link": "https://www.onlyoffice.com/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} diff --git a/public/locales/pt-BR/CampaignPersonalCloud.json b/public/locales/pt-BR/CampaignPersonalCloud.json deleted file mode 100644 index 4ad7c5f06f3..00000000000 --- a/public/locales/pt-BR/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for business", - "SubHeader": "Docs, projects, clients & emails", - "ButtonLabel": "Start free trial", - "Link": "https://www.onlyoffice.com/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/pt-BR/CampaignPersonalDesktop.json b/public/locales/pt-BR/CampaignPersonalDesktop.json deleted file mode 100644 index 2162ac26074..00000000000 --- a/public/locales/pt-BR/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for PC", - "SubHeader": "Get a free alternative to MS Office", - "ButtonLabel": "Download", - "Link": "https://www.onlyoffice.com/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/pt-BR/CampaignPersonalEducation.json b/public/locales/pt-BR/CampaignPersonalEducation.json deleted file mode 100644 index 9bb6588eba1..00000000000 --- a/public/locales/pt-BR/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for schools", - "SubHeader": "Learn about education discounts", - "ButtonLabel": "Learn more", - "Link": "https://www.onlyoffice.com/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/pt-BR/CampaignPersonalEnterprise.json b/public/locales/pt-BR/CampaignPersonalEnterprise.json deleted file mode 100644 index 25ce985a869..00000000000 --- a/public/locales/pt-BR/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE on-premises", - "SubHeader": "Keep your docs and projects safe", - "ButtonLabel": "Get it now", - "Link": "https://www.onlyoffice.com/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/pt-BR/CampaignPersonalIntegration.json b/public/locales/pt-BR/CampaignPersonalIntegration.json deleted file mode 100644 index 4e35e4aa51e..00000000000 --- a/public/locales/pt-BR/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for integration", - "SubHeader": "Use online editors with your platform", - "ButtonLabel": "Integrate now", - "Link": "https://www.onlyoffice.com/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} diff --git a/public/locales/ro/CampaignPersonalCloud.json b/public/locales/ro/CampaignPersonalCloud.json deleted file mode 100644 index 4ad7c5f06f3..00000000000 --- a/public/locales/ro/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for business", - "SubHeader": "Docs, projects, clients & emails", - "ButtonLabel": "Start free trial", - "Link": "https://www.onlyoffice.com/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/ro/CampaignPersonalDesktop.json b/public/locales/ro/CampaignPersonalDesktop.json deleted file mode 100644 index 2162ac26074..00000000000 --- a/public/locales/ro/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for PC", - "SubHeader": "Get a free alternative to MS Office", - "ButtonLabel": "Download", - "Link": "https://www.onlyoffice.com/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/ro/CampaignPersonalEducation.json b/public/locales/ro/CampaignPersonalEducation.json deleted file mode 100644 index 9bb6588eba1..00000000000 --- a/public/locales/ro/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for schools", - "SubHeader": "Learn about education discounts", - "ButtonLabel": "Learn more", - "Link": "https://www.onlyoffice.com/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/ro/CampaignPersonalEnterprise.json b/public/locales/ro/CampaignPersonalEnterprise.json deleted file mode 100644 index 25ce985a869..00000000000 --- a/public/locales/ro/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE on-premises", - "SubHeader": "Keep your docs and projects safe", - "ButtonLabel": "Get it now", - "Link": "https://www.onlyoffice.com/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/ro/CampaignPersonalIntegration.json b/public/locales/ro/CampaignPersonalIntegration.json deleted file mode 100644 index 4e35e4aa51e..00000000000 --- a/public/locales/ro/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for integration", - "SubHeader": "Use online editors with your platform", - "ButtonLabel": "Integrate now", - "Link": "https://www.onlyoffice.com/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} diff --git a/public/locales/ru/CampaignPersonalCloud.json b/public/locales/ru/CampaignPersonalCloud.json deleted file mode 100644 index 15dd4b3f506..00000000000 --- a/public/locales/ru/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE для бизнеса", - "SubHeader": "Документы, проекты, клиенты и почта", - "ButtonLabel": "Начните бесплатно", - "Link": "https://www.onlyoffice.com/ru/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/ru/CampaignPersonalDesktop.json b/public/locales/ru/CampaignPersonalDesktop.json deleted file mode 100644 index bcc498a35fa..00000000000 --- a/public/locales/ru/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE для ПК", - "SubHeader": "Получите бесплатную альтернативу MS Office", - "ButtonLabel": "Скачать", - "Link": "https://www.onlyoffice.com/ru/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/ru/CampaignPersonalEducation.json b/public/locales/ru/CampaignPersonalEducation.json deleted file mode 100644 index f86e0cc2afb..00000000000 --- a/public/locales/ru/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE для школ", - "SubHeader": "Узнайте больше об образовательных скидках", - "ButtonLabel": "Узнать больше", - "Link": "https://www.onlyoffice.com/ru/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/ru/CampaignPersonalEnterprise.json b/public/locales/ru/CampaignPersonalEnterprise.json deleted file mode 100644 index 01ce1c89160..00000000000 --- a/public/locales/ru/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE локально", - "SubHeader": "Обеспечьте сохранность документов и проектов", - "ButtonLabel": "Получить сейчас", - "Link": "https://www.onlyoffice.com/ru/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/ru/CampaignPersonalIntegration.json b/public/locales/ru/CampaignPersonalIntegration.json deleted file mode 100644 index faa53a82ebc..00000000000 --- a/public/locales/ru/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE для интеграции", - "SubHeader": "Используйте онлайн-редакторы с вашей платформой", - "ButtonLabel": "Интегрировать сейчас", - "Link": "https://www.onlyoffice.com/ru/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} diff --git a/public/locales/sk/CampaignPersonalCloud.json b/public/locales/sk/CampaignPersonalCloud.json deleted file mode 100644 index 4ad7c5f06f3..00000000000 --- a/public/locales/sk/CampaignPersonalCloud.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for business", - "SubHeader": "Docs, projects, clients & emails", - "ButtonLabel": "Start free trial", - "Link": "https://www.onlyoffice.com/registration.aspx?utm_source=personal&utm_campaign=BannerPersonalCloud" -} diff --git a/public/locales/sk/CampaignPersonalDesktop.json b/public/locales/sk/CampaignPersonalDesktop.json deleted file mode 100644 index 2162ac26074..00000000000 --- a/public/locales/sk/CampaignPersonalDesktop.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for PC", - "SubHeader": "Get a free alternative to MS Office", - "ButtonLabel": "Download", - "Link": "https://www.onlyoffice.com/download-desktop.aspx?utm_source=personal&utm_campaign=BannerPersonalDesktop" -} diff --git a/public/locales/sk/CampaignPersonalEducation.json b/public/locales/sk/CampaignPersonalEducation.json deleted file mode 100644 index 9bb6588eba1..00000000000 --- a/public/locales/sk/CampaignPersonalEducation.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for schools", - "SubHeader": "Learn about education discounts", - "ButtonLabel": "Learn more", - "Link": "https://www.onlyoffice.com/education.aspx?utm_source=personal&utm_campaign=BannerPersonalEducation" -} diff --git a/public/locales/sk/CampaignPersonalEnterprise.json b/public/locales/sk/CampaignPersonalEnterprise.json deleted file mode 100644 index 25ce985a869..00000000000 --- a/public/locales/sk/CampaignPersonalEnterprise.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE on-premises", - "SubHeader": "Keep your docs and projects safe", - "ButtonLabel": "Get it now", - "Link": "https://www.onlyoffice.com/download-commercial.aspx?utm_source=personal&utm_campaign=BannerPersonalEnterprise" -} diff --git a/public/locales/sk/CampaignPersonalIntegration.json b/public/locales/sk/CampaignPersonalIntegration.json deleted file mode 100644 index 4e35e4aa51e..00000000000 --- a/public/locales/sk/CampaignPersonalIntegration.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Header": "ONLYOFFICE for integration", - "SubHeader": "Use online editors with your platform", - "ButtonLabel": "Integrate now", - "Link": "https://www.onlyoffice.com/connectors.aspx?utm_source=personal&utm_campaign=BannerPersonalIntegration" -} From c46ebd5af9f3025e56678b0bb65d742515fbdf51 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 7 Sep 2021 12:48:22 +0300 Subject: [PATCH 05/16] Web: Common: get campaigns translations from firebase --- packages/asc-web-common/utils/firebase.js | 8 ++++++++ packages/asc-web-common/utils/index.js | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/asc-web-common/utils/firebase.js b/packages/asc-web-common/utils/firebase.js index b7dfe158541..3d5459bae8e 100644 --- a/packages/asc-web-common/utils/firebase.js +++ b/packages/asc-web-common/utils/firebase.js @@ -100,6 +100,14 @@ class FirebaseHelper { ); return await tangRef.getDownloadURL(); } + + async getCampaignsTranslations(banner, lng) { + const storageRef = this.firebaseStorage.ref(); + const tangRef = storageRef.child( + `campaigns/locales/${lng}/CampaignPersonal${banner}.json` + ); + return await tangRef.getDownloadURL(); + } } export default FirebaseHelper; diff --git a/packages/asc-web-common/utils/index.js b/packages/asc-web-common/utils/index.js index 167a9c30687..4bdb23422e9 100644 --- a/packages/asc-web-common/utils/index.js +++ b/packages/asc-web-common/utils/index.js @@ -273,7 +273,8 @@ export function loadLanguagePath(homepage, fixedNS = null) { return `/static/locales/${language}/Common.json`; } if (ns.length > 0 && ns[0].includes("Campaign")) { - return `/static/locales/${language}/${ns[0]}.json`; + const url = localStorage.getItem("campaignsT"); + return url; } return `${homepage}/locales/${language}/${fixedNS || ns}.json`; }; From da96e4777318c5e2546a6a0803f2f5c7a70e18f4 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 7 Sep 2021 12:48:41 +0300 Subject: [PATCH 06/16] Web: Files: get campaigns translations from firebase --- .../Client/src/components/Article/Body/Banner.js | 12 ++++++++++-- products/ASC.Files/Client/src/i18n.js | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/products/ASC.Files/Client/src/components/Article/Body/Banner.js b/products/ASC.Files/Client/src/components/Article/Body/Banner.js index 521399d711c..b9dd3be63c8 100644 --- a/products/ASC.Files/Client/src/components/Article/Body/Banner.js +++ b/products/ASC.Files/Client/src/components/Article/Body/Banner.js @@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next"; import CampaignsBanner from "@appserver/components/campaigns-banner"; import { ADS_TIMEOUT } from "../../../helpers/constants"; +import { LANGUAGE } from "@appserver/common/constants"; const Banner = ({ FirebaseHelper }) => { const campaigns = (localStorage.getItem("campaigns") || "") @@ -25,13 +26,20 @@ const Banner = ({ FirebaseHelper }) => { index++; } - localStorage.setItem("bannerIndex", index); - setBannerName(campaign); + const lng = localStorage.getItem(LANGUAGE).split("-")[0] || "en"; + const translate = await FirebaseHelper.getCampaignsTranslations( + campaign, + lng + ); + localStorage.setItem("campaignsT", translate); const image = await FirebaseHelper.getCampaignsImages( campaign.toLowerCase() ); setBannerImage(image); + + localStorage.setItem("bannerIndex", index); + setBannerName(campaign); }; useEffect(() => { diff --git a/products/ASC.Files/Client/src/i18n.js b/products/ASC.Files/Client/src/i18n.js index 2aed42098c6..1c91cfa4dd8 100644 --- a/products/ASC.Files/Client/src/i18n.js +++ b/products/ASC.Files/Client/src/i18n.js @@ -25,7 +25,7 @@ newInstance.use(Backend).init({ backend: { loadPath: loadLanguagePath(config.homepage), allowMultiLoading: false, - crossDomain: false, + crossDomain: true, }, react: { From fa1d01655431c41a7338fcd8a1750fd765a8e7a6 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 7 Sep 2021 18:34:30 +0300 Subject: [PATCH 07/16] Web: Common: fixed banner translations --- packages/asc-web-common/store/SettingsStore.js | 3 ++- packages/asc-web-common/utils/index.js | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/asc-web-common/store/SettingsStore.js b/packages/asc-web-common/store/SettingsStore.js index 71652f9de7e..c7fa5aad7e4 100644 --- a/packages/asc-web-common/store/SettingsStore.js +++ b/packages/asc-web-common/store/SettingsStore.js @@ -320,7 +320,8 @@ class SettingsStore { }; get firebaseHelper() { - return new FirebaseHelper(this.firebase); + window.firebaseHelper = new FirebaseHelper(this.firebase); + return window.firebaseHelper; } } diff --git a/packages/asc-web-common/utils/index.js b/packages/asc-web-common/utils/index.js index 4bdb23422e9..9d56f6cdadf 100644 --- a/packages/asc-web-common/utils/index.js +++ b/packages/asc-web-common/utils/index.js @@ -247,7 +247,7 @@ export function getProviderTranslation(provider, t) { } } -function getLanguage(lng) { +export function getLanguage(lng) { try { let language = lng == "en-US" || lng == "en-GB" ? "en" : lng; @@ -272,10 +272,6 @@ export function loadLanguagePath(homepage, fixedNS = null) { if (ns.length > 0 && ns[0] === "Common") { return `/static/locales/${language}/Common.json`; } - if (ns.length > 0 && ns[0].includes("Campaign")) { - const url = localStorage.getItem("campaignsT"); - return url; - } return `${homepage}/locales/${language}/${fixedNS || ns}.json`; }; } From ecc5c69722f0d39b7839e0e6bd7392e601bdf982 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Tue, 7 Sep 2021 18:34:46 +0300 Subject: [PATCH 08/16] Web: Files: fixed banner translations --- .../src/components/Article/Body/Banner.js | 100 ++++++++++++++---- 1 file changed, 80 insertions(+), 20 deletions(-) diff --git a/products/ASC.Files/Client/src/components/Article/Body/Banner.js b/products/ASC.Files/Client/src/components/Article/Body/Banner.js index b9dd3be63c8..fec7a738fee 100644 --- a/products/ASC.Files/Client/src/components/Article/Body/Banner.js +++ b/products/ASC.Files/Client/src/components/Article/Body/Banner.js @@ -1,11 +1,54 @@ import React, { useEffect, useState } from "react"; -import { useTranslation } from "react-i18next"; +import { useTranslation, withTranslation } from "react-i18next"; import CampaignsBanner from "@appserver/components/campaigns-banner"; import { ADS_TIMEOUT } from "../../../helpers/constants"; import { LANGUAGE } from "@appserver/common/constants"; +import i18n from "i18next"; +import Backend from "i18next-http-backend"; +import { getLanguage } from "@appserver/common/utils"; + +const i18nConfig = i18n.createInstance(); + +let translationUrl; + +const loadLanguagePath = async () => { + if (!window.firebaseHelper) return; + + const lng = localStorage.getItem(LANGUAGE) || "en"; + const language = getLanguage(lng instanceof Array ? lng[0] : lng); + + const campaigns = (localStorage.getItem("campaigns") || "") + .split(",") + .filter((campaign) => campaign.length > 0); + const index = Number(localStorage.getItem("bannerIndex") || 0); + const campaign = campaigns[index]; + + translationUrl = await window.firebaseHelper.getCampaignsTranslations( + campaign, + language + ); + console.log("translationUrl", translationUrl); + return translationUrl; +}; + +i18nConfig.use(Backend).init({ + lng: localStorage.getItem(LANGUAGE) || "en", + fallbackLng: "en", + load: "all", + debug: true, + defaultNS: "", + + backend: { + loadPath: function () { + return translationUrl; + }, + }, +}); + +const bannerHOC = (WrappedComponent) => (props) => { + const { FirebaseHelper } = props; -const Banner = ({ FirebaseHelper }) => { const campaigns = (localStorage.getItem("campaigns") || "") .split(",") .filter((campaign) => campaign.length > 0); @@ -13,6 +56,7 @@ const Banner = ({ FirebaseHelper }) => { const defaultBannerName = "Cloud"; const [bannerName, setBannerName] = useState(defaultBannerName); const [bannerImage, setBannerImage] = useState(""); + const [bannerTranslation, setBannerTranslation] = useState(); const updateBanner = async () => { console.log("update banner"); @@ -26,13 +70,6 @@ const Banner = ({ FirebaseHelper }) => { index++; } - const lng = localStorage.getItem(LANGUAGE).split("-")[0] || "en"; - const translate = await FirebaseHelper.getCampaignsTranslations( - campaign, - lng - ); - localStorage.setItem("campaignsT", translate); - const image = await FirebaseHelper.getCampaignsImages( campaign.toLowerCase() ); @@ -42,32 +79,55 @@ const Banner = ({ FirebaseHelper }) => { setBannerName(campaign); }; - useEffect(() => { + useEffect(async () => { + const translationUrl = await loadLanguagePath(); + setBannerTranslation(translationUrl); updateBanner(); setInterval(updateBanner, ADS_TIMEOUT); }, []); - const { t, i18n, ready } = useTranslation(`CampaignPersonal${bannerName}`, { - useSuspense: false, - }); + console.log("banner hoc render", bannerTranslation); + if (!bannerTranslation || !bannerName || !bannerImage) return

Loading

; + + return ( + + ); +}; + +const Banner = (props) => { + console.log("Banner render", props); + const { t, tReady, bannerName, bannerImage, FirebaseHelper } = props; + const campaigns = (localStorage.getItem("campaigns") || "") + .split(",") + .filter((campaign) => campaign.length > 0); if ( !campaigns.length || - !ready || - !i18n.exists(`CampaignPersonal${bannerName}:Header`) + !tReady /*|| + !i18n.exists(`CampaignPersonal${bannerName}:Header`)*/ ) { return <>; } return ( ); }; -export default Banner; +const ExtendedComponent = withTranslation()(Banner); + +const WrapperComponent = (props) => ( + +); + +export default bannerHOC(WrapperComponent); From 8e6fa7f5fab3874251686fec74543315d2ff959f Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Wed, 8 Sep 2021 10:35:36 +0300 Subject: [PATCH 09/16] Web: Components: added banner img loader --- .../asc-web-components/campaigns-banner/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/asc-web-components/campaigns-banner/index.js b/packages/asc-web-components/campaigns-banner/index.js index f1f93a92b2e..dfded8d915e 100644 --- a/packages/asc-web-components/campaigns-banner/index.js +++ b/packages/asc-web-components/campaigns-banner/index.js @@ -1,9 +1,10 @@ -import React from "react"; +import React, { useState } from "react"; import PropTypes from "prop-types"; import BannerWrapper from "./styled-campaigns-banner"; import Button from "../button"; import Text from "../text"; +import Loaders from "@appserver/common/components/Loaders"; const onButtonClick = (url) => { window.location = url; @@ -11,6 +12,12 @@ const onButtonClick = (url) => { const CampaignsBanner = (props) => { const { headerLabel, subHeaderLabel, img, btnLabel, link } = props; + const [imageLoad, setImageLoad] = useState(false); + + const handleImageLoaded = () => { + setImageLoad(true); + }; + return ( @@ -21,7 +28,8 @@ const CampaignsBanner = (props) => { {subHeaderLabel} - + {!imageLoad && } +