Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Restrict export pattern action to user patterns #63228

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

ntsekouras
Copy link
Contributor

@ntsekouras ntsekouras commented Jul 8, 2024

What?

According to this issue: #61787 the export pattern action is not meant to be for theme patterns. With a recent refactoring of that action this regressed and we ended up with showing this action in theme patterns, which also caused other issues of not exporting properly(#63217).

I think the solution is to add back the check about the wp_block (theme patterns have type===pattern). This makes it a bit confusing though with our API for registering actions, which right now is registerEntityAction( 'postType', 'wp_block', exportPattern );.

We should look into the type===pattern and where/why is needed..

Testing Instructions

  1. Exporting/importing patterns should work properly in patterns list (there is an open issue for the post summary actions)
  2. Export action should not be available for theme patterns
@ntsekouras ntsekouras added the [Type] Bug An existing feature does not function as intended label Jul 8, 2024
@ntsekouras ntsekouras self-assigned this Jul 8, 2024
Copy link

github-actions bot commented Jul 8, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I can export custom patterns but not theme patterns 👍🏻

Screenshot 2024-07-08 at 5 55 47 PM Screenshot 2024-07-08 at 5 55 52 PM
packages/editor/src/dataviews/actions/export-pattern.tsx Outdated Show resolved Hide resolved
Co-authored-by: Ramon <ramonjd@users.noreply.github.com>
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Not a blocker, but I think it might be better to use PATTERN_TYPES.user instead of a hardcoded string.

However, it seems necessary to write @ts-ignore to avoid type errors in typescript file, like here:

// @ts-ignore
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';

@ntsekouras ntsekouras merged commit f6133cd into trunk Jul 8, 2024
61 checks passed
@ntsekouras ntsekouras deleted the fix/restrict-export-to-user-patterns branch July 8, 2024 10:16
@github-actions github-actions bot added this to the Gutenberg 18.8 milestone Jul 8, 2024
@andrewserong andrewserong added the [Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced label Jul 9, 2024
huubl pushed a commit to huubl/gutenberg that referenced this pull request Jul 10, 2024
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jul 18, 2024
Co-authored-by: ntsekouras <ntsekouras@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Patterns A collection of blocks that can be synced (previously reusable blocks) or unsynced [Type] Bug An existing feature does not function as intended
4 participants