-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Expand file tree
/
Copy pathautomations-list.tsx
More file actions
84 lines (77 loc) · 3.7 KB
/
Copy pathautomations-list.tsx
File metadata and controls
84 lines (77 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import AutomationStatusBadge from './automation-status-badge';
import React from 'react';
import {Automation} from '@tryghost/admin-x-framework/api/automations';
import {Link} from '@tryghost/admin-x-framework';
import {Skeleton, Table, TableBody, TableCell, TableRow} from '@tryghost/shade/components';
const AUTOMATION_DESCRIPTIONS: Record<string, string> = {
'member-welcome-email-free': 'Welcome new free members after they sign up.',
'member-welcome-email-paid': 'Welcome new paid members after they start their subscription.'
};
interface AutomationsListProps {
automations?: Automation[];
isLoading?: boolean;
}
const AutomationsListSkeleton: React.FC = () => {
return (
<Table className="flex flex-col border-t" data-testid="automations-list-loading">
<TableBody className="flex flex-col">
{Array.from({length: 2}, (_, index) => (
<TableRow
key={index}
aria-hidden="true"
className="grid w-full grid-cols-[1fr_auto] items-center gap-x-4 p-2 lg:p-0"
>
<TableCell className="min-w-0 lg:p-4">
<Skeleton className="mb-1 h-3 w-48 max-w-full " />
<Skeleton className="h-3 w-80 max-w-full" />
</TableCell>
<TableCell className="text-right lg:w-32 lg:p-4">
<Skeleton className="ml-auto h-3 w-16" />
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
);
};
const AutomationsList: React.FC<AutomationsListProps> = ({automations = [], isLoading = false}) => {
if (isLoading) {
return <AutomationsListSkeleton />;
}
return (
<Table className="flex flex-col border-t" data-testid="automations-list">
<TableBody className="flex flex-col">
{automations.map((automation) => {
const description = AUTOMATION_DESCRIPTIONS[automation.slug];
return (
<TableRow
key={automation.slug}
className="grid w-full cursor-pointer grid-cols-[1fr_auto] items-center gap-x-4 p-2 hover:bg-table-row-hover lg:p-0"
data-testid="automation-list-row"
>
<TableCell className="static min-w-0 lg:p-4">
<Link
className="before:absolute before:inset-0 before:z-10 before:rounded-sm focus-visible:outline-hidden focus-visible:before:ring-2 focus-visible:before:ring-focus-ring"
to={`/automations/${automation.id}`}
>
<span className="block text-md font-semibold">
{automation.name}
</span>
</Link>
{description && (
<span className="block text-muted-foreground">
{description}
</span>
)}
</TableCell>
<TableCell className="text-right lg:w-32 lg:p-4">
<AutomationStatusBadge status={automation.status} />
</TableCell>
</TableRow>
);
})}
</TableBody>
</Table>
);
};
export default AutomationsList;