diff --git a/src/index.js b/src/index.js index 32558cd4ec93844c558ce5d45fed8d54824ac01a..d0b5c4557cda8a0e408ef01c6e5fa2ae680a01ed 100644 --- a/src/index.js +++ b/src/index.js @@ -10,6 +10,9 @@ const qs = queryString.parse(location.search); registerTelemetry(); ReactDOM.render( - <HomeRoot dialogType={qs.list_signup ? InfoDialog.dialogTypes.updates : null} />, + <HomeRoot + initialEnvironment={qs.initial_environment} + dialogType={qs.list_signup ? InfoDialog.dialogTypes.updates : null} + />, document.getElementById("home-root") ); diff --git a/src/react-components/home-root.js b/src/react-components/home-root.js index 318fc88d95acd9d95d67adbb507ecd08cce843ee..d27bc310dac25f0a480aa634afb2ae61ae7fa243 100644 --- a/src/react-components/home-root.js +++ b/src/react-components/home-root.js @@ -17,7 +17,8 @@ addLocaleData([...en]); class HomeRoot extends Component { static propTypes = { intl: PropTypes.object, - dialogType: PropTypes.symbol + dialogType: PropTypes.symbol, + initialEnvironment: PropTypes.string }; state = { @@ -155,7 +156,12 @@ class HomeRoot extends Component { </div> </div> <div className="hero-content__create"> - {this.state.environments.length > 0 && <HubCreatePanel environments={this.state.environments} />} + {this.state.environments.length > 0 && ( + <HubCreatePanel + initialEnvironment={this.props.initialEnvironment} + environments={this.state.environments} + /> + )} </div> </div> <div className="footer-content"> diff --git a/src/react-components/hub-create-panel.js b/src/react-components/hub-create-panel.js index dc10b99ac217609b07bda59422c805c5ea4f1581..959a4a9331a1975a83a0ab315b7fa092c8f05418 100644 --- a/src/react-components/hub-create-panel.js +++ b/src/react-components/hub-create-panel.js @@ -15,16 +15,25 @@ const HUB_NAME_PATTERN = "^[A-Za-z0-9-'\":!@#$%^&*(),.?~ ]{4,64}$"; class HubCreatePanel extends Component { static propTypes = { intl: PropTypes.object, - environments: PropTypes.array + environments: PropTypes.array, + initialEnvironment: PropTypes.string }; constructor(props) { super(props); + let environmentIndex = Math.floor(Math.random() * props.environments.length); + + if (props.initialEnvironment) { + environmentIndex = props.environments.findIndex( + e => e.name.toLowerCase() === props.initialEnvironment.toLowerCase() + ); + } + this.state = { ready: false, name: generateHubName(), - environmentIndex: Math.floor(Math.random() * props.environments.length), + environmentIndex, // HACK: expand on small screens by default to ensure scene selection possible. // Eventually this could/should be done via media queries. expanded: window.innerWidth < 420