application/components/admin/plugins.js
import React, {Component} from 'react';
import Immutable from 'immutable';
import {List, ListItem} from 'material-ui/List';
import Subheader from 'material-ui/Subheader';
import Divider from 'material-ui/Divider';
import Toggle from 'material-ui/Toggle';
import FlatButton from 'material-ui/FlatButton';
import RaisedButton from 'material-ui/RaisedButton';
import IconButton from 'material-ui/IconButton';
import TextField from 'material-ui/TextField';
import {Toolbar, ToolbarGroup, ToolbarSeparator, ToolbarTitle} from 'material-ui/Toolbar';
import {connect} from 'react-redux';
import Config from '../../config';
import ExpandingCard from './../expanding-card';
import {
snackbarShowMessage
} from './../../redux/actions/snackbar-actions';
import {
applicationFetchSettings,
applicationUpdateSetting
} from './../../redux/actions/application-actions';
import {Row, Col} from './../flexbox';
class PluginsCard extends Component {
constructor(props) {
super(props);
this.state = {
expanded: false,
};
}
handleToggle(expanded) {
if (this.props.onToggle) {
this.props.onToggle('plugins', expanded);
}
if (expanded && !this.state.hasLoaded) {
const {dispatch} = this.props;
}
}
toggleSetting(slug, e, checked) {
const {dispatch} = this.props;
if (checked) {
dispatch(snackbarShowMessage('Installing...'));
} else {
dispatch(snackbarShowMessage('Uninstalling...'));
}
dispatch(applicationUpdateSetting(slug, checked)).
then(() => dispatch(snackbarShowMessage('Done')));
}
render() {
return (
<ExpandingCard
onToggle={this.handleToggle.bind(this)}
title="Plugins"
subtitle="Manage installed plugins"
expanded={this.props.openCard === 'plugins'}
>
<Toggle
label='Classifieds'
labelPosition='right'
toggled={this.props.application.settings.get('plugin_classifieds') ? true : false}
onToggle={this.toggleSetting.bind(this, 'plugin_classifieds')}
/>
<p>Manage import and display of classified ads from Pre1 SmartPublisher or Eclipse AdPro.</p>
<Divider />
<Toggle
label='DocSync'
labelPosition='right'
toggled={this.props.application.settings.get('plugin_docSync') ? true : false}
onToggle={this.toggleSetting.bind(this, 'plugin_docSync')}
/>
<p>Enable one-way document sync with Issuu or ScribD. Requires a paid account with either service.</p>
<Divider />
<Toggle
label='Google Calendar'
labelPosition='right'
toggled={this.props.application.settings.get('plugin_gcalendar') ? true : false}
onToggle={this.toggleSetting.bind(this, 'plugin_gcalendar')}
/>
<p>Enable Google Calendar event sync. Please make sure you have your SNworks provided Google credentials.</p>
<Divider />
<Toggle
label='Polls'
labelPosition='right'
toggled={this.props.application.settings.get('plugin_polls') ? true : false}
onToggle={this.toggleSetting.bind(this, 'plugin_polls')}
/>
<p>Create and manage opinion polls.</p>
<Divider />
<Toggle
label='Ad Manager'
labelPosition='right'
toggled={this.props.application.settings.get('plugin_admanager') ? true : false}
onToggle={this.toggleSetting.bind(this, 'plugin_admanager')}
/>
<p>Simple web ad management. Does not track campaigns or metering.</p>
<Divider />
<Toggle
label='Dropbox'
labelPosition='right'
toggled={this.props.application.settings.get('plugin_dropbox') ? true : false}
onToggle={this.toggleSetting.bind(this, 'plugin_dropbox')}
/>
<p>Upload files to CEO to be processed by custom handlers. Generally, SNworks will enable this as necessary.</p>
</ExpandingCard>
);
}
}
let mapStateToProps = (state) => {
return {
application: state.application
};
};
export default connect(mapStateToProps)(PluginsCard);