Redux changes and refactoring
This commit is contained in:
@@ -12,9 +12,9 @@ import {displayConfiguration, setProviderState} from '../../redux/actions/mount_
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
return {
|
||||
MState: state.mounts.MountState[ownProps.provider],
|
||||
Platform: state.common.Platform,
|
||||
ProviderState: state.mounts.ProviderState,
|
||||
State: state.mounts.ProviderState[ownProps.provider]
|
||||
PState: state.mounts.ProviderState[ownProps.provider]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ const mapDispatchToProps = dispatch => {
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||
const handleAutoMountChanged = e => {
|
||||
const state = {
|
||||
...props.ProviderState[props.provider],
|
||||
...props.PState,
|
||||
AutoMount: e.target.checked,
|
||||
};
|
||||
props.setProviderState(props.provider, state);
|
||||
@@ -36,7 +36,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||
|
||||
const handleAutoRestartChanged = e => {
|
||||
const state = {
|
||||
...props.ProviderState[props.provider],
|
||||
...props.PState,
|
||||
AutoRestart: e.target.checked,
|
||||
};
|
||||
props.setProviderState(props.provider, state);
|
||||
@@ -45,13 +45,13 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||
let configButton = null;
|
||||
let secondRow = 6;
|
||||
if (props.allowConfig) {
|
||||
const pointer = {cursor: props.allowMount ? 'pointer' : 'no-drop'};
|
||||
const pointer = {cursor: props.MState.AllowMount ? 'pointer' : 'no-drop'};
|
||||
configButton = (
|
||||
<RootElem colSpan={4}
|
||||
rowSpan={6}>
|
||||
<img alt=''
|
||||
height={'16px'}
|
||||
onClick={props.allowMount ? ()=>props.displayConfiguration(props.provider) : e=>{e.preventDefault();}}
|
||||
onClick={props.MState.AllowMount ? ()=>props.displayConfiguration(props.provider) : e=>{e.preventDefault();}}
|
||||
src={configureImage}
|
||||
style={{padding: 0, border: 0, margin: 0, ...pointer}}
|
||||
width={'16px'}/>
|
||||
@@ -65,11 +65,11 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||
inputColumnSpan = 20;
|
||||
inputControls = <DropDown changed={props.changed}
|
||||
colSpan={inputColumnSpan}
|
||||
disabled={!props.allowMount || props.mounted}
|
||||
items={props.items}
|
||||
disabled={!props.MState.AllowMount || props.MState.Mounted}
|
||||
items={props.MState.DriveLetters}
|
||||
row={secondRow}
|
||||
rowSpan={7}
|
||||
selected={props.items.indexOf(props.State.MountLocation)}/>;
|
||||
selected={props.MState.DriveLetters.indexOf(props.PState.MountLocation)}/>;
|
||||
|
||||
} else {
|
||||
inputColumnSpan = 58;
|
||||
@@ -80,38 +80,38 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||
key={'i' + key++}
|
||||
row={secondRow}
|
||||
rowSpan={7}>
|
||||
<input disabled={!props.allowMount || props.mounted}
|
||||
<input disabled={!props.MState.AllowMount || props.MState.Mounted}
|
||||
maxLength={4096}
|
||||
onChange={props.changed}
|
||||
size={4096}
|
||||
className={'MountItemInput'}
|
||||
type={'text'}
|
||||
value={props.State.MountLocation}/>
|
||||
value={props.PState.MountLocation}/>
|
||||
</RootElem>
|
||||
));
|
||||
inputControls.push((
|
||||
<Button clicked={()=>props.browseClicked(props.title, props.State.MountLocation)}
|
||||
<Button clicked={()=>props.browseClicked(props.provider, props.PState.MountLocation)}
|
||||
col={inputColumnSpan - 7}
|
||||
colSpan={7}
|
||||
disabled={props.mounted || !props.allowMount}
|
||||
disabled={props.MState.Mounted || !props.MState.AllowMount}
|
||||
key={'b' + key++}
|
||||
row={secondRow}
|
||||
rowSpan={7}>...</Button>
|
||||
));
|
||||
}
|
||||
|
||||
const buttonDisplay = props.allowMount ?
|
||||
(props.mounted ? 'Unmount' : 'Mount') :
|
||||
const buttonDisplay = props.MState.AllowMount ?
|
||||
(props.MState.Mounted ? 'Unmount' : 'Mount') :
|
||||
<Loader color={'var(--heading_text_color)'}
|
||||
height='19px'
|
||||
type='Circles'
|
||||
width='19px'/>;
|
||||
|
||||
const actionsDisplay = (
|
||||
<Button clicked={()=>props.clicked(props.title, !props.mounted, props.State.MountLocation)}
|
||||
<Button clicked={()=>props.clicked(props.provider, !props.MState.Mounted, props.PState.MountLocation)}
|
||||
col={inputColumnSpan + 2}
|
||||
colSpan={21}
|
||||
disabled={!props.allowMount}
|
||||
disabled={!props.MState.AllowMount}
|
||||
row={secondRow}
|
||||
rowSpan={7}>
|
||||
{buttonDisplay}
|
||||
@@ -122,7 +122,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||
colSpan={28}
|
||||
row={secondRow}
|
||||
rowSpan={7}>
|
||||
<input checked={props.State.AutoMount}
|
||||
<input checked={props.PState.AutoMount}
|
||||
onChange={handleAutoMountChanged}
|
||||
type='checkbox'/>Auto-mount
|
||||
</RootElem>
|
||||
@@ -133,7 +133,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||
colSpan={24}
|
||||
row={secondRow}
|
||||
rowSpan={7}>
|
||||
<input checked={props.State.AutoRestart}
|
||||
<input checked={props.PState.AutoRestart}
|
||||
onChange={handleAutoRestartChanged}
|
||||
type='checkbox'/>Restart
|
||||
</RootElem>
|
||||
@@ -145,7 +145,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(props => {
|
||||
<Text
|
||||
col={configButton ? 6 : 0}
|
||||
rowSpan={5}
|
||||
text={props.title}
|
||||
text={props.provider}
|
||||
type={'Heading1'}/>
|
||||
{inputControls}
|
||||
{actionsDisplay}
|
||||
|
||||
Reference in New Issue
Block a user