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,
|
TextListItem,
|
||||||
TextListItemVariants,
|
TextListItemVariants,
|
||||||
TextListVariants,
|
TextListVariants,
|
||||||
|
Label,
|
||||||
} from '@patternfly/react-core';
|
} from '@patternfly/react-core';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
|
|
||||||
@ -53,6 +54,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);
|
||||||
@ -240,6 +244,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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,174 +1,182 @@
|
|||||||
{
|
{
|
||||||
"id": 7,
|
"id": 7,
|
||||||
"type": "job_template",
|
"type": "job_template",
|
||||||
"url": "/api/v2/job_templates/7/",
|
"url": "/api/v2/job_templates/7/",
|
||||||
"related": {
|
"related": {
|
||||||
"named_url": "/api/v2/job_templates/Mike's JT/",
|
"named_url": "/api/v2/job_templates/Mike's JT/",
|
||||||
"created_by": "/api/v2/users/1/",
|
"created_by": "/api/v2/users/1/",
|
||||||
"modified_by": "/api/v2/users/1/",
|
"modified_by": "/api/v2/users/1/",
|
||||||
"labels": "/api/v2/job_templates/7/labels/",
|
"labels": "/api/v2/job_templates/7/labels/",
|
||||||
"inventory": "/api/v2/inventories/1/",
|
"inventory": "/api/v2/inventories/1/",
|
||||||
"project": "/api/v2/projects/6/",
|
"project": "/api/v2/projects/6/",
|
||||||
"extra_credentials": "/api/v2/job_templates/7/extra_credentials/",
|
"extra_credentials": "/api/v2/job_templates/7/extra_credentials/",
|
||||||
"credentials": "/api/v2/job_templates/7/credentials/",
|
"credentials": "/api/v2/job_templates/7/credentials/",
|
||||||
"last_job": "/api/v2/jobs/12/",
|
"last_job": "/api/v2/jobs/12/",
|
||||||
"jobs": "/api/v2/job_templates/7/jobs/",
|
"jobs": "/api/v2/job_templates/7/jobs/",
|
||||||
"schedules": "/api/v2/job_templates/7/schedules/",
|
"schedules": "/api/v2/job_templates/7/schedules/",
|
||||||
"activity_stream": "/api/v2/job_templates/7/activity_stream/",
|
"activity_stream": "/api/v2/job_templates/7/activity_stream/",
|
||||||
"launch": "/api/v2/job_templates/7/launch/",
|
"launch": "/api/v2/job_templates/7/launch/",
|
||||||
"notification_templates_started": "/api/v2/job_templates/7/notification_templates_started/",
|
"notification_templates_started": "/api/v2/job_templates/7/notification_templates_started/",
|
||||||
"notification_templates_success": "/api/v2/job_templates/7/notification_templates_success/",
|
"notification_templates_success": "/api/v2/job_templates/7/notification_templates_success/",
|
||||||
"notification_templates_error": "/api/v2/job_templates/7/notification_templates_error/",
|
"notification_templates_error": "/api/v2/job_templates/7/notification_templates_error/",
|
||||||
"access_list": "/api/v2/job_templates/7/access_list/",
|
"access_list": "/api/v2/job_templates/7/access_list/",
|
||||||
"survey_spec": "/api/v2/job_templates/7/survey_spec/",
|
"survey_spec": "/api/v2/job_templates/7/survey_spec/",
|
||||||
"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": {
|
},
|
||||||
"inventory": {
|
"summary_fields": {
|
||||||
"id": 1,
|
"inventory": {
|
||||||
"name": "Mike's Inventory",
|
"id": 1,
|
||||||
"description": "",
|
"name": "Mike's Inventory",
|
||||||
"has_active_failures": false,
|
"description": "",
|
||||||
"total_hosts": 1,
|
"has_active_failures": false,
|
||||||
"hosts_with_active_failures": 0,
|
"total_hosts": 1,
|
||||||
"total_groups": 0,
|
"hosts_with_active_failures": 0,
|
||||||
"groups_with_active_failures": 0,
|
"total_groups": 0,
|
||||||
"has_inventory_sources": false,
|
"groups_with_active_failures": 0,
|
||||||
"total_inventory_sources": 0,
|
"has_inventory_sources": false,
|
||||||
"inventory_sources_with_failures": 0,
|
"total_inventory_sources": 0,
|
||||||
"organization_id": 1,
|
"inventory_sources_with_failures": 0,
|
||||||
"kind": ""
|
"organization_id": 1,
|
||||||
},
|
"kind": ""
|
||||||
"project": {
|
},
|
||||||
"id": 6,
|
"project": {
|
||||||
"name": "Mike's Project",
|
"id": 6,
|
||||||
"description": "",
|
"name": "Mike's Project",
|
||||||
"status": "successful",
|
"description": "",
|
||||||
"scm_type": "git"
|
"status": "successful",
|
||||||
},
|
"scm_type": "git"
|
||||||
"last_job": {
|
},
|
||||||
"id": 12,
|
"last_job": {
|
||||||
"name": "Mike's JT",
|
"id": 12,
|
||||||
"description": "",
|
"name": "Mike's JT",
|
||||||
"finished": "2019-10-01T14:34:35.142483Z",
|
"description": "",
|
||||||
"status": "successful",
|
"finished": "2019-10-01T14:34:35.142483Z",
|
||||||
"failed": false
|
"status": "successful",
|
||||||
},
|
"failed": false
|
||||||
"last_update": {
|
},
|
||||||
"id": 12,
|
"last_update": {
|
||||||
"name": "Mike's JT",
|
"id": 12,
|
||||||
"description": "",
|
"name": "Mike's JT",
|
||||||
"status": "successful",
|
"description": "",
|
||||||
"failed": false
|
"status": "successful",
|
||||||
},
|
"failed": false
|
||||||
"created_by": {
|
},
|
||||||
"id": 1,
|
"created_by": {
|
||||||
"username": "admin",
|
"id": 1,
|
||||||
"first_name": "",
|
"username": "admin",
|
||||||
"last_name": ""
|
"first_name": "",
|
||||||
},
|
"last_name": ""
|
||||||
"modified_by": {
|
},
|
||||||
"id": 1,
|
"modified_by": {
|
||||||
"username": "admin",
|
"id": 1,
|
||||||
"first_name": "",
|
"username": "admin",
|
||||||
"last_name": ""
|
"first_name": "",
|
||||||
},
|
"last_name": ""
|
||||||
"object_roles": {
|
},
|
||||||
"admin_role": {
|
"object_roles": {
|
||||||
"description": "Can manage all aspects of the job template",
|
"admin_role": {
|
||||||
"name": "Admin",
|
"description": "Can manage all aspects of the job template",
|
||||||
"id": 24
|
"name": "Admin",
|
||||||
},
|
"id": 24
|
||||||
"execute_role": {
|
},
|
||||||
"description": "May run the job template",
|
"execute_role": {
|
||||||
"name": "Execute",
|
"description": "May run the job template",
|
||||||
"id": 25
|
"name": "Execute",
|
||||||
},
|
"id": 25
|
||||||
"read_role": {
|
},
|
||||||
"description": "May view settings for the job template",
|
"read_role": {
|
||||||
"name": "Read",
|
"description": "May view settings for the job template",
|
||||||
"id": 26
|
"name": "Read",
|
||||||
}
|
"id": 26
|
||||||
},
|
}
|
||||||
"user_capabilities": {
|
},
|
||||||
"edit": true,
|
"user_capabilities": {
|
||||||
"delete": true,
|
"edit": true,
|
||||||
"start": true,
|
"delete": true,
|
||||||
"schedule": true,
|
"start": true,
|
||||||
"copy": true
|
"schedule": true,
|
||||||
},
|
"copy": true
|
||||||
"labels": {
|
},
|
||||||
"count": 1,
|
"labels": {
|
||||||
"results": [
|
"count": 1,
|
||||||
{
|
"results": [{
|
||||||
"id": 91,
|
"id": 91,
|
||||||
"name": "L_91o2"
|
"name": "L_91o2"
|
||||||
}
|
}]
|
||||||
]
|
|
||||||
},
|
|
||||||
"survey": {
|
|
||||||
"title": "",
|
|
||||||
"description": ""
|
|
||||||
},
|
|
||||||
"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"
|
|
||||||
},
|
},
|
||||||
{
|
"survey": {
|
||||||
"id": 2, "kind": "awx" , "name": "Credential 2"
|
"title": "",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"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"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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",
|
"name": "Mike's JT",
|
||||||
"name": "Mike's JT",
|
"description": "",
|
||||||
"description": "",
|
"job_type": "run",
|
||||||
"job_type": "run",
|
"inventory": 1,
|
||||||
"inventory": 1,
|
"project": 6,
|
||||||
"project": 6,
|
"playbook": "ping.yml",
|
||||||
"playbook": "ping.yml",
|
"scm_branch": "Foo branch",
|
||||||
"scm_branch": "Foo branch",
|
"forks": 0,
|
||||||
"forks": 0,
|
"limit": "",
|
||||||
"limit": "",
|
"verbosity": 0,
|
||||||
"verbosity": 0,
|
"extra_vars": "",
|
||||||
"extra_vars": "",
|
"job_tags": "T_100,T_200",
|
||||||
"job_tags": "T_100,T_200",
|
"force_handlers": false,
|
||||||
"force_handlers": false,
|
"skip_tags": "S_100,S_200",
|
||||||
"skip_tags": "S_100,S_200",
|
"start_at_task": "",
|
||||||
"start_at_task": "",
|
"timeout": 0,
|
||||||
"timeout": 0,
|
"use_fact_cache": true,
|
||||||
"use_fact_cache": true,
|
"last_job_run": "2019-10-01T14:34:35.142483Z",
|
||||||
"last_job_run": "2019-10-01T14:34:35.142483Z",
|
"last_job_failed": false,
|
||||||
"last_job_failed": false,
|
"next_job_run": null,
|
||||||
"next_job_run": null,
|
"status": "successful",
|
||||||
"status": "successful",
|
"host_config_key": "",
|
||||||
"host_config_key": "",
|
"ask_scm_branch_on_launch": false,
|
||||||
"ask_scm_branch_on_launch": false,
|
"ask_diff_mode_on_launch": false,
|
||||||
"ask_diff_mode_on_launch": false,
|
"ask_variables_on_launch": false,
|
||||||
"ask_variables_on_launch": false,
|
"ask_limit_on_launch": false,
|
||||||
"ask_limit_on_launch": false,
|
"ask_tags_on_launch": false,
|
||||||
"ask_tags_on_launch": false,
|
"ask_skip_tags_on_launch": false,
|
||||||
"ask_skip_tags_on_launch": false,
|
"ask_job_type_on_launch": false,
|
||||||
"ask_job_type_on_launch": false,
|
"ask_verbosity_on_launch": false,
|
||||||
"ask_verbosity_on_launch": false,
|
"ask_inventory_on_launch": false,
|
||||||
"ask_inventory_on_launch": false,
|
"ask_credential_on_launch": false,
|
||||||
"ask_credential_on_launch": false,
|
"survey_enabled": true,
|
||||||
"survey_enabled": true,
|
"become_enabled": false,
|
||||||
"become_enabled": false,
|
"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"
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user