Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 });
}
});
(props: Props) => {
const { open, onClose, onSubmit, plugin: pluginName } = props;
const plugin = getPlugin(pluginName);
return (
<dialog open="{open}">
{plugin && (
<form>
{({ submit, Bind }) => (
Update {plugin.title}
<input label="{"Name"}"></form></dialog>
const actions = plugin.settings.map(pl => {
if (typeof pl === "string") {
return { plugin: getPlugin(pl || divider), options: {} };
}
if (Array.isArray(pl)) {
return { plugin: getPlugin(pl[0] || divider), options: pl[1] };
}
return null;
});
const actions = plugin.settings.map(pl => {
if (typeof pl === "string") {
return { plugin: getPlugin(pl || divider), options: {} };
}
if (Array.isArray(pl)) {
return { plugin: getPlugin(pl[0] || divider), options: pl[1] };
}
return null;
});
return [
...actions,
{ plugin: getPlugin("pb-page-element-settings-advanced") },
{ plugin: getPlugin("pb-page-element-settings-save") }
].filter(pl => pl);
};
const actions = plugin.settings.map(pl => {
if (typeof pl === "string") {
return { plugin: getPlugin(pl || divider), options: {} };
}
if (Array.isArray(pl)) {
return { plugin: getPlugin(pl[0] || divider), options: pl[1] };
}
return null;
});
return [
...actions,
{ plugin: getPlugin("pb-page-element-settings-advanced") },
{ plugin: getPlugin("pb-page-element-settings-save") }
].filter(pl => pl);
};
const actions = plugin.settings.map(pl => {
if (typeof pl === "string") {
return { plugin: getPlugin(pl || divider), options: {} };
}
if (Array.isArray(pl)) {
return { plugin: getPlugin(pl[0] || divider), options: pl[1] };
}
return null;
});
const onSubmit = useHandler(props, ({ element }) => async formData => {
formData.content = removeIdsAndPaths(cloneDeep(element));
const meta = await getDataURLImageDimensions(formData.preview);
const blob = dataURLtoBlob(formData.preview);
blob.name = "pb-page-element-" + element.id + ".png";
const fileUploaderPlugin = getPlugin("file-uploader");
const previewImage = await fileUploaderPlugin.upload(blob, { apolloClient: client });
previewImage.meta = meta;
previewImage.meta.private = true;
const createdImageResponse = await client.mutate({
mutation: CREATE_FILE,
variables: {
data: previewImage
}
});
const createdImage = get(createdImageResponse, "data.files.createFile", {});
if (createdImage.error) {
return showSnackbar("Image could not be saved.");
}
if (!file) {
return null;
}
const plugins = getPlugins("file-manager-file-type");
let plugin = null;
for (let i = 0; i < plugins.length; i++) {
let current = plugins[i];
if (Array.isArray(current.types) && current.types.includes(file.type)) {
plugin = current;
}
}
if (!plugin) {
plugin = getPlugin("file-manager-file-type-default");
invariant(plugin, `Missing default "file-manager-file-type" plugin.`);
}
return plugin;
}
addReducer([TOGGLE_PLUGIN], "ui.plugins", (state, action) => {
const { name, params, closeOtherInGroup = false } = 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);
} else {
if (closeOtherInGroup) {
export default () => {
const fileUploaderPlugin = getPlugin("file-uploader");
return fileUploaderPlugin.upload;
};