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

Bug 1830125: Add fallback create operand form if schema is missing or invalid #5287

Merged
merged 1 commit into from May 13, 2020

Conversation

TheRealJon
Copy link
Member

@TheRealJon TheRealJon commented May 4, 2020

Add the 4.4 operand form component as a fallback so that CRD's without a structural schema don't render a blank form.
This required a few small updates to the old form component as well as some other small bug fixes that were discovered during implementation:

  • Updated legacy create operand form component to accept same props as new component
  • Update legacy form FieldGroup component so that it creates same DOM structure as new component. This is for test stability.
  • Update legacy form html id attributes to match new form. Also test stability.
  • Remove dead code frontend/public/components/utils/expandable-section.tsx and
    frontend/packages/operator-lifecycle-manager/src/components/descriptors/spec/field-group.tsx. These were only used by the legacy form field group implementation.
  • Fix edge case in operand util function hasNoFields where schemas with no valid type were returning false.
  • Fix edge case in operand util function hasNoFields where schema.additionalProperties has a valid type, but function was returning true.
  • Add unit test case for the above two fixes
  • Fixed some magic strings

@openshift-ci-robot openshift-ci-robot added bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels May 4, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1830125, which is invalid:

  • expected the bug to target the "4.5.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1830125: Add fallback create operand form if schema is missing or invalid

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added component/olm Related to OLM component/shared Related to console-shared labels May 4, 2020
@TheRealJon
Copy link
Member Author

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added the bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. label May 4, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1830125, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot removed the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label May 4, 2020
@TheRealJon
Copy link
Member Author

/assign @benjaminapetersen

@@ -13,14 +13,6 @@ export const getSchemaErrors = (schema: JSONSchema6): SchemaError[] => {
},
]
: []),
...(_.isArray(schema.type)
Copy link
Member Author

Choose a reason for hiding this comment

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

Swagger OpenAPI schema doesn't allow array types, so this check was not necessary.

@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1830125, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1830125: Add fallback create operand form if schema is missing or invalid

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@TheRealJon
Copy link
Member Author

/retest

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 8, 2020
@TheRealJon
Copy link
Member Author

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot removed the bugzilla/severity-unspecified Referenced Bugzilla bug's severity is unspecified for the PR. label May 11, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1830125, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label May 11, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 11, 2020
@TheRealJon
Copy link
Member Author

/hold

Something broke while rebasing

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 11, 2020
@TheRealJon
Copy link
Member Author

/hold cancel

Fixed

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 11, 2020
Copy link
Member

@jcaianirh jcaianirh left a comment

Choose a reason for hiding this comment

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

tested with BusinessAutomation/KieApp with success. lgtm

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label May 12, 2020
@TheRealJon TheRealJon requested a review from jcaianirh May 12, 2020 15:42
Copy link
Member

@jcaianirh jcaianirh left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 12, 2020
@@ -11,18 +11,17 @@ export const DEFAULT_K8S_SCHEMA: JSONSchema6 = {
type: SchemaType.object,
properties: {
metadata: {
type: 'object',
Copy link
Member Author

Choose a reason for hiding this comment

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

These are just some magic strings I think I missed on initial implementation.

@@ -14,22 +14,14 @@ import { HIDDEN_UI_SCHEMA } from './const';
describe('getJSONSchemaOrder', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Formatting and added another unit test to check an edge case in the hasNoFields helper.

@@ -70,14 +62,14 @@ export const getDefaultUISchemaForPropertyName = (name) =>

// Determine if a schema will produce an empty form field.
export const hasNoFields = (jsonSchema: JSONSchema6): boolean => {
const type = getSchemaType(jsonSchema ?? {});
const type = getSchemaType(jsonSchema ?? {}) ?? '';
Copy link
Member Author

Choose a reason for hiding this comment

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

Default to empty string when type cannot be guessed and add new case in switch to handle it. If the schema type cannot be determined by getSchemaType, the schema will not render any fields.

const handleArray = () => {
return hasNoFields(jsonSchema.items as JSONSchema6);
};
const handleObject = () => {
return (
_.every(jsonSchema?.properties, hasNoFields) &&
_.every(jsonSchema?.additionalProperties as JSONSchema6, hasNoFields)
hasNoFields(jsonSchema?.additionalProperties as JSONSchema6)
Copy link
Member Author

Choose a reason for hiding this comment

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

additionalProperties is either boolean or JSONSchema6. It doesn't have nested schemas like properties.

@TheRealJon
Copy link
Member Author

/hold

Updating html id's used in the old form component so that they match the new implementation. This will help reduce test flakes since the current integration tests us id selectors to get form input values.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 12, 2020
@openshift-ci-robot openshift-ci-robot added component/core Related to console core functionality and removed lgtm Indicates that a PR is ready to be merged. labels May 12, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1830125, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1830125: Add fallback create operand form if schema is missing or invalid

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: This pull request references Bugzilla bug 1830125, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1830125: Add fallback create operand form if schema is missing or invalid

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@TheRealJon
Copy link
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 13, 2020
@TheRealJon TheRealJon requested a review from jcaianirh May 13, 2020 13:39
Copy link
Member

@jcaianirh jcaianirh left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 13, 2020
Copy link
Contributor

@benjaminapetersen benjaminapetersen left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

I'll make a Jira for removing this in 4.6.

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benjaminapetersen, jcaianirh, TheRealJon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 13, 2020
@openshift-merge-robot openshift-merge-robot merged commit b3c4abc into openshift:master May 13, 2020
@openshift-ci-robot
Copy link
Contributor

@TheRealJon: All pull requests linked via external trackers have merged: openshift/console#5287. Bugzilla bug 1830125 has been moved to the MODIFIED state.

In response to this:

Bug 1830125: Add fallback create operand form if schema is missing or invalid

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/core Related to console core functionality component/olm Related to OLM component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants