2019-07-04 11:32:51 +02:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import { bindActionCreators, compose } from 'redux';
|
|
|
|
|
import { Switch, Route } from 'react-router-dom';
|
|
|
|
|
import { LoadingIndicatorPage } from 'strapi-helper-plugin';
|
|
|
|
|
|
|
|
|
|
import pluginId from '../../pluginId';
|
|
|
|
|
|
2019-07-04 18:28:57 +02:00
|
|
|
import SettingViewModel from '../SettingViewModel';
|
|
|
|
|
import SettingViewGroup from '../SettingViewGroup';
|
2019-07-04 11:32:51 +02:00
|
|
|
import SettingsView from '../SettingsView';
|
|
|
|
|
|
|
|
|
|
import reducer from './reducer';
|
|
|
|
|
import saga from './saga';
|
|
|
|
|
import makeSelectMain from './selectors';
|
|
|
|
|
|
2019-07-04 13:08:31 +02:00
|
|
|
function Main({ isLoading, emitEvent }) {
|
2019-07-04 11:32:51 +02:00
|
|
|
strapi.useInjectReducer({ key: 'main', reducer, pluginId });
|
|
|
|
|
strapi.useInjectSaga({ key: 'main', saga, pluginId });
|
|
|
|
|
|
|
|
|
|
if (isLoading) {
|
|
|
|
|
return <LoadingIndicatorPage />;
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-04 13:08:31 +02:00
|
|
|
const renderRoute = props => (
|
|
|
|
|
<SettingsView emitEvent={emitEvent} {...props} />
|
|
|
|
|
);
|
|
|
|
|
|
2019-07-04 11:32:51 +02:00
|
|
|
return (
|
|
|
|
|
<Switch>
|
2019-07-04 15:56:42 +02:00
|
|
|
<Route
|
2019-07-04 18:28:57 +02:00
|
|
|
path="/plugins/content-manager/ctm-configurations/models/:name/:settingType"
|
|
|
|
|
component={SettingViewModel}
|
|
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
path="/plugins/content-manager/ctm-configurations/groups/:name"
|
|
|
|
|
component={SettingViewGroup}
|
2019-07-04 15:56:42 +02:00
|
|
|
/>
|
2019-07-04 11:32:51 +02:00
|
|
|
<Route
|
|
|
|
|
path="/plugins/content-manager/ctm-configurations/:type"
|
2019-07-04 13:08:31 +02:00
|
|
|
render={renderRoute}
|
2019-07-04 11:32:51 +02:00
|
|
|
/>
|
|
|
|
|
</Switch>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Main.propTypes = {
|
2019-07-04 13:08:31 +02:00
|
|
|
emitEvent: PropTypes.func.isRequired,
|
2019-07-04 11:32:51 +02:00
|
|
|
isLoading: PropTypes.bool.isRequired,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = makeSelectMain();
|
|
|
|
|
|
|
|
|
|
export function mapDispatchToProps(dispatch) {
|
|
|
|
|
return bindActionCreators({}, dispatch);
|
|
|
|
|
}
|
|
|
|
|
const withConnect = connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
|
withConnect,
|
|
|
|
|
memo
|
|
|
|
|
)(Main);
|