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

Handle form submission errors that may be deeply nested in the return object #7821

Merged

Conversation

mabashian
Copy link
Member

SUMMARY

link #7814

The issue here was that the error message for an error on the url field in the credential form was nested down in the second level of the return object. The code that we previously had in FormSubmitError didn't handle that very well so I built a recursive solution that will traverse the entire object and gather up all of the strings in an array to be displayed in the Alert. This solution also handles arrays of strings which can happen when a field has multiple errors.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • UI

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@@ -2,6 +2,26 @@ import React, { useState, useEffect } from 'react';
import { useFormikContext } from 'formik';
import { Alert } from '@patternfly/react-core';

const findErrorStrings = (obj, messages = []) => {
if (typeof obj === 'string') {
messages.push(obj);
Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 16ce7b4 into ansible:devel Aug 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants