mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 23:51:09 +03:00
Merge pull request #6808 from AlexSCorey/6694-WebhookDataOnJTDEETs
Adds webhook fields to job template details Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
commit
5e223db945
@ -9,6 +9,7 @@ import {
|
||||
TextListItem,
|
||||
TextListItemVariants,
|
||||
TextListVariants,
|
||||
Label,
|
||||
} from '@patternfly/react-core';
|
||||
import { t } from '@lingui/macro';
|
||||
|
||||
@ -53,6 +54,9 @@ function JobTemplateDetail({ i18n, template }) {
|
||||
use_fact_cache,
|
||||
url,
|
||||
verbosity,
|
||||
webhook_service,
|
||||
related: { webhook_receiver },
|
||||
webhook_key,
|
||||
} = template;
|
||||
const [contentError, setContentError] = useState(null);
|
||||
const [deletionError, setDeletionError] = useState(null);
|
||||
@ -240,6 +244,35 @@ function JobTemplateDetail({ i18n, template }) {
|
||||
/>
|
||||
</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 && (
|
||||
<Detail label={i18n._(t`Options`)} value={renderOptions} />
|
||||
)}
|
||||
|
@ -30,7 +30,6 @@ describe('<JobTemplateDetail />', () => {
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
test('should render successfully with missing summary fields', async () => {
|
||||
await act(async () => {
|
||||
wrapper = mountWithContexts(
|
||||
@ -138,4 +137,16 @@ describe('<JobTemplateDetail />', () => {
|
||||
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/",
|
||||
"instance_groups": "/api/v2/job_templates/7/instance_groups/",
|
||||
"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": {
|
||||
"inventory": {
|
||||
@ -102,34 +103,38 @@
|
||||
},
|
||||
"labels": {
|
||||
"count": 1,
|
||||
"results": [
|
||||
{
|
||||
"results": [{
|
||||
"id": 91,
|
||||
"name": "L_91o2"
|
||||
}
|
||||
]
|
||||
}]
|
||||
},
|
||||
"survey": {
|
||||
"title": "",
|
||||
"description": ""
|
||||
},
|
||||
"recent_jobs": [
|
||||
{
|
||||
"recent_jobs": [{
|
||||
"id": 12,
|
||||
"status": "successful",
|
||||
"finished": "2019-10-01T14:34:35.142483Z",
|
||||
"type": "job"
|
||||
}
|
||||
],
|
||||
}],
|
||||
"extra_credentials": [],
|
||||
"credentials": [
|
||||
{
|
||||
"id": 1, "kind": "ssh" , "name": "Credential 1"
|
||||
"credentials": [{
|
||||
"id": 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",
|
||||
"modified": "2019-10-01T14:47:31.818431Z",
|
||||
@ -170,5 +175,8 @@
|
||||
"diff_mode": false,
|
||||
"allow_simultaneous": false,
|
||||
"custom_virtualenv": null,
|
||||
"job_slice_count": 1
|
||||
"job_slice_count": 1,
|
||||
"webhook_credential": 1,
|
||||
"webhook_key": "asertdyuhjkhgfd234567kjgfds",
|
||||
"webhook_service": "github"
|
||||
}
|
Loading…
Reference in New Issue
Block a user