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.
83 lines
1.9 KiB
83 lines
1.9 KiB
6 years ago
|
import PropTypes from 'prop-types';
|
||
|
import React, { Component } from 'react';
|
||
|
import { connect } from 'react-redux';
|
||
|
import { createSelector } from 'reselect';
|
||
3 years ago
|
import { fetchIndexerSchema, selectIndexerSchema, setIndexerSchemaSort } from 'Store/Actions/indexerActions';
|
||
|
import createClientSideCollectionSelector from 'Store/Selectors/createClientSideCollectionSelector';
|
||
6 years ago
|
import AddIndexerModalContent from './AddIndexerModalContent';
|
||
|
|
||
|
function createMapStateToProps() {
|
||
|
return createSelector(
|
||
3 years ago
|
createClientSideCollectionSelector('indexers.schema'),
|
||
6 years ago
|
(indexers) => {
|
||
|
const {
|
||
3 years ago
|
isFetching,
|
||
|
isPopulated,
|
||
|
error,
|
||
|
items,
|
||
|
sortDirection,
|
||
|
sortKey
|
||
6 years ago
|
} = indexers;
|
||
|
|
||
|
return {
|
||
3 years ago
|
isFetching,
|
||
|
isPopulated,
|
||
|
error,
|
||
|
indexers: items,
|
||
|
sortKey,
|
||
|
sortDirection
|
||
6 years ago
|
};
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
const mapDispatchToProps = {
|
||
|
fetchIndexerSchema,
|
||
3 years ago
|
selectIndexerSchema,
|
||
|
setIndexerSchemaSort
|
||
6 years ago
|
};
|
||
|
|
||
|
class AddIndexerModalContentConnector extends Component {
|
||
|
|
||
|
//
|
||
|
// Lifecycle
|
||
|
|
||
|
componentDidMount() {
|
||
|
this.props.fetchIndexerSchema();
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// Listeners
|
||
|
|
||
|
onIndexerSelect = ({ implementation, name }) => {
|
||
4 years ago
|
this.props.selectIndexerSchema({ implementation, name });
|
||
6 years ago
|
this.props.onModalClose({ indexerSelected: true });
|
||
|
}
|
||
|
|
||
3 years ago
|
onSortPress = (sortKey, sortDirection) => {
|
||
|
this.props.setIndexerSchemaSort({ sortKey, sortDirection });
|
||
|
}
|
||
|
|
||
6 years ago
|
//
|
||
|
// Render
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
|
<AddIndexerModalContent
|
||
|
{...this.props}
|
||
3 years ago
|
onSortPress={this.onSortPress}
|
||
6 years ago
|
onIndexerSelect={this.onIndexerSelect}
|
||
|
/>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
AddIndexerModalContentConnector.propTypes = {
|
||
|
fetchIndexerSchema: PropTypes.func.isRequired,
|
||
|
selectIndexerSchema: PropTypes.func.isRequired,
|
||
3 years ago
|
setIndexerSchemaSort: PropTypes.func.isRequired,
|
||
6 years ago
|
onModalClose: PropTypes.func.isRequired
|
||
|
};
|
||
|
|
||
|
export default connect(createMapStateToProps, mapDispatchToProps)(AddIndexerModalContentConnector);
|