Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const fetchUserAuthorities = username => async (dispatch) => {
try {
dispatch(toggleLoading('users'));
const response = await getUserAuthorities(username);
const json = await response.json();
if (response.ok) {
dispatch(setSelectedUserAuthorities(username, json.payload));
dispatch(initialize('autorityForm', { groupRolesCombo: json.payload }));
} else {
dispatch(addErrors(json.errors.map(e => e.message)));
}
dispatch(toggleLoading('users'));
} catch (e) {
// do nothing
}
};
export const announceSuccess = ( { form, posts, siteId, zoneId } ) => [
stopSubmit( form ),
initialize( form, { posts } ),
updateFeed( siteId, zoneId, posts ),
successNotice( translate( 'Zone feed saved!' ), { id: saveFeedNotice } ),
];
export function goToSend(formValues) {
store.dispatch(initialize(formName, { ...defaultValues, ...formValues }));
store.dispatch(reset(formName));
history.push('/Send');
}
setData(data) {
const name = this.props.schema.title || 'form';
this.store.dispatch(initialize(name, data));
}
}
export const updateSettings = settings => dispatch => {
dispatch(switchLocale(settings.locale))
dispatch(initialize('settings', {}))
setTimeout(() => history.push('/settings'), 0)
}
response.json().then((json) => {
if (response.ok) {
dispatch(setSelectedDataType(json.payload));
dispatch(initialize('DataType', json.payload));
} else {
dispatch(addErrors(json.errors.map(err => err.message)));
}
resolve();
});
}).catch(() => {});
response.json().then((json) => {
if (response.ok) {
if (get(configJson, 'axis.x.tick.hours')) {
configJson.axis.x.tick.format = get(configJson, 'axis.x.tick.format').substring(0, 8).trim();
}
dispatch(initialize(formName, configJson));
dispatch(clearSelectedDatasource());
dispatch(setSelectedDatasource(configJson.datasource));
const { mappings } = json.payload;
dispatch(setDatasourceColumns(mappings.map(m => ({
key: m.sourceName,
value: m.destinationName,
}))));
if (configJson.columns && configJson.columns.x.length > 0) {
configJson.columns.x.map(item =>
dispatch(arrayPush(formName, 'columns.x', item)));
}
if (configJson.columns.y && configJson.columns.y.length > 0) {
configJson.columns.y.map(item =>
dispatch(arrayPush(formName, 'columns.y', item)));
}
fetchPageModel(pageModelCode)(dispatch).then((json) => {
const pageModel = json.payload;
pageModel.configuration = JSON.stringify(pageModel.configuration, null, 2);
dispatch(initialize('pageModel', pageModel));
}).catch(() => {})
);
this.setState({initialized: true}, ()=>{
this.props.dispatch(initialize(name, snapshot.val(), true))
})
}
(dispatch, getState) => {
const pageConfig = makeGetSelectedPageConfig(pageCode)(getState());
const pageConfigItem = (pageConfig && pageConfig[frameId]);
if (pageConfigItem && pageConfigItem.config) {
dispatch(initialize('widgetConfigForm', pageConfigItem.config));
history.push(routeConverter(
ROUTE_WIDGET_CONFIG,
{ pageCode, widgetCode: pageConfigItem.code, framePos: frameId },
));
}
};