|
|
|
@ -10,6 +10,7 @@ import { parseVersion } from 'soapbox/utils/features';
|
|
|
|
|
import sourceCode from 'soapbox/utils/code';
|
|
|
|
|
import { getSubscribersCsv, getUnsubscribersCsv, getCombinedCsv } from 'soapbox/actions/email_list';
|
|
|
|
|
import { getFeatures } from 'soapbox/utils/features';
|
|
|
|
|
import { isAdmin } from 'soapbox/utils/accounts';
|
|
|
|
|
|
|
|
|
|
// https://stackoverflow.com/a/53230807
|
|
|
|
|
const download = (response, filename) => {
|
|
|
|
@ -26,10 +27,15 @@ const messages = defineMessages({
|
|
|
|
|
heading: { id: 'column.admin.dashboard', defaultMessage: 'Dashboard' },
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, props) => ({
|
|
|
|
|
instance: state.get('instance'),
|
|
|
|
|
supportsEmailList: getFeatures(state.get('instance')).emailList,
|
|
|
|
|
});
|
|
|
|
|
const mapStateToProps = (state, props) => {
|
|
|
|
|
const me = state.get('me');
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
instance: state.get('instance'),
|
|
|
|
|
supportsEmailList: getFeatures(state.get('instance')).emailList,
|
|
|
|
|
account: state.getIn(['accounts', me]),
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default @connect(mapStateToProps)
|
|
|
|
|
@injectIntl
|
|
|
|
@ -39,6 +45,7 @@ class Dashboard extends ImmutablePureComponent {
|
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
|
instance: ImmutablePropTypes.map.isRequired,
|
|
|
|
|
supportsEmailList: PropTypes.bool,
|
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
handleSubscribersClick = e => {
|
|
|
|
@ -63,12 +70,14 @@ class Dashboard extends ImmutablePureComponent {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { intl, instance, supportsEmailList } = this.props;
|
|
|
|
|
const { intl, instance, supportsEmailList, account } = this.props;
|
|
|
|
|
const v = parseVersion(instance.get('version'));
|
|
|
|
|
const userCount = instance.getIn(['stats', 'user_count']);
|
|
|
|
|
const mau = instance.getIn(['pleroma', 'stats', 'mau']);
|
|
|
|
|
const retention = (userCount && mau) ? Math.round(mau / userCount * 100) : null;
|
|
|
|
|
|
|
|
|
|
if (!account) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Column icon='tachometer' heading={intl.formatMessage(messages.heading)} backBtnSlim>
|
|
|
|
|
<div className='dashcounters'>
|
|
|
|
@ -123,7 +132,7 @@ class Dashboard extends ImmutablePureComponent {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<RegistrationModePicker />
|
|
|
|
|
{isAdmin(account) && <RegistrationModePicker />}
|
|
|
|
|
<div className='dashwidgets'>
|
|
|
|
|
<div className='dashwidget'>
|
|
|
|
|
<h4><FormattedMessage id='admin.dashwidgets.software_header' defaultMessage='Software' /></h4>
|
|
|
|
@ -132,7 +141,7 @@ class Dashboard extends ImmutablePureComponent {
|
|
|
|
|
<li>{v.software} <span className='pull-right'>{v.version}</span></li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
{supportsEmailList && <div className='dashwidget'>
|
|
|
|
|
{supportsEmailList && isAdmin(account) && <div className='dashwidget'>
|
|
|
|
|
<h4><FormattedMessage id='admin.dashwidgets.email_list_header' defaultMessage='Email list' /></h4>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><a href='#' onClick={this.handleSubscribersClick} target='_blank'>subscribers.csv</a></li>
|
|
|
|
|