From 2dd0f3002120052385c13adee551d1a76bcc2649 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Fri, 18 Nov 2022 11:52:08 +0200 Subject: [PATCH] fix: proper near you mode validation --- .../package.json | 2 +- .../src/index.js | 13 ++++++++++++- .../packages/digitransit-component/package.json | 2 +- yarn.lock | 4 ++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/digitransit-component/packages/digitransit-component-control-panel/package.json b/digitransit-component/packages/digitransit-component-control-panel/package.json index 631550f9e2..940ef63a8d 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.0", + "version": "1.1.1", "description": "digitransit-component control-panel module", "main": "index.js", "files": [ 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 8684c73192..cac1a679ef 100644 --- a/digitransit-component/packages/digitransit-component-control-panel/src/index.js +++ b/digitransit-component/packages/digitransit-component-control-panel/src/index.js @@ -165,6 +165,17 @@ BubbleDialog.propTypes = { * */ +const validNearYouModes = [ + 'favorite', + 'bus', + 'tram', + 'rail', + 'subway', + 'airplane', + 'ferry', + 'citybike', +]; + function getIconName(mode, modeSet) { return modeSet === 'default' ? `mode-${mode}` : `mode-${modeSet}-${mode}`; } @@ -218,7 +229,7 @@ function NearStopsAndRoutes({ urlStart = urlParts.join('/'); } const buttons = modeArray - .filter(mode => mode !== 'funicular') + .filter(mode => validNearYouModes.includes(mode)) .map(mode => { const withAlert = modesWithAlerts.includes(mode.toUpperCase()); let url = `${urlStart}/${mode.toUpperCase()}/POS`; diff --git a/digitransit-component/packages/digitransit-component/package.json b/digitransit-component/packages/digitransit-component/package.json index 8acf479bbe..db4f2fe717 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": "^1.9.2", "@digitransit-component/digitransit-component-autosuggest-panel": "^1.5.3", - "@digitransit-component/digitransit-component-control-panel": "^1.1.0", + "@digitransit-component/digitransit-component-control-panel": "^1.1.1", "@digitransit-component/digitransit-component-favourite-bar": "1.1.0", "@digitransit-component/digitransit-component-favourite-editing-modal": "^1.1.0", "@digitransit-component/digitransit-component-favourite-modal": "^0.4.0", diff --git a/yarn.lock b/yarn.lock index d2b4fc50c9..e61f1e3bb5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2034,7 +2034,7 @@ __metadata: languageName: unknown linkType: soft -"@digitransit-component/digitransit-component-control-panel@^1.1.0, @digitransit-component/digitransit-component-control-panel@workspace:digitransit-component/packages/digitransit-component-control-panel": +"@digitransit-component/digitransit-component-control-panel@^1.1.1, @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: @@ -2188,7 +2188,7 @@ __metadata: dependencies: "@digitransit-component/digitransit-component-autosuggest": ^1.9.2 "@digitransit-component/digitransit-component-autosuggest-panel": ^1.5.3 - "@digitransit-component/digitransit-component-control-panel": ^1.1.0 + "@digitransit-component/digitransit-component-control-panel": ^1.1.1 "@digitransit-component/digitransit-component-favourite-bar": 1.1.0 "@digitransit-component/digitransit-component-favourite-editing-modal": ^1.1.0 "@digitransit-component/digitransit-component-favourite-modal": ^0.4.0