-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: show theme patterns from directory in site editor #55877
Changes from all commits
6aca0b3
316bc22
3106b51
f518f6c
0a0dbfe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,10 @@ export const PATTERN_TYPES = { | |
|
||
export const PATTERN_DEFAULT_CATEGORY = 'all-patterns'; | ||
export const PATTERN_USER_CATEGORY = 'my-patterns'; | ||
export const PATTERN_CORE_SOURCES = [ | ||
export const EXCLUDED_PATTERN_SOURCES = [ | ||
'core', | ||
'pattern-directory/core', | ||
'pattern-directory/featured', | ||
'pattern-directory/theme', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this makes the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it actually applies better now as previously it included theme specified patterns from the directory which are essentially theme patterns rather than core, now it is more strictly just core patterns that are not related to the current theme at all. Having looked at the places where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @talldan on the naming here.
The source of the patterns is core and the pattern directory, not the theme. The theme doesn't create or define the patterns, it only "opts into" using them, which doesn't change their actual source. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it confuses things to not think of these as theme patterns - from the user perspective they are a theme pattern regardless of the source, but I will try and come up with a name for the constant that better reflects the situation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Luckily, we're referring to a variable name here that isn't exposed to users, so we can afford to be accurate. We could also argue that for most users they only see patterns, not user, theme, or core patterns etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the new naming of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have renamed the constant to const selectThemePatterns = createSelector(
...
.filter( ( pattern ) => ! NON_THEME_PATTERN_SOURCES.includes( pattern.source ))
...
) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dan's suggested name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have updated that inline comment and variable |
||
]; | ||
export const PATTERN_SYNC_TYPES = { | ||
full: 'fully', | ||
|
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.
It's unusual that the functions aren't called here ... Is this a bug? I think it should be:
Right now I'd expect it always evaluates to
true
. If so, it's curious that there's not visible bug. Maybe the logic is duplicated, perhaps the call to filter can be deleted?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.
hmm, well spotted. In my testing of this only the last method is called. I will put up a separate PR for this as will be easier to review/test in isolation.
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.
PR to update this here