Skip to content

Commit

Permalink
false value checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed May 14, 2024
1 parent 64d782a commit a4afd42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 9 additions & 2 deletions packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,10 @@ const duplicatePostAction = {
};

const isTemplatePartRevertable = ( item ) => {
const hasThemeFile = item.templatePart.has_theme_file;
if ( ! item ) {
return false;
}
const hasThemeFile = item.templatePart?.has_theme_file;
return canDeleteOrReset( item ) && hasThemeFile;
};

Expand Down Expand Up @@ -1020,8 +1023,12 @@ export const deletePatternAction = {
id: 'delete-pattern',
label: __( 'Delete' ),
isEligible: ( item ) => {
if ( ! item ) {
return false;
}
const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file;
const hasThemeFile =
isTemplatePart && item.templatePart?.has_theme_file;
return canDeleteOrReset( item ) && ! hasThemeFile;
},
hideModalHeader: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ export const exportPatternAsJSONAction = {
id: 'export-pattern',
label: __( 'Export as JSON' ),
supportsBulk: true,
isEligible: ( item ) => item.type === PATTERN_TYPES.user,
isEligible: ( item ) => {
if ( ! item.type ) {
return false;
}
return item.type === PATTERN_TYPES.user
},
callback: async ( items ) => {
if ( items.length === 1 ) {
return downloadBlob(
Expand Down

0 comments on commit a4afd42

Please sign in to comment.