[2.0.0-rc1] Compatibility with XB

Created on 1 December 2024, 4 months ago

Problem/Motivation

Following πŸ› [2.0.0-beta2] plugin.manager.sdc conflict with Experience Builder Active we can now test UI Patterns 2 with Experience Builder (XB). Careful: in Decmeber 2024, XB is still in early dev and very unstable, so the results may change from day to day.

Using XB components in UIP2

XB's json-schema-definitions stream wrapper is not triggered by UI Patterns 2. Normally, it must be done automatically by the JSON Schema library, without any actions on our side, but let's check.

sounds crazy, but XB is also providing some SDC components, but most of them are not using the attributes variable in templates. Unfortunately, there is nothing to do on out side.

Using UIP2 components in WB

Let's investigate this error:
ValueError: "" is not a valid backing value for enum Drupal\experience_builder\JsonSchemaInterpreter\SdcPropJsonSchemaType in Drupal\experience_builder\JsonSchemaInterpreter\SdcPropJsonSchemaType::from() (line 131 of /src/PropShape/PropShape.php).

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡«πŸ‡·France pdureau Paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @pdureau
  • πŸ‡«πŸ‡·France pdureau Paris
  • πŸ‡«πŸ‡·France just_like_good_vibes PARIS

    i just gave a test with a fresh 11.1.0 drupal and the last experience_builder from dev branch.

    i did not receive the mentioned errors.
    i managed to check the UI and almost nothing worked. My components were appearing but they are still in such an early stage, it seems difficult to check anything yet.

  • πŸ‡«πŸ‡·France pdureau Paris

    No error? That s'great news. I will check again.

    By the way, I know they are still very early stage, and I don't expect the builder to work properly, I just want the 2 JSON schema resolvers ($ref: ui-patterns:// and $ref: json-schema-definitions://) to work well together.

  • πŸ‡«πŸ‡·France pdureau Paris

    No, it doesn't work.

    Using XB components in UIP2

    • I install both ui_patterns_library and experience_builder
    • I got to /admin/appearance/ui/components/experience_builder/shoe_button
    • icon prop has this unknown prop type: {"$ref":"json-schema-definitions:\/\/experience_builder.module\/shoe-icon","type":"object"}

    According to https://git.drupalcode.org/project/experience_builder/-/blob/0.x/schema.... the expected resolved json schema must be

    title: Icon
    type: object
    properties:
      name:
        type: string
        title: Name
        default: primary
        enum:
        - moon-stars-fill
        - moon-stars
        - star-fill
        - star
        - stars
        - rocket-fill
        - rocket-takeoff-fill
        - rocket-takeoff
        - rocket
    

    Which will be loaded as Enum prop by UIP2.

    So, what is happening? Why the JSON schema reference is not resolved?

    • It is broken on Experience Builder side?
    • Is it broken because of having XB & UIP2 together?

    Using UIP2 components in WB

    I was not able to test because XB is currently broken:

    Symfony\Component\Routing\Exception\RouteNotFoundException: Route "experience_builder.experience_builder" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 211 of core/lib/Drupal/Core/Routing/RouteProvider.php).

    Let's try later.

  • πŸ‡«πŸ‡·France pdureau Paris
  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    christian.wiedemann β†’ made their first commit to this issue’s fork.

  • πŸ‡«πŸ‡·France pdureau Paris

    Using XB components in UIP2

    The issue was on UIP2 side. Fixed by Christian in https://git.drupalcode.org/issue/ui_patterns-3490873/-/commit/51c4ea3e22...

    But he needs to add some tests.

    Using UIP2 components in WB

    We are not able to test because XB is currently broken (not the same bug as yesterday...). Let's wait a bit and pull again.

  • πŸ‡«πŸ‡·France pdureau Paris
  • Merge request !310Add support for β†’ (Merged) created by Christian.wiedemann
  • Pipeline finished with Canceled
    4 months ago
    Total: 86s
    #375031
  • Pipeline finished with Failed
    4 months ago
    Total: 570s
    #375033
  • πŸ‡«πŸ‡·France pdureau Paris

    Today, we decided to merge this issue because the Using XB components in UIP2 fix is enough for RC1 (after adding some tests, right?).

    About Using UIP2 components in WB:

    • It seems XB is not resvolving $ref: ui-patterns:// but it may not resolved "$ref":"json-schema-definitions: either, so let's wait they implement a working reference resolver
    • when both XB and UIP2 are installed, XB is raising errors, so our component plugin manager decorators may not be fully compatible
    • XB is not loading UIP2 components (!) but is loading the ui_patterns_blocks's blocks twice, because of our (UIP2) context management; we derivate blocks twice, one with entity context and one without

    Let's create a 2.1.0 issue.

  • Pipeline finished with Success
    4 months ago
    Total: 560s
    #376857
  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    This ticket takes way too long. The problem behind the phpunit error was that we don't validate the scheme correctly because we imported the refs after the validation. enum_list returns false empty values which leads than to the error. So I fixed the empty value handling of enum_list. I also try to test validation with schema.json like expierence_builder does. The problem here is that xb uses its own stream wrapper. All my tests with refs with local files doesn't work and I also could not find any solution to handle this. So i removed the the test again.

  • Pipeline finished with Success
    4 months ago
    Total: 553s
    #376910
  • πŸ‡«πŸ‡·France pdureau Paris
        $values = array_filter($values, fn($value) => !is_null($value) && $value !== '');
    

    Why are you removing the empty values? They can be legit in some enumerations. Is removing only the null values enough?

  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    We need to remove empty strings if they are not part of the enum list. Propably we should remove all values which are not part of the enum list. Removing a entry from the enum list would lead to an exception which will be hard to fix for sitebuilders because the page crashes before. So I would suggest removing values which are not part of the enum list.

  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    Propably the bug occurst because EnumTrait::normalizeEnumListSize is not triggerd before. I will investigate that.

  • πŸ‡«πŸ‡·France pdureau Paris

    We need to remove empty strings if they are not part of the enum list. Propably we should remove all values which are not part of the enum list

    It is nice to do it in the source plugin, but the prop type plugin have a ::normalization() method.

  • πŸ‡©πŸ‡ͺGermany Christian.wiedemann

    Okay I checked it again. We need to load non ui-patterns references first and after that we load ui patterns references. So actual problem was a wrong schema guessing if we load all references and than we do prop type guessing only on schema (without $ref="ui-patterns://").
    So I split the ref loading in two steps. This should work. But we can also wait for rc2 with this fix. Not sure if "ref" is often used in SDC right now without custom stream wrappers like xb is doing.

  • Pipeline finished with Failed
    4 months ago
    Total: 524s
    #377331
  • πŸ‡«πŸ‡·France pdureau Paris

    Not sure if "ref" is often used in SDC right now without custom stream wrappers like xb is doing.

    There are 2 ways of using the JSON Schema $ref system AFAIK:

    • With a custom stream wrapper like we do in UI Patterns 2 (ui-patterns:// with StreamWrapper) and Experience builder (json-schema-definitions:// with JsonSchemaDefinitionsStreamwrapper)
    • With simple URI retrieval when the URI is dereferencable: http(s), file, ftp...
  • Pipeline finished with Success
    4 months ago
    Total: 574s
    #377333
  • πŸ‡«πŸ‡·France pdureau Paris
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024