// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Parity is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Parity. If not, see . import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import IdentityIcon from '@parity/ui/IdentityIcon'; import styles from './requestOrigin.css'; export default class RequestOrigin extends Component { static contextTypes = { api: PropTypes.object.isRequired }; static propTypes = { origin: PropTypes.shape({ type: PropTypes.oneOf(['unknown', 'dapp', 'rpc', 'ipc', 'signer']), details: PropTypes.oneOfType([ PropTypes.string, PropTypes.shape({ session: PropTypes.string.isRequired }) ]).isRequired }).isRequired }; render () { const { origin } = this.props; return (
Requested { this.renderOrigin(origin) }
); } renderOrigin (origin) { if (origin.type === 'unknown') { return ( ); } if (origin.type === 'dapp') { return ( { origin.details || ( ) } ) } } /> ); } if (origin.type === 'rpc') { return ( ({ origin.details || ( ) }) ) } } /> ); } if (origin.type === 'ipc') { return ( ); } if (origin.type === 'signer') { const session = origin.details && origin.details.session || origin.details; return this.renderSigner(session); } } renderSigner (session) { if (session.substr(2) === this.context.api.transport.sessionHash) { return ( ); } return ( ); } }