Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onSubmit: ({ element, updateElement, closeDialog }) => (formData: Object) => {
// Get element settings plugins
const plugins = getPlugins("pb-page-element-advanced-settings").filter(
pl => pl.elementType === element.type
);
formData = plugins.reduce((formData, pl) => {
if (pl.onSave) {
return pl.onSave(formData);
}
return formData;
}, formData);
updateElement({
element: merge(element, "data", formData)
});
closeDialog();
},
onClose: ({ closeDialog }) => () => closeDialog()
onSubmit: ({ element, updateElement, closeDialog }) => (formData: Object) => {
// Get element settings plugins
const plugins = getPlugins("cms-element-advanced-settings").filter(
pl => pl.element === element.type
);
formData = plugins.reduce((formData, pl) => {
if (pl.onSave) {
return pl.onSave(formData);
}
return formData;
}, formData);
updateElement({
element: merge(element, "data", formData)
});
closeDialog();
},
onClose: ({ closeDialog }) => () => closeDialog()
return (name: string, newValue: mixed, history = false) => {
const propName = `${valueKey}.${name}`;
if (name !== "advanced") {
newValue = parseInt(newValue) || 0;
}
let newElement = set(element, propName, newValue);
// Update all values in advanced settings
if (propName.endsWith(".all")) {
const prefix = propName.includes("desktop") ? "desktop" : "mobile";
newElement = merge(newElement, `${valueKey}.${prefix}`, {
top: newValue,
right: newValue,
bottom: newValue,
left: newValue
});
}
updateElement({
element: newElement,
history,
merge: true
});
};
});
case "RESET":
// Reset the entire state
if (action.path === undefined) {
return initialState;
}
// Reset specific state
return dotProp.set(
state,
action.path,
dotProp.get(initialState, action.path)
);
case "PUSH":
return dotProp.merge(state, action.path, [action.value]);
case "INCREMENT":
var initialValue = Number(dotProp.get(state, action.path, 0))
var newValue = initialValue + action.value
return dotProp.set(state, action.path, newValue)
case "DECREMENT":
var initialValue = Number(dotProp.get(state, action.path, 0))
var newValue = initialValue - action.value
return dotProp.set(state, action.path, newValue)
case "DELETE":
return dotProp.delete(state, action.path);
default:
return state;
return (name: string, newValue: mixed, history = false) => {
const propName = `${valueKey}.${name}`;
if (name !== "advanced") {
newValue = parseInt(newValue) || 0;
}
let newElement = set(element, propName, newValue);
// Update all values in advanced settings
if (propName.endsWith(".all")) {
const prefix = propName.includes("desktop") ? "desktop" : "mobile";
newElement = merge(newElement, `${valueKey}.${prefix}`, {
top: newValue,
right: newValue,
bottom: newValue,
left: newValue
});
}
if (!history) {
updateElement({
element: newElement,
history
});
return;
}
if (historyUpdated[propName] !== newValue) {
updateSettings = data => {
const { element, updateElement } = this.props;
const attrKey = `data.link`;
const newElement = merge(element, attrKey, data);
updateElement({ element: newElement });
if (!isEqual(this.historyUpdated, data)) {
this.historyUpdated = data;
updateElement({ element: newElement });
}
};
export const reduxFormReducer = (state: {}, action: any) => {
switch (action.type) {
case VALIDATION_ERRORS:
state = dotProp.set(state, "submitSucceeded", false)
return dotProp.merge(state, "syncErrors", action.errors)
default:
return state
}
}
updateSettings = data => {
const { element, updateElement } = this.props;
const attrKey = `data.link`;
const newElement = merge(element, attrKey, data);
updateElement({ element: newElement });
if (!isEqual(this.historyUpdated, data)) {
this.historyUpdated = data;
updateElement({ element: newElement });
}
};
layerForm: (state: {}, action: any) => {
switch(action.type) {
case RECEIVE_LAYERFORM_ERRORS:
state = dotProp.set(state, "submitSucceeded", false)
return dotProp.merge(state, "syncErrors", action.errors)
default:
return state
}
}
})
...getRehydratePayload(action, 'invite'),
isSendingInvite: false,
}
}
case Actions.SEND_INVITE:
return {
...state,
isSendingInvite: true,
}
case Actions.SEND_INVITE_FAILURE:
return {
...state,
isSendingInvite: false,
}
case Actions.STORE_INVITEE_DATA:
return dotProp.merge(state, 'invitees', { [action.address]: action.e164Number })
case Actions.REDEEM_INVITE:
return {
...state,
redeemedInviteCode: action.inviteCode,
isRedeemingInvite: true,
}
case Actions.REDEEM_INVITE_SUCCESS:
return {
...state,
redeemComplete: true,
isRedeemingInvite: false,
}
case Actions.REDEEM_INVITE_FAILURE:
return {
...state,
redeemComplete: false,