feat: color domain names about to expire

This commit is contained in:
Maël Gangloff
2024-12-18 19:40:34 +01:00
parent 9df6c24a75
commit ab7ce83518
3 changed files with 17 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
import {Card, Divider, Space, Table, Tag, Tooltip} from "antd"; import {Card, Divider, Space, Table, Tag, Tooltip} from "antd";
import {DisconnectOutlined, LinkOutlined} from "@ant-design/icons"; import {ClockCircleOutlined, DeleteOutlined, DisconnectOutlined, LinkOutlined} from "@ant-design/icons";
import {t} from "ttag"; import {t} from "ttag";
import {ViewDiagramWatchlistButton} from "./diagram/ViewDiagramWatchlistButton"; import {ViewDiagramWatchlistButton} from "./diagram/ViewDiagramWatchlistButton";
import {UpdateWatchlistButton} from "./UpdateWatchlistButton"; import {UpdateWatchlistButton} from "./UpdateWatchlistButton";
@@ -78,7 +78,17 @@ export function WatchlistCard({watchlist, onUpdateWatchlist, connectors, onDelet
pagination={false} pagination={false}
style={{width: '100%'}} style={{width: '100%'}}
dataSource={[{ dataSource={[{
domains: watchlist.domains.map(d => <Tag>{punycode.toUnicode(d.ldhName)}</Tag>), domains: watchlist.domains.map(d => <Tag
color={
d.deleted ? 'red' : // If the domain is deleted
d.status.includes('redemption period') ? 'yellow' :
d.status.includes('pending delete') ? 'orange' : 'default'
}
icon={
d.deleted ? <DeleteOutlined/> : // If the domain is deleted
d.status.includes('redemption period') ? <ClockCircleOutlined/> :
d.status.includes('pending delete') ? <DeleteOutlined/> : null
}>{punycode.toUnicode(d.ldhName)}</Tag>),
events: watchlist.triggers?.filter(t => t.action === 'email') events: watchlist.triggers?.filter(t => t.action === 'email')
.map(t => <Tooltip .map(t => <Tooltip
title={t.event in rdapEventDetailTranslated ? rdapEventDetailTranslated[t.event as keyof typeof rdapEventDetailTranslated] : undefined}> title={t.event in rdapEventDetailTranslated ? rdapEventDetailTranslated[t.event as keyof typeof rdapEventDetailTranslated] : undefined}>

View File

@@ -15,7 +15,7 @@ import {AimOutlined} from "@ant-design/icons";
export type Watchlist = { export type Watchlist = {
name?: string name?: string
token: string, token: string,
domains: { ldhName: string }[], domains: { ldhName: string, deleted: boolean, status: string[] }[],
triggers?: { event: EventAction, action: string }[], triggers?: { event: EventAction, action: string }[],
dsn?: string[] dsn?: string[]
connector?: { connector?: {

View File

@@ -70,7 +70,7 @@ class Domain
private Collection $domainEntities; private Collection $domainEntities;
#[ORM\Column(type: Types::SIMPLE_ARRAY, nullable: true)] #[ORM\Column(type: Types::SIMPLE_ARRAY, nullable: true)]
#[Groups(['domain:item', 'domain:list'])] #[Groups(['domain:item', 'domain:list', 'watchlist:item', 'watchlist:list'])]
private array $status = []; private array $status = [];
/** /**
@@ -103,7 +103,7 @@ class Domain
private ?Tld $tld = null; private ?Tld $tld = null;
#[ORM\Column(nullable: false)] #[ORM\Column(nullable: false)]
#[Groups(['domain:item', 'domain:list'])] #[Groups(['domain:item', 'domain:list', 'watchlist:item', 'watchlist:list'])]
private ?bool $deleted; private ?bool $deleted;
/** /**
@@ -375,8 +375,8 @@ class Domain
return $this->getUpdatedAt() return $this->getUpdatedAt()
->diff(new \DateTimeImmutable())->days >= 7 ->diff(new \DateTimeImmutable())->days >= 7
|| (($fromUser || ($this->getUpdatedAt() || (($fromUser || ($this->getUpdatedAt()
->diff(new \DateTimeImmutable())->h * 60 + $this->getUpdatedAt() ->diff(new \DateTimeImmutable())->h * 60 + $this->getUpdatedAt()
->diff(new \DateTimeImmutable())->i) >= 50) ->diff(new \DateTimeImmutable())->i) >= 50)
&& $this->isToBeWatchClosely()) && $this->isToBeWatchClosely())
|| (count(array_intersect($this->getStatus(), ['auto renew period', 'client hold', 'server hold'])) > 0 || (count(array_intersect($this->getStatus(), ['auto renew period', 'client hold', 'server hold'])) > 0