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
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,6 @@
|
||||||
import { Record } from 'immutable';
|
import { Record } from 'immutable';
|
||||||
|
|
||||||
|
import { ADMIN_CONFIG_UPDATE_REQUEST } from 'soapbox/actions/admin';
|
||||||
import { INSTANCE_REMEMBER_SUCCESS } from 'soapbox/actions/instance';
|
import { INSTANCE_REMEMBER_SUCCESS } from 'soapbox/actions/instance';
|
||||||
|
|
||||||
import reducer from '../instance';
|
import reducer from '../instance';
|
||||||
|
@ -116,4 +117,23 @@ describe('instance reducer', () => {
|
||||||
expect(result.toJS()).toMatchObject(expected);
|
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;
|
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.
|
// FIXME: This is pretty hacked together. Need to make a cleaner map.
|
||||||
const config = ConfigDB.find(configs, ':pleroma', ':instance');
|
const config = ConfigDB.find(configs, ':pleroma', ':instance');
|
||||||
const simplePolicy = ConfigDB.toSimplePolicy(configs);
|
const simplePolicy = ConfigDB.toSimplePolicy(configs);
|
||||||
|
@ -126,7 +126,7 @@ export default function instance(state = initialState, action: AnyAction) {
|
||||||
return importNodeinfo(state, ImmutableMap(fromJS(action.nodeinfo)));
|
return importNodeinfo(state, ImmutableMap(fromJS(action.nodeinfo)));
|
||||||
case ADMIN_CONFIG_UPDATE_REQUEST:
|
case ADMIN_CONFIG_UPDATE_REQUEST:
|
||||||
case ADMIN_CONFIG_UPDATE_SUCCESS:
|
case ADMIN_CONFIG_UPDATE_SUCCESS:
|
||||||
return importConfigs(state, ImmutableMap(fromJS(action.configs)));
|
return importConfigs(state, ImmutableList(fromJS(action.configs)));
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue