2024-08-20 15:22:14 +02:00
|
|
|
import {Card, Divider, Space, Table, Tag, Typography} from "antd";
|
2024-08-18 17:28:45 +02:00
|
|
|
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 punycode from "punycode/punycode";
|
2024-08-20 15:22:14 +02:00
|
|
|
import {actionToColor} from "../../search/EventTimeline";
|
|
|
|
|
import React from "react";
|
2024-08-18 17:28:45 +02:00
|
|
|
import {Watchlist} from "../../../pages/tracking/WatchlistPage";
|
|
|
|
|
import {Connector} from "../../../utils/api/connectors";
|
|
|
|
|
import useBreakpoint from "../../../hooks/useBreakpoint";
|
|
|
|
|
import {CalendarWatchlistButton} from "./CalendarWatchlistButton";
|
2024-08-20 17:32:58 +02:00
|
|
|
import {rdapEventNameTranslation} from "../../search/rdapTranslation";
|
2024-08-18 17:28:45 +02:00
|
|
|
|
|
|
|
|
export function WatchlistCard({watchlist, onUpdateWatchlist, connectors, onDelete}: {
|
|
|
|
|
watchlist: Watchlist,
|
|
|
|
|
onUpdateWatchlist: (values: { domains: string[], triggers: string[], token: string }) => Promise<void>,
|
|
|
|
|
connectors: (Connector & { id: string })[],
|
|
|
|
|
onDelete: () => void
|
|
|
|
|
}) {
|
|
|
|
|
const sm = useBreakpoint('sm')
|
2024-08-20 15:22:14 +02:00
|
|
|
const rdapEventNameTranslated = rdapEventNameTranslation()
|
2024-08-18 17:28:45 +02:00
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
title: t`Domain names`,
|
|
|
|
|
dataIndex: 'domains'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: t`Tracked events`,
|
|
|
|
|
dataIndex: 'events'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
return <>
|
|
|
|
|
<Card
|
|
|
|
|
type='inner'
|
|
|
|
|
title={<>
|
|
|
|
|
{
|
|
|
|
|
watchlist.connector ?
|
|
|
|
|
<Tag icon={<LinkOutlined/>} color="lime-inverse" title={watchlist.connector.id}/> :
|
|
|
|
|
<Tag icon={<DisconnectOutlined/>} color="default"
|
|
|
|
|
title={t`This Watchlist is not linked to a Connector.`}/>
|
|
|
|
|
}
|
|
|
|
|
<Typography.Text title={new Date(watchlist.createdAt).toLocaleString()}>
|
|
|
|
|
{t`Watchlist` + (watchlist.name ? ` (${watchlist.name})` : '')}
|
|
|
|
|
</Typography.Text>
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
size='small'
|
|
|
|
|
style={{width: '100%'}}
|
|
|
|
|
extra={
|
|
|
|
|
<Space size='middle'>
|
|
|
|
|
<ViewDiagramWatchlistButton token={watchlist.token}/>
|
|
|
|
|
|
|
|
|
|
<CalendarWatchlistButton watchlist={watchlist}/>
|
|
|
|
|
|
|
|
|
|
<UpdateWatchlistButton
|
|
|
|
|
watchlist={watchlist}
|
|
|
|
|
onUpdateWatchlist={onUpdateWatchlist}
|
|
|
|
|
connectors={connectors}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<DeleteWatchlistButton watchlist={watchlist} onDelete={onDelete}/>
|
|
|
|
|
</Space>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<Card.Meta description={watchlist.token} style={{marginBottom: '1em'}}/>
|
|
|
|
|
<Table
|
|
|
|
|
size='small'
|
|
|
|
|
columns={columns}
|
|
|
|
|
pagination={false}
|
|
|
|
|
style={{width: '100%'}}
|
|
|
|
|
dataSource={[{
|
|
|
|
|
domains: watchlist.domains.map(d => <Tag>{punycode.toUnicode(d.ldhName)}</Tag>),
|
|
|
|
|
events: watchlist.triggers?.filter(t => t.action === 'email')
|
|
|
|
|
.map(t => <Tag color={actionToColor(t.event)}>
|
2024-08-20 15:22:14 +02:00
|
|
|
{rdapEventNameTranslated[t.event as keyof typeof rdapEventNameTranslated]}
|
2024-08-18 17:28:45 +02:00
|
|
|
</Tag>
|
|
|
|
|
)
|
|
|
|
|
}]}
|
|
|
|
|
{...(sm ? {scroll: {y: 'max-content'}} : {scroll: {y: 240}})}
|
|
|
|
|
/>
|
|
|
|
|
</Card>
|
|
|
|
|
<Divider/>
|
|
|
|
|
</>
|
|
|
|
|
}
|