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.
89 lines
2.5 KiB
89 lines
2.5 KiB
import PropTypes from 'prop-types';
|
|
import React, { Component } from 'react';
|
|
import { connect } from 'react-redux';
|
|
import { createSelector } from 'reselect';
|
|
import { fetchDelayProfiles, fetchDownloadClients, fetchImportLists, fetchIndexers, fetchNotifications, fetchReleaseProfiles } from 'Store/Actions/settingsActions';
|
|
import { fetchTagDetails, fetchTags } from 'Store/Actions/tagActions';
|
|
import Tags from './Tags';
|
|
|
|
function createMapStateToProps() {
|
|
return createSelector(
|
|
(state) => state.tags,
|
|
(tags) => {
|
|
const isFetching = tags.isFetching || tags.details.isFetching;
|
|
const error = tags.error || tags.details.error;
|
|
const isPopulated = tags.isPopulated && tags.details.isPopulated;
|
|
|
|
return {
|
|
...tags,
|
|
isFetching,
|
|
error,
|
|
isPopulated
|
|
};
|
|
}
|
|
);
|
|
}
|
|
|
|
const mapDispatchToProps = {
|
|
dispatchFetchTags: fetchTags,
|
|
dispatchFetchTagDetails: fetchTagDetails,
|
|
dispatchFetchDelayProfiles: fetchDelayProfiles,
|
|
dispatchFetchNotifications: fetchNotifications,
|
|
dispatchFetchReleaseProfiles: fetchReleaseProfiles,
|
|
dispatchFetchImportLists: fetchImportLists,
|
|
dispatchFetchIndexers: fetchIndexers,
|
|
dispatchFetchDownloadClients: fetchDownloadClients
|
|
};
|
|
|
|
class MetadatasConnector extends Component {
|
|
|
|
//
|
|
// Lifecycle
|
|
|
|
componentDidMount() {
|
|
const {
|
|
dispatchFetchTags,
|
|
dispatchFetchTagDetails,
|
|
dispatchFetchDelayProfiles,
|
|
dispatchFetchNotifications,
|
|
dispatchFetchReleaseProfiles,
|
|
dispatchFetchImportLists,
|
|
dispatchFetchIndexers,
|
|
dispatchFetchDownloadClients
|
|
} = this.props;
|
|
|
|
dispatchFetchTags();
|
|
dispatchFetchTagDetails();
|
|
dispatchFetchDelayProfiles();
|
|
dispatchFetchNotifications();
|
|
dispatchFetchReleaseProfiles();
|
|
dispatchFetchImportLists();
|
|
dispatchFetchIndexers();
|
|
dispatchFetchDownloadClients();
|
|
}
|
|
|
|
//
|
|
// Render
|
|
|
|
render() {
|
|
return (
|
|
<Tags
|
|
{...this.props}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
|
|
MetadatasConnector.propTypes = {
|
|
dispatchFetchTags: PropTypes.func.isRequired,
|
|
dispatchFetchTagDetails: PropTypes.func.isRequired,
|
|
dispatchFetchDelayProfiles: PropTypes.func.isRequired,
|
|
dispatchFetchNotifications: PropTypes.func.isRequired,
|
|
dispatchFetchReleaseProfiles: PropTypes.func.isRequired,
|
|
dispatchFetchImportLists: PropTypes.func.isRequired,
|
|
dispatchFetchIndexers: PropTypes.func.isRequired,
|
|
dispatchFetchDownloadClients: PropTypes.func.isRequired
|
|
};
|
|
|
|
export default connect(createMapStateToProps, mapDispatchToProps)(MetadatasConnector);
|