diff --git a/app/panel/components/CreateAccount.jsx b/app/panel/components/CreateAccount.jsx index fab828e02..e2349b54c 100644 --- a/app/panel/components/CreateAccount.jsx +++ b/app/panel/components/CreateAccount.jsx @@ -15,7 +15,9 @@ import React from 'react'; import { Link } from 'react-router-dom'; import ClassNames from 'classnames'; import RSVP from 'rsvp'; + import { validateEmail, validateConfirmEmail, validatePassword } from '../utils/utils'; +import I18nWithLink from '../../shared-components/I18nWithLink'; /** * @class Implement Create Account view which opens @@ -215,7 +217,9 @@ class CreateAccount extends React.Component { diff --git a/app/shared-components/I18nWithLink/I18nWithLink.jsx b/app/shared-components/I18nWithLink/I18nWithLink.jsx new file mode 100644 index 000000000..17c76339e --- /dev/null +++ b/app/shared-components/I18nWithLink/I18nWithLink.jsx @@ -0,0 +1,42 @@ +import React, { Component, createRef } from 'react'; +import PropTypes from 'prop-types'; + +import { sendMessage } from '../../panel/utils/msg'; + +class I18nWithLink extends Component { + constructor(props) { + super(props); + this.containerRef = createRef(); + } + + componentDidMount() { + const { current: { children } } = this.containerRef; + for (let i = 0; i < children.length; i++) { + const ele = children[i]; + if (ele.nodeName.toLowerCase() !== 'a') { + return; + } + ele.onclick = (e) => { + e.preventDefault(); + const { href } = e.target; + sendMessage('openNewTab', { + url: href, + become_active: true, + }); + }; + } + } + + render() { + const { value } = this.props; + return ( + + ); + } +} + +export default I18nWithLink; + +I18nWithLink.propTypes = { + value: PropTypes.string.isRequired, +}; diff --git a/app/shared-components/I18nWithLink/index.js b/app/shared-components/I18nWithLink/index.js new file mode 100644 index 000000000..c8dfa5de1 --- /dev/null +++ b/app/shared-components/I18nWithLink/index.js @@ -0,0 +1,16 @@ +/** + * Point of entry index.js file for I18nWithLink + * + * Ghostery Browser Extension + * https://www.ghostery.com/ + * + * Copyright 2019 Ghostery, Inc. All rights reserved. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0 + */ + +import I18nWithLink from './I18nWithLink'; + +export default I18nWithLink;