You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Prowlarr/frontend/src/Settings/Applications/Applications/EditApplicationModalConnect...

66 lines
1.7 KiB

import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { clearPendingChanges } from 'Store/Actions/baseActions';
import { cancelSaveApplication, cancelTestApplication } from 'Store/Actions/settingsActions';
import EditApplicationModal from './EditApplicationModal';
function createMapDispatchToProps(dispatch, props) {
const section = 'settings.applications';
return {
dispatchClearPendingChanges() {
dispatch(clearPendingChanges({ section }));
},
dispatchCancelTestApplication() {
dispatch(cancelTestApplication({ section }));
},
dispatchCancelSaveApplication() {
dispatch(cancelSaveApplication({ section }));
}
};
}
class EditApplicationModalConnector extends Component {
//
// Listeners
onModalClose = () => {
this.props.dispatchClearPendingChanges();
this.props.dispatchCancelTestApplication();
this.props.dispatchCancelSaveApplication();
this.props.onModalClose();
}
//
// Render
render() {
const {
dispatchClearPendingChanges,
dispatchCancelTestApplication,
dispatchCancelSaveApplication,
...otherProps
} = this.props;
return (
<EditApplicationModal
{...otherProps}
onModalClose={this.onModalClose}
/>
);
}
}
EditApplicationModalConnector.propTypes = {
onModalClose: PropTypes.func.isRequired,
dispatchClearPendingChanges: PropTypes.func.isRequired,
dispatchCancelTestApplication: PropTypes.func.isRequired,
dispatchCancelSaveApplication: PropTypes.func.isRequired
};
export default connect(null, createMapDispatchToProps)(EditApplicationModalConnector);