Merge branch 'fe-config-fix' into 'develop'
Fix Soapbox Config Closes #864 See merge request soapbox-pub/soapbox-fe!1120
This commit is contained in:
commit
83a49e7d35
3 changed files with 3142 additions and 2 deletions
3120
app/soapbox/__fixtures__/pleroma-admin-config.json
Normal file
3120
app/soapbox/__fixtures__/pleroma-admin-config.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,6 @@
|
|||
import { Record } from 'immutable';
|
||||
|
||||
import { ADMIN_CONFIG_UPDATE_REQUEST } from 'soapbox/actions/admin';
|
||||
import { INSTANCE_REMEMBER_SUCCESS } from 'soapbox/actions/instance';
|
||||
|
||||
import reducer from '../instance';
|
||||
|
@ -116,4 +117,23 @@ describe('instance reducer', () => {
|
|||
expect(result.toJS()).toMatchObject(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ADMIN_CONFIG_UPDATE_REQUEST', () => {
|
||||
const { configs } = require('soapbox/__fixtures__/pleroma-admin-config.json');
|
||||
|
||||
it('imports the configs', () => {
|
||||
const action = {
|
||||
type: ADMIN_CONFIG_UPDATE_REQUEST,
|
||||
configs,
|
||||
};
|
||||
|
||||
// The normalizer has `registrations: closed` by default
|
||||
const state = reducer(undefined, {});
|
||||
expect(state.registrations).toBe(false);
|
||||
|
||||
// After importing the configs, registration will be open
|
||||
const result = reducer(state, action);
|
||||
expect(result.registrations).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -52,7 +52,7 @@ const getConfigValue = (instanceConfig: ImmutableMap<string, any>, key: string)
|
|||
return v ? v.getIn(['tuple', 1]) : undefined;
|
||||
};
|
||||
|
||||
const importConfigs = (state: typeof initialState, configs: ImmutableMap<string, any>) => {
|
||||
const importConfigs = (state: typeof initialState, configs: ImmutableList<any>) => {
|
||||
// FIXME: This is pretty hacked together. Need to make a cleaner map.
|
||||
const config = ConfigDB.find(configs, ':pleroma', ':instance');
|
||||
const simplePolicy = ConfigDB.toSimplePolicy(configs);
|
||||
|
@ -126,7 +126,7 @@ export default function instance(state = initialState, action: AnyAction) {
|
|||
return importNodeinfo(state, ImmutableMap(fromJS(action.nodeinfo)));
|
||||
case ADMIN_CONFIG_UPDATE_REQUEST:
|
||||
case ADMIN_CONFIG_UPDATE_SUCCESS:
|
||||
return importConfigs(state, ImmutableMap(fromJS(action.configs)));
|
||||
return importConfigs(state, ImmutableList(fromJS(action.configs)));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue