mirror of
https://github.com/ansible/awx.git
synced 2026-07-05 13:28:04 -02:30
Adds webhook fields to job template details
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
|||||||
TextListItem,
|
TextListItem,
|
||||||
TextListItemVariants,
|
TextListItemVariants,
|
||||||
TextListVariants,
|
TextListVariants,
|
||||||
|
Label,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
@@ -55,6 +56,9 @@ function JobTemplateDetail({ i18n, template }) {
|
|||||||
use_fact_cache,
|
use_fact_cache,
|
||||||
url,
|
url,
|
||||||
verbosity,
|
verbosity,
|
||||||
|
webhook_service,
|
||||||
|
related: { webhook_receiver },
|
||||||
|
webhook_key,
|
||||||
} = template;
|
} = template;
|
||||||
const [contentError, setContentError] = useState(null);
|
const [contentError, setContentError] = useState(null);
|
||||||
const [deletionError, setDeletionError] = useState(null);
|
const [deletionError, setDeletionError] = useState(null);
|
||||||
@@ -245,6 +249,35 @@ function JobTemplateDetail({ i18n, template }) {
|
|||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)}
|
)}
|
||||||
|
{webhook_service && (
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Webhook Service`)}
|
||||||
|
value={
|
||||||
|
webhook_service === 'github'
|
||||||
|
? i18n._(t`GitHub`)
|
||||||
|
: i18n._(t`GitLab`)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{webhook_receiver && (
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Webhook URL`)}
|
||||||
|
value={`${document.location.origin}${webhook_receiver}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Detail label={i18n._(t`Webhook Key`)} value={webhook_key} />
|
||||||
|
{summary_fields.webhook_credential && (
|
||||||
|
<Detail
|
||||||
|
label={i18n._(t`Webhook Credential`)}
|
||||||
|
value={
|
||||||
|
<Link
|
||||||
|
to={`/credentials/${summary_fields.webhook_credential.id}/details`}
|
||||||
|
>
|
||||||
|
<Label>{summary_fields.webhook_credential.name}</Label>
|
||||||
|
</Link>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
{renderOptionsField && (
|
{renderOptionsField && (
|
||||||
<Detail label={i18n._(t`Options`)} value={renderOptions} />
|
<Detail label={i18n._(t`Options`)} value={renderOptions} />
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ describe('<JobTemplateDetail />', () => {
|
|||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should render successfully with missing summary fields', async () => {
|
test('should render successfully with missing summary fields', async () => {
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
wrapper = mountWithContexts(
|
wrapper = mountWithContexts(
|
||||||
@@ -138,4 +137,16 @@ describe('<JobTemplateDetail />', () => {
|
|||||||
el => el.length === 0
|
el => el.length === 0
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
test('webhook fields should render properly', () => {
|
||||||
|
expect(wrapper.find('Detail[label="Webhook Service"]').length).toBe(1);
|
||||||
|
expect(wrapper.find('Detail[label="Webhook Service"]').prop('value')).toBe(
|
||||||
|
'GitHub'
|
||||||
|
);
|
||||||
|
expect(wrapper.find('Detail[label="Webhook URL"]').length).toBe(1);
|
||||||
|
expect(wrapper.find('Detail[label="Webhook URL"]').prop('value')).toContain(
|
||||||
|
'api/v2/job_templates/7/github/'
|
||||||
|
);
|
||||||
|
expect(wrapper.find('Detail[label="Webhook Key"]').length).toBe(1);
|
||||||
|
expect(wrapper.find('Detail[label="Webhook Credential"]').length).toBe(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,7 +24,8 @@
|
|||||||
"object_roles": "/api/v2/job_templates/7/object_roles/",
|
"object_roles": "/api/v2/job_templates/7/object_roles/",
|
||||||
"instance_groups": "/api/v2/job_templates/7/instance_groups/",
|
"instance_groups": "/api/v2/job_templates/7/instance_groups/",
|
||||||
"slice_workflow_jobs": "/api/v2/job_templates/7/slice_workflow_jobs/",
|
"slice_workflow_jobs": "/api/v2/job_templates/7/slice_workflow_jobs/",
|
||||||
"copy": "/api/v2/job_templates/7/copy/"
|
"copy": "/api/v2/job_templates/7/copy/",
|
||||||
|
"webhook_receiver": "/api/v2/job_templates/7/github/"
|
||||||
},
|
},
|
||||||
"summary_fields": {
|
"summary_fields": {
|
||||||
"inventory": {
|
"inventory": {
|
||||||
@@ -102,34 +103,38 @@
|
|||||||
},
|
},
|
||||||
"labels": {
|
"labels": {
|
||||||
"count": 1,
|
"count": 1,
|
||||||
"results": [
|
"results": [{
|
||||||
{
|
|
||||||
"id": 91,
|
"id": 91,
|
||||||
"name": "L_91o2"
|
"name": "L_91o2"
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"survey": {
|
"survey": {
|
||||||
"title": "",
|
"title": "",
|
||||||
"description": ""
|
"description": ""
|
||||||
},
|
},
|
||||||
"recent_jobs": [
|
"recent_jobs": [{
|
||||||
{
|
|
||||||
"id": 12,
|
"id": 12,
|
||||||
"status": "successful",
|
"status": "successful",
|
||||||
"finished": "2019-10-01T14:34:35.142483Z",
|
"finished": "2019-10-01T14:34:35.142483Z",
|
||||||
"type": "job"
|
"type": "job"
|
||||||
}
|
}],
|
||||||
],
|
|
||||||
"extra_credentials": [],
|
"extra_credentials": [],
|
||||||
"credentials": [
|
"credentials": [{
|
||||||
{
|
"id": 1,
|
||||||
"id": 1, "kind": "ssh" , "name": "Credential 1"
|
"kind": "ssh",
|
||||||
|
"name": "Credential 1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2, "kind": "awx" , "name": "Credential 2"
|
"id": 2,
|
||||||
|
"kind": "awx",
|
||||||
|
"name": "Credential 2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"webhook_credential": {
|
||||||
|
"id": "1",
|
||||||
|
"name": "Webhook Credential"
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"created": "2019-09-30T16:18:34.564820Z",
|
"created": "2019-09-30T16:18:34.564820Z",
|
||||||
"modified": "2019-10-01T14:47:31.818431Z",
|
"modified": "2019-10-01T14:47:31.818431Z",
|
||||||
@@ -170,5 +175,8 @@
|
|||||||
"diff_mode": false,
|
"diff_mode": false,
|
||||||
"allow_simultaneous": false,
|
"allow_simultaneous": false,
|
||||||
"custom_virtualenv": null,
|
"custom_virtualenv": null,
|
||||||
"job_slice_count": 1
|
"job_slice_count": 1,
|
||||||
|
"webhook_credential": 1,
|
||||||
|
"webhook_key": "asertdyuhjkhgfd234567kjgfds",
|
||||||
|
"webhook_service": "github"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user