import * as React from 'react' import BooleanSwitch from './BooleanSwitch' import BrokerStatistics from './BrokerStatistics' import ChevronRight from '@material-ui/icons/ChevronRight' import { AppState } from '../../reducers' import { bindActionCreators } from 'redux' import { connect } from 'react-redux' import { globalActions, settingsActions } from '../../actions' import { shell } from 'electron' import { StyleRulesCallback, withStyles } from '@material-ui/core/styles' import { TopicOrder } from '../../reducers/Settings' import { Divider, Drawer, IconButton, Input, InputLabel, MenuItem, Select, Typography, Tooltip, } from '@material-ui/core' export const autoExpandLimitSet = [{ limit: 0, name: 'Collapsed', }, { limit: 2, name: 'Few', }, { limit: 3, name: 'Some', }, { limit: 15, name: 'Most', }, { limit: 1E6, name: 'All', }] const styles: StyleRulesCallback = theme => ({ drawer: { backgroundColor: theme.palette.background.default, flexShrink: 0, userSelect: 'none' as 'none', }, paper: { width: '300px', }, title: { color: theme.palette.text.primary, paddingTop: theme.spacing(1), ...theme.mixins.toolbar, }, input: { minWidth: '150px', margin: `auto ${theme.spacing(1)} auto ${theme.spacing(2)}px`, }, author: { margin: 'auto 8px 8px auto', color: theme.palette.text.hint, cursor: 'pointer' as 'pointer', }, }) interface Props { actions: { settings: typeof settingsActions, global: typeof globalActions, } autoExpandLimit: number classes: any highlightTopicUpdates: boolean selectTopicWithMouseOver: boolean store?: any topicOrder: TopicOrder visible: boolean theme: 'light' | 'dark' } class Settings extends React.Component { constructor(props: any) { super(props) this.state = {} } private openGithubPage = () => { shell.openExternal('https://github.com/thomasnordquist') } private renderHighlightTopicUpdates() { const { highlightTopicUpdates, actions } = this.props return } private selectTopicsOnMouseOver() { const { actions, selectTopicWithMouseOver } = this.props const toggle = () => actions.settings.selectTopicWithMouseOver(!selectTopicWithMouseOver) return } private toggleTheme() { const { actions, theme } = this.props return } private renderAutoExpand() { const { classes, autoExpandLimit } = this.props const limits = autoExpandLimitSet.map(limit => {limit.limit < 10000 && limit.limit > 0 ? `≤ ${limit.limit} topics` : limit.name}) return (
Auto Expand
) } private onChangeAutoExpand = (e: React.ChangeEvent) => { this.props.actions.settings.setAutoExpandLimit(parseInt(e.target.value, 10)) } private renderNodeOrder() { const { classes, topicOrder } = this.props return (
Topic Order
) } private onChangeSorting = (e: React.ChangeEvent) => { this.props.actions.settings.setTopicOrder(e.target.value as TopicOrder) } public render() { const { classes, actions, visible } = this.props return (
Settings
{this.renderAutoExpand()} {this.renderNodeOrder()} {this.renderHighlightTopicUpdates()} {this.selectTopicsOnMouseOver()} {this.toggleTheme()}
by Thomas Nordquist
) } } const mapStateToProps = (state: AppState) => { return { autoExpandLimit: state.settings.get('autoExpandLimit'), topicOrder: state.settings.get('topicOrder'), visible: state.globalState.get('settingsVisible'), highlightTopicUpdates: state.settings.get('highlightTopicUpdates'), selectTopicWithMouseOver: state.settings.get('selectTopicWithMouseOver'), theme: state.settings.get('theme'), } } const mapDispatchToProps = (dispatch: any) => { return { actions: { settings: bindActionCreators(settingsActions, dispatch), global: bindActionCreators(globalActions, dispatch), }, } } export default withStyles(styles)(connect(mapStateToProps, mapDispatchToProps)(Settings))