Signer plugin attachment
This commit is contained in:
@@ -20,15 +20,18 @@ import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { observer } from 'mobx-react';
|
||||
|
||||
import * as RequestsActions from '@parity/shared/redux/providers/signerActions';
|
||||
import Container from '@parity/ui/Container';
|
||||
import RequestPending from '@parity/ui/Signer/RequestPending';
|
||||
|
||||
import Store from '@parity/shared/mobx/signerStore';
|
||||
|
||||
import PluginStore from '../pluginStore';
|
||||
|
||||
import styles from './embedded.css';
|
||||
|
||||
@observer
|
||||
class Embedded extends Component {
|
||||
static contextTypes = {
|
||||
api: PropTypes.object.isRequired
|
||||
@@ -49,6 +52,7 @@ class Embedded extends Component {
|
||||
};
|
||||
|
||||
store = new Store(this.context.api, false, this.props.externalLink);
|
||||
pluginStore = PluginStore.get();
|
||||
|
||||
render () {
|
||||
return (
|
||||
@@ -87,6 +91,22 @@ class Embedded extends Component {
|
||||
renderPending = (data, index) => {
|
||||
const { actions, gasLimit, netVersion } = this.props;
|
||||
const { date, id, isSending, payload, origin } = data;
|
||||
const Handler = this.pluginStore.findHandler(payload);
|
||||
|
||||
// if (Handler) {
|
||||
// return (
|
||||
// <Handler
|
||||
// gasLimit={ gasLimit }
|
||||
// id={ id }
|
||||
// isSending={ isSending }
|
||||
// key={ id }
|
||||
// netVersion={ netVersion }
|
||||
// onConfirm={ actions.startConfirmRequest }
|
||||
// onReject={ actions.startRejectRequest }
|
||||
// payload={ payload }
|
||||
// />
|
||||
// );
|
||||
// }
|
||||
|
||||
return (
|
||||
<RequestPending
|
||||
|
||||
45
js/src/Signer/pluginStore.js
Normal file
45
js/src/Signer/pluginStore.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { action, observable } from 'mobx';
|
||||
|
||||
let instance = null;
|
||||
|
||||
export default class PluginStore {
|
||||
@observable components = [];
|
||||
|
||||
@action addComponent (Component) {
|
||||
if (!Component || (typeof Component.isHandler !== 'function')) {
|
||||
throw new Error(`Unable to attach Signer component, 'isHandler' function is not defined`);
|
||||
}
|
||||
|
||||
this.components.push(Component);
|
||||
}
|
||||
|
||||
findHandler (payload) {
|
||||
return this.components.find((component) => {
|
||||
return component.isHandler(payload);
|
||||
});
|
||||
}
|
||||
|
||||
static get () {
|
||||
if (!instance) {
|
||||
instance = new PluginStore();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user