diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginField.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginField.jsx deleted file mode 100644 index 187ce8f7e4..0000000000 --- a/awx/ui_next/src/screens/Credential/shared/CredentialPlugins/CredentialPluginField.jsx +++ /dev/null @@ -1,103 +0,0 @@ -import React, { useState } from 'react'; -import PropTypes from 'prop-types'; -import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; -import { useField } from 'formik'; -import { - Button, - ButtonVariant, - FormGroup, - InputGroup, - Tooltip, -} from '@patternfly/react-core'; -import { KeyIcon } from '@patternfly/react-icons'; -import { CredentialPluginPrompt } from './CredentialPluginPrompt'; -import CredentialPluginSelected from './CredentialPluginSelected'; - -function CredentialPluginField(props) { - const { - children, - id, - name, - label, - validate, - isRequired, - isDisabled, - i18n, - } = props; - const [showPluginWizard, setShowPluginWizard] = useState(false); - const [field, meta, helpers] = useField({ name, validate }); - const isValid = !(meta.touched && meta.error); - - return ( - - {field?.value?.credential ? ( - helpers.setValue('')} - onEditPlugin={() => setShowPluginWizard(true)} - /> - ) : ( - - {React.cloneElement(children, { - ...field, - isRequired, - onChange: (_, event) => { - field.onChange(event); - }, - })} - - - - - )} - {showPluginWizard && ( - setShowPluginWizard(false)} - onSubmit={val => { - val.touched = true; - helpers.setValue(val); - setShowPluginWizard(false); - }} - /> - )} - - ); -} - -CredentialPluginField.propTypes = { - id: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - label: PropTypes.string.isRequired, - validate: PropTypes.func, - isRequired: PropTypes.bool, - isDisabled: PropTypes.bool, -}; - -CredentialPluginField.defaultProps = { - validate: () => {}, - isRequired: false, - isDisabled: false, -}; - -export default withI18n()(CredentialPluginField); diff --git a/awx/ui_next/src/screens/Credential/shared/CredentialSubForms/GoogleComputeEngineSubForm.jsx b/awx/ui_next/src/screens/Credential/shared/CredentialSubForms/GoogleComputeEngineSubForm.jsx deleted file mode 100644 index 85445b7aa2..0000000000 --- a/awx/ui_next/src/screens/Credential/shared/CredentialSubForms/GoogleComputeEngineSubForm.jsx +++ /dev/null @@ -1,136 +0,0 @@ -import React, { useState } from 'react'; -import { withI18n } from '@lingui/react'; -import { t } from '@lingui/macro'; -import { useField } from 'formik'; -import { - FileUpload, - FormGroup, - TextArea, - TextInput, -} from '@patternfly/react-core'; -import { - FormColumnLayout, - FormFullWidthLayout, -} from '../../../../components/FormLayout'; -import { required } from '../../../../util/validators'; -import { CredentialPluginField } from '../CredentialPlugins'; - -const GoogleComputeEngineSubForm = ({ i18n }) => { - const [fileError, setFileError] = useState(null); - const [filename, setFilename] = useState(''); - const [file, setFile] = useState(''); - const inputsUsernameHelpers = useField({ - name: 'inputs.username', - })[2]; - const inputsProjectHelpers = useField({ - name: 'inputs.project', - })[2]; - const inputsSSHKeyDataHelpers = useField({ - name: 'inputs.ssh_key_data', - })[2]; - - return ( - - - { - if (value) { - try { - setFile(value); - setFilename(value.name); - const fileText = await value.text(); - const fileJSON = JSON.parse(fileText); - if ( - !fileJSON.client_email && - !fileJSON.project_id && - !fileJSON.private_key - ) { - setFileError( - i18n._( - t`Expected at least one of client_email, project_id or private_key to be present in the file.` - ) - ); - } else { - inputsUsernameHelpers.setValue(fileJSON.client_email || ''); - inputsProjectHelpers.setValue(fileJSON.project_id || ''); - inputsSSHKeyDataHelpers.setValue(fileJSON.private_key || ''); - setFileError(null); - } - } catch { - setFileError( - i18n._( - t`There was an error parsing the file. Please check the file formatting and try again.` - ) - ); - } - } else { - setFile(''); - setFilename(''); - inputsUsernameHelpers.setValue(''); - inputsProjectHelpers.setValue(''); - inputsSSHKeyDataHelpers.setValue(''); - setFileError(null); - } - }} - dropzoneProps={{ - accept: '.json', - onDropRejected: () => { - setFileError( - i18n._( - t`File upload rejected. Please select a single .json file.` - ) - ); - }, - }} - /> - - - - - - - - - -