Skip to content
Snippets Groups Projects
Commit cc367061 authored by Evelyn Eastmond's avatar Evelyn Eastmond
Browse files

Adding an alert reconnect button to the alert component.

parent b18bc447
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,29 @@ ...@@ -30,7 +30,29 @@
} }
.alert-close-button { .alert-close-button {
outline-style:none;
}
.alert-close-button-container {
margin-top: 7px; margin-top: 7px;
margin-right: 4px; margin-right: 4px;
outline-style:none; outline-style:none;
width: 30px;
height: 30px;
}
.connection-button {
padding: 0.55rem 0.9rem;
border-radius: 0.35rem;
background: #FF8C1A;
color: white;
font-weight: 700;
font-size: 0.77rem;
margin: 0.25rem;
border: none;
cursor: pointer;
display: flex;
align-items: center;
margin-right: 13px;
outline-style:none;
} }
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import {FormattedMessage} from 'react-intl';
import Box from '../box/box.jsx'; import Box from '../box/box.jsx';
import CloseButton from '../close-button/close-button.jsx'; import CloseButton from '../close-button/close-button.jsx';
...@@ -9,7 +10,8 @@ import styles from './alert.css'; ...@@ -9,7 +10,8 @@ import styles from './alert.css';
const AlertComponent = ({ const AlertComponent = ({
iconURL, iconURL,
message, message,
onCloseAlert onCloseAlert,
onReconnect
}) => ( }) => (
<Box <Box
className={styles.alert} className={styles.alert}
...@@ -23,19 +25,34 @@ const AlertComponent = ({ ...@@ -23,19 +25,34 @@ const AlertComponent = ({
) : null} ) : null}
{message} {message}
</div> </div>
<CloseButton <button
className={styles.alertCloseButton} className={styles.connectionButton}
color={CloseButton.COLOR_ORANGE} onClick={onReconnect}
size={CloseButton.SIZE_LARGE} >
onClick={onCloseAlert} <FormattedMessage
/> defaultMessage="Reconnect"
description="Button to disconnect the device"
id="gui.connection.disconnect"
/>
</button>
<Box
className={styles.alertCloseButtonContainer}
>
<CloseButton
className={styles.alertCloseButton}
color={CloseButton.COLOR_ORANGE}
size={CloseButton.SIZE_LARGE}
onClick={onCloseAlert}
/>
</Box>
</Box> </Box>
); );
AlertComponent.propTypes = { AlertComponent.propTypes = {
iconURL: PropTypes.string, iconURL: PropTypes.string,
message: PropTypes.string, message: PropTypes.string,
onCloseAlert: PropTypes.func.isRequired onCloseAlert: PropTypes.func.isRequired,
onReconnect: PropTypes.func.isRequired
}; };
export default AlertComponent; export default AlertComponent;
...@@ -3,11 +3,13 @@ import PropTypes from 'prop-types'; ...@@ -3,11 +3,13 @@ import PropTypes from 'prop-types';
import Box from '../box/box.jsx'; import Box from '../box/box.jsx';
import Alert from '../../containers/alert.jsx'; import Alert from '../../containers/alert.jsx';
import VM from 'scratch-vm';
const AlertsComponent = ({ const AlertsComponent = ({
alertsList, alertsList,
className, className,
onCloseAlert onCloseAlert,
vm
}) => ( }) => (
<Box <Box
bounds="parent" bounds="parent"
...@@ -19,6 +21,7 @@ const AlertsComponent = ({ ...@@ -19,6 +21,7 @@ const AlertsComponent = ({
index={index} index={index}
key={index} key={index}
message={a.message} message={a.message}
vm={vm}
onCloseAlert={onCloseAlert} onCloseAlert={onCloseAlert}
/> />
))} ))}
...@@ -28,7 +31,8 @@ const AlertsComponent = ({ ...@@ -28,7 +31,8 @@ const AlertsComponent = ({
AlertsComponent.propTypes = { AlertsComponent.propTypes = {
alertsList: PropTypes.arrayOf(PropTypes.object), alertsList: PropTypes.arrayOf(PropTypes.object),
className: PropTypes.string, className: PropTypes.string,
onCloseAlert: PropTypes.func onCloseAlert: PropTypes.func,
vm: PropTypes.instanceOf(VM).isRequired
}; };
export default AlertsComponent; export default AlertsComponent;
...@@ -130,7 +130,10 @@ const GUIComponent = props => { ...@@ -130,7 +130,10 @@ const GUIComponent = props => {
vm={vm} vm={vm}
> >
{alertsVisible ? ( {alertsVisible ? (
<Alerts className={styles.alertsContainer} /> <Alerts
className={styles.alertsContainer}
vm={vm}
/>
) : null} ) : null}
</StageWrapper> </StageWrapper>
) : ( ) : (
...@@ -158,7 +161,10 @@ const GUIComponent = props => { ...@@ -158,7 +161,10 @@ const GUIComponent = props => {
<Cards /> <Cards />
) : null} ) : null}
{alertsVisible ? ( {alertsVisible ? (
<Alerts className={styles.alertsContainer} /> <Alerts
className={styles.alertsContainer}
vm={vm}
/>
) : null} ) : null}
{connectionModalVisible ? ( {connectionModalVisible ? (
<ConnectionModal <ConnectionModal
......
import React from 'react'; import React from 'react';
import bindAll from 'lodash.bindall'; import bindAll from 'lodash.bindall';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import VM from 'scratch-vm';
import AlertComponent from '../components/alerts/alert.jsx'; import AlertComponent from '../components/alerts/alert.jsx';
import {openConnectionModal} from '../reducers/modals';
import {setConnectionModalExtensionId} from '../reducers/connection-modal';
class Alert extends React.Component { class Alert extends React.Component {
constructor (props) { constructor (props) {
...@@ -14,6 +18,10 @@ class Alert extends React.Component { ...@@ -14,6 +18,10 @@ class Alert extends React.Component {
handleOnCloseAlert () { handleOnCloseAlert () {
this.props.onCloseAlert(this.props.index); this.props.onCloseAlert(this.props.index);
} }
handleOnReconnect () {
// this.props.vm.emit('')
console.log('hello');
}
render () { render () {
const { const {
index, // eslint-disable-line no-unused-vars index, // eslint-disable-line no-unused-vars
...@@ -25,16 +33,28 @@ class Alert extends React.Component { ...@@ -25,16 +33,28 @@ class Alert extends React.Component {
iconURL={iconURL} iconURL={iconURL}
message={message} message={message}
onCloseAlert={this.handleOnCloseAlert} onCloseAlert={this.handleOnCloseAlert}
onReconnect={this.handleOnReconnect}
/> />
); );
} }
} }
const mapDispatchToProps = dispatch => ({
onOpenConnectionModal: id => {
dispatch(setConnectionModalExtensionId(id));
dispatch(openConnectionModal());
}
});
Alert.propTypes = { Alert.propTypes = {
iconURL: PropTypes.string, iconURL: PropTypes.string,
index: PropTypes.number, index: PropTypes.number,
message: PropTypes.string, message: PropTypes.string,
onCloseAlert: PropTypes.func.isRequired onCloseAlert: PropTypes.func.isRequired,
onOpenConnectionModal: PropTypes.func,
vm: PropTypes.instanceOf(VM).isRequired
}; };
export default Alert; export default connect(
mapDispatchToProps
)(Alerts);
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import VM from 'scratch-vm';
import { import {
closeAlert closeAlert
...@@ -11,11 +12,13 @@ import AlertsComponent from '../components/alerts/alerts.jsx'; ...@@ -11,11 +12,13 @@ import AlertsComponent from '../components/alerts/alerts.jsx';
const Alerts = ({ const Alerts = ({
alertsList, alertsList,
className, className,
onCloseAlert onCloseAlert,
vm
}) => ( }) => (
<AlertsComponent <AlertsComponent
alertsList={alertsList} alertsList={alertsList}
className={className} className={className}
vm={vm}
onCloseAlert={onCloseAlert} onCloseAlert={onCloseAlert}
/> />
); );
...@@ -23,7 +26,8 @@ const Alerts = ({ ...@@ -23,7 +26,8 @@ const Alerts = ({
Alerts.propTypes = { Alerts.propTypes = {
alertsList: PropTypes.arrayOf(PropTypes.object), alertsList: PropTypes.arrayOf(PropTypes.object),
className: PropTypes.string, className: PropTypes.string,
onCloseAlert: PropTypes.func onCloseAlert: PropTypes.func,
vm: PropTypes.instanceOf(VM).isRequired
}; };
const mapStateToProps = state => ({ const mapStateToProps = state => ({
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment