Skip to content

Commit

Permalink
Moved maps to the liftoff reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
stylesuxx committed Feb 6, 2017
1 parent 182a814 commit 780499c
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 26 deletions.
9 changes: 8 additions & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ AppComponent.propTypes = {
value: React.PropTypes.string.isRequired,
text: React.PropTypes.string.isRequired
})
).isRequired,
maps: React.PropTypes.arrayOf(
React.PropTypes.shape({
value: React.PropTypes.string.isRequired,
text: React.PropTypes.string.isRequired
})
).isRequired
})
};
Expand Down Expand Up @@ -180,7 +186,8 @@ AppComponent.defaultProps = {
}
},
liftoff: {
markers: []
markers: [],
maps: []
}
};

Expand Down
41 changes: 21 additions & 20 deletions src/components/trackSettings/Open.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import cssmodules from 'react-css-modules';
import {
FormControl,
FormGroup,
Button,
Form,
Expand All @@ -10,19 +9,10 @@ import {
} from 'react-bootstrap';
import styles from './open.cssmodule.scss';
import MonitoredTextbox from '../MonitoredTextbox';
import MonitoredSelectbox from '../MonitoredSelectbox';

class Open extends React.Component {

constructor(props) {
super(props);

this.handleMapChange = this.handleMapChange.bind(this);
}

handleMapChange(event) {
this.props.actions.setMap(event.target.value);
}

render() {
return (
<Row className="open-component">
Expand All @@ -42,13 +32,11 @@ class Open extends React.Component {
onClick={this.props.actions.deletePoint}
>Delete Point</Button>&nbsp;

<FormControl
componentClass="select"
onChange={this.handleMapChange}
>
<option value="LiftoffArena">Liftoff Arena</option>
<option value="TheDrawingBoard">The Drawing Board</option>
</FormControl>&nbsp;
<MonitoredSelectbox
updateSelection={this.props.actions.setMap}
selected={this.props.track.map}
options={this.props.liftoff.maps}
/>&nbsp;

<MonitoredTextbox
label=""
Expand Down Expand Up @@ -81,7 +69,16 @@ Open.propTypes = {
setMap: React.PropTypes.func.isRequired,
}).isRequired,
track: React.PropTypes.shape({
name: React.PropTypes.string.isRequired
name: React.PropTypes.string.isRequired,
map: React.PropTypes.string.isRequired
}),
liftoff: React.PropTypes.shape({
maps: React.PropTypes.arrayOf(
React.PropTypes.shape({
value: React.PropTypes.string.isRequired,
text: React.PropTypes.string.isRequired
})
)
})
};
/* istanbul ignore next */
Expand All @@ -94,7 +91,11 @@ Open.defaultProps = {
setMap: () => {}
},
track: {
name: 'Trackname'
name: 'name (Open.js)',
map: 'map (Open.js)',
},
liftoff: {
maps: []
}
};

Expand Down
15 changes: 13 additions & 2 deletions src/components/trackSettings/TrackSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class TrackSettings extends React.Component {
return (
<Open
className="tracksettings-component"
actions={this.props.actions} />
actions={this.props.actions}
liftoff={this.props.liftoff}
track={this.props.track} />
);
}
}
Expand Down Expand Up @@ -68,6 +70,12 @@ TrackSettings.propTypes = {
value: React.PropTypes.string.isRequired,
text: React.PropTypes.string.isRequired
})
).isRequired,
maps: React.PropTypes.arrayOf(
React.PropTypes.shape({
value: React.PropTypes.string.isRequired,
text: React.PropTypes.string.isRequired
})
).isRequired
})
};
Expand All @@ -91,6 +99,8 @@ TrackSettings.defaultProps = {
},
track: {
markerType: 'DiscConeBlue01 (Tracksettings.js)',
name: 'name (Tracksettings.js)',
map: 'map (Tracksettings.js)',
gatesEnabled: false,
markerSpacing: 20,
doubleLine: false,
Expand All @@ -109,7 +119,8 @@ TrackSettings.defaultProps = {
}
},
liftoff: {
markers: []
markers: [],
maps: []
}
};

Expand Down
6 changes: 6 additions & 0 deletions src/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ App.propTypes = {
value: React.PropTypes.string.isRequired,
text: React.PropTypes.string.isRequired
})
).isRequired,
maps: React.PropTypes.arrayOf(
React.PropTypes.shape({
value: React.PropTypes.string.isRequired,
text: React.PropTypes.string.isRequired
})
).isRequired
})
};
Expand Down
10 changes: 10 additions & 0 deletions src/reducers/liftoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ const initialState = {
value: 'AirPylonLuGusStudios01',
text: 'Air Polygon'
}
],
maps: [
{
value: 'LiftoffArena',
text: 'Liftoff Arena'
},
{
value: 'TheDrawingBoard',
text: 'The Drawing Board'
}
]
};

Expand Down
6 changes: 3 additions & 3 deletions test/components/trackSettings/OpenTest.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { mount } from 'enzyme';
import Open from 'components/trackSettings/Open.js';

describe('<Open />', function () {
Expand All @@ -13,14 +13,14 @@ describe('<Open />', function () {
setName: sinon.spy()
};

const component = shallow(<Open actions={actions} />);
const component = mount(<Open actions={actions} />);

it('should have a className of "open-component"', function () {
expect(component.hasClass('open-component')).to.equal(true);
});

it('should trigger SET_MAP action', function () {
const wrapper = component.find('FormControl');
const wrapper = component.find('MonitoredSelectbox');
wrapper.simulate('change', {target: {value: 'TheDrawingBoard'}});

expect(actions.setMap.called).to.be.true;
Expand Down
2 changes: 2 additions & 0 deletions test/components/trackSettings/TrackSettingsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ describe('<TrackSettings />', function () {
download: false,
closed: true,
markerType: 'foo',
name: 'Trackname',
map: 'map'
};

component = shallow(<TrackSettings track={track} />);
Expand Down

0 comments on commit 780499c

Please sign in to comment.