import PropTypes from 'prop-types'; import React, { Component } from 'react'; import ArtistMonitoringOptionsPopoverContent from 'AddArtist/ArtistMonitoringOptionsPopoverContent'; import Alert from 'Components/Alert'; import Form from 'Components/Form/Form'; import FormGroup from 'Components/Form/FormGroup'; import FormInputGroup from 'Components/Form/FormInputGroup'; import FormLabel from 'Components/Form/FormLabel'; import Icon from 'Components/Icon'; import Button from 'Components/Link/Button'; import SpinnerButton from 'Components/Link/SpinnerButton'; import ModalBody from 'Components/Modal/ModalBody'; import ModalContent from 'Components/Modal/ModalContent'; import ModalFooter from 'Components/Modal/ModalFooter'; import ModalHeader from 'Components/Modal/ModalHeader'; import Popover from 'Components/Tooltip/Popover'; import { icons, inputTypes, kinds, tooltipPositions } from 'Helpers/Props'; import translate from 'Utilities/String/translate'; import styles from './MonitoringOptionsModalContent.css'; const NO_CHANGE = 'noChange'; class MonitoringOptionsModalContent extends Component { // // Lifecycle constructor(props, context) { super(props, context); this.state = { monitor: NO_CHANGE }; } componentDidUpdate(prevProps) { const { isSaving, saveError } = this.props; if (prevProps.isSaving && !isSaving && !saveError) { this.setState({ monitor: NO_CHANGE }); } } onInputChange = ({ name, value }) => { this.setState({ [name]: value }); }; // // Listeners onSavePress = () => { const { onSavePress } = this.props; const { monitor } = this.state; if (monitor !== NO_CHANGE) { onSavePress({ monitor }); } }; // // Render render() { const { isSaving, onInputChange, onModalClose, ...otherProps } = this.props; const { monitor } = this.state; return ( {translate('MonitorArtist')} {translate('MonitorAlbumExistingOnlyWarning')}
{translate('MonitorExistingAlbums')} } title={translate('MonitoringOptions')} body={} position={tooltipPositions.RIGHT} />
{translate('Save')}
); } } MonitoringOptionsModalContent.propTypes = { artistId: PropTypes.number.isRequired, saveError: PropTypes.object, isSaving: PropTypes.bool.isRequired, onInputChange: PropTypes.func.isRequired, onSavePress: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired }; MonitoringOptionsModalContent.defaultProps = { isSaving: false }; export default MonitoringOptionsModalContent;