From f957ef724981c89627e0076775ac699efcc8c58a Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Tue, 14 Apr 2020 15:07:32 -0400 Subject: [PATCH] Add webhook fields to wf node job template detail --- .../components/PromptDetail/PromptDetail.jsx | 12 +++-- .../PromptDetail/PromptJobTemplateDetail.jsx | 52 ++++++++++++++----- .../PromptJobTemplateDetail.test.jsx | 16 ++++++ .../PromptDetail/data.job_template.json | 24 ++++++++- 4 files changed, 85 insertions(+), 19 deletions(-) diff --git a/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx index cfb2745904..26e47d2956 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptDetail.jsx @@ -8,6 +8,7 @@ import { toTitleCase } from '@util/strings'; import { Chip, ChipGroup } from '@patternfly/react-core'; import { VariablesDetail } from '@components/CodeMirrorInput'; +import CredentialChip from '@components/CredentialChip'; import { DetailList, Detail, UserDateDetail } from '@components/DetailList'; import PromptProjectDetail from './PromptProjectDetail'; @@ -172,7 +173,6 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) { /> )} - {/* TODO: Add JT, WFJT, Inventory Source Details */} {details?.type === 'project' && ( )} @@ -211,14 +211,16 @@ function PromptDetail({ i18n, resource, launchConfig = {} }) { {overrides?.credentials && ( {overrides.credentials.map(cred => ( - - {cred.name} - + ))} } diff --git a/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx index bb34806a19..e8f979247b 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.jsx @@ -24,12 +24,14 @@ function PromptJobTemplateDetail({ i18n, resource }) { job_type, limit, playbook, + related, scm_branch, skip_tags, summary_fields, - url, use_fact_cache, verbosity, + webhook_key, + webhook_service, } = resource; const VERBOSITY = { @@ -114,23 +116,49 @@ function PromptJobTemplateDetail({ i18n, resource }) { value={diff_mode ? 'On' : 'Off'} /> - {host_config_key && ( - - - - + + {related?.callback && ( + + )} + + {related.webhook_receiver && ( + + )} + + {summary_fields?.webhook_credential && ( + + } + /> )} {optionsList && } {summary_fields?.credentials?.length > 0 && ( ( - - ))} + value={ + + {summary_fields.credentials.map(cred => ( + + ))} + + } /> )} {summary_fields?.labels?.results?.length > 0 && ( diff --git a/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.test.jsx b/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.test.jsx index b33af6c040..30f92824ab 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.test.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptJobTemplateDetail.test.jsx @@ -5,6 +5,7 @@ import mockData from './data.job_template.json'; const mockJT = { ...mockData, + webhook_key: 'PiM3n2', instance_groups: [ { id: 1, @@ -49,9 +50,24 @@ describe('PromptJobTemplateDetail', () => { assertDetail('Show Changes', 'Off'); assertDetail('Job Slicing', '1'); assertDetail('Host Config Key', 'a1b2c3'); + assertDetail('Webhook Service', 'Github'); + assertDetail('Webhook Key', 'PiM3n2'); + expect(wrapper.find('StatusIcon')).toHaveLength(2); + expect(wrapper.find('Detail[label="Webhook URL"] dd').text()).toEqual( + expect.stringContaining('/api/v2/job_templates/7/github/') + ); expect( wrapper.find('Detail[label="Provisioning Callback URL"] dd').text() ).toEqual(expect.stringContaining('/api/v2/job_templates/7/callback/')); + expect( + wrapper + .find('Detail[label="Webhook Credential"]') + .containsAllMatchingElements([ + + Github Token:GitHub Cred + , + ]) + ).toEqual(true); expect( wrapper.find('Detail[label="Credentials"]').containsAllMatchingElements([ diff --git a/awx/ui_next/src/components/PromptDetail/data.job_template.json b/awx/ui_next/src/components/PromptDetail/data.job_template.json index 34dfc47154..0f29f134d2 100644 --- a/awx/ui_next/src/components/PromptDetail/data.job_template.json +++ b/awx/ui_next/src/components/PromptDetail/data.job_template.json @@ -16,6 +16,8 @@ "schedules": "/api/v2/job_templates/7/schedules/", "activity_stream": "/api/v2/job_templates/7/activity_stream/", "launch": "/api/v2/job_templates/7/launch/", + "webhook_key": "/api/v2/job_templates/7/webhook_key/", + "webhook_receiver": "/api/v2/job_templates/7/github/", "notification_templates_started": "/api/v2/job_templates/7/notification_templates_started/", "notification_templates_success": "/api/v2/job_templates/7/notification_templates_success/", "notification_templates_error": "/api/v2/job_templates/7/notification_templates_error/", @@ -24,7 +26,9 @@ "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/", + "callback": "/api/v2/job_templates/7/callback/", + "webhook_credential": "/api/v2/credentials/8/" }, "summary_fields": { "inventory": { @@ -64,6 +68,14 @@ "status": "successful", "failed": false }, + "webhook_credential": { + "id": 8, + "name": "GitHub Cred", + "description": "", + "kind": "github_token", + "cloud": false, + "credential_type_id": 12 + }, "created_by": { "id": 1, "username": "admin", @@ -123,6 +135,12 @@ "status": "successful", "finished": "2019-10-01T14:34:35.142483Z", "type": "job" + }, + { + "id": 13, + "status": "successful", + "finished": "2019-10-01T14:34:35.142483Z", + "type": "job" } ], "extra_credentials": [], @@ -174,5 +192,7 @@ "diff_mode": false, "allow_simultaneous": true, "custom_virtualenv": null, - "job_slice_count": 1 + "job_slice_count": 1, + "webhook_service": "github", + "webhook_credential": 8 } \ No newline at end of file