-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[Patterns]: Add a flag to hide patterns from UI #36108
Conversation
hideFromUI: true, | ||
content: | ||
'<!-- wp:test-block-a --><!-- /wp:test-block-a -->', | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above was added just to verify that the current behavior is not affected by patterns with inserter
flag set to false
.
__experimentalGetParsedPattern( state, name ) | ||
); | ||
const parsedPatterns = patterns | ||
.filter( ( { hideFromUI } ) => ! hideFromUI ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do wonder whether hideFormUI is the right name for it. Maybe at some point we'd want to show patterns in the UI somewhere but not in the inserter. Anyway, maybe we should just base it on how we do it for blocks. So (inserter: false
or supports.inserter: false
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have strong opinion on this and I can change it. I just named it this way, as by using inserter
made me think the Inserter
(main+quick) where there might be more places that we do no want these patterns displayed like the pattern explorer modal (if it lands 😄 ).
Size Change: -78 B (0%) Total Size: 1.08 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, maybe folks could have different opinions about the naming of this but still have some weeks where we can make changes.
Resolves: #36084
Previously there was an implementation to control where patterns should appear with a
scope
property (similar to block variations), which was discussed and decided to be removed and every pattern should be shown in inserter. The context for that was for patterns used in the experimentalBlockPatternSetup
component, which can suggest patterns in a Placeholder - seeQuery Loop
.Now with Pattern block merged, themes can create patterns for dealing with some issues like internationalized content etc.. and a similar flag for hiding such patterns is needed.
In this PR I decided to add a
inserter
flag and make the filtering with this flag directly in__experimentalGetAllowedPatterns
which is used in every place that we need to handle patterns and show them in UI. Patterns with the flag set totrue
can still be retrieved individually by__experimentalGetParsedPattern
.Testing instructions
'inserter' => false
and observe that is not shown in any UI with pattern handling, like the inserter or theBlockPatternSetup
.Pattern
block by using a pattern with this flag and verify that is working properly and is not shown in any UI, like the Inserter