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

Made onReconnect not required, and added showReconnect boolean to optionally show reconnect button.

parent 8d3b798a
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,8 @@ const AlertComponent = ({ ...@@ -11,7 +11,8 @@ const AlertComponent = ({
iconURL, iconURL,
message, message,
onCloseAlert, onCloseAlert,
onReconnect onReconnect,
showReconnect
}) => ( }) => (
<Box <Box
className={styles.alert} className={styles.alert}
...@@ -25,16 +26,18 @@ const AlertComponent = ({ ...@@ -25,16 +26,18 @@ const AlertComponent = ({
) : null} ) : null}
{message} {message}
</div> </div>
<button {showReconnect ? (
className={styles.connectionButton} <button
onClick={onReconnect} className={styles.connectionButton}
> onClick={onReconnect}
<FormattedMessage >
defaultMessage="Reconnect" <FormattedMessage
description="Button to reconnect the device" defaultMessage="Reconnect"
id="gui.connection.reconnect" description="Button to reconnect the device"
/> id="gui.connection.reconnect"
</button> />
</button>
) : null}
<Box <Box
className={styles.alertCloseButtonContainer} className={styles.alertCloseButtonContainer}
> >
...@@ -52,7 +55,8 @@ AlertComponent.propTypes = { ...@@ -52,7 +55,8 @@ 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 onReconnect: PropTypes.func,
showReconnect: PropTypes.bool.isRequired
}; };
export default AlertComponent; export default AlertComponent;
...@@ -20,6 +20,7 @@ const AlertsComponent = ({ ...@@ -20,6 +20,7 @@ const AlertsComponent = ({
index={index} index={index}
key={index} key={index}
message={a.message} message={a.message}
showReconnect={a.showReconnect}
onCloseAlert={onCloseAlert} onCloseAlert={onCloseAlert}
/> />
))} ))}
......
...@@ -26,12 +26,14 @@ class Alert extends React.Component { ...@@ -26,12 +26,14 @@ class Alert extends React.Component {
const { const {
index, // eslint-disable-line no-unused-vars index, // eslint-disable-line no-unused-vars
iconURL, iconURL,
message message,
showReconnect
} = this.props; } = this.props;
return ( return (
<AlertComponent <AlertComponent
iconURL={iconURL} iconURL={iconURL}
message={message} message={message}
showReconnect={showReconnect}
onCloseAlert={this.handleOnCloseAlert} onCloseAlert={this.handleOnCloseAlert}
onReconnect={this.handleOnReconnect} onReconnect={this.handleOnReconnect}
/> />
...@@ -56,7 +58,8 @@ Alert.propTypes = { ...@@ -56,7 +58,8 @@ Alert.propTypes = {
index: PropTypes.number, index: PropTypes.number,
message: PropTypes.string, message: PropTypes.string,
onCloseAlert: PropTypes.func.isRequired, onCloseAlert: PropTypes.func.isRequired,
onOpenConnectionModal: PropTypes.func onOpenConnectionModal: PropTypes.func,
showReconnect: PropTypes.bool.isRequired
}; };
export default connect( export default connect(
......
...@@ -15,12 +15,14 @@ const reducer = function (state, action) { ...@@ -15,12 +15,14 @@ const reducer = function (state, action) {
const newList = state.alertsList.slice(); const newList = state.alertsList.slice();
const newAlert = {message: action.data.message}; const newAlert = {message: action.data.message};
const extensionId = action.data.extensionId; const extensionId = action.data.extensionId;
newAlert.showReconnect = false;
if (extensionId) { // if it's an extension if (extensionId) { // if it's an extension
const extension = extensionData.find(ext => ext.extensionId === extensionId); const extension = extensionData.find(ext => ext.extensionId === extensionId);
if (extension && extension.name) { if (extension && extension.name) {
// TODO: is this the right place to assemble this message? // TODO: is this the right place to assemble this message?
newAlert.extensionId = extensionId; newAlert.extensionId = extensionId;
newAlert.message = `${newAlert.message} ${extension.name}.`; newAlert.message = `${newAlert.message} ${extension.name}.`;
newAlert.showReconnect = true;
} }
if (extension && extension.smallPeripheralImage) { if (extension && extension.smallPeripheralImage) {
newAlert.iconURL = extension.smallPeripheralImage; newAlert.iconURL = extension.smallPeripheralImage;
......
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