Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
next(action);
store.dispatch(deactivateElement());
const state = store.getState();
let { element } = action.payload;
let parent = getParentElementWithChildren(state, element.id);
// Remove child from parent
// $FlowFixMe
if (!parent) {
return;
}
const index = parent.elements.findIndex(el => el.id === element.id);
parent = dotProp.delete(parent, "elements." + index);
store.dispatch(updateElement({ element: parent }));
// Execute `onChildDeleted` if defined
const plugin = getPlugin(parent.type);
if (!plugin) {
return;
}
if (typeof plugin.onChildDeleted === "function") {
plugin.onChildDeleted({ element: parent, child: element });
}
});
next(action);
store.dispatch(deactivateElement());
const state = store.getState();
let { element } = action.payload;
let parent = getParentElementWithChildren(state, element.id);
// Remove child from parent
// $FlowFixMe
if (!parent) {
return;
}
const index = parent.elements.findIndex(el => el.id === element.id);
parent = dotProp.delete(parent, "elements." + index);
store.dispatch(updateElement({ element: parent }));
// Execute `onChildDeleted` if defined
const plugin = getPlugin(parent.type);
if (!plugin) {
return;
}
if (typeof plugin.onChildDeleted === "function") {
plugin.onChildDeleted({ element: parent, child: element });
}
});
static getDerivedStateFromProps(props, state) {
const { validate } = props;
let derived = {};
if (state.values.node) {
if (validate.NODE === 'PENDING') {
derived = set(state, 'valids.endpoint', false);
derived = set(derived, 'loading.endpoint', true);
derived = del(derived, 'errors.endpoint');
}
if (validate.NODE === 'FAILURE') {
derived = set(state, 'errors.endpoint', validate.NODE_ERROR);
derived = del(derived, 'loading.endpoint');
}
if (validate.NODE === 'SUCCESS') {
derived = set(state, 'valids.endpoint', true);
derived = del(derived, 'loading.endpoint');
derived = del(derived, 'errors.endpoint');
}
}
return derived;
}
componentDidMount() {
addReducer([DEACTIVATE_PLUGIN], "ui.plugins", (state, action) => {
const { name } = action.payload;
const plugin = getPlugin(name);
if (!plugin) {
return state;
}
let typePlugins = dotProp.get(state, plugin.type);
if (!Array.isArray(typePlugins)) {
typePlugins = [];
}
const alreadyActive = typePlugins.findIndex(pl => pl.name === plugin.name);
if (alreadyActive > -1) {
typePlugins = dotProp.delete(typePlugins, alreadyActive);
}
return dotProp.set(state, `${plugin.type}`, typePlugins);
});
onRemoveKey = (e, { name }) => {
const { [`${name}.key`]: value, ...validFields } = this.state.validFields;
this.setState({
auth: del(this.state.auth, name),
validFields
});
}
onSubmit = () => {
removeData = (index: number) => {
const { value, onChange } = this.props;
onChange(dotProp.delete(value, index));
};
const plugin = getPlugin(name);
if (!plugin) {
return state;
}
let typePlugins = dotProp.get(state, plugin.type);
if (!Array.isArray(typePlugins)) {
typePlugins = [];
}
const alreadyActive = typePlugins.findIndex(pl => pl.name === plugin.name);
if (alreadyActive > -1) {
typePlugins = dotProp.delete(typePlugins, alreadyActive);
} else {
if (closeOtherInGroup) {
typePlugins = [{ name, params }];
} else {
typePlugins.push({ name, params });
}
}
return dotProp.set(state, `${plugin.type}`, typePlugins);
});
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;
}
};
};
export const remove = id => (state = initialState) => dotprop.delete(
state,
`data.${id}`
);
case RECEIVE_MAPS:
return action.maps
case RECEIVE_UPDATED_MAP:
return dotProp.set(state, `${action.map.id}`, action.map)
case CREATE_MAP:
return {
...state,
[action.map.id]: action.map
}
case DELETE_MAP:
let { [action.mapId]: deletedItem, ...rest } = state
return rest
case RECEIVE_UPDATED_LAYER:
return dotProp.set(state, `${action.mapId}.json.layers.${action.layerId}`, action.layer)
case RECEIVE_DELETE_MAP_LAYER:
return dotProp.delete(state, `${action.mapId}.json.layers.${action.layerId}`)
case RECEIVE_CLONE_MAP_LAYER:
let layerCopy = JSON.parse(JSON.stringify(state[action.mapId].json.layers[action.layerId]))
layerCopy.name += " Copy"
return dotProp.set(state, `${action.mapId}.json.layers`, [...state[action.mapId].json.layers, layerCopy])
case CHANGE_LAYER_VISIBILITY:
return dotProp.toggle(state, `${action.mapId}.json.layers.${action.layerId}.visible`)
case CHANGE_LAYER_PROPERTY:
return dotProp.set(state, `${action.mapId}.json.layers.${action.layerId}.${action.layerPropertyPath}`, action.layerPropertyValue)
case MERGE_LAYER_PROPERTIES:
const newLayer = merge(dotProp.get(state, `${action.mapId}.json.layers.${action.layerId}`), action.layer)
return dotProp.set(state, `${action.mapId}.json.layers.${action.layerId}`, newLayer)
case RECEIVE_SET_MAP_ORIGIN:
return dotProp.set(state, `${action.mapId}.json.map_defaults`, {
lat: action.position.center.lat,
lon: action.position.center.lon,
zoom: action.position.zoom,