2017-06-19 17:25:17 +02:00
|
|
|
// 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 { observer } from 'mobx-react';
|
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
|
2017-07-10 17:03:16 +02:00
|
|
|
import { Page } from '@parity/ui';
|
|
|
|
|
|
|
|
import Store from './store';
|
2017-06-19 17:25:17 +02:00
|
|
|
|
|
|
|
import MethodCheck from './MethodCheck';
|
2017-07-10 17:03:16 +02:00
|
|
|
import styles from './dappMethods.css';
|
2017-06-19 17:25:17 +02:00
|
|
|
|
|
|
|
@observer
|
2017-07-03 17:05:56 +02:00
|
|
|
export default class SelectMethods extends Component {
|
2017-07-10 17:03:16 +02:00
|
|
|
static contextTypes = {
|
|
|
|
api: PropTypes.object.isRequired
|
2017-06-19 17:25:17 +02:00
|
|
|
};
|
|
|
|
|
2017-07-10 17:03:16 +02:00
|
|
|
store = new Store(this.context.api);
|
2017-06-19 17:25:17 +02:00
|
|
|
|
2017-07-10 17:03:16 +02:00
|
|
|
render () {
|
2017-06-19 17:25:17 +02:00
|
|
|
return (
|
2017-07-10 17:03:16 +02:00
|
|
|
<Page
|
|
|
|
className={ styles.body }
|
2017-06-19 17:25:17 +02:00
|
|
|
title={
|
|
|
|
<FormattedMessage
|
|
|
|
id='dapps.methods.label'
|
|
|
|
defaultMessage='allowed methods'
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
<table>
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th> </th>
|
|
|
|
{
|
2017-07-10 17:03:16 +02:00
|
|
|
this.store.methods.map((method, methodIndex) => (
|
|
|
|
<th key={ methodIndex }>
|
2017-06-19 17:25:17 +02:00
|
|
|
<div>
|
|
|
|
<span>{ method }</span>
|
|
|
|
</div>
|
|
|
|
</th>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{
|
2017-07-10 17:03:16 +02:00
|
|
|
this.store.apps.map(({ id, name }, dappIndex) => (
|
2017-06-19 17:25:17 +02:00
|
|
|
<tr key={ dappIndex }>
|
|
|
|
<td>{ name }</td>
|
|
|
|
{
|
2017-07-10 17:03:16 +02:00
|
|
|
this.store.methods.map((method, methodIndex) => (
|
2017-06-19 17:25:17 +02:00
|
|
|
<td
|
|
|
|
className={ styles.check }
|
2017-07-10 17:03:16 +02:00
|
|
|
key={ `${dappIndex}_${methodIndex}` }
|
2017-06-19 17:25:17 +02:00
|
|
|
>
|
|
|
|
<MethodCheck
|
2017-07-10 17:03:16 +02:00
|
|
|
checked={ this.store.hasAppPermission(method, id) }
|
2017-06-19 17:25:17 +02:00
|
|
|
dappId={ id }
|
|
|
|
method={ method }
|
2017-07-10 17:03:16 +02:00
|
|
|
onToggle={ this.store.toggleAppPermission }
|
2017-06-19 17:25:17 +02:00
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</tr>
|
|
|
|
))
|
|
|
|
}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
2017-07-10 17:03:16 +02:00
|
|
|
</Page>
|
2017-06-19 17:25:17 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|