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

Allow Names on Preset Blocks #917

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions schemas/theme/preset_blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"properties": {
"static": true,
"type": true,
"name": true,
"settings": true,
"blocks": {
"$ref": "#/definitions/blocksArray"
Expand Down Expand Up @@ -52,6 +53,7 @@
"properties": {
"static": true,
"type": true,
"name": true,
"settings": true,
"blocks": {
"$ref": "#/definitions/blocksHash"
Expand All @@ -72,6 +74,10 @@
"type": "string",
"description": "The block type."
},
"name": {
"type": "string",
"description": "The block name."
},
"settings": {
"$ref": "./default_setting_values.json"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/section-nested-blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"type": "group",
"blocks": [
{ "type": "text", "settings": { "text": "Hello" } },
{ "type": "header", "settings": { "text": "World" } }
{ "type": "header", "name": "Header", "settings": { "text": "World" } }
]
}
]
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/section-schema-preset-blocks-as-hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"blocks": {
"exampleBlock": {
"type": "text",
"name": "Example Block",
"settings": {}
},
"exampleBlock2": {
Expand Down
10 changes: 9 additions & 1 deletion tests/fixtures/theme-block-basics.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@
"blocks": [
{
"type": "thing",
"name": "The Thing",

Choose a reason for hiding this comment

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

changing these fixtures did not require updating any tests?

Copy link
Contributor Author

@miazbikowski miazbikowski Feb 19, 2025

Choose a reason for hiding this comment

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

The tests that run on these fixtures test that they are valid, so by adding this and having the existing tests be green, I prove that names are now valid.

If you wanna tophat, you can also clone this repo, and if you tweak these json fixtures, it'll actually run the json schema on the fixtures in real time (you'll see any of your errors in your IDE), which is super helpful when you're updating the json schema!

"settings": {
"some-setting": "some-value"
}
},
"blocks": [
{
"type": "text",
"name": "Nested Text Block",
"settings": {}
}
]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a nested block since there wasn't one.

},
{
"type": "button",
Expand Down
4 changes: 3 additions & 1 deletion tests/fixtures/theme-block-presets-as-hash.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
},
"some-other-block-id": {
"type": "image",
"name": "Image Block",
"static": true,
"settings": {
"some-setting": "some-value"
},
"blocks": {
"nested-block-id": {
"type": "text"
"type": "text",
"name": "Nested Text Block"
}
},
"block_order": ["nested-block-id"]
Expand Down