mirror of
https://github.com/ansible/awx.git
synced 2026-05-22 08:17:39 -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 && (
|
{enableWebhooks && (
|
||||||
<>
|
<>
|
||||||
<Title size="md" headingLevel="h4">{i18n._(t`Webhook details`)}</Title>
|
<Title size="md" headingLevel="h4">
|
||||||
|
{i18n._(t`Webhook details`)}
|
||||||
|
</Title>
|
||||||
<FormColumnLayout>
|
<FormColumnLayout>
|
||||||
<WebhookSubForm
|
<WebhookSubForm templateType={template.type} />
|
||||||
enableWebhooks={enableWebhooks}
|
|
||||||
templateType={template.type}
|
|
||||||
/>
|
|
||||||
</FormColumnLayout>
|
</FormColumnLayout>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
CredentialTypesAPI,
|
CredentialTypesAPI,
|
||||||
} from '../../../api';
|
} from '../../../api';
|
||||||
|
|
||||||
function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
function WebhookSubForm({ i18n, templateType }) {
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
|
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
@@ -36,6 +36,7 @@ function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
|||||||
webhookServiceHelpers,
|
webhookServiceHelpers,
|
||||||
] = useField('webhook_service');
|
] = useField('webhook_service');
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
const [webhookUrlField, webhookUrlMeta, webhookUrlHelpers] = useField(
|
const [webhookUrlField, webhookUrlMeta, webhookUrlHelpers] = useField(
|
||||||
'webhook_url'
|
'webhook_url'
|
||||||
);
|
);
|
||||||
@@ -71,21 +72,6 @@ function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
|||||||
loadCredentialType();
|
loadCredentialType();
|
||||||
}, [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(
|
const { request: fetchWebhookKey, error: webhookKeyError } = useRequest(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const updateWebhookKey =
|
const updateWebhookKey =
|
||||||
@@ -134,7 +120,6 @@ function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
|||||||
return <ContentLoading />;
|
return <ContentLoading />;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
enableWebhooks && (
|
|
||||||
<FormColumnLayout>
|
<FormColumnLayout>
|
||||||
<FormGroup
|
<FormGroup
|
||||||
name="webhook_service"
|
name="webhook_service"
|
||||||
@@ -235,7 +220,6 @@ function WebhookSubForm({ i18n, enableWebhooks, templateType }) {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</FormColumnLayout>
|
</FormColumnLayout>
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default withI18n()(WebhookSubForm);
|
export default withI18n()(WebhookSubForm);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ describe('<WebhookSubForm />', () => {
|
|||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
<Route path="templates/:templateType/:id/edit">
|
<Route path="templates/:templateType/:id/edit">
|
||||||
<Formik initialValues={initialValues}>
|
<Formik initialValues={initialValues}>
|
||||||
<WebhookSubForm enableWebhooks templateType="job_template" />
|
<WebhookSubForm templateType="job_template" />
|
||||||
</Formik>
|
</Formik>
|
||||||
</Route>,
|
</Route>,
|
||||||
{
|
{
|
||||||
@@ -103,7 +103,7 @@ describe('<WebhookSubForm />', () => {
|
|||||||
webhook_key: 'A NEW WEBHOOK KEY WILL BE GENERATED ON SAVE.',
|
webhook_key: 'A NEW WEBHOOK KEY WILL BE GENERATED ON SAVE.',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<WebhookSubForm enableWebhooks templateType="job_template" />
|
<WebhookSubForm templateType="job_template" />
|
||||||
</Formik>
|
</Formik>
|
||||||
</Route>,
|
</Route>,
|
||||||
{
|
{
|
||||||
@@ -133,10 +133,7 @@ describe('<WebhookSubForm />', () => {
|
|||||||
newWrapper = mountWithContexts(
|
newWrapper = mountWithContexts(
|
||||||
<Route path="templates/:templateType/:id/edit">
|
<Route path="templates/:templateType/:id/edit">
|
||||||
<Formik initialValues={{ ...initialValues, webhook_url }}>
|
<Formik initialValues={{ ...initialValues, webhook_url }}>
|
||||||
<WebhookSubForm
|
<WebhookSubForm templateType="workflow_job_template" />
|
||||||
enableWebhooks
|
|
||||||
templateType="workflow_job_template"
|
|
||||||
/>
|
|
||||||
</Formik>
|
</Formik>
|
||||||
</Route>,
|
</Route>,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -216,11 +216,10 @@ function WorkflowJobTemplateForm({
|
|||||||
|
|
||||||
{enableWebhooks && (
|
{enableWebhooks && (
|
||||||
<SubFormLayout>
|
<SubFormLayout>
|
||||||
<Title size="md" headingLevel="h4">{i18n._(t`Webhook details`)}</Title>
|
<Title size="md" headingLevel="h4">
|
||||||
<WebhookSubForm
|
{i18n._(t`Webhook details`)}
|
||||||
enableWebhooks={enableWebhooks}
|
</Title>
|
||||||
templateType={template.type}
|
<WebhookSubForm templateType={template.type} />
|
||||||
/>
|
|
||||||
</SubFormLayout>
|
</SubFormLayout>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user