2024-12-30 23:50:15 +01:00
|
|
|
import {Card, Col, Divider, Row, Space, Tag, Tooltip} from 'antd'
|
|
|
|
|
import {DisconnectOutlined, LinkOutlined} from '@ant-design/icons'
|
|
|
|
|
import {t} from 'ttag'
|
|
|
|
|
import {ViewDiagramWatchlistButton} from './diagram/ViewDiagramWatchlistButton'
|
|
|
|
|
import {UpdateWatchlistButton} from './UpdateWatchlistButton'
|
|
|
|
|
import {DeleteWatchlistButton} from './DeleteWatchlistButton'
|
|
|
|
|
import React from 'react'
|
2024-12-31 13:55:42 +01:00
|
|
|
import type {Connector} from '../../../utils/api/connectors'
|
2024-12-30 23:50:15 +01:00
|
|
|
import {CalendarWatchlistButton} from './CalendarWatchlistButton'
|
|
|
|
|
import {rdapEventDetailTranslation, rdapEventNameTranslation} from '../../../utils/functions/rdapTranslation'
|
2024-08-22 01:44:50 +02:00
|
|
|
|
2024-12-30 23:50:15 +01:00
|
|
|
import {actionToColor} from '../../../utils/functions/actionToColor'
|
2025-01-01 02:42:51 +01:00
|
|
|
import {DomainToTag} from '../../../utils/functions/DomainToTag'
|
2024-12-31 13:55:42 +01:00
|
|
|
import type {Watchlist} from '../../../utils/api'
|
2024-08-18 17:28:45 +02:00
|
|
|
|
|
|
|
|
export function WatchlistCard({watchlist, onUpdateWatchlist, connectors, onDelete}: {
|
2024-12-30 23:50:15 +01:00
|
|
|
watchlist: Watchlist
|
|
|
|
|
onUpdateWatchlist: (values: { domains: string[], triggers: string[], token: string }) => Promise<void>
|
|
|
|
|
connectors: Array<Connector & { id: string }>
|
2024-08-18 17:28:45 +02:00
|
|
|
onDelete: () => void
|
|
|
|
|
}) {
|
2024-08-20 15:22:14 +02:00
|
|
|
const rdapEventNameTranslated = rdapEventNameTranslation()
|
2024-08-20 19:15:04 +02:00
|
|
|
const rdapEventDetailTranslated = rdapEventDetailTranslation()
|
2024-08-18 17:28:45 +02:00
|
|
|
|
2024-12-30 23:50:15 +01:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Card
|
|
|
|
|
type='inner'
|
|
|
|
|
title={<>
|
|
|
|
|
{
|
|
|
|
|
(watchlist.connector != null)
|
|
|
|
|
? <Tooltip title={watchlist.connector.id}>
|
|
|
|
|
<Tag icon={<LinkOutlined/>} color='lime-inverse'/>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
: <Tooltip title={t`This Watchlist is not linked to a Connector.`}>
|
|
|
|
|
<Tag icon={<DisconnectOutlined/>} color='default'/>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
}
|
|
|
|
|
<Tooltip title={new Date(watchlist.createdAt).toLocaleString()}>
|
|
|
|
|
{t`Watchlist` + (watchlist.name ? ` (${watchlist.name})` : '')}
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</>}
|
|
|
|
|
size='small'
|
|
|
|
|
style={{width: '100%'}}
|
|
|
|
|
extra={
|
|
|
|
|
<Space size='middle'>
|
|
|
|
|
<ViewDiagramWatchlistButton token={watchlist.token}/>
|
2024-08-18 17:28:45 +02:00
|
|
|
|
2024-12-30 23:50:15 +01:00
|
|
|
<CalendarWatchlistButton watchlist={watchlist}/>
|
2024-08-18 17:28:45 +02:00
|
|
|
|
2024-12-30 23:50:15 +01:00
|
|
|
<UpdateWatchlistButton
|
|
|
|
|
watchlist={watchlist}
|
|
|
|
|
onUpdateWatchlist={onUpdateWatchlist}
|
|
|
|
|
connectors={connectors}
|
|
|
|
|
/>
|
2024-08-18 17:28:45 +02:00
|
|
|
|
2024-12-30 23:50:15 +01:00
|
|
|
<DeleteWatchlistButton watchlist={watchlist} onDelete={onDelete}/>
|
|
|
|
|
</Space>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<Card.Meta description={watchlist.token} style={{marginBottom: '1em'}}/>
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
<Col span={16}>
|
|
|
|
|
{watchlist.domains.map(d => <DomainToTag key={d.ldhName} domain={d}/>)}
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={8}>
|
|
|
|
|
{watchlist.triggers?.filter(t => t.action === 'email')
|
|
|
|
|
.map(t => <Tooltip
|
|
|
|
|
key={t.event}
|
|
|
|
|
title={rdapEventDetailTranslated[t.event as keyof typeof rdapEventDetailTranslated] || undefined}
|
|
|
|
|
>
|
|
|
|
|
<Tag color={actionToColor(t.event)}>
|
|
|
|
|
{rdapEventNameTranslated[t.event as keyof typeof rdapEventNameTranslated]}
|
|
|
|
|
</Tag>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
)}
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
</Card>
|
|
|
|
|
<Divider/>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|