[2.0.0-beta4] Comopnent converter: don't abuse schema referneces

Created on 3 October 2024, 2 months ago

Problem/Motivation

The migration drush command from ui_patterns_legacy is currently putting a reference at every prop.

Example:

props:
  type: object
  properties:
    active:
      title: "Active?"
      description: "It is possible to set button as active?"
      $ref: "ui-patterns://boolean"
    size:
      title: Size
      description: "It is possible to set the size of buttons."
      $ref: "ui-patterns://enum"
      enum:
        - xs
        - sm
        - md
        - lg
      "meta:enum":
        xs: "Extra small"
        sm: Small
        md: Medium
        lg: Large
    url:
      title: URL
      description: "The button URL. Optional."
      $ref: "ui-patterns://url"

https://git.drupalcode.org/project/ui_suite_daisyui/-/blob/4.0.x/compone...

However, some references provide the same schema as a simple JSON type:

  • $ref: "ui-patterns://boolean" is the same as type: boolean according to
    BooleanPropType
  • $ref: "ui-patterns://string" is the same as type: string according to StringPropType

Proposed resolution

Let's update the drush command to put the JSON type instead of the references.

The straightforward changes:

  • Replace all $ref: "ui-patterns://boolean" by type: boolean.
  • Replace all $ref: "ui-patterns://string" by type: string

Also, we need to try it before, but all $ref: "ui-patterns://number" could be replaced by type: number or type: integer according to the context.

And $ref: "ui-patterns://enum" could be replaced by type: string, type: number or type: integer according to the context.

📌 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

Production build 0.71.5 2024