-
Notifications
You must be signed in to change notification settings - Fork 9
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
Allow block_order on preset #849
Conversation
a59c9e7
to
42ed549
Compare
42ed549
to
1fedd6d
Compare
}, | ||
{ | ||
"$ref": "#/definitions/presetWithBlocksHash" | ||
} |
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 encountered an issue where presets with only name
and settings
could be validated by either of these refs, so by adding blocks
as required
to the presetWithBlocksHash
it ensured there was no such conflict. A preset with only name
(and usually settings
, otherwise the whole preset's kinda useless) will get validated by the presetWithBlocksArray
.
Optionally, we could make blocks
required in presetWithBlocksArray
too and require a third option for presets with just name
and settings
. A trivial change, if it's preferred. I'm on the fence, myself.
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.
maybe...
"allOf": [
{ "$ref": "#/definitions/presetBase" }
{ "oneOf": [
{ "$ref": "#/definitions/presetBlocksArray" },
{ "$ref": "#/definitions/presetBlocksHash" },
]}
]
?
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.
So I remember when we chatted in person, we agreed it wasn't worth complicating things just to extract out name
and settings
- though I'd be down to do it if it solved the presets with "only" name
and settings
more elegantly... Although the one you posted still requires that the data fit into either presetBlocksArray
and presetBlocksHash
?
Wouldn't it be more like this to accommodate all 3 possible cases?
{ "oneOf": [
{ "$ref": "#/definitions/presetBase" }
{ "$ref": "#/definitions/presetBlocksArray" },
{ "$ref": "#/definitions/presetBlocksHash" },
]}
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 mean that works too so long as presetBase doesn't accept other properties and that the array/hash have blocks & blocks order required. Same same
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.
2e05ecd
to
9441dfa
Compare
9441dfa
to
8f7b484
Compare
"blocks": { | ||
"$ref": "#/definitions/blocksHash" | ||
}, |
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.
ezpz!
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.
tophat looks good to me! We'll need to adjust the types in Shopify/theme-tools to match but we're good to go!
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.
Looks great! Thank you Mia!
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.
🎩 ed and things look good!
When preset blocks are a hash, they require
block_order
since the order is lost (as opposed to the blocks array).We noticed while working in theme-tools that we were getting a red highlight saying
block_order property not allowed
(or something to that effect). This is to fix that.🎩
I was able to get the autocomplete for both the root and nested level blocks:
You can also tophat by opening this repo on this branch and playing with the fixtures, it should pop up the autocomplete.
Additional case: nested blocks must be the same type as their parents - blocks arrays can only contain blocks that are also arrays, block hashes can only contain blocks that have block hashes
🎩