Spaces:
Running
Running
File size: 1,687 Bytes
6bcb42f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
import {connect} from 'react-redux';
import {FormattedMessage} from 'react-intl';
import PropTypes from 'prop-types';
import React from 'react';
import InlineMessages from '../../containers/inline-messages.jsx';
import {
manualUpdateProject
} from '../../reducers/project-state';
import {
filterInlineAlerts
} from '../../reducers/alerts';
import styles from './save-status.css';
// Wrapper for inline messages in the nav bar, which are all related to saving.
// Show any inline messages if present, else show the "Save Now" button if the
// project has changed.
// We decided to not use an inline message for "Save Now" because it is a reflection
// of the project state, rather than an event.
const SaveStatus = ({
alertsList,
projectChanged,
onClickSave
}) => (
filterInlineAlerts(alertsList).length > 0 ? (
<InlineMessages />
) : projectChanged && (
<div
className={styles.saveNow}
onClick={onClickSave}
>
<FormattedMessage
defaultMessage="Save Now"
description="Title bar link for saving now"
id="gui.menuBar.saveNowLink"
/>
</div>
));
SaveStatus.propTypes = {
alertsList: PropTypes.arrayOf(PropTypes.object),
onClickSave: PropTypes.func,
projectChanged: PropTypes.bool
};
const mapStateToProps = state => ({
alertsList: state.scratchGui.alerts.alertsList,
projectChanged: state.scratchGui.projectChanged
});
const mapDispatchToProps = dispatch => ({
onClickSave: () => dispatch(manualUpdateProject())
});
export default connect(
mapStateToProps,
mapDispatchToProps
)(SaveStatus);
|