import * as React from 'react'; import I18n from 'i18n-js'; import { IWebhook } from '../../../interfaces/IWebhook'; import { WebhookPages } from './WebhooksSiteSettingsP'; import Switch from '../../common/Switch'; import ActionLink from '../../common/ActionLink'; import { DeleteIcon, EditIcon, TestIcon } from '../../common/Icons'; import buildRequestHeaders from '../../../helpers/buildRequestHeaders'; const WEBHOOK_DESCRIPTION_MAX_LENGTH = 100; interface Props { webhook: IWebhook; handleToggleEnabledWebhook: (id: number, enabled: boolean) => void; handleDeleteWebhook: (id: number) => void; handleTestWebhook: (id: number) => void; setSelectedWebhook: React.Dispatch>; setPage: React.Dispatch>; } const WebhookListItem = ({ webhook, handleToggleEnabledWebhook, handleDeleteWebhook, handleTestWebhook, setSelectedWebhook, setPage, }: Props) => (
  • {webhook.name}
    { webhook.description &&

    { webhook.description.length > WEBHOOK_DESCRIPTION_MAX_LENGTH ? `${webhook.description.slice(0, WEBHOOK_DESCRIPTION_MAX_LENGTH)}...` : webhook.description }

    } handleToggleEnabledWebhook(webhook.id, !webhook.isEnabled)} checked={webhook.isEnabled} htmlId={`webhook${webhook.name}EnabledSwitch`} />
    handleTestWebhook(webhook.id)} icon={} customClass='testAction' > {I18n.t('common.buttons.test')} { setSelectedWebhook(webhook.id); setPage('edit'); }} icon={} customClass="editAction" > {I18n.t('common.buttons.edit')} confirm(I18n.t('common.confirmation')) && handleDeleteWebhook(webhook.id)} icon={} customClass="deleteAction" > {I18n.t('common.buttons.delete')}
  • ); export default WebhookListItem;