Skip to content
Snippets Groups Projects
Commit 67a449ab authored by Eric Rosenbaum's avatar Eric Rosenbaum
Browse files

wip

parent 554e5913
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ const ConnectedStep = props => ( ...@@ -14,7 +14,7 @@ const ConnectedStep = props => (
onClick={props.onSearch} onClick={props.onSearch}
> >
<FormattedMessage <FormattedMessage
defaultMessage="connected" defaultMessage="🔥connected🔥"
description="Button in prompt for starting a search" description="Button in prompt for starting a search"
id="gui.connection.search" id="gui.connection.search"
/> />
......
...@@ -14,7 +14,7 @@ const ConnectingStep = props => ( ...@@ -14,7 +14,7 @@ const ConnectingStep = props => (
onClick={props.onSearch} onClick={props.onSearch}
> >
<FormattedMessage <FormattedMessage
defaultMessage="connecting" defaultMessage="🔌connecting🔌"
description="Button in prompt for starting a search" description="Button in prompt for starting a search"
id="gui.connection.search" id="gui.connection.search"
/> />
......
...@@ -11,13 +11,6 @@ import ErrorStep from './error-step.jsx'; ...@@ -11,13 +11,6 @@ import ErrorStep from './error-step.jsx';
import styles from './connection-modal.css'; import styles from './connection-modal.css';
const phases = {
scanning: ScanningStep,
connecting: ConnectingStep,
connected: ConnectedStep,
error: ErrorStep
};
const ConnectionModalComponent = props => ( const ConnectionModalComponent = props => (
<Modal <Modal
className={styles.modalContent} className={styles.modalContent}
...@@ -26,14 +19,16 @@ const ConnectionModalComponent = props => ( ...@@ -26,14 +19,16 @@ const ConnectionModalComponent = props => (
onRequestClose={props.onCancel} onRequestClose={props.onCancel}
> >
<Box className={styles.body}> <Box className={styles.body}>
{React.createElement(phases[props.phase], props)} {props.phase === 'scanning' && <ScanningStep {...props} />}
{props.phase === 'connecting' && <ConnectingStep {...props} />}
{props.phase === 'connected' && <ConnectedStep {...props} />}
{props.phase === 'error' && <ErrorStep {...props} />}
</Box> </Box>
</Modal> </Modal>
); );
ConnectionModalComponent.propTypes = { ConnectionModalComponent.propTypes = {
onCancel: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired,
onSearch: PropTypes.func.isRequired,
phase: PropTypes.string.isRequired, phase: PropTypes.string.isRequired,
title: PropTypes.string.isRequired title: PropTypes.string.isRequired
}; };
......
...@@ -14,7 +14,7 @@ const ErrorStep = props => ( ...@@ -14,7 +14,7 @@ const ErrorStep = props => (
onClick={props.onSearch} onClick={props.onSearch}
> >
<FormattedMessage <FormattedMessage
defaultMessage="error" defaultMessage="🤕error🤕"
description="Button in prompt for starting a search" description="Button in prompt for starting a search"
id="gui.connection.search" id="gui.connection.search"
/> />
......
...@@ -11,14 +11,20 @@ const ScanningStep = props => ( ...@@ -11,14 +11,20 @@ const ScanningStep = props => (
<Box className={styles.activityArea}> <Box className={styles.activityArea}>
{props.searching ? ( {props.searching ? (
props.devices.length === 0 ? ( props.devices.length === 0 ? (
<div>search icon here</div> <div>{'👀Scanning👀'}</div>
) : ( ) : (
props.devices.map(device => ( props.devices.map(device => (
<div>{device.name}</div> <div>{device.name}</div>
)) ))
) )
) : ( ) : (
<div>No devices found, click on this hyperlink right now</div> <Box className={styles.instructions}>
<FormattedMessage
defaultMessage="Select your device in the list above."
description=""
id="gui.connection.scanning.instructions"
/>
</Box>
)} )}
</Box> </Box>
<Box className={styles.instructions}> <Box className={styles.instructions}>
...@@ -34,7 +40,7 @@ const ScanningStep = props => ( ...@@ -34,7 +40,7 @@ const ScanningStep = props => (
onClick={props.onSearch} onClick={props.onSearch}
> >
<FormattedMessage <FormattedMessage
defaultMessage="scanning" defaultMessage="refresh"
description="Button in prompt for starting a search" description="Button in prompt for starting a search"
id="gui.connection.search" id="gui.connection.search"
/> />
......
...@@ -2,13 +2,13 @@ import PropTypes from 'prop-types'; ...@@ -2,13 +2,13 @@ import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import bindAll from 'lodash.bindall'; import bindAll from 'lodash.bindall';
import ConnectionModalComponent from '../components/connection-modal/connection-modal.jsx'; import ConnectionModalComponent from '../components/connection-modal/connection-modal.jsx';
import VM from 'scratch-vm';
class ConnectionModal extends React.Component { class ConnectionModal extends React.Component {
constructor (props) { constructor (props) {
super(props); super(props);
bindAll(this, [ bindAll(this, [
'handleCancel', 'handleCancel'
'handleSearch'
]); ]);
this.state = { this.state = {
phase: 'scanning' phase: 'scanning'
...@@ -17,16 +17,13 @@ class ConnectionModal extends React.Component { ...@@ -17,16 +17,13 @@ class ConnectionModal extends React.Component {
handleCancel () { handleCancel () {
this.props.onCancel(); this.props.onCancel();
} }
handleSearch () {
this.props.onSearch();
}
render () { render () {
return ( return (
<ConnectionModalComponent <ConnectionModalComponent
phase={this.state.phase}
title={this.props.id} title={this.props.id}
vm={this.props.vm}
onCancel={this.handleCancel} onCancel={this.handleCancel}
onSearch={this.handleSearch}
phase={this.state.phase}
/> />
); );
} }
...@@ -35,7 +32,7 @@ class ConnectionModal extends React.Component { ...@@ -35,7 +32,7 @@ class ConnectionModal extends React.Component {
ConnectionModal.propTypes = { ConnectionModal.propTypes = {
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
onCancel: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired,
onSearch: PropTypes.func.isRequired vm: PropTypes.instanceOf(VM).isRequired
}; };
export default ConnectionModal; export default ConnectionModal;
...@@ -2,19 +2,28 @@ import PropTypes from 'prop-types'; ...@@ -2,19 +2,28 @@ import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import bindAll from 'lodash.bindall'; import bindAll from 'lodash.bindall';
import ScanningStepComponent from '../components/connection-modal/scanning-step.jsx'; import ScanningStepComponent from '../components/connection-modal/scanning-step.jsx';
import VM from 'scratch-vm';
class ScanningStep extends React.Component { class ScanningStep extends React.Component {
constructor (props) { constructor (props) {
super(props); super(props);
bindAll(this, [ bindAll(this, [
'handleCancel', 'handleCancel'
'handleSearch'
]); ]);
this.state = { this.state = {
searching: true, searching: true,
devices: [] devices: []
}; };
} }
componentDidMount () {
this.props.vm.on('peripheral_added', id => {
// console.log('gui says peripheral added', id);
this.setState({devices:this.state.devices.concat(id)})
});
}
componentWillUnmount () {
// remove the listener
}
handleCancel () { handleCancel () {
this.props.onCancel(); this.props.onCancel();
} }
...@@ -24,10 +33,9 @@ class ScanningStep extends React.Component { ...@@ -24,10 +33,9 @@ class ScanningStep extends React.Component {
render () { render () {
return ( return (
<ScanningStepComponent <ScanningStepComponent
phase={this.state.phase}
title={this.props.id} title={this.props.id}
onCancel={this.handleCancel} onCancel={this.handleCancel}
onSearch={this.handleSearch}
phase={this.state.phase}
/> />
); );
} }
...@@ -36,7 +44,8 @@ class ScanningStep extends React.Component { ...@@ -36,7 +44,8 @@ class ScanningStep extends React.Component {
ScanningStep.propTypes = { ScanningStep.propTypes = {
id: PropTypes.string.isRequired, id: PropTypes.string.isRequired,
onCancel: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired,
onSearch: PropTypes.func.isRequired onSearch: PropTypes.func.isRequired,
vm: PropTypes.instanceOf(VM).isRequired
}; };
export default ScanningStep; export default ScanningStep;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment