From ab4628b1990afd2cc86b94edc374f2bc4e7b80ec Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Tue, 4 Aug 2020 16:27:03 -0700 Subject: [PATCH] flush out template detail --- .../NotificationTemplate.jsx | 10 +- .../NotificationTemplateDetail.jsx | 225 ++++++++++++++++++ .../NotificationTemplateDetail/index.js | 4 +- .../NotificationTemplates.jsx | 29 ++- 4 files changed, 252 insertions(+), 16 deletions(-) diff --git a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplate.jsx b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplate.jsx index 5182ba645a..4b6692f72c 100644 --- a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplate.jsx +++ b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplate.jsx @@ -18,8 +18,9 @@ function NotificationTemplate({ i18n, setBreadcrumb }) { } = useRequest( useCallback(async () => { const { data } = await NotificationTemplatesAPI.readDetail(templateId); + setBreadcrumb(data); return data; - }, [templateId]), + }, [templateId, setBreadcrumb]), null ); @@ -49,7 +50,12 @@ function NotificationTemplate({ i18n, setBreadcrumb }) { return ( - + {template && ( + + )} ); diff --git a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateDetail/NotificationTemplateDetail.jsx b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateDetail/NotificationTemplateDetail.jsx index 5c8a592a1c..77cadb74cd 100644 --- a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateDetail/NotificationTemplateDetail.jsx +++ b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateDetail/NotificationTemplateDetail.jsx @@ -31,7 +31,23 @@ import { VariablesDetail } from '../../../components/CodeMirrorInput'; import { JobTemplatesAPI } from '../../../api'; import useRequest, { useDismissableError } from '../../../util/useRequest'; +const TYPES = { + email: 'Email', + grafana: 'Grafana', + irc: 'IRC', + mattermost: 'Mattermost', + pagerduty: 'Pagerduty', + rocketchat: 'Rocket.Chat', + slack: 'Slack', + twilio: 'Twilio', + webhook: 'Webhook', +}; + function NotificationTemplateDetail({ i18n, template }) { + const { + notification_configuration: configuration, + summary_fields, + } = template; return ( @@ -40,6 +56,215 @@ function NotificationTemplateDetail({ i18n, template }) { value={template.name} dataCy="nt-detail-name" /> + + {summary_fields.organization ? ( + + {summary_fields.organization.name} + + } + /> + ) : ( + + )} + + {template.notification_type === 'email' && ( + <> + + + + + + + + + )} + {template.notification_type === 'grafana' && ( + <> + + + + + + + )} + {template.notification_type === 'irc' && ( + <> + + + + + + + )} + {template.notification_type === 'mattermost' && ( + <> + + + + + + + )} + {template.notification_type === 'pagerduty' && ( + <> + + + + + )} + {template.notification_type === 'rocketchat' && ( + <> + + + + + + )} ); diff --git a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateDetail/index.js b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateDetail/index.js index 431403014d..118818bb64 100644 --- a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateDetail/index.js +++ b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplateDetail/index.js @@ -1 +1,3 @@ -export default from './NotificationTemplateDetail'; +import NotificationTemplateDetail from './NotificationTemplateDetail'; + +export default NotificationTemplateDetail; diff --git a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplates.jsx b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplates.jsx index 6d828175a0..2ae913202f 100644 --- a/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplates.jsx +++ b/awx/ui_next/src/screens/NotificationTemplate/NotificationTemplates.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useCallback } from 'react'; import { Route, Switch, useRouteMatch } from 'react-router-dom'; import { withI18n } from '@lingui/react'; import { t } from '@lingui/macro'; @@ -14,18 +14,21 @@ function NotificationTemplates({ i18n }) { '/notification_templates/add': i18n._(t`Create New Notification Template`), }); - const updateBreadcrumbConfig = notification => { - const { id } = notification; - setBreadcrumbConfig({ - '/notification_templates': i18n._(t`Notification Templates`), - '/notification_templates/add': i18n._( - t`Create New Notification Template` - ), - [`/notification_templates/${id}`]: notification.name, - [`/notification_templates/${id}/edit`]: i18n._(t`Edit Details`), - [`/notification_templates/${id}/details`]: i18n._(t`Details`), - }); - }; + const updateBreadcrumbConfig = useCallback( + notification => { + const { id } = notification; + setBreadcrumbConfig({ + '/notification_templates': i18n._(t`Notification Templates`), + '/notification_templates/add': i18n._( + t`Create New Notification Template` + ), + [`/notification_templates/${id}`]: notification.name, + [`/notification_templates/${id}/edit`]: i18n._(t`Edit Details`), + [`/notification_templates/${id}/details`]: i18n._(t`Details`), + }); + }, + [i18n] + ); return ( <>