mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-29 02:57:19 +00:00
[web] Try toggle options in option modal.
This commit is contained in:
parent
d7bbfca167
commit
2e6f56c4e7
@ -27,6 +27,7 @@ export default class WebsocketBackend {
|
||||
this.fetchData("settings")
|
||||
this.fetchData("flows")
|
||||
this.fetchData("events")
|
||||
this.fetchData("options")
|
||||
this.store.dispatch(connectionActions.startFetching())
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import * as modalAction from '../../ducks/ui/modal'
|
||||
import { SettingsToggle } from '../Header/MenuToggle'
|
||||
import { OptionsToggle } from './OptionTypes'
|
||||
|
||||
class PureOptionModal extends Component {
|
||||
|
||||
@ -26,7 +28,9 @@ class PureOptionModal extends Component {
|
||||
</div>
|
||||
|
||||
<div className="modal-body">
|
||||
...
|
||||
<OptionsToggle option="http2">HTTP/2.0</OptionsToggle>
|
||||
<OptionsToggle option="anticache">Anticache</OptionsToggle>
|
||||
<OptionsToggle option="anticomp">Anticomp</OptionsToggle>
|
||||
</div>
|
||||
|
||||
<div className="modal-footer">
|
||||
|
48
web/src/js/components/Modal/OptionTypes.jsx
Normal file
48
web/src/js/components/Modal/OptionTypes.jsx
Normal file
@ -0,0 +1,48 @@
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { update as updateOptions } from '../../ducks/options'
|
||||
|
||||
MenuToggle.propTypes = {
|
||||
value: PropTypes.bool.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
children: PropTypes.node.isRequired,
|
||||
}
|
||||
|
||||
export function MenuToggle({ value, onChange, children }) {
|
||||
return (
|
||||
<div className="menu-entry">
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
checked={value}
|
||||
onChange={onChange}/>
|
||||
{children}
|
||||
</label>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
OptionsToggle.propTypes = {
|
||||
option: PropTypes.string.isRequired,
|
||||
children: PropTypes.node.isRequired,
|
||||
}
|
||||
|
||||
export function OptionsToggle({ option, children, options, updateOptions }) {
|
||||
return (
|
||||
<MenuToggle
|
||||
value={ options[option].value }
|
||||
onChange={() => {console.log(options[option]);
|
||||
updateOptions({ [option]: !(options[option].value)}) }}
|
||||
>
|
||||
{children}
|
||||
</MenuToggle>
|
||||
)
|
||||
}
|
||||
|
||||
OptionsToggle = connect(
|
||||
state => ({
|
||||
options: state.options,
|
||||
}),
|
||||
{
|
||||
updateOptions,
|
||||
}
|
||||
)(OptionsToggle)
|
@ -4,6 +4,7 @@ import flows from "./flows"
|
||||
import settings from "./settings"
|
||||
import ui from "./ui/index"
|
||||
import connection from "./connection"
|
||||
import options from './options'
|
||||
|
||||
export default combineReducers({
|
||||
eventLog,
|
||||
@ -11,4 +12,5 @@ export default combineReducers({
|
||||
settings,
|
||||
connection,
|
||||
ui,
|
||||
options,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user