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

Create additional "JSON Schema form" param renderers #5436

Closed
5 tasks
antgamdia opened this issue Oct 6, 2022 · 1 comment
Closed
5 tasks

Create additional "JSON Schema form" param renderers #5436

antgamdia opened this issue Oct 6, 2022 · 1 comment
Assignees
Labels
component/ui Issue related to kubeapps UI kind/enhancement An issue that reports an enhancement for an implemented feature

Comments

@antgamdia
Copy link
Contributor

Summary
After #5412 is done, there are some param renderers for some data types that haven't been implemented yet.

Background and rationale
We implemented some params for the more frequent data types (string, number, array, etc), but there are some still pending.

Description
Create these missing renderers (we are currently falling back to a textarea):

  • 1st level: object (at least, as array of tuples <string, any> for defining each property.
  • Array level:
    • enum
    • arrays
    • objects

Acceptance criteria

  • The aforementioned renderers have been implemented,

Additional context
Related to #4917

@antgamdia antgamdia added component/ui Issue related to kubeapps UI kind/enhancement An issue that reports an enhancement for an implemented feature labels Oct 6, 2022
@kubeapps-bot kubeapps-bot moved this to 🗂 Backlog in Kubeapps Oct 6, 2022
@ppbaena ppbaena added the next-iteration Issues to be discussed in planning session label Oct 6, 2022
@antgamdia antgamdia moved this from 🗂 Backlog to 🏗 In Progress in Kubeapps Oct 20, 2022
@antgamdia antgamdia self-assigned this Oct 20, 2022
This was referenced Oct 20, 2022
@antgamdia antgamdia moved this from 🏗 In Progress to 🔎 In Review in Kubeapps Oct 20, 2022
antgamdia added a commit that referenced this issue Oct 21, 2022
### Description of the change

While working on #5436, I noticed some errors during the YAML parsing;
well not errors, but unexpected (for me) values being returned by the
`genIn` method. In collections, the returned thing is not a js object,
but a custom data type from the YAML library.

This PR is just to convert collections (YAML sequences and YAML maps)
back to plain js objects (even if the function says `toJSON()` 😅

### Benefits

We will be able to use arrays and object fields in the form.

### Possible drawbacks

N/A

### Applicable issues

- fixes #5519

### Additional information

> **Note**
> This PR is part of a series of PRs aimed at closing [this
milestone](https://github.com/vmware-tanzu/kubeapps/milestone/27). I
have split the changes to ease the review process, but as there are many
interrelated changes, the tests will be performed in a separate PR (on
top of the branch containing all the changes).
>  PR 2 out of 6

Signed-off-by: Antonio Gamez Diaz <[email protected]>
antgamdia added a commit that referenced this issue Oct 21, 2022
### Description of the change

In #5436 we mentioned that several fields were still pending, namely

- 1st level: object (at least, as array of tuples <string, any> for
defining each property.
-  Array level:  enum, arrays, objects

WRT the top-level objects, it is not an actual problem: if they have
`properties`, they will get rendered as any other nested param more. It
is only the case when it lacks the `properties` fields that we need to
handle.
- Solution: allow any serialized object like `{"foo": 1234}` and add
more validation messages.

WRT the array-level properties:
- Solution for enum: use the same approach as in the top-level enum.
- Solution for arrays and objects: use the same approach as in the
top-level objects: render a text field but enforce validation.

Additionally, the array now enforces `maxItems` and `minItems`

### Benefits

Every json schema datatype is now supported.

### Possible drawbacks

N/A

### Applicable issues

- fixes #5436 

### Additional information

> **Note**
> This PR is part of a series of PRs aimed at closing [this
milestone](https://github.com/vmware-tanzu/kubeapps/milestone/27). I
have split the changes to ease the review process, but as there are many
interrelated changes, the tests will be performed in a separate PR (on
top of the branch containing all the changes).
>  PR 5 out of 6

#### `Top-level objects`:


![image](https://user-images.githubusercontent.com/11535726/197029146-c81a3001-4ca3-4251-87a1-d2eab55df864.png)

#### `Array<enum>`:


![image](https://user-images.githubusercontent.com/11535726/197028415-653f1e3d-f7b3-4d49-aca1-ac788ca2924f.png)

#### `Array<array>`:


![image](https://user-images.githubusercontent.com/11535726/197028515-a64aee32-5796-4dac-9eb3-8fc179435e71.png)

#### `Array<object>`:


![image](https://user-images.githubusercontent.com/11535726/197028310-fd815a03-4f5b-4004-bd0d-c3640f0dd023.png)

#### `YAML output`


![image](https://user-images.githubusercontent.com/11535726/197028679-83146445-7dc1-4516-9b37-d180e403ccee.png)

#### `Array max/min items`

Min items:

![image](https://user-images.githubusercontent.com/11535726/197030005-98e84cca-d78f-4fff-91ac-b02ec84c6a53.png)

Max items:

![image](https://user-images.githubusercontent.com/11535726/197029933-a162625e-da17-4846-be73-4339b97f9f1c.png)

Signed-off-by: Antonio Gamez Diaz <[email protected]>
@antgamdia
Copy link
Contributor Author

Closed by #5534 (merged in main by #5530)

Repository owner moved this from 🔎 In Review to ✅ Done in Kubeapps Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/ui Issue related to kubeapps UI kind/enhancement An issue that reports an enhancement for an implemented feature
Projects
Archived in project
Development

No branches or pull requests

2 participants