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

Passing custom alert messages.

parent fa596645
No related branches found
No related tags found
No related merge requests found
...@@ -139,7 +139,9 @@ const vmListenerHOC = function (WrappedComponent) { ...@@ -139,7 +139,9 @@ const vmListenerHOC = function (WrappedComponent) {
onProjectRunStop: () => dispatch(setRunningState(false)), onProjectRunStop: () => dispatch(setRunningState(false)),
onTurboModeOn: () => dispatch(setTurboState(true)), onTurboModeOn: () => dispatch(setTurboState(true)),
onTurboModeOff: () => dispatch(setTurboState(false)), onTurboModeOff: () => dispatch(setTurboState(false)),
onShowAlert: () => dispatch(showAlert()) onShowAlert: data => {
dispatch(showAlert(data.message));
}
}); });
return connect( return connect(
mapStateToProps, mapStateToProps,
......
...@@ -2,7 +2,7 @@ const CLOSE_ALERT = 'scratch-gui/alerts/CLOSE_ALERT'; ...@@ -2,7 +2,7 @@ const CLOSE_ALERT = 'scratch-gui/alerts/CLOSE_ALERT';
const SHOW_ALERT = 'scratch-gui/alerts/SHOW_ALERT'; const SHOW_ALERT = 'scratch-gui/alerts/SHOW_ALERT';
const initialState = { const initialState = {
message: 'Peripheral error', message: 'Alert',
visible: false visible: false
}; };
...@@ -11,7 +11,8 @@ const reducer = function (state, action) { ...@@ -11,7 +11,8 @@ const reducer = function (state, action) {
switch (action.type) { switch (action.type) {
case SHOW_ALERT: case SHOW_ALERT:
return Object.assign({}, state, { return Object.assign({}, state, {
visible: true visible: true,
message: action.message
}); });
case CLOSE_ALERT: case CLOSE_ALERT:
return Object.assign({}, state, { return Object.assign({}, state, {
...@@ -26,8 +27,11 @@ const closeAlert = function () { ...@@ -26,8 +27,11 @@ const closeAlert = function () {
return {type: CLOSE_ALERT}; return {type: CLOSE_ALERT};
}; };
const showAlert = function () { const showAlert = function (message) {
return {type: SHOW_ALERT}; return {
type: SHOW_ALERT,
message
};
}; };
export { export {
......
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