From 175c1b9e9b71d03f57d2237e48532c2d27976eb3 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 4 Sep 2024 10:54:51 +0300 Subject: [PATCH 1/3] fix: unreliable translation of control panel strings --- .../src/index.js | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/digitransit-component/packages/digitransit-component-control-panel/src/index.js b/digitransit-component/packages/digitransit-component-control-panel/src/index.js index a37e345afe..9dbd94653e 100644 --- a/digitransit-component/packages/digitransit-component-control-panel/src/index.js +++ b/digitransit-component/packages/digitransit-component-control-panel/src/index.js @@ -202,9 +202,7 @@ function NearStopsAndRoutes({ const [cookies, setCookie] = useCookies(['nearbyTeaserShown']); useEffect(() => { - Object.keys(translations).forEach(lang => { - i18next.addResourceBundle(lang, 'translation', translations[lang]); - }); + i18next.changeLanguage(language); if (alertsContext) { alertsContext .getModesWithAlerts(alertsContext.currentTime, alertsContext.feedIds) @@ -436,7 +434,6 @@ class CtrlPanel extends React.Component { static propTypes = { children: PropTypes.arrayOf(PropTypes.node), - language: PropTypes.string.isRequired, position: PropTypes.string.isRequired, fontWeights: PropTypes.shape({ medium: PropTypes.number, @@ -450,29 +447,25 @@ class CtrlPanel extends React.Component { }, }; + constructor(props) { + super(props); + Object.keys(translations).forEach(lang => { + i18next.addResourceBundle(lang, 'translation', translations[lang]); + }); + } + render() { const className = this.props.position === 'bottom' ? styles['main-bottom'] : styles['main-left']; - const children = React.Children.map(this.props.children, child => { - if (child) { - let lang = this.props.language; - if (lang === undefined) { - lang = 'fi'; - } - i18next.changeLanguage(lang); - return React.cloneElement(child, { lang }); - } - return null; - }); return (
- {children} + {this.props.children}
); } From 992c601b4fc41ea2a7db2f28c04eda186bddf664 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 4 Sep 2024 11:00:17 +0300 Subject: [PATCH 2/3] chore: remove outdated introduction feature --- .../src/index.js | 95 ------------------- 1 file changed, 95 deletions(-) diff --git a/digitransit-component/packages/digitransit-component-control-panel/src/index.js b/digitransit-component/packages/digitransit-component-control-panel/src/index.js index 9dbd94653e..8a783fad54 100644 --- a/digitransit-component/packages/digitransit-component-control-panel/src/index.js +++ b/digitransit-component/packages/digitransit-component-control-panel/src/index.js @@ -4,8 +4,6 @@ import PropTypes from 'prop-types'; import React, { Fragment, useEffect, useState } from 'react'; import i18next from 'i18next'; -import { useCookies } from 'react-cookie'; -import cx from 'classnames'; import Icon from '@digitransit-component/digitransit-component-icon'; import styles from './helpers/styles.scss'; import translations from './helpers/translations'; @@ -67,73 +65,6 @@ OriginToDestination.defaultProps = { language: 'fi', }; -function BubbleDialog({ title, content, closeDialog, shouldRender, lang }) { - const [show, setShow] = useState(false); - useEffect(() => { - setTimeout(() => { - setShow(true); - }, 500); - }, [show]); - - return ( -
-
-
-
- {title} -
-
- {content} -
- -
-
-
-
-
-
- ); -} - -BubbleDialog.propTypes = { - title: PropTypes.string.isRequired, - content: PropTypes.string.isRequired, - closeDialog: PropTypes.func.isRequired, - shouldRender: PropTypes.bool.isRequired, - lang: PropTypes.string.isRequired, -}; - /** * Show button links to near you page for different travel modes * @@ -196,10 +127,8 @@ function NearStopsAndRoutes({ modeSet, modeIconColors, fontWeights, - showTeaser, }) { const [modesWithAlerts, setModesWithAlerts] = useState([]); - const [cookies, setCookie] = useCookies(['nearbyTeaserShown']); useEffect(() => { i18next.changeLanguage(language); @@ -212,12 +141,6 @@ function NearStopsAndRoutes({ } }, []); - const closeBubbleDialog = () => - setCookie('nearbyTeaserShown', true, { - path: '/', - maxAge: 10 * 365 * 24 * 60 * 60, - }); - let urlStart; if (omitLanguageUrl) { urlStart = urlPrefix; @@ -326,20 +249,6 @@ function NearStopsAndRoutes({ : title[language]} )} - {showTeaser && !cookies?.nearbyTeaserShown && ( - - )}
Date: Wed, 4 Sep 2024 11:09:27 +0300 Subject: [PATCH 3/3] chore: bump up version --- .../packages/digitransit-component-control-panel/package.json | 2 +- .../packages/digitransit-component/package.json | 2 +- yarn.lock | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/digitransit-component/packages/digitransit-component-control-panel/package.json b/digitransit-component/packages/digitransit-component-control-panel/package.json index 1dd0b6ef9d..7b5c56a801 100644 --- a/digitransit-component/packages/digitransit-component-control-panel/package.json +++ b/digitransit-component/packages/digitransit-component-control-panel/package.json @@ -1,6 +1,6 @@ { "name": "@digitransit-component/digitransit-component-control-panel", - "version": "1.1.8", + "version": "2.0.0", "description": "digitransit-component control-panel module", "main": "index.js", "files": [ diff --git a/digitransit-component/packages/digitransit-component/package.json b/digitransit-component/packages/digitransit-component/package.json index 10045a9523..ffbee607d6 100644 --- a/digitransit-component/packages/digitransit-component/package.json +++ b/digitransit-component/packages/digitransit-component/package.json @@ -16,7 +16,7 @@ "dependencies": { "@digitransit-component/digitransit-component-autosuggest": "^2.0.8", "@digitransit-component/digitransit-component-autosuggest-panel": "^3.0.8", - "@digitransit-component/digitransit-component-control-panel": "^1.1.8", + "@digitransit-component/digitransit-component-control-panel": "^2.0.0", "@digitransit-component/digitransit-component-favourite-bar": "2.0.5", "@digitransit-component/digitransit-component-favourite-editing-modal": "^2.0.2", "@digitransit-component/digitransit-component-favourite-modal": "^1.0.6", diff --git a/yarn.lock b/yarn.lock index 16cad571df..1b00cb003e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2013,7 +2013,7 @@ __metadata: languageName: unknown linkType: soft -"@digitransit-component/digitransit-component-control-panel@^1.1.8, @digitransit-component/digitransit-component-control-panel@workspace:digitransit-component/packages/digitransit-component-control-panel": +"@digitransit-component/digitransit-component-control-panel@^2.0.0, @digitransit-component/digitransit-component-control-panel@workspace:digitransit-component/packages/digitransit-component-control-panel": version: 0.0.0-use.local resolution: "@digitransit-component/digitransit-component-control-panel@workspace:digitransit-component/packages/digitransit-component-control-panel" peerDependencies: @@ -2168,7 +2168,7 @@ __metadata: dependencies: "@digitransit-component/digitransit-component-autosuggest": ^2.0.8 "@digitransit-component/digitransit-component-autosuggest-panel": ^3.0.8 - "@digitransit-component/digitransit-component-control-panel": ^1.1.8 + "@digitransit-component/digitransit-component-control-panel": ^2.0.0 "@digitransit-component/digitransit-component-favourite-bar": 2.0.5 "@digitransit-component/digitransit-component-favourite-editing-modal": ^2.0.2 "@digitransit-component/digitransit-component-favourite-modal": ^1.0.6