forked from linode/manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamTableRow.tsx
More file actions
90 lines (84 loc) · 2.71 KB
/
StreamTableRow.tsx
File metadata and controls
90 lines (84 loc) · 2.71 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
85
86
87
88
89
90
import { Hidden } from '@linode/ui';
import * as React from 'react';
import { DateTimeDisplay } from 'src/components/DateTimeDisplay';
import { StatusIcon } from 'src/components/StatusIcon/StatusIcon';
import { TableCell } from 'src/components/TableCell';
import { TableRow } from 'src/components/TableRow';
import {
getDestinationTypeOption,
getStreamTypeOption,
} from 'src/features/Delivery/deliveryUtils';
import { LinkWithTooltipAndEllipsis } from 'src/features/Delivery/Shared/LinkWithTooltipAndEllipsis';
import { StreamActionMenu } from 'src/features/Delivery/Streams/StreamActionMenu';
import type { Stream, StreamStatus } from '@linode/api-v4';
import type { Status } from 'src/components/StatusIcon/StatusIcon';
import type { StreamHandlers } from 'src/features/Delivery/Streams/StreamActionMenu';
interface StreamTableRowProps extends StreamHandlers {
stream: Stream;
}
export const StreamTableRow = React.memo((props: StreamTableRowProps) => {
const { stream, onDelete, onDisableOrEnable, onEdit } = props;
const { id, status } = stream;
const iconStatus = ((): Status => {
if (status === 'failed') return 'error';
if (['active', 'error', 'inactive'].includes(status)) {
return status as Status;
}
return 'other';
})();
return (
<TableRow key={id}>
<TableCell>
<LinkWithTooltipAndEllipsis
pendoId="Logs Delivery Streams-Name"
to={`/logs/delivery/streams/${id}/edit`}
>
{stream.label}
</LinkWithTooltipAndEllipsis>
</TableCell>
<TableCell>{getStreamTypeOption(stream.type)?.label}</TableCell>
<TableCell statusCell>
<StatusIcon pulse={false} status={iconStatus} />
{humanizeStreamStatus(status)}
</TableCell>
<TableCell>{id}</TableCell>
<Hidden mdDown>
<TableCell>
{getDestinationTypeOption(stream.destinations[0]?.type)?.label}
</TableCell>
</Hidden>
<Hidden lgDown>
<TableCell>
<DateTimeDisplay value={stream.updated} />
</TableCell>
</Hidden>
<Hidden lgDown>
<TableCell>{stream.updated_by}</TableCell>
</Hidden>
<TableCell actionCell>
<StreamActionMenu
onDelete={onDelete}
onDisableOrEnable={onDisableOrEnable}
onEdit={onEdit}
stream={stream}
/>
</TableCell>
</TableRow>
);
});
const humanizeStreamStatus = (status: StreamStatus) => {
switch (status) {
case 'active':
return 'Active';
case 'deactivating':
return 'Deactivating';
case 'failed':
return 'Failed';
case 'inactive':
return 'Inactive';
case 'provisioning':
return 'Provisioning';
default:
return 'Unknown';
}
};