mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 03:17:39 -02:30
Fix linting errors
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useField } from 'formik';
|
import { useField } from 'formik';
|
||||||
import { FormGroup, InputGroup } from '@patternfly/react-core';
|
import { FormGroup, InputGroup } from '@patternfly/react-core';
|
||||||
import { PasswordInput } from '.';
|
import PasswordInput from './PasswordInput';
|
||||||
|
|
||||||
function PasswordField(props) {
|
function PasswordField(props) {
|
||||||
const { id, name, label, validate, isRequired } = props;
|
const { id, name, label, validate, isRequired } = props;
|
||||||
|
|||||||
@@ -43,14 +43,13 @@ function CredentialAdd({ me }) {
|
|||||||
|
|
||||||
const handleSubmit = async values => {
|
const handleSubmit = async values => {
|
||||||
const { inputs, organization, ...remainingValues } = values;
|
const { inputs, organization, ...remainingValues } = values;
|
||||||
let pluginInputs = [];
|
const pluginInputs = [];
|
||||||
const inputEntries = Object.entries(inputs);
|
Object.entries(inputs).forEach(([key, value]) => {
|
||||||
for (const [key, value] of inputEntries) {
|
|
||||||
if (value.credential && value.inputs) {
|
if (value.credential && value.inputs) {
|
||||||
pluginInputs.push([key, value]);
|
pluginInputs.push([key, value]);
|
||||||
delete inputs[key];
|
delete inputs[key];
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
setFormSubmitError(null);
|
setFormSubmitError(null);
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ function CredentialAdd({ me }) {
|
|||||||
...remainingValues,
|
...remainingValues,
|
||||||
});
|
});
|
||||||
const inputSourceRequests = [];
|
const inputSourceRequests = [];
|
||||||
for (const [key, value] of pluginInputs) {
|
pluginInputs.forEach(([key, value]) => {
|
||||||
if (value.credential && value.inputs) {
|
if (value.credential && value.inputs) {
|
||||||
inputSourceRequests.push(
|
inputSourceRequests.push(
|
||||||
CredentialInputSourcesAPI.create({
|
CredentialInputSourcesAPI.create({
|
||||||
@@ -75,7 +74,7 @@ function CredentialAdd({ me }) {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
await Promise.all(inputSourceRequests);
|
await Promise.all(inputSourceRequests);
|
||||||
const url = `/credentials/${credentialId}/details`;
|
const url = `/credentials/${credentialId}/details`;
|
||||||
history.push(`${url}`);
|
history.push(`${url}`);
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ function CredentialEdit({ credential, me }) {
|
|||||||
source_credential: fieldValue.credential.id,
|
source_credential: fieldValue.credential.id,
|
||||||
target_credential: credential.id,
|
target_credential: credential.id,
|
||||||
});
|
});
|
||||||
} else if (fieldValue.touched) {
|
}
|
||||||
|
if (fieldValue.touched) {
|
||||||
return CredentialInputSourcesAPI.update(inputSources[fieldName].id, {
|
return CredentialInputSourcesAPI.update(inputSources[fieldName].id, {
|
||||||
metadata: fieldValue.inputs,
|
metadata: fieldValue.inputs,
|
||||||
source_credential: fieldValue.credential.id,
|
source_credential: fieldValue.credential.id,
|
||||||
@@ -89,14 +90,13 @@ function CredentialEdit({ credential, me }) {
|
|||||||
|
|
||||||
const handleSubmit = async values => {
|
const handleSubmit = async values => {
|
||||||
const { inputs, organization, ...remainingValues } = values;
|
const { inputs, organization, ...remainingValues } = values;
|
||||||
let pluginInputs = {};
|
const pluginInputs = {};
|
||||||
const inputEntries = Object.entries(inputs);
|
Object.entries(inputs).forEach(([key, value]) => {
|
||||||
for (const [key, value] of inputEntries) {
|
|
||||||
if (value.credential && value.inputs) {
|
if (value.credential && value.inputs) {
|
||||||
pluginInputs[key] = value;
|
pluginInputs[key] = value;
|
||||||
delete inputs[key];
|
delete inputs[key];
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
setFormSubmitError(null);
|
setFormSubmitError(null);
|
||||||
try {
|
try {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
@@ -112,7 +112,6 @@ function CredentialEdit({ credential, me }) {
|
|||||||
const url = `/credentials/${credential.id}/details`;
|
const url = `/credentials/${credential.id}/details`;
|
||||||
history.push(`${url}`);
|
history.push(`${url}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
|
||||||
setFormSubmitError(err);
|
setFormSubmitError(err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import { KeyIcon } from '@patternfly/react-icons';
|
import { KeyIcon } from '@patternfly/react-icons';
|
||||||
import { CredentialPluginPrompt } from './CredentialPluginPrompt';
|
import { CredentialPluginPrompt } from './CredentialPluginPrompt';
|
||||||
import { CredentialPluginSelected } from '.';
|
import CredentialPluginSelected from './CredentialPluginSelected';
|
||||||
|
|
||||||
function CredentialPluginField(props) {
|
function CredentialPluginField(props) {
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import { Formik, useField } from 'formik';
|
|||||||
import { withI18n } from '@lingui/react';
|
import { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Wizard } from '@patternfly/react-core';
|
import { Wizard } from '@patternfly/react-core';
|
||||||
import { CredentialsStep, MetadataStep } from './';
|
import CredentialsStep from './CredentialsStep';
|
||||||
|
import MetadataStep from './MetadataStep';
|
||||||
|
|
||||||
function CredentialPluginWizard({ i18n, handleSubmit, onClose }) {
|
function CredentialPluginWizard({ i18n, handleSubmit, onClose }) {
|
||||||
const [selectedCredential] = useField('credential');
|
const [selectedCredential] = useField('credential');
|
||||||
@@ -29,7 +30,7 @@ function CredentialPluginWizard({ i18n, handleSubmit, onClose }) {
|
|||||||
title={i18n._(t`External Secret Management System`)}
|
title={i18n._(t`External Secret Management System`)}
|
||||||
steps={steps}
|
steps={steps}
|
||||||
onSave={handleSubmit}
|
onSave={handleSubmit}
|
||||||
></Wizard>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ function MetadataStep({ i18n }) {
|
|||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const {
|
const {
|
||||||
data: {
|
data: {
|
||||||
inputs: { required, metadata },
|
inputs: { required: requiredFields, metadata },
|
||||||
},
|
},
|
||||||
} = await CredentialTypesAPI.readDetail(
|
} = await CredentialTypesAPI.readDetail(
|
||||||
selectedCredential.value.credential_type ||
|
selectedCredential.value.credential_type ||
|
||||||
@@ -45,15 +45,13 @@ function MetadataStep({ i18n }) {
|
|||||||
metadata.forEach(field => {
|
metadata.forEach(field => {
|
||||||
if (inputValues.value[field.id]) {
|
if (inputValues.value[field.id]) {
|
||||||
form.initialValues.inputs[field.id] = inputValues.value[field.id];
|
form.initialValues.inputs[field.id] = inputValues.value[field.id];
|
||||||
|
} else if (field.type === 'string' && field.choices) {
|
||||||
|
form.initialValues.inputs[field.id] =
|
||||||
|
field.default || field.choices[0];
|
||||||
} else {
|
} else {
|
||||||
if (field.type === 'string' && field.choices) {
|
form.initialValues.inputs[field.id] = '';
|
||||||
form.initialValues.inputs[field.id] =
|
|
||||||
field.default || field.choices[0];
|
|
||||||
} else {
|
|
||||||
form.initialValues.inputs[field.id] = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (required && required.includes(field.id)) {
|
if (requiredFields && requiredFields.includes(field.id)) {
|
||||||
field.required = true;
|
field.required = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -68,7 +66,7 @@ function MetadataStep({ i18n }) {
|
|||||||
}, [fetchMetadataOptions]);
|
}, [fetchMetadataOptions]);
|
||||||
|
|
||||||
const testMetadata = () => {
|
const testMetadata = () => {
|
||||||
alert('not implemented');
|
// todo: implement
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
|
|||||||
Reference in New Issue
Block a user