-
Notifications
You must be signed in to change notification settings - Fork 7
Curate queries within a block #530
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
Open
ingeniumed
wants to merge
88
commits into
trunk
Choose a base branch
from
add/multiple-queries-to-single-block
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
48e710d
Attempting to port code from PR405 into here
ingeniumed 7b90e48
Add support for multiple display queries
ingeniumed 5854bb4
Clean up the code and add in validation framework
ingeniumed 3d2828d
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
ingeniumed 716415b
Stop crashes for the old query way, and remove the deprecated buttong…
ingeniumed 790215f
Abstract away the query selection to another level and show query nam…
ingeniumed f5bb77f
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
ingeniumed 9385d73
Simplify the query configuration
ingeniumed 22349fe
Simplify the query_configuration schema
ingeniumed f8363d7
Pop in more configuration at the query level
ingeniumed bc7208b
Attempting to use the type instead of the query key for display queries
ingeniumed 14ce52a
Bug: look at the console log and you'll see the wrong query is always…
ingeniumed b130ff2
Comment away everything that initializes remote data with teh wrong q…
ingeniumed 74699d7
Attempting to move just the remote data lgic to another component, le…
ingeniumed d67ccb2
Load the queryKey and queryInputs from state if they are available
ingeniumed de3a742
Attempting to redo the whole queries system
ingeniumed dda2bdd
Group selectors by query
ingeniumed d5e40e4
Got the UI working finally, with the exception of pattern selection b…
ingeniumed 330c959
Fix the pattern selection bug
ingeniumed 49ece05
Fix the bug related to the query group and query key not being picked…
ingeniumed 5cbf9d9
Fix the query input schema for a non-display query being wrong
ingeniumed 4228e43
Fix more bugs
ingeniumed df8e1b6
Another bug fix and some debuggers
ingeniumed d13b991
Port the missing caching fix
ingeniumed 9958984
Fix the merge conflicts from trunk. Still need to port the new Edit c…
ingeniumed c1b79c8
Adding ToDos for pending work for this PR
ingeniumed 0d16b94
Fix the reset block function and remove the unnecessary code
ingeniumed eac246f
Fix shortcode selection
ingeniumed 88681d9
Remove the remaining ToDos
ingeniumed 4369c29
Implement the skeleton migrate config method, and add in validation m…
ingeniumed 50086ac
Add a migration pathway for the older format. The query input panel i…
ingeniumed fd831c2
Remove last remaining todo/fixmes
ingeniumed 0e86399
Reverting unnecessary changes, and re-adding the max width for the co…
ingeniumed 9e823fe
Remove the deprecated notices
ingeniumed 54e69ae
Functions are called with the brackets, otherwise they aren't called …
ingeniumed 8460688
Solve the test failures
ingeniumed 3ec1eec
Fix all the integration tests
ingeniumed ba6ef35
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
ingeniumed 5ce7cf8
Re-write the config processing to be in one go, and be well documented
ingeniumed d3b1219
Add a check to make sure a display query is defined
ingeniumed a3d7fea
Fix existing data breaking, and change the name of the conference eve…
ingeniumed 4eee95e
Add in a fallback query key, and update the tests to remove workaroun…
ingeniumed 3351e6e
Attempting to make the Art Institute block backwards compatible
ingeniumed 4f4e40a
More comments and bug fixes
ingeniumed 3b354f1
Got block bindings working with multiple output schemas. Inline bindi…
ingeniumed 5bdd833
Get inline binding working for multiple display queries
ingeniumed 726959b
Fix the linting
ingeniumed 1c608f4
Fix the block binding tests based on the new format
ingeniumed 50ed548
I did indeed forget to run prettier
ingeniumed 952ad64
Change the schema to use display_queries, and infer types as much as …
ingeniumed 6a6121b
Finish migration, fix bug in user supplied patterns not showing up an…
ingeniumed bd65475
Add guards from the tests
ingeniumed cfb5bf0
update from trunk and fix the merge conflicts
ingeniumed 7e8bcf1
Fix all errors
ingeniumed 364e638
Tweak the function name
ingeniumed cf8a99d
Minor code review points
ingeniumed ab4cd35
Remove more unecessary lines
ingeniumed 4f01da2
Add Extra tests
ingeniumed 43715f4
Fix the merge conflict with the config schema
ingeniumed 7e1205d
Fix merge conflicts
ingeniumed 830a0d3
Merge branch 'trunk' into add/multiple-queries-to-single-block
chriszarate 82b3054
Add RemoteDataBlock serializable config
chriszarate 3ec4f57
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
ingeniumed ff81040
Remove unused code
ingeniumed 84196d8
Switch from using display queries to placeholder
ingeniumed 19ff3b4
Get the case working when no placeholders are provided
ingeniumed f852297
Add support for a query being a display, and
ingeniumed 2eb260b
Drop selectorQueryKey and attempt to fix errors in happy path
ingeniumed 805f4ad
Backport a bug fix from trunk into my branch
ingeniumed 426671b
Re-enable inline-bindings with hardcoded display query
ingeniumed 4b54f34
Add a display query selector for new inline bindings
ingeniumed 5995b71
Got inline bindings to fully function. Assumed the first display quer…
ingeniumed 97bfd42
Added in the name property, and cleaned up the frontend code as a result
ingeniumed f6904c6
tweak the inline bindings to re-use the existing method
ingeniumed a75a78b
Add a quick comment
ingeniumed 2bc60cc
Fix merge conflicts
ingeniumed 4518af7
Fixing some linting errors. There's still a bug with Google Sheets
ingeniumed 0aa9510
Add an extra filter to fix the memory caching bug
ingeniumed ef0d3e9
Fix the psalm erro
ingeniumed d62c56a
Fix psalm again
ingeniumed 5ea6dbd
Merge branch 'add/bug-fix-for-google-sheets' of github.com:Automattic…
ingeniumed e823cc8
Fix all the tests
ingeniumed af45470
Fix js test
ingeniumed f6dcba5
Migrate the config of the example blocks, and fix the lack of error b…
ingeniumed 110c547
Merge branch 'trunk' into add/multiple-queries-to-single-block
ingeniumed 852581c
Merge branch 'trunk' of github.com:Automattic/remote-data-blocks into…
ingeniumed d8eef25
Revert new config changes to the example blocks
ingeniumed 0394f70
Merge branch 'trunk' into add/multiple-queries-to-single-block
ingeniumed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace RemoteDataBlocks\Config\Block; | ||
|
||
use RemoteDataBlocks\Config\ArraySerializable; | ||
use RemoteDataBlocks\Editor\BlockManagement\ConfigRegistry; | ||
use RemoteDataBlocks\Validation\ConfigSchemas; | ||
use WP_Error; | ||
|
||
/** | ||
* RemoteDataBlock class | ||
* | ||
* Represents the block configuration for a remote data block. | ||
*/ | ||
class RemoteDataBlock extends ArraySerializable { | ||
protected const DEPRECATED_RENDER_QUERY_KEY = 'render_query'; | ||
protected const DEPRECATED_SELECTION_QUERIES_KEY = 'selection_queries'; | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function get_config_schema(): array { | ||
return ConfigSchemas::get_remote_data_block_config_schema(); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public static function migrate_config( array $config = [] ): array|WP_Error { | ||
// Nothing to migrate, return the block config as is. | ||
if ( isset( $config[ ConfigRegistry::QUERIES_KEY ] ) ) { | ||
return $config; | ||
} | ||
|
||
$queries = []; | ||
$placeholders = []; | ||
|
||
if ( isset( $config[ self::DEPRECATED_RENDER_QUERY_KEY ]['query'] ) ) { | ||
$queries[ ConfigRegistry::DEPRECATED_DISPLAY_QUERY_KEY ] = $config[ self::DEPRECATED_RENDER_QUERY_KEY ]['query']; | ||
$placeholders[] = [ | ||
'name' => 'Display', | ||
'query_key' => ConfigRegistry::DEPRECATED_DISPLAY_QUERY_KEY, | ||
]; | ||
unset( $config[ self::DEPRECATED_RENDER_QUERY_KEY ] ); | ||
} | ||
|
||
if ( isset( $config[ self::DEPRECATED_SELECTION_QUERIES_KEY ] ) ) { | ||
// Get the selection queries, inflate them, and add them to the queries array using the type as the key. | ||
foreach ( $config[ self::DEPRECATED_SELECTION_QUERIES_KEY ] as $selection_query ) { | ||
$queries[ $selection_query['type'] ] = $selection_query['query']; | ||
} | ||
|
||
unset( $config[ self::DEPRECATED_SELECTION_QUERIES_KEY ] ); | ||
} | ||
|
||
// Set queries. | ||
$config[ ConfigRegistry::QUERIES_KEY ] = $queries; | ||
$config[ ConfigRegistry::PLACEHOLDERS_KEY ] = $placeholders; | ||
|
||
return $config; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 haven't been able to solve a psalm error that complains about the types being invalidated and the key being unused, when
array_keys
was used for the loop. So I gave up, and instead just changed the name of the unused selectors to be such that psalm ignores it. If anyone knows this error, feel free to suggest a fix.