import type { FormikProps } from 'formik'; import React from 'react'; import type { Option } from 'react-select'; import type { INotification, INotificationTypeConfig, IPipelineCommand } from '../../domain'; import { NotificationSelector, NotificationTransformer } from '../../notification'; import { CheckboxInput, FormikFormField, HoverablePopover } from '../../presentation'; import { Registry } from '../../registry'; export interface INotificationDetailsProps { formik: FormikProps; notifications: INotification[]; } export interface INotificationDetailsState { notificationTypes: Option[]; } export class NotificationDetails extends React.Component { constructor(props: INotificationDetailsProps) { super(props); this.state = { notificationTypes: Registry.pipeline.getNotificationTypes().map((type: INotificationTypeConfig) => ({ label: type.label, value: type.key, })), }; } private notificationToolTip = (notifications: INotification[]) => (
    {notifications.map((notification, i) => { return (
  • {notification.address} when: {notification.when.map((w, j) => { return (
    • {NotificationTransformer.getNotificationWhenDisplayName(w)}
    ); })}
  • ); })}
); private onNotificationTypeChange = (type: string) => { const notificationTypeUpdate = Registry.pipeline.getNotificationConfig(type); const { values } = this.props.formik; if (!!notificationTypeUpdate && values.notification && values.notification.address) { this.props.formik.setFieldValue('notification.address', ''); } }; public render() { const { notificationToolTip, onNotificationTypeChange } = this; const { formik, notifications } = this.props; const { values } = formik; return ( <> } />
{notifications.length === 1 && (
There is{' '} one notification {' '} for this pipeline
)} {notifications.length > 1 && (
There are{' '} {notifications.length} notifications {' '} configured for this pipeline
)}
{values.notificationEnabled && ( )} ); } }