mirror of
https://github.com/ansible/awx.git
synced 2026-05-25 01:27:45 -02:30
Remove enableWebhooks conditional in WebhookSubForm
Signed-off-by: Vadiem Janssens <info@vadiemjanssens.nl>
This commit is contained in:
committed by
John Mitchell
parent
be33627755
commit
f9039703ee
@@ -583,16 +583,15 @@ function JobTemplateForm({
|
||||
</>
|
||||
)}
|
||||
|
||||
{allowCallbacks && enableWebhooks && (<br />)}
|
||||
{allowCallbacks && enableWebhooks && <br />}
|
||||
|
||||
{enableWebhooks && (
|
||||
<>
|
||||
<Title size="md" headingLevel="h4">{i18n._(t`Webhook details`)}</Title>
|
||||
<Title size="md" headingLevel="h4">
|
||||
{i18n._(t`Webhook details`)}
|
||||
</Title>
|
||||
<FormColumnLayout>
|
||||
<WebhookSubForm
|
||||
enableWebhooks={enableWebhooks}
|
||||
templateType={template.type}
|
||||
/>
|
||||
<WebhookSubForm templateType={template.type} />
|
||||
</FormColumnLayout>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
CredentialTypesAPI,
|
||||
} from '../../../api';
|
||||
|
||||
function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
||||
function WebhookSubForm({ i18n, templateType }) {
|
||||
const { id } = useParams();
|
||||
|
||||
const { pathname } = useLocation();
|
||||
@@ -36,6 +36,7 @@ function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
||||
webhookServiceHelpers,
|
||||
] = useField('webhook_service');
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const [webhookUrlField, webhookUrlMeta, webhookUrlHelpers] = useField(
|
||||
'webhook_url'
|
||||
);
|
||||
@@ -71,21 +72,6 @@ function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
||||
loadCredentialType();
|
||||
}, [loadCredentialType]);
|
||||
|
||||
useEffect(() => {
|
||||
if (enableWebhooks) {
|
||||
webhookServiceHelpers.setValue(webhookServiceMeta.initialValue);
|
||||
webhookUrlHelpers.setValue(webhookUrlMeta.initialValue);
|
||||
webhookKeyHelpers.setValue(webhookKeyMeta.initialValue);
|
||||
webhookCredentialHelpers.setValue(webhookCredentialMeta.initialValue);
|
||||
} else {
|
||||
webhookServiceHelpers.setValue('');
|
||||
webhookUrlHelpers.setValue('');
|
||||
webhookKeyHelpers.setValue('');
|
||||
webhookCredentialHelpers.setValue(null);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [enableWebhooks]);
|
||||
|
||||
const { request: fetchWebhookKey, error: webhookKeyError } = useRequest(
|
||||
useCallback(async () => {
|
||||
const updateWebhookKey =
|
||||
@@ -134,7 +120,6 @@ function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
||||
return <ContentLoading />;
|
||||
}
|
||||
return (
|
||||
enableWebhooks && (
|
||||
<FormColumnLayout>
|
||||
<FormGroup
|
||||
name="webhook_service"
|
||||
@@ -235,7 +220,6 @@ function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
||||
/>
|
||||
)}
|
||||
</FormColumnLayout>
|
||||
)
|
||||
);
|
||||
}
|
||||
export default withI18n()(WebhookSubForm);
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('<WebhookSubForm />', () => {
|
||||
wrapper = mountWithContexts(
|
||||
<Route path="templates/:templateType/:id/edit">
|
||||
<Formik initialValues={initialValues}>
|
||||
<WebhookSubForm enableWebhooks templateType="job_template" />
|
||||
<WebhookSubForm templateType="job_template" />
|
||||
</Formik>
|
||||
</Route>,
|
||||
{
|
||||
@@ -103,7 +103,7 @@ describe('<WebhookSubForm />', () => {
|
||||
webhook_key: 'A NEW WEBHOOK KEY WILL BE GENERATED ON SAVE.',
|
||||
}}
|
||||
>
|
||||
<WebhookSubForm enableWebhooks templateType="job_template" />
|
||||
<WebhookSubForm templateType="job_template" />
|
||||
</Formik>
|
||||
</Route>,
|
||||
{
|
||||
@@ -133,10 +133,7 @@ describe('<WebhookSubForm />', () => {
|
||||
newWrapper = mountWithContexts(
|
||||
<Route path="templates/:templateType/:id/edit">
|
||||
<Formik initialValues={{ ...initialValues, webhook_url }}>
|
||||
<WebhookSubForm
|
||||
enableWebhooks
|
||||
templateType="workflow_job_template"
|
||||
/>
|
||||
<WebhookSubForm templateType="workflow_job_template" />
|
||||
</Formik>
|
||||
</Route>,
|
||||
{
|
||||
|
||||
@@ -216,11 +216,10 @@ function WorkflowJobTemplateForm({
|
||||
|
||||
{enableWebhooks && (
|
||||
<SubFormLayout>
|
||||
<Title size="md" headingLevel="h4">{i18n._(t`Webhook details`)}</Title>
|
||||
<WebhookSubForm
|
||||
enableWebhooks={enableWebhooks}
|
||||
templateType={template.type}
|
||||
/>
|
||||
<Title size="md" headingLevel="h4">
|
||||
{i18n._(t`Webhook details`)}
|
||||
</Title>
|
||||
<WebhookSubForm templateType={template.type} />
|
||||
</SubFormLayout>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user