From c2e4ca882f5e29a9b28ccad0a68e72ada0852f58 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Wed, 8 Sep 2021 11:08:16 +0100 Subject: [PATCH 1/3] fix: remove dead links --- lib/components/user/terms-of-use-pane.js | 16 ++++++++++++++-- lib/util/auth.js | 7 ------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/components/user/terms-of-use-pane.js b/lib/components/user/terms-of-use-pane.js index e7c0e94fd..b6f67f25c 100644 --- a/lib/components/user/terms-of-use-pane.js +++ b/lib/components/user/terms-of-use-pane.js @@ -1,4 +1,5 @@ import React from 'react' +import { connect } from 'react-redux' import { Checkbox, ControlLabel, FormGroup } from 'react-bootstrap' import { TERMS_OF_SERVICE_PATH, TERMS_OF_STORAGE_PATH } from '../../util/constants' @@ -10,12 +11,15 @@ const TermsOfUsePane = ({ disableCheckTerms, handleBlur, handleChange, + otpConfig, values: userData }) => { const { hasConsentedToTerms, storeTripHistory } = userData + const { persistence } = otpConfig + const { terms_of_storage: termsOfStorageSet } = persistence return (
@@ -46,11 +50,19 @@ const TermsOfUsePane = ({ > {/* TODO: Implement the link */} Optional: I consent to the Trip Planner storing my historical planned trips in order to - improve transit services in my area. More info... + improve transit services in my area. {termsOfStorageSet && More info...}
) } +const mapStateToProps = (state, ownProps) => { + return { + otpConfig: state.otp.config + } +} + +const mapDispatchToProps = { +} -export default TermsOfUsePane +export default connect(mapStateToProps, mapDispatchToProps)(TermsOfUsePane) diff --git a/lib/util/auth.js b/lib/util/auth.js index e96aae9d4..4d4a940f2 100644 --- a/lib/util/auth.js +++ b/lib/util/auth.js @@ -8,13 +8,6 @@ export const accountLinks = [ { text: 'My account', url: ACCOUNT_PATH - }, - { - // Add a target attribute if you need the link to open in a new window, etc. - // (supports the same values as ). - // target: '_blank', - text: 'Help', - url: '/help' } ] From 930a4a70377fbdb913b653ff77dd7ef1aa3c0e7f Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Wed, 8 Sep 2021 15:02:47 +0100 Subject: [PATCH 2/3] refactor(terms-of-use-pane): optimize redux state access --- lib/components/user/terms-of-use-pane.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/components/user/terms-of-use-pane.js b/lib/components/user/terms-of-use-pane.js index b6f67f25c..9388a6028 100644 --- a/lib/components/user/terms-of-use-pane.js +++ b/lib/components/user/terms-of-use-pane.js @@ -11,15 +11,13 @@ const TermsOfUsePane = ({ disableCheckTerms, handleBlur, handleChange, - otpConfig, + termsOfStorageSet, values: userData }) => { const { hasConsentedToTerms, storeTripHistory } = userData - const { persistence } = otpConfig - const { terms_of_storage: termsOfStorageSet } = persistence return (
@@ -58,7 +56,7 @@ const TermsOfUsePane = ({ } const mapStateToProps = (state, ownProps) => { return { - otpConfig: state.otp.config + termsOfStorageSet: state.otp.config.persistence?.terms_of_storage } } From 62278865204a45e1afa33483a5742f794c7f5b5e Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Wed, 8 Sep 2021 15:38:50 +0100 Subject: [PATCH 3/3] refactor: address pr feedback --- example-config.yml | 4 ++++ lib/components/user/terms-of-use-pane.js | 8 ++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example-config.yml b/example-config.yml index 95fb8ca8f..889ba5ab8 100644 --- a/example-config.yml +++ b/example-config.yml @@ -42,6 +42,10 @@ api: persistence: enabled: true strategy: localStorage + ### This variable hides the "more info" link when accepting the terms of storage. + ### If no terms of storage page content is set, this removes an otherwise dead link + ### False is default in that if the value isn't set, the link isn't shown + # terms_of_storage: true ### If using the OTP Middleware to store user profiles ### with Auth0 as the authentication mechanism, diff --git a/lib/components/user/terms-of-use-pane.js b/lib/components/user/terms-of-use-pane.js index 9388a6028..e7d860412 100644 --- a/lib/components/user/terms-of-use-pane.js +++ b/lib/components/user/terms-of-use-pane.js @@ -54,13 +54,9 @@ const TermsOfUsePane = ({
) } -const mapStateToProps = (state, ownProps) => { +const mapStateToProps = (state) => { return { termsOfStorageSet: state.otp.config.persistence?.terms_of_storage } } - -const mapDispatchToProps = { -} - -export default connect(mapStateToProps, mapDispatchToProps)(TermsOfUsePane) +export default connect(mapStateToProps)(TermsOfUsePane)