Admin: fetch ConfigDB config, start RegistrationModePicker
This commit is contained in:
parent
7507553bfd
commit
bfd01d0316
6 changed files with 84 additions and 3 deletions
|
@ -1,5 +1,9 @@
|
||||||
import api from '../api';
|
import api from '../api';
|
||||||
|
|
||||||
|
export const ADMIN_CONFIG_FETCH_REQUEST = 'ADMIN_CONFIG_FETCH_REQUEST';
|
||||||
|
export const ADMIN_CONFIG_FETCH_SUCCESS = 'ADMIN_CONFIG_FETCH_SUCCESS';
|
||||||
|
export const ADMIN_CONFIG_FETCH_FAIL = 'ADMIN_CONFIG_FETCH_FAIL';
|
||||||
|
|
||||||
export const ADMIN_CONFIG_UPDATE_REQUEST = 'ADMIN_CONFIG_UPDATE_REQUEST';
|
export const ADMIN_CONFIG_UPDATE_REQUEST = 'ADMIN_CONFIG_UPDATE_REQUEST';
|
||||||
export const ADMIN_CONFIG_UPDATE_SUCCESS = 'ADMIN_CONFIG_UPDATE_SUCCESS';
|
export const ADMIN_CONFIG_UPDATE_SUCCESS = 'ADMIN_CONFIG_UPDATE_SUCCESS';
|
||||||
export const ADMIN_CONFIG_UPDATE_FAIL = 'ADMIN_CONFIG_UPDATE_FAIL';
|
export const ADMIN_CONFIG_UPDATE_FAIL = 'ADMIN_CONFIG_UPDATE_FAIL';
|
||||||
|
@ -20,6 +24,19 @@ export const ADMIN_USERS_APPROVE_REQUEST = 'ADMIN_USERS_APPROVE_REQUEST';
|
||||||
export const ADMIN_USERS_APPROVE_SUCCESS = 'ADMIN_USERS_APPROVE_SUCCESS';
|
export const ADMIN_USERS_APPROVE_SUCCESS = 'ADMIN_USERS_APPROVE_SUCCESS';
|
||||||
export const ADMIN_USERS_APPROVE_FAIL = 'ADMIN_USERS_APPROVE_FAIL';
|
export const ADMIN_USERS_APPROVE_FAIL = 'ADMIN_USERS_APPROVE_FAIL';
|
||||||
|
|
||||||
|
export function fetchConfig() {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
dispatch({ type: ADMIN_CONFIG_FETCH_REQUEST });
|
||||||
|
return api(getState)
|
||||||
|
.get('/api/pleroma/admin/config')
|
||||||
|
.then(({ data }) => {
|
||||||
|
dispatch({ type: ADMIN_CONFIG_FETCH_SUCCESS, configs: data.configs, needsReboot: data.need_reboot });
|
||||||
|
}).catch(error => {
|
||||||
|
dispatch({ type: ADMIN_CONFIG_FETCH_FAIL, error });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function updateAdminConfig(params) {
|
export function updateAdminConfig(params) {
|
||||||
return (dispatch, getState) => {
|
return (dispatch, getState) => {
|
||||||
dispatch({ type: ADMIN_CONFIG_UPDATE_REQUEST });
|
dispatch({ type: ADMIN_CONFIG_UPDATE_REQUEST });
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
import {
|
||||||
|
SimpleForm,
|
||||||
|
FieldsGroup,
|
||||||
|
RadioGroup,
|
||||||
|
RadioItem,
|
||||||
|
} from 'soapbox/features/forms';
|
||||||
|
|
||||||
|
const mapStateToProps = (state, props) => ({
|
||||||
|
instance: state.get('instance'),
|
||||||
|
openReportCount: state.getIn(['admin', 'open_report_count']),
|
||||||
|
});
|
||||||
|
|
||||||
|
export default @connect(mapStateToProps)
|
||||||
|
class RegistrationModePicker extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<SimpleForm>
|
||||||
|
<FieldsGroup>
|
||||||
|
<RadioGroup
|
||||||
|
label={<FormattedMessage id='admin.dashboard.registration_mode_label' defaultMessage='Registrations' />}
|
||||||
|
checked
|
||||||
|
onChange={this.onChange}
|
||||||
|
>
|
||||||
|
<RadioItem
|
||||||
|
label={<FormattedMessage id='admin.dashboard.registration_mode.open_label' defaultMessage='Open' />}
|
||||||
|
hint={<FormattedMessage id='admin.dashboard.registration_mode.open_hint' defaultMessage='Anyone can join.' />}
|
||||||
|
value='open'
|
||||||
|
/>
|
||||||
|
<RadioItem
|
||||||
|
label={<FormattedMessage id='admin.dashboard.registration_mode.approval_label' defaultMessage='Approval Required' />}
|
||||||
|
hint={<FormattedMessage id='admin.dashboard.registration_mode.approval_hint' defaultMessage='Users can sign up, but their account only gets activated when an admin approves it.' />}
|
||||||
|
value='approval'
|
||||||
|
/>
|
||||||
|
<RadioItem
|
||||||
|
label={<FormattedMessage id='admin.dashboard.registration_mode.closed_label' defaultMessage='Closed' />}
|
||||||
|
hint={<FormattedMessage id='admin.dashboard.registration_mode.closed_hint' defaultMessage='Nobody can sign up. You can still invite people.' />}
|
||||||
|
value='closed'
|
||||||
|
/>
|
||||||
|
</RadioGroup>
|
||||||
|
</FieldsGroup>
|
||||||
|
</SimpleForm>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import Column from '../ui/components/column';
|
import Column from '../ui/components/column';
|
||||||
|
import RegistrationModePicker from './components/registration_mode_picker';
|
||||||
import { parseVersion } from 'soapbox/utils/features';
|
import { parseVersion } from 'soapbox/utils/features';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
|
@ -63,8 +64,8 @@ class Dashboard extends ImmutablePureComponent {
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{/* TODO: Awaiting approval users count */}
|
|
||||||
</div>
|
</div>
|
||||||
|
<RegistrationModePicker />
|
||||||
<div className='dashwidgets'>
|
<div className='dashwidgets'>
|
||||||
<div class='dashwidget'>
|
<div class='dashwidget'>
|
||||||
<h4><FormattedMessage id='admin.dashwidgets.software_header' defaultMessage='Software' /></h4>
|
<h4><FormattedMessage id='admin.dashwidgets.software_header' defaultMessage='Software' /></h4>
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { debounce } from 'lodash';
|
||||||
import { uploadCompose, resetCompose } from '../../actions/compose';
|
import { uploadCompose, resetCompose } from '../../actions/compose';
|
||||||
import { expandHomeTimeline } from '../../actions/timelines';
|
import { expandHomeTimeline } from '../../actions/timelines';
|
||||||
import { expandNotifications } from '../../actions/notifications';
|
import { expandNotifications } from '../../actions/notifications';
|
||||||
import { fetchReports, fetchUsers } from '../../actions/admin';
|
import { fetchReports, fetchUsers, fetchConfig } from '../../actions/admin';
|
||||||
import { fetchFilters } from '../../actions/filters';
|
import { fetchFilters } from '../../actions/filters';
|
||||||
import { fetchChats } from 'soapbox/actions/chats';
|
import { fetchChats } from 'soapbox/actions/chats';
|
||||||
import { clearHeight } from '../../actions/height_cache';
|
import { clearHeight } from '../../actions/height_cache';
|
||||||
|
@ -465,6 +465,7 @@ class UI extends React.PureComponent {
|
||||||
if (isStaff(account)) {
|
if (isStaff(account)) {
|
||||||
this.props.dispatch(fetchReports({ state: 'open' }));
|
this.props.dispatch(fetchReports({ state: 'open' }));
|
||||||
this.props.dispatch(fetchUsers({ page: 1, filters: 'local,need_approval' }));
|
this.props.dispatch(fetchUsers({ page: 1, filters: 'local,need_approval' }));
|
||||||
|
this.props.dispatch(fetchConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
setTimeout(() => this.props.dispatch(fetchFilters()), 500);
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import reducer from '../admin';
|
import reducer from '../admin';
|
||||||
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet, fromJS } from 'immutable';
|
import {
|
||||||
|
Map as ImmutableMap,
|
||||||
|
List as ImmutableList,
|
||||||
|
OrderedSet as ImmutableOrderedSet,
|
||||||
|
fromJS,
|
||||||
|
} from 'immutable';
|
||||||
|
|
||||||
describe('admin reducer', () => {
|
describe('admin reducer', () => {
|
||||||
it('should return the initial state', () => {
|
it('should return the initial state', () => {
|
||||||
|
@ -8,6 +13,8 @@ describe('admin reducer', () => {
|
||||||
open_report_count: 0,
|
open_report_count: 0,
|
||||||
users: ImmutableMap(),
|
users: ImmutableMap(),
|
||||||
awaitingApproval: ImmutableOrderedSet(),
|
awaitingApproval: ImmutableOrderedSet(),
|
||||||
|
configs: ImmutableList(),
|
||||||
|
needsReboot: false,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import {
|
import {
|
||||||
|
ADMIN_CONFIG_FETCH_SUCCESS,
|
||||||
ADMIN_REPORTS_FETCH_SUCCESS,
|
ADMIN_REPORTS_FETCH_SUCCESS,
|
||||||
ADMIN_USERS_FETCH_SUCCESS,
|
ADMIN_USERS_FETCH_SUCCESS,
|
||||||
ADMIN_USERS_DELETE_REQUEST,
|
ADMIN_USERS_DELETE_REQUEST,
|
||||||
|
@ -18,6 +19,8 @@ const initialState = ImmutableMap({
|
||||||
users: ImmutableMap(),
|
users: ImmutableMap(),
|
||||||
open_report_count: 0,
|
open_report_count: 0,
|
||||||
awaitingApproval: ImmutableOrderedSet(),
|
awaitingApproval: ImmutableOrderedSet(),
|
||||||
|
configs: ImmutableList(),
|
||||||
|
needsReboot: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
function importUsers(state, users) {
|
function importUsers(state, users) {
|
||||||
|
@ -51,6 +54,8 @@ function approveUsers(state, users) {
|
||||||
|
|
||||||
export default function admin(state = initialState, action) {
|
export default function admin(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
|
case ADMIN_CONFIG_FETCH_SUCCESS:
|
||||||
|
return state.set('configs', fromJS(action.configs));
|
||||||
case ADMIN_REPORTS_FETCH_SUCCESS:
|
case ADMIN_REPORTS_FETCH_SUCCESS:
|
||||||
if (action.params && action.params.state === 'open') {
|
if (action.params && action.params.state === 'open') {
|
||||||
return state
|
return state
|
||||||
|
|
Loading…
Reference in a new issue