hivemq-edge icon indicating copy to clipboard operation
hivemq-edge copied to clipboard

Add a `uiSchema` property to the payload of a protocol adapter type

Open vanch3d opened this issue 1 year ago • 0 comments

The react-jsonschema-form library is used to create a form out of the JSON Schema specification of an adapter. It introduced a secondary schema to provide information on how the form should be rendered, uiSchema .

See https://rjsf-team.github.io/react-jsonschema-form/docs/api-reference/uiSchema for a description of the schema.

At the moment, the uiSchema is hardcoded in the frontend and contains the combined information of most of the known adapters, by property name. This is not a sustainable situation, for two reasons:

  • The number of adapters is increasing fast and are not all incorporated
  • Different adapters might use the same property name for different attributes

The uiSchema should therefore be located within each adapters, along their configSchema.

The schema is a JSON object, whose attributes are described in the document above. If strongly typed, the description of the UiSchema type can be found here: https://github.com/rjsf-team/react-jsonschema-form/blob/6ffc2ceb1f24e2661d0acbc0c3e09e5e443e9f27/packages/utils/src/types.ts#L784

To the list of default options, we have added a new one to combine top-level properties into separate tabs:

{
  "ui:tabs": [
    {
      "id": "coreFields",
      "title": "title",
      "properties": ["id", "port", "host", "uri", "url", "pollingIntervalMillis"]
    },
    {
      "id": "subFields",
      "title": "Subscription",
      "properties": ["subscriptions"]
    }
  ]
}

vanch3d avatar Sep 12 '23 10:09 vanch3d