From 3330ed7594d6e215cc124223dd2a629b7ebe0423 Mon Sep 17 00:00:00 2001 From: Evelyn Eastmond <evhan55@gmail.com> Date: Fri, 14 Sep 2018 16:25:30 -0400 Subject: [PATCH] Passing custom alert messages. --- src/lib/vm-listener-hoc.jsx | 4 +++- src/reducers/alerts.js | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/vm-listener-hoc.jsx b/src/lib/vm-listener-hoc.jsx index 4359e9865..97b6a637b 100644 --- a/src/lib/vm-listener-hoc.jsx +++ b/src/lib/vm-listener-hoc.jsx @@ -139,7 +139,9 @@ const vmListenerHOC = function (WrappedComponent) { onProjectRunStop: () => dispatch(setRunningState(false)), onTurboModeOn: () => dispatch(setTurboState(true)), onTurboModeOff: () => dispatch(setTurboState(false)), - onShowAlert: () => dispatch(showAlert()) + onShowAlert: data => { + dispatch(showAlert(data.message)); + } }); return connect( mapStateToProps, diff --git a/src/reducers/alerts.js b/src/reducers/alerts.js index 7442394e7..74e488829 100644 --- a/src/reducers/alerts.js +++ b/src/reducers/alerts.js @@ -2,7 +2,7 @@ const CLOSE_ALERT = 'scratch-gui/alerts/CLOSE_ALERT'; const SHOW_ALERT = 'scratch-gui/alerts/SHOW_ALERT'; const initialState = { - message: 'Peripheral error', + message: 'Alert', visible: false }; @@ -11,7 +11,8 @@ const reducer = function (state, action) { switch (action.type) { case SHOW_ALERT: return Object.assign({}, state, { - visible: true + visible: true, + message: action.message }); case CLOSE_ALERT: return Object.assign({}, state, { @@ -26,8 +27,11 @@ const closeAlert = function () { return {type: CLOSE_ALERT}; }; -const showAlert = function () { - return {type: SHOW_ALERT}; +const showAlert = function (message) { + return { + type: SHOW_ALERT, + message + }; }; export { -- GitLab