2016-10-20 11:22:25 +02:00
|
|
|
// Copyright 2015, 2016 Ethcore (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 React, { Component, PropTypes } from 'react';
|
|
|
|
import DoneIcon from 'material-ui/svg-icons/action/done';
|
|
|
|
import { List, ListItem } from 'material-ui/List';
|
|
|
|
import Checkbox from 'material-ui/Checkbox';
|
|
|
|
|
|
|
|
import { Modal, Button } from '../../../ui';
|
|
|
|
|
2016-10-22 15:49:39 +02:00
|
|
|
import styles from './addDapps.css';
|
2016-10-20 11:22:25 +02:00
|
|
|
|
|
|
|
export default class AddDapps extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
available: PropTypes.array.isRequired,
|
2016-10-22 15:49:39 +02:00
|
|
|
hidden: PropTypes.array.isRequired,
|
2016-10-20 11:22:25 +02:00
|
|
|
open: PropTypes.bool.isRequired,
|
2016-10-22 15:49:39 +02:00
|
|
|
onHideApp: PropTypes.func.isRequired,
|
|
|
|
onShowApp: PropTypes.func.isRequired,
|
2016-10-20 11:22:25 +02:00
|
|
|
onClose: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const { onClose, open, available } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
2016-10-22 15:49:39 +02:00
|
|
|
compact
|
|
|
|
title='visible applications'
|
2016-10-20 11:22:25 +02:00
|
|
|
actions={ [
|
2016-10-22 15:49:39 +02:00
|
|
|
<Button label={ 'Done' } key='done' onClick={ onClose } icon={ <DoneIcon /> } />
|
2016-10-20 11:22:25 +02:00
|
|
|
] }
|
|
|
|
visible={ open }
|
2016-10-22 15:49:39 +02:00
|
|
|
scroll>
|
2016-10-20 11:22:25 +02:00
|
|
|
<List>
|
|
|
|
{ available.map(this.renderApp) }
|
|
|
|
</List>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderApp = (app) => {
|
2016-10-22 15:49:39 +02:00
|
|
|
const { hidden, onHideApp, onShowApp } = this.props;
|
|
|
|
const isHidden = hidden.includes(app.id);
|
|
|
|
const description = (
|
|
|
|
<div className={ styles.description }>
|
|
|
|
{ app.description }
|
|
|
|
</div>
|
|
|
|
);
|
2016-10-20 11:22:25 +02:00
|
|
|
const onCheck = () => {
|
2016-10-22 15:49:39 +02:00
|
|
|
if (isHidden) {
|
|
|
|
onShowApp(app.id);
|
|
|
|
} else {
|
|
|
|
onHideApp(app.id);
|
|
|
|
}
|
2016-10-20 11:22:25 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ListItem
|
|
|
|
key={ app.id }
|
2016-10-22 15:49:39 +02:00
|
|
|
leftCheckbox={ <Checkbox checked={ !isHidden } onCheck={ onCheck } /> }
|
2016-10-20 11:22:25 +02:00
|
|
|
primaryText={ app.name }
|
2016-10-22 15:49:39 +02:00
|
|
|
secondaryText={ description } />
|
2016-10-20 11:22:25 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|