2024-07-31 02:55:20 +02:00
|
|
|
import {Card, Divider, Popconfirm, Typography, theme} from "antd";
|
2024-07-29 18:54:28 +02:00
|
|
|
import {t} from "ttag";
|
|
|
|
|
import {deleteWatchlist, EventAction} from "../../utils/api";
|
|
|
|
|
import {DeleteFilled} from "@ant-design/icons";
|
|
|
|
|
import React from "react";
|
|
|
|
|
|
2024-07-31 02:55:20 +02:00
|
|
|
const { useToken } = theme;
|
|
|
|
|
|
2024-07-29 18:54:28 +02:00
|
|
|
type Watchlist = { token: string, domains: { ldhName: string }[], triggers?: { event: EventAction, action: string }[] }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function WatchlistsList({watchlists, onDelete}: { watchlists: Watchlist[], onDelete: () => void }) {
|
2024-07-31 02:55:20 +02:00
|
|
|
const { token } = useToken()
|
|
|
|
|
|
2024-07-29 18:54:28 +02:00
|
|
|
return <>
|
|
|
|
|
{watchlists.map(watchlist =>
|
|
|
|
|
<>
|
2024-07-31 02:55:20 +02:00
|
|
|
<Card title={t`Watchlist`} type="inner" extra={<Popconfirm
|
2024-07-29 18:54:28 +02:00
|
|
|
title={t`Delete the Watchlist`}
|
|
|
|
|
description={t`Are you sure to delete this Watchlist?`}
|
2024-07-29 19:04:50 +02:00
|
|
|
onConfirm={() => deleteWatchlist(watchlist.token).then(onDelete)}
|
2024-07-29 18:54:28 +02:00
|
|
|
okText={t`Yes`}
|
|
|
|
|
cancelText={t`No`}
|
2024-07-31 02:55:20 +02:00
|
|
|
okButtonProps={{danger: true}}
|
|
|
|
|
><DeleteFilled style={{color: token.colorError}} /></Popconfirm>}>
|
|
|
|
|
<Card.Meta description={watchlist.token} style={{marginBottom: '1em'}} />
|
2024-07-29 18:54:28 +02:00
|
|
|
<Typography.Paragraph>
|
|
|
|
|
{t`Domain name`} : {watchlist?.domains.map(d => d.ldhName).join(',')}
|
|
|
|
|
</Typography.Paragraph>
|
|
|
|
|
{
|
|
|
|
|
watchlist.triggers && <Typography.Paragraph>
|
|
|
|
|
{t`Domain triggers`} : {watchlist.triggers.map(t => `${t.event} => ${t.action}`).join(',')}
|
|
|
|
|
</Typography.Paragraph>
|
|
|
|
|
}
|
|
|
|
|
</Card>
|
|
|
|
|
<Divider/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
}
|