mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 19:10:07 -03:30
Fix merge conflict
This commit is contained in:
parent
67f46b4d7e
commit
aed96de195
@ -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';
|
||||
|
||||
@ -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({
|
||||
<AlertGroup isToast>
|
||||
{testMessage && testVariant && (
|
||||
<Alert
|
||||
actionClose={
|
||||
<AlertActionCloseButton
|
||||
onClose={() => {
|
||||
setTestMessage(null);
|
||||
setTestVariant(null);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
title={
|
||||
<>
|
||||
<b id="credential-plugin-test-name">{credentialName}</b>
|
||||
@ -71,21 +61,22 @@ function CredentialPluginTestAlert({
|
||||
</>
|
||||
}
|
||||
variant={testVariant}
|
||||
action={
|
||||
<AlertActionCloseButton
|
||||
onClose={() => {
|
||||
setTestMessage(null);
|
||||
setTestVariant(null);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</AlertGroup>
|
||||
);
|
||||
}
|
||||
|
||||
CredentialPluginTestAlert.propTypes = {
|
||||
credentialName: string.isRequired,
|
||||
successResponse: shape({}),
|
||||
errorResponse: shape({}),
|
||||
};
|
||||
CredentialPluginTestAlert.propTypes = {};
|
||||
|
||||
CredentialPluginTestAlert.defaultProps = {
|
||||
successResponse: null,
|
||||
errorResponse: null,
|
||||
};
|
||||
CredentialPluginTestAlert.defaultProps = {};
|
||||
|
||||
export default withI18n()(CredentialPluginTestAlert);
|
||||
|
||||
@ -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 (
|
||||
<AlertGroup isToast>
|
||||
{testMessage && testVariant && (
|
||||
<Alert
|
||||
title={
|
||||
<>
|
||||
<b id="credential-plugin-test-name">{credentialName}</b>
|
||||
<p id="credential-plugin-test-message">{testMessage}</p>
|
||||
</>
|
||||
}
|
||||
variant={testVariant}
|
||||
action={
|
||||
<AlertActionCloseButton
|
||||
onClose={() => {
|
||||
setTestMessage(null);
|
||||
setTestVariant(null);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</AlertGroup>
|
||||
);
|
||||
}
|
||||
|
||||
CredentialPluginTestAlert.propTypes = {};
|
||||
|
||||
CredentialPluginTestAlert.defaultProps = {};
|
||||
|
||||
export default withI18n()(CredentialPluginTestAlert);
|
||||
Loading…
x
Reference in New Issue
Block a user