refactor: decouple config actions from auth actions (#4843)
This commit is contained in:
parent
bed71274cb
commit
3568017bfe
@ -2,7 +2,6 @@ import yaml from 'yaml';
|
||||
import { Map, fromJS } from 'immutable';
|
||||
import deepmerge from 'deepmerge';
|
||||
import { trimStart, trim, get, isPlainObject, isEmpty } from 'lodash';
|
||||
import { authenticateUser } from 'Actions/auth';
|
||||
import * as publishModes from 'Constants/publishModes';
|
||||
import { validateConfig } from 'Constants/configSchema';
|
||||
import { selectDefaultSortableFields, traverseFields } from '../reducers/collections';
|
||||
@ -404,7 +403,7 @@ export async function handleLocalBackend(originalConfig) {
|
||||
return mergedConfig;
|
||||
}
|
||||
|
||||
export function loadConfig(manualConfig = {}) {
|
||||
export function loadConfig(manualConfig = {}, onLoad) {
|
||||
if (window.CMS_CONFIG) {
|
||||
return configLoaded(fromJS(window.CMS_CONFIG));
|
||||
}
|
||||
@ -429,7 +428,10 @@ export function loadConfig(manualConfig = {}) {
|
||||
const config = applyDefaults(normalizeConfig(fromJS(mergedConfig)));
|
||||
|
||||
dispatch(configLoaded(config));
|
||||
dispatch(authenticateUser());
|
||||
|
||||
if (typeof onLoad === 'function') {
|
||||
onLoad();
|
||||
}
|
||||
} catch (err) {
|
||||
dispatch(configFailed(err));
|
||||
throw err;
|
||||
|
7
packages/netlify-cms-core/src/bootstrap.js
vendored
7
packages/netlify-cms-core/src/bootstrap.js
vendored
@ -6,6 +6,7 @@ import { ConnectedRouter } from 'connected-react-router';
|
||||
import history from 'Routing/history';
|
||||
import store from 'ReduxStore';
|
||||
import { loadConfig } from 'Actions/config';
|
||||
import { authenticateUser } from 'Actions/auth';
|
||||
import { getPhrases } from 'Lib/phrases';
|
||||
import { selectLocale } from 'Reducers/config';
|
||||
import { I18n } from 'react-polyglot';
|
||||
@ -72,7 +73,11 @@ function bootstrap(opts = {}) {
|
||||
* config.yml if it exists, and any portion that produces a conflict will be
|
||||
* overwritten.
|
||||
*/
|
||||
store.dispatch(loadConfig(config));
|
||||
store.dispatch(
|
||||
loadConfig(config, function onLoad() {
|
||||
store.dispatch(authenticateUser());
|
||||
}),
|
||||
);
|
||||
|
||||
/**
|
||||
* Create connected root component.
|
||||
|
Loading…
x
Reference in New Issue
Block a user