mirror of
https://github.com/ansible/awx.git
synced 2026-03-28 06:15:04 -02:30
Fix merge conflict
This commit is contained in:
@@ -5,7 +5,7 @@ import { useField, useFormikContext } from 'formik';
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { Button, Form, FormGroup, Tooltip } from '@patternfly/react-core';
|
import { Button, Form, FormGroup, Tooltip } from '@patternfly/react-core';
|
||||||
import { QuestionCircleIcon as PFQuestionCircleIcon } from '@patternfly/react-icons';
|
import { QuestionCircleIcon as PFQuestionCircleIcon } from '@patternfly/react-icons';
|
||||||
import { CredentialTypesAPI } from '../../../../../../api';
|
import { CredentialsAPI, CredentialTypesAPI } from '../../../../../../api';
|
||||||
import AnsibleSelect from '../../../../../../components/AnsibleSelect';
|
import AnsibleSelect from '../../../../../../components/AnsibleSelect';
|
||||||
import ContentError from '../../../../../../components/ContentError';
|
import ContentError from '../../../../../../components/ContentError';
|
||||||
import ContentLoading from '../../../../../../components/ContentLoading';
|
import ContentLoading from '../../../../../../components/ContentLoading';
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { string, shape } from 'prop-types';
|
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
AlertActionCloseButton,
|
AlertActionCloseButton,
|
||||||
@@ -16,7 +15,6 @@ function CredentialPluginTestAlert({
|
|||||||
}) {
|
}) {
|
||||||
const [testMessage, setTestMessage] = useState('');
|
const [testMessage, setTestMessage] = useState('');
|
||||||
const [testVariant, setTestVariant] = useState(false);
|
const [testVariant, setTestVariant] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (errorResponse) {
|
if (errorResponse) {
|
||||||
if (errorResponse?.response?.data?.inputs) {
|
if (errorResponse?.response?.data?.inputs) {
|
||||||
@@ -56,14 +54,6 @@ function CredentialPluginTestAlert({
|
|||||||
<AlertGroup isToast>
|
<AlertGroup isToast>
|
||||||
{testMessage && testVariant && (
|
{testMessage && testVariant && (
|
||||||
<Alert
|
<Alert
|
||||||
actionClose={
|
|
||||||
<AlertActionCloseButton
|
|
||||||
onClose={() => {
|
|
||||||
setTestMessage(null);
|
|
||||||
setTestVariant(null);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
title={
|
title={
|
||||||
<>
|
<>
|
||||||
<b id="credential-plugin-test-name">{credentialName}</b>
|
<b id="credential-plugin-test-name">{credentialName}</b>
|
||||||
@@ -71,21 +61,22 @@ function CredentialPluginTestAlert({
|
|||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
variant={testVariant}
|
variant={testVariant}
|
||||||
|
action={
|
||||||
|
<AlertActionCloseButton
|
||||||
|
onClose={() => {
|
||||||
|
setTestMessage(null);
|
||||||
|
setTestVariant(null);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</AlertGroup>
|
</AlertGroup>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
CredentialPluginTestAlert.propTypes = {
|
CredentialPluginTestAlert.propTypes = {};
|
||||||
credentialName: string.isRequired,
|
|
||||||
successResponse: shape({}),
|
|
||||||
errorResponse: shape({}),
|
|
||||||
};
|
|
||||||
|
|
||||||
CredentialPluginTestAlert.defaultProps = {
|
CredentialPluginTestAlert.defaultProps = {};
|
||||||
successResponse: null,
|
|
||||||
errorResponse: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default withI18n()(CredentialPluginTestAlert);
|
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);
|
|
||||||
Reference in New Issue
Block a user