-
Notifications
You must be signed in to change notification settings - Fork 6
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
Update JSON Forms #241
Update JSON Forms #241
Conversation
src/actions/InstallationHandler.ts
Outdated
const serverCommon = JSON.parse(readPaxYamlAndSchema.details.serverCommon); | ||
updateSchemaReferences(readPaxYamlAndSchema.details, yamlSchema); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we duplicating changes made in #240 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is built on the top of #240
src/actions/InstallationHandler.ts
Outdated
@@ -181,7 +175,7 @@ class Installation { | |||
ConfigurationStore.setSchema(FALLBACK_SCHEMA); | |||
return {status: false, details: {message: 'no schemas found from pax'}} | |||
} | |||
return {status: parsedSchema && parsedYaml, details: {message: "Successfully retrieved example-zowe.yaml and schemas", mergedYaml: yamlObj}} | |||
return {status: parsedSchema && parsedYaml, details: {message: "Successfully retrieved example-zowe.yaml and schemas", mergedYaml: yamlObj, yamlSchema: yamlSchema}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schema is already saved to the ConfigurationStore, lines 162, 169 and 175.
Then we take yamlSchema that will exist only in successful case (as you only set it in the try block on line 157 and so it will be empty in other cases instead of FALLBACK_SCHEMA)
And then you return it to the UI (Unpax.tsx:180) where use for rendering and override the ConfigurationStore scheme if it exists, which makes not much sense to me, or am i missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good catch. Thanks. I fixed it.
if (!schema || !formData) { | ||
return ""; | ||
// To handle the "if", "else", and "then" in the schema | ||
const conditionalSchema = (schema: any, formData: any, prop: any): boolean=> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What reference were you using for this definition? I am looking at https://json-schema.org/understanding-json-schema/reference/conditionals#ifthenelse and it states that then
or else
can be omitted, also then
and else
sections can have properties
with pattern, not only required
field
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section was initially added to handle if-else conditions in the certificate schema for previous versions of Zowe. At that time, we were only verifying whether the conditional attributes were met.
These sections can also contain properties, and while all the properties were displayed, our primary focus was on checking if the condition matched.
config={{showUnfocusedDescription: true}} | ||
onChange={({ data, errors }) => { onChange(data) }} | ||
/> | ||
{ schema.oneOf && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General question, can't JSONForms work with "oneOf" out of the box?
I didn't research much but from here it seems that is should be supported using tabs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could work, but we had a slightly different approach in mind:
- We preferred radio buttons instead of tabs.
- The JSON form data is stored in YAML, so we needed the YAML to comply with only one schema at a time. For this, we created a function called filterFormData.
- We also required AJV to validate the data against the correct schema selected from the oneOf schemas.
- Additionally, we don't use the JsonForms renderer as-is. We customize it as needed in the makeUISchema function. To make this work, we had to take this approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, but please review the comment to InitApfAuth.tsx before merge
@@ -231,21 +230,7 @@ const InitApfAuth = () => { | |||
}, {}); | |||
} | |||
|
|||
if(validate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this validation here? There is unused code block a few lines above, newData
is never being used, so i wonder if it is not a mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this part of the code because it is unnecessary. The APF authorization stage includes read-only fields populated during the previous "Dataset Initialization" stage, where validations for these fields have already been performed. Re-validating them here is redundant.
I also considered removing the formChangeHandler function, as it's no longer required. However, I chose not to do so in this PR to keep the focus solely on the schema updates. I plan to address it in future code optimization PRs.
Proposed changes
This PR addresses Issue:
Type of change
Please delete options that are not relevant.
PR Checklist
Please delete options that are not relevant.
Testing
Further comments