Skip to content
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

feat(24318): Create a compact editable table for attribute/value editor #509

Merged
merged 18 commits into from
Aug 6, 2024

Conversation

vanch3d
Copy link
Contributor

@vanch3d vanch3d commented Jul 26, 2024

See https://hivemq.kanbanize.com/ctrl_board/57/cards/24318/details/

The PR creates a custom renderer for JSONSchema array of properties, intended for usage with limited object properties such as the User Properties

The default rendering is similar to every array of properties, a flat verbose list of input fields with their own management (title, descriptions, error messages, etc.).

The PR reorganises the templates for the different parts of the schema to deliver a more compact, table-based editor

Design

  • As with custom renderer, the editor is activated through the uiSchema configuration, by adding 'ui:field': 'compactTable' to the relevant property , e.g.
  "subscriptions": {
    "items": {
      "userProperties": {
        "ui:field": "compactTable"
      }
    }

Out-of-scope

  • There is no control over the number of items in the property being rendered with the grid, i.e. the number of columns in the grid. It is assumed to be a (very) limited number of items. Safeguards will be added in a subsequent ticket.

Before

screenshot-localhost_3000-2024 07 26-16_47_07

After

screenshot-localhost_3000-2024 07 26-16_46_04

@vanch3d vanch3d requested review from h2xd and sfrehse July 26, 2024 14:44
@vanch3d vanch3d self-assigned this Jul 26, 2024
@cla-bot cla-bot bot added the cla-signed label Jul 26, 2024
@vanch3d vanch3d marked this pull request as ready for review July 29, 2024 07:45
<Box>
<ArrayFieldTitleTemplate
idSchema={idSchema}
title={uiOptions.title || title}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we document somewhere that uiOptions.title takes precedence over title?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the expected behaviour of the RJSF library: the (JSON)schema provides the bulk of the information (e.g. title, description, validation rules, ...) unless they are overridden by the optional uiSchema

/>
<ArrayFieldDescriptionTemplate
idSchema={idSchema}
description={uiOptions.description || schema.description}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question as above regarding description

const inputProps = getInputProps(schema, type, options)

const _onChange = ({ target: { value } }: ChangeEvent<HTMLInputElement>) =>
onChange(value === '' ? options.emptyValue : value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are strings made of spaces only valid?
Would you want to trim the input somewhere to avoid bad surprises?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think spaces can be valid. it should be capable of any UTF-8 Character, so I would not recommend trimming

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also merely replicating the code from the component I'm overriding, in order to maintain consistency

Copy link
Contributor

@oli-hivemq oli-hivemq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments but approving anyway 🦣

@vanch3d vanch3d force-pushed the feat/24318/compact-properties-adapter branch 2 times, most recently from d29440f to 8afcf33 Compare August 6, 2024 08:59
@vanch3d vanch3d force-pushed the feat/24318/compact-properties-adapter branch from 8afcf33 to cd035eb Compare August 6, 2024 09:44
@vanch3d vanch3d merged commit ee9ae1f into master Aug 6, 2024
10 checks passed
@vanch3d vanch3d deleted the feat/24318/compact-properties-adapter branch August 6, 2024 10:20
sfrehse pushed a commit that referenced this pull request Aug 8, 2024
feat(24318): Create a compact editable table for attribute/value editor

* refactor(24318): add mapping for custom fields

* feat(24318): add custom editable table for user properties

* feat(24143): add custom editor for compact property/value items

* fix(24143): fix JSX

* feat(24143): add support for add and delete item

* refactor(24143): refactor editable cell and add required checks

* refactor(24143): refactor initial state

* refactor(24143): fix publish

* feat(24143): add ui mapping to adapters

* refactor(24318): update dependencies

* refactor(24318): refactor the form widget to export the UI components

* refactor(24318): refactor the table component

* refactor(24318): add a grid component

* refactor(24318): revert datagrid trials

* feat(24318): add custom templates for the compact grid

* refactor(24318): refactor compact grid field

* feat(24318): add custom field to the configuration of the adapter editor

* test(24318): add mocks and tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants