Problem/Motivation
Prop types have JSON schemas, example:
#[PropType(
id: 'enum',
label: new TranslatableMarkup('Enum'),
default_source: 'select',
schema: ['type' => ['string', 'number', 'integer'], 'enum' => []],
typed_data: ['float', 'integer', 'string'],
)]Today, they have 2 distinct usages:
- as syntax shortcut for component authors thanks to the
ui-patterns://stream wrapper in JSON schema references - used by the
CompatibilityCheckerto guess which prop has which type
We have 2 problems here:
- Those 2 different usages can sometimes take us to conflicting situation where a schema must be complete enough to be used in JSON schema references but not too specific to be caught by
CompatibilityChecker. Example: https://www.drupal.org/project/ui_patterns/issues/3510711 - The JSON schema references case is now covered by Drupal Core: https://www.drupal.org/node/2352923 and we don't need to keep our own stream mwrapper
Proposed resolution
- Create a schema.json file at the root of the module with the schema of all our prop types
- Update our codes and our tests to use
module://ui_patterns/schema.json#fooinstead ofui-patterns://foo - Add a drush command to convert existing SDC files
- Deprecate
Drupal\ui_patterns\SchemaManager\StreamWrapper. It will be removed in UI Patterns 3.0.
Issue fork ui_patterns-3567610
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
pdureau commentedComment #4
pdureau commentedWork in progress. Some phpunit errors to fix:
And 4 failures in
Drupal\Tests\ui_patterns\Kernel\SchemaManagerTest::testResolveOnce mergeable, let's discuss about the strategy before committing. This MR will not be comaptible with Drupal 10.x, 11.0, 11.1 & 11.2.
Do we need to also add Drupal 11.3's stream wrapper? Or do we need to wait UI Patterns 2.1 (the version getting rid of 10.x compatibility)
Comment #5
pdureau commentedPipeline fails bu the same tests are OK on my local environment, so it is the time for a first review and to open the discusssion.
Let's discuss about the strategy before committing. This MR will not be compatible with Drupal 10.x, 11.0, 11.1 & 11.2.
Comment #6
grimreaperMigration command tested on #3586282: Adopt Core's stream wrapper: OK
Comment #7
grimreaperComment #8
pdureau commentedWe do both:
All new features will only land in 2.x branch, only bugfixes will be backported to 2.0.x
Comment #9
pdureau commentedPipeline has phpunit fails i don't have at home.
The 4 tests of
Drupal\Tests\ui_patterns\Kernel\SchemaManagerTest::testResolveare KO:The reference resolution is not done.
Can you try in your environment?