diff --git a/i18n/en-US.yml b/i18n/en-US.yml index 8216c7667..24cc85cb1 100644 --- a/i18n/en-US.yml +++ b/i18n/en-US.yml @@ -577,11 +577,18 @@ components: linkCopied: Copied reportIssue: Report Issue reportEmailSubject: Reporting an Issue with OpenTripPlanner - reportEmailTemplate: > - ***INSTRUCTIONS TO USER*** + reportEmailTemplate: |+ + *** INSTRUCTIONS TO USER *** This feature allows you to email a report to site administrators for review. - Please add any additional feedback for this trip under the 'Additional Comments' - section below and send using your regular email program." + Please fill out the prompts below and send using your regular email program. + + *** PLEASE COMPLETE THE FOLLOWING *** + + Issue encountered: + + Type of trip you wanted to take (ex. walk + transit, bike + transit, car + transit): + + *** TECHNICAL DETAILS *** # Used in both desktop and mobile TripViewer: accessible: Accessible diff --git a/i18n/fr-FR.yml b/i18n/fr-FR.yml index 64908ebd7..52ce58fdb 100644 --- a/i18n/fr-FR.yml +++ b/i18n/fr-FR.yml @@ -561,11 +561,18 @@ components: linkCopied: Copié reportIssue: Un problème ? # "Signaler un problème" does not fit. reportEmailSubject: Signaler un problème avec OpenTripPlanner - reportEmailTemplate: > - *** À L'ATTENTION DE L'UTILISATEUR *** - Vous pouvez communiquer votre problème par e-mail et en détail aux administrateurs de ce site. - Veuillez ajouter toute remarque sur cet itinéraire dans la section 'Additional Comments' - ci-dessous, puis envoyez depuis votre logiciel de messagerie usuel." + reportEmailTemplate: |+ + *** CONSIGNES POUR L'UTILISATEUR *** + Cet email signalera votre problème aux administrateurs de ce site. + Veuillez remplir les détails ci-dessous, puis envoyez depuis votre logiciel de messagerie habituel. + + *** VEUILLEZ REMPLIR CI-DESSOUS *** + + Problème rencontré : + + Type de trajet recherché (ex. à pied + transports, vélo + transports, voiture + transports) : + + *** DÉTAILS TECHNIQUES *** # Used in both desktop and mobile TripViewer: accessible: Accessible diff --git a/lib/components/narrative/trip-tools.js b/lib/components/narrative/trip-tools.js index 9b89a814b..2bc3d7dd9 100644 --- a/lib/components/narrative/trip-tools.js +++ b/lib/components/narrative/trip-tools.js @@ -1,88 +1,18 @@ +/* eslint-disable no-case-declarations */ +import { Button } from 'react-bootstrap' +import { connect } from 'react-redux' import bowser from 'bowser' import copyToClipboard from 'copy-to-clipboard' -import React, {Component} from 'react' -import { connect } from 'react-redux' -import { Button } from 'react-bootstrap' +import PropTypes from 'prop-types' +import React, { Component } from 'react' // import { DropdownButton, MenuItem } from 'react-bootstrap' import { FormattedMessage, injectIntl } from 'react-intl' import Icon from '../util/icon' - -class TripTools extends Component { - static defaultProps = { - buttonTypes: [ 'COPY_URL', 'PRINT', 'REPORT_ISSUE', 'START_OVER' ] - } - - render () { - const { buttonTypes, reactRouterConfig, reportConfig } = this.props - - const buttonComponents = [] - buttonTypes.forEach((type) => { - switch (type) { - case 'COPY_URL': - buttonComponents.push() - break - case 'PRINT': - buttonComponents.push() - break - case 'REPORT_ISSUE': - if (!reportConfig || !reportConfig.mailto) break - buttonComponents.push() - break - case 'START_OVER': - // Determine "home" URL - let startOverUrl = '/' - if (reactRouterConfig && reactRouterConfig.basename) { - startOverUrl += reactRouterConfig.basename - } - buttonComponents.push( - // FIXME: The Spanish string does not fit in button width. - } - url={startOverUrl} - /> - ) - break - } - }) - - return ( -
- {buttonComponents.map((btn, i) =>
{btn}
)} -
- ) - } -} - -// Share/Save Dropdown Component -- not used currently - -/* -class ShareSaveDropdownButton extends Component { - _onCopyToClipboardClick = () => { - copyToClipboard(window.location.href) - } - - render () { - return ( - Share/Save} - id={'tool-share-dropdown'} - > - - Copy Link to Clipboard - - - ) - } -} -*/ - // Copy URL Button class CopyUrlButton extends Component { - constructor (props) { + constructor(props) { super(props) this.state = { showCopied: false } } @@ -100,7 +30,10 @@ class CopyUrlButton extends Component { url = `${parts[0]}#/start/x/x/x/${routerId}${parts[1]}` } else { // Console logs are not internationalized. - console.warn('URL not formatted as expected, copied URL will not contain session routerId.', routerId) + console.warn( + 'URL not formatted as expected, copied URL will not contain session routerId.', + routerId + ) } } copyToClipboard(url) @@ -108,27 +41,21 @@ class CopyUrlButton extends Component { window.setTimeout(this._resetState, 2000) } - render () { + render() { return (
-
) @@ -144,15 +71,12 @@ class PrintButton extends Component { window.open(printUrl, '_blank') } - render () { + render() { return (
-
) @@ -164,37 +88,45 @@ class PrintButton extends Component { class ReportIssueButtonBase extends Component { _onClick = () => { const { intl, mailto, subject: configuredSubject } = this.props - const subject = configuredSubject || intl.formatMessage({id: 'components.TripTools.reportEmailSubject'}) + const subject = + configuredSubject || + intl.formatMessage({ id: 'components.TripTools.reportEmailSubject' }) const bodyLines = [ - intl.formatMessage({id: 'components.TripTools.reportEmailTemplate'}), + intl.formatMessage({ id: 'components.TripTools.reportEmailTemplate' }), '', // Search data section is for support and is not translated. 'SEARCH DATA:', 'Address: ' + window.location.href, 'Browser: ' + bowser.name + ' ' + bowser.version, 'OS: ' + bowser.osname + ' ' + bowser.osversion, - '', - 'ADDITIONAL COMMENTS:', '' ] - window.open(`mailto:${mailto}?subject=${subject}&body=${encodeURIComponent(bodyLines.join('\n'))}`, '_self') + window.open( + `mailto:${mailto}?subject=${subject}&body=${encodeURIComponent( + bodyLines.join('\n') + )}`, + '_self' + ) } - render () { + render() { return ( - ) } } +ReportIssueButtonBase.propTypes = { + intl: PropTypes.object, + mailto: PropTypes.string, + subject: PropTypes.string +} + // The ReportIssueButton component above, with an intl prop // for retrieving messages shown outside of React rendering. const ReportIssueButton = injectIntl(ReportIssueButtonBase) @@ -206,14 +138,11 @@ class LinkButton extends Component { window.location.href = this.props.url } - render () { + render() { const { icon, text } = this.props return (
- @@ -222,9 +151,74 @@ class LinkButton extends Component { } } +LinkButton.propTypes = { + icon: PropTypes.string, + text: PropTypes.string, + url: PropTypes.string +} + +class TripTools extends Component { + static defaultProps = { + buttonTypes: ['COPY_URL', 'PRINT', 'REPORT_ISSUE', 'START_OVER'] + } + + render() { + const { buttonTypes, reactRouterConfig, reportConfig } = this.props + + const buttonComponents = [] + buttonTypes.forEach((type) => { + switch (type) { + case 'COPY_URL': + buttonComponents.push() + break + case 'PRINT': + buttonComponents.push() + break + case 'REPORT_ISSUE': + if (!reportConfig || !reportConfig.mailto) break + buttonComponents.push() + break + case 'START_OVER': + // Determine "home" URL + let startOverUrl = '/' + if (reactRouterConfig && reactRouterConfig.basename) { + startOverUrl += reactRouterConfig.basename + } + buttonComponents.push( + // FIXME: The Spanish string does not fit in button width. + } + url={startOverUrl} + /> + ) + break + default: + console.warn(`TripTools called with invalid button type ${type}!`) + } + }) + + return ( +
+ {buttonComponents.map((btn, i) => ( +
+ {btn} +
+ ))} +
+ ) + } +} + +TripTools.propTypes = { + buttonTypes: PropTypes.arrayOf(PropTypes.string), + reactRouterConfig: PropTypes.object, + reportConfig: PropTypes.object +} + // Connect main class to redux store -const mapStateToProps = (state, ownProps) => { +const mapStateToProps = (state) => { return { reactRouterConfig: state.otp.config.reactRouter, reportConfig: state.otp.config.reportIssue