-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from nextstrain/experimental_merge
Experimental merge
- Loading branch information
Showing
20 changed files
with
892 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import React from "react"; | ||
import _ from "lodash"; | ||
import { select} from "../../globalStyles"; | ||
import { connect } from "react-redux"; | ||
import { CHANGE_GEO_RESOLUTION } from "../../actions/types"; | ||
import { changeColorBy } from "../../actions/colors"; | ||
import { modifyURLquery } from "../../util/urlHelpers"; | ||
|
||
/* Why does this have colorBy set as state (here) and in redux? | ||
it's for the case where we select genotype, then wait for the | ||
base to be selected, so we modify state but not yet dispatch | ||
*/ | ||
|
||
@connect((state) => { | ||
return { | ||
metadata: state.metadata.metadata, | ||
geoResolution: state.controls.geoResolution, | ||
}; | ||
}) | ||
class GeoResolution extends React.Component { | ||
static contextTypes = { | ||
router: React.PropTypes.object.isRequired | ||
} | ||
getStyles() { | ||
return { | ||
base: { | ||
marginBottom: 10 | ||
} | ||
}; | ||
} | ||
createResolutions() { | ||
let resolutions = null; | ||
|
||
if (this.props.metadata) { | ||
const resolutionKeys = _.keys(this.props.metadata.geo) | ||
resolutions = resolutionKeys.map((resolution, i) => { | ||
return ( | ||
<option key={i} value={ resolution }> | ||
{ resolution.toLowerCase() } | ||
</option> | ||
) | ||
}) | ||
} | ||
return resolutions; | ||
} | ||
render() { | ||
|
||
const styles = this.getStyles(); | ||
|
||
return ( | ||
<div style={styles.base}> | ||
<select | ||
value={this.props.geoResolution} | ||
style={select} | ||
id="geoResolution" | ||
onChange={(e) => { | ||
this.props.dispatch({ type: CHANGE_GEO_RESOLUTION, data: e.target.value }); | ||
modifyURLquery(this.context.router, {r: e.target.value}, true); | ||
}} | ||
> | ||
{this.createResolutions()} | ||
</select> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default GeoResolution; |
Oops, something went wrong.