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

Connecting a view alerts reducer.

parent d4b9f52a
Branches
Tags
No related merge requests found
import {connect} from 'react-redux';
import {
viewAlert
} from '../reducers/alerts';
import AlertsComponent from '../components/alerts/alerts.jsx';
const mapStateToProps = state => ({
......@@ -7,20 +11,11 @@ const mapStateToProps = state => ({
message: state.scratchGui.alerts.message
});
/* const mapDispatchToProps = dispatch => ({
onActivateDeckFactory: id => () => dispatch(activateDeck(id)),
onShowAll: () => {
dispatch(openTipsLibrary());
dispatch(closeCards());
},
onCloseCards: () => dispatch(closeCards()),
onNextStep: () => dispatch(nextStep()),
onPrevStep: () => dispatch(prevStep()),
onDrag: (e_, data) => dispatch(dragCard(data.x, data.y)),
onStartDrag: () => dispatch(startDrag()),
onEndDrag: () => dispatch(endDrag())
}); */
const mapDispatchToProps = dispatch => ({
onViewAlert: () => dispatch(viewAlert())
});
export default connect(
mapStateToProps
mapStateToProps,
mapDispatchToProps
)(AlertsComponent);
......@@ -22,6 +22,7 @@ import {updateToolbox} from '../reducers/toolbox';
import {activateColorPicker} from '../reducers/color-picker';
import {closeExtensionLibrary} from '../reducers/modals';
import {activateCustomProcedures, deactivateCustomProcedures} from '../reducers/custom-procedures';
import {viewAlert} from '../reducers/alerts';
const addFunctionListener = (object, property, callback) => {
const oldFn = object[property];
......@@ -378,6 +379,7 @@ class Blocks extends React.Component {
this.setState({connectionModal: null});
}
handleStatusButtonUpdate () {
this.props.onViewAlert();
this.ScratchBlocks.refreshStatusButtons(this.workspace);
}
handlePromptCallback (input, optionSelection) {
......@@ -412,6 +414,7 @@ class Blocks extends React.Component {
onActivateCustomProcedures,
onRequestCloseExtensionLibrary,
onRequestCloseCustomProcedures,
onViewAlert,
toolboxXML,
...props
} = this.props;
......@@ -473,6 +476,7 @@ Blocks.propTypes = {
onActivateCustomProcedures: PropTypes.func,
onRequestCloseCustomProcedures: PropTypes.func,
onRequestCloseExtensionLibrary: PropTypes.func,
onViewAlert: PropTypes.func,
options: PropTypes.shape({
media: PropTypes.string,
zoom: PropTypes.shape({
......@@ -556,6 +560,7 @@ const mapDispatchToProps = dispatch => ({
onRequestCloseCustomProcedures: data => {
dispatch(deactivateCustomProcedures(data));
},
onViewAlert: () => dispatch(viewAlert()),
updateToolboxState: toolboxXML => {
dispatch(updateToolbox(toolboxXML));
}
......
const CLOSE_ALERT = 'scratch-gui/alerts/CLOSE_ALERT';
const VIEW_ALERT = 'scratch-gui/alerts/VIEW_ALERT';
const initialState = {
message: 'testing alerts!!',
visible: true
visible: false
};
const reducer = function (state, action) {
if (typeof state === 'undefined') state = initialState;
switch (action.type) {
case VIEW_ALERT:
return Object.assign({}, state, {
visible: true
});
case CLOSE_ALERT:
return Object.assign({}, state, {
message: 'closing alert!'
......@@ -21,8 +26,13 @@ const closeAlert = function () {
return {type: CLOSE_ALERT};
};
const viewAlert = function () {
return {type: VIEW_ALERT};
};
export {
reducer as default,
initialState as alertsInitialState,
closeAlert
closeAlert,
viewAlert
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment