Skip to content

Commit

Permalink
feat: changed clone blocks structure (#787)
Browse files Browse the repository at this point in the history
* feat: changed clone blocks structure

* fix: changed import for cloneBlock

* fix: removed cloneBlock from utils
  • Loading branch information
Wagner3UB authored Oct 18, 2024
1 parent 437b242 commit d8ebfae
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,7 @@ module.exports = {
},
},
},
globals: {
structuredClone: true,
},
};
1 change: 0 additions & 1 deletion src/config/Blocks/ListingOptions/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export {
addSchemaField,
templatesOptions,
cloneBlock,
} from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils';
export addDefaultOptions from 'design-comuni-plone-theme/config/Blocks/ListingOptions/defaultOptions';
export addDefaultAdditionalOptions from 'design-comuni-plone-theme/config/Blocks/ListingOptions/defaultAdditionalOptions';
Expand Down
6 changes: 0 additions & 6 deletions src/config/Blocks/ListingOptions/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,3 @@ export const addLighthouseField = (schema, intl, position = 0) => {

return pos;
};

export const cloneBlock = (blockData) => {
const blockID = uuid();
const clonedData = { ...blockData, block: blockID };
return [blockID, clonedData];
};
2 changes: 1 addition & 1 deletion src/config/Blocks/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import countDownSVG from 'design-comuni-plone-theme/icons/count-down.svg';
import CountDownBlockView from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/CountDown/View';
import CountDownBlockEdit from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/CountDown/Edit';

import { cloneBlock } from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks';

const italiaBlocks = {
highlitedContent: {
Expand Down
6 changes: 2 additions & 4 deletions src/config/Blocks/listingVariations.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ import {
addSmallBlockLinksTemplateOptions,
} from 'design-comuni-plone-theme/config/Blocks/ListingOptions';

import {
addLighthouseField,
cloneBlock,
} from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils';
import { addLighthouseField } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils';
import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks';

const italiaListingVariations = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Icon } from '@plone/volto/components';
import { Plug } from '@plone/volto/components/manage/Pluggable';
import { load } from 'redux-localstorage-simple';
import { isEqual, omit, without } from 'lodash';
import { cloneBlock } from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
import { cloneBlock } from 'design-comuni-plone-theme/helpers/blocks';
import { setBlocksClipboard, resetBlocksClipboard } from '@plone/volto/actions';
import config from '@plone/volto/registry';

Expand Down
8 changes: 8 additions & 0 deletions src/helpers/blocks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { v4 as uuid } from 'uuid';

export const cloneBlock = (blockData) => {
const blockID = uuid();
const clonedData = structuredClone(blockData);
clonedData.block = blockID;
return [blockID, clonedData];
};

0 comments on commit d8ebfae

Please sign in to comment.