PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
import { useTranslation } from 'react-i18next';
import type { Notifier, WebhookHeader } from '../../../../../entity/notifiers';
import { NOTIFICATION_TYPE_LABEL_KEYS, WebhookMethod } from '../../../../../entity/notifiers';
import { DEFAULT_ACCEPT_NOTIFICATION_TYPES } from '../../../lib/defaultAcceptNotificationTypes';
interface Props {
notifier: Notifier;
}
export function ShowWebhookNotifierComponent({ notifier }: Props) {
const { t } = useTranslation();
const headers = notifier?.webhookNotifier?.headers || [];
const hasHeaders = headers.filter((h: WebhookHeader) => h.key).length > 0;
const acceptNotificationTypes =
notifier?.webhookNotifier?.acceptNotificationTypes || DEFAULT_ACCEPT_NOTIFICATION_TYPES;
return (
<>
<div className="flex items-center">
<div className="min-w-[110px] pr-2">{t('notifiers.fields.webhookUrl')}</div>
<div className="max-w-[350px] truncate">{notifier?.webhookNotifier?.webhookUrl || '-'}</div>
</div>
<div className="mt-1 mb-1 flex items-center">
<div className="min-w-[110px] pr-2">{t('notifiers.webhook.method')}</div>
<div>{notifier?.webhookNotifier?.webhookMethod || '-'}</div>
</div>
<div className="mt-1 mb-1 flex items-center">
<div className="min-w-[110px] pr-2">{t('notifiers.webhook.sendOn')}</div>
<div>
{acceptNotificationTypes
.map((type) => t(NOTIFICATION_TYPE_LABEL_KEYS[type]))
.join(t('common.listSeparator')) || '-'}
</div>
</div>
{hasHeaders && (
<div className="mt-1 mb-1 flex items-start">
<div className="min-w-[110px] pr-2">{t('notifiers.webhook.headers')}</div>
<div className="flex flex-col text-sm">
{headers
.filter((h: WebhookHeader) => h.key)
.map((h: WebhookHeader, i: number) => (
<div key={i} className="text-gray-600">
<span className="font-medium">{h.key}:</span>{' '}
{h.value || t('notifiers.webhook.hiddenHeaderValue')}
</div>
))}
</div>
</div>
)}
{notifier?.webhookNotifier?.webhookMethod === WebhookMethod.POST &&
notifier?.webhookNotifier?.bodyTemplate && (
<div className="mt-1 mb-1 flex items-start">
<div className="min-w-[110px] pr-2">{t('notifiers.webhook.bodyTemplate.title')}</div>
<div className="max-w-[350px] rounded bg-gray-50 p-2 font-mono text-xs whitespace-pre-wrap dark:bg-gray-700">
{notifier.webhookNotifier.bodyTemplate}
</div>
</div>
)}
</>
);
}