Skip to content

Commit

Permalink
update patterns actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Jan 11, 2024
1 parent 344bf8a commit 7320420
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const exportJSONaction = {
id: 'export-pattern',
label: __( 'Export as JSON' ),
isEligible: ( item ) => item.type === PATTERN_TYPES.user,
callback: ( item ) => {
callback: ( [ item ] ) => {
const json = {
__file: item.type,
title: item.title || item.name,
Expand All @@ -71,7 +71,8 @@ export const renameAction = {
const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file;
return isCustomPattern && ! hasThemeFile;
},
RenderModal: ( { item, closeModal } ) => {
RenderModal: ( { items, closeModal } ) => {
const [ item ] = items;
const [ title, setTitle ] = useState( () => item.title );
const { editEntityRecord, saveEditedEntityRecord } =
useDispatch( coreStore );
Expand Down Expand Up @@ -160,7 +161,8 @@ export const deleteAction = {
return canDeleteOrReset( item ) && ! hasThemeFile;
},
hideModalHeader: true,
RenderModal: ( { item, closeModal } ) => {
RenderModal: ( { items, closeModal } ) => {
const [ item ] = items;
const { __experimentalDeleteReusableBlock } =
useDispatch( reusableBlocksStore );
const { createErrorNotice, createSuccessNotice } =
Expand Down Expand Up @@ -224,7 +226,8 @@ export const resetAction = {
return canDeleteOrReset( item ) && hasThemeFile;
},
hideModalHeader: true,
RenderModal: ( { item, closeModal } ) => {
RenderModal: ( { items, closeModal } ) => {
const [ item ] = items;
const { removeTemplate } = useDispatch( editSiteStore );
return (
<VStack spacing="5">
Expand Down Expand Up @@ -254,7 +257,8 @@ export const duplicatePatternAction = {
label: _x( 'Duplicate', 'action label' ),
isEligible: ( item ) => item.type !== TEMPLATE_PART_POST_TYPE,
modalHeader: _x( 'Duplicate pattern', 'action label' ),
RenderModal: ( { item, closeModal } ) => {
RenderModal: ( { items, closeModal } ) => {
const [ item ] = items;
const { categoryId = PATTERN_DEFAULT_CATEGORY } = getQueryArgs(
window.location.href
);
Expand Down Expand Up @@ -288,7 +292,8 @@ export const duplicateTemplatePartAction = {
label: _x( 'Duplicate', 'action label' ),
isEligible: ( item ) => item.type === TEMPLATE_PART_POST_TYPE,
modalHeader: _x( 'Duplicate template part', 'action label' ),
RenderModal: ( { item, closeModal } ) => {
RenderModal: ( { items, closeModal } ) => {
const [ item ] = items;
const { createSuccessNotice } = useDispatch( noticesStore );
const { categoryId = PATTERN_DEFAULT_CATEGORY } = getQueryArgs(
window.location.href
Expand Down

0 comments on commit 7320420

Please sign in to comment.