diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginPrompt/MetadataStep.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginPrompt/MetadataStep.jsx index 86e8f148c6..b9537fe456 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginPrompt/MetadataStep.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginPrompt/MetadataStep.jsx @@ -5,7 +5,7 @@ import { useField, useFormikContext } from 'formik'; import styled from 'styled-components'; import { Button, Form, FormGroup, Tooltip } from '@patternfly/react-core'; import { QuestionCircleIcon as PFQuestionCircleIcon } from '@patternfly/react-icons'; -import { CredentialTypesAPI } from '../../../../../../api'; +import { CredentialsAPI, CredentialTypesAPI } from '../../../../../../api'; import AnsibleSelect from '../../../../../../components/AnsibleSelect'; import ContentError from '../../../../../../components/ContentError'; import ContentLoading from '../../../../../../components/ContentLoading'; diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginTestAlert.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginTestAlert.jsx index f1c4a4ae97..866ca1dae3 100644 --- a/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginTestAlert.jsx +++ b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginTestAlert.jsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from 'react'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; -import { string, shape } from 'prop-types'; import { Alert, AlertActionCloseButton, @@ -16,7 +15,6 @@ function CredentialPluginTestAlert({ }) { const [testMessage, setTestMessage] = useState(''); const [testVariant, setTestVariant] = useState(false); - useEffect(() => { if (errorResponse) { if (errorResponse?.response?.data?.inputs) { @@ -56,14 +54,6 @@ function CredentialPluginTestAlert({ {testMessage && testVariant && ( { - setTestMessage(null); - setTestVariant(null); - }} - /> - } title={ <> {credentialName} @@ -71,21 +61,22 @@ function CredentialPluginTestAlert({ } variant={testVariant} + action={ + { + setTestMessage(null); + setTestVariant(null); + }} + /> + } /> )} ); } -CredentialPluginTestAlert.propTypes = { - credentialName: string.isRequired, - successResponse: shape({}), - errorResponse: shape({}), -}; +CredentialPluginTestAlert.propTypes = {}; -CredentialPluginTestAlert.defaultProps = { - successResponse: null, - errorResponse: null, -}; +CredentialPluginTestAlert.defaultProps = {}; export default withI18n()(CredentialPluginTestAlert); diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.test.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginTestAlert.test.jsx similarity index 100% rename from awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.test.jsx rename to awx/ui_next/src/screens/Credential/shared/CredentialFormFields/CredentialPlugins/CredentialPluginTestAlert.test.jsx diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.jsx deleted file mode 100644 index 866ca1dae3..0000000000 --- a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginTestAlert.jsx +++ /dev/null @@ -1,82 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; -import { - Alert, - AlertActionCloseButton, - AlertGroup, -} from '@patternfly/react-core'; - -function CredentialPluginTestAlert({ - i18n, - credentialName, - successResponse, - errorResponse, -}) { - const [testMessage, setTestMessage] = useState(''); - const [testVariant, setTestVariant] = useState(false); - useEffect(() => { - if (errorResponse) { - if (errorResponse?.response?.data?.inputs) { - if (errorResponse.response.data.inputs.startsWith('HTTP')) { - const [ - errorCode, - errorStr, - ] = errorResponse.response.data.inputs.split('\n'); - try { - const errorJSON = JSON.parse(errorStr); - setTestMessage( - `${errorCode}${ - errorJSON?.errors[0] ? `: ${errorJSON.errors[0]}` : '' - }` - ); - } catch { - setTestMessage(errorResponse.response.data.inputs); - } - } else { - setTestMessage(errorResponse.response.data.inputs); - } - } else { - setTestMessage( - i18n._( - t`Something went wrong with the request to test this credential and metadata.` - ) - ); - } - setTestVariant('danger'); - } else if (successResponse) { - setTestMessage(i18n._(t`Test passed`)); - setTestVariant('success'); - } - }, [i18n, successResponse, errorResponse]); - - return ( - - {testMessage && testVariant && ( - - {credentialName} -

{testMessage}

- - } - variant={testVariant} - action={ - { - setTestMessage(null); - setTestVariant(null); - }} - /> - } - /> - )} -
- ); -} - -CredentialPluginTestAlert.propTypes = {}; - -CredentialPluginTestAlert.defaultProps = {}; - -export default withI18n()(CredentialPluginTestAlert);