import PropTypes from 'prop-types'; import React from 'react'; import ReactModal from 'react-modal'; import Box from '../box/box.jsx'; import {defineMessages, injectIntl, intlShape, FormattedMessage} from 'react-intl'; import { isRendererSupported, isNewFunctionSupported, findIncompatibleUserscripts } from '../../lib/tw-environment-support-prober.js'; import {APP_NAME} from '../../lib/brand.js'; import styles from './browser-modal.css'; import unhappyBrowser from './unsupported-browser.svg'; const messages = defineMessages({ browserNotSupported: { id: 'gui.unsupportedBrowser.label', defaultMessage: 'Browser is not supported', description: '' }, systemNotSupported: { id: 'tw.browserModal.desktopTitle', defaultMessage: 'System is not supported', description: 'Title of error message in desktop app when system does not support required API, such as WebGL' } }); const noop = () => {}; const BrowserModal = ({intl, ...props}) => { const title = props.onClickDesktopSettings ? messages.systemNotSupported : messages.browserNotSupported; const incompatibleUserscripts = findIncompatibleUserscripts(); return (

{/* eslint-disable max-len */} {isNewFunctionSupported() ? null : ( // This message should only be seen by website operators, so we don't need to translate it

{'Unable to compile JavaScript with new Function(). This is most likely caused by an overly-strict Content-Security-Policy. The CSP must include \'unsafe-eval\'.'}

)} {incompatibleUserscripts.length > 0 && ( {incompatibleUserscripts.map((message, index) => (

{message}

))}
)} {!isRendererSupported() && (

{props.onClickDesktopSettings ? (

) : (

)}
)} {/* eslint-enable max-len */}
); }; BrowserModal.propTypes = { intl: intlShape.isRequired, isRtl: PropTypes.bool, onClickDesktopSettings: PropTypes.func }; const WrappedBrowserModal = injectIntl(BrowserModal); WrappedBrowserModal.setAppElement = ReactModal.setAppElement; export default WrappedBrowserModal;