-
-
Notifications
You must be signed in to change notification settings - Fork 638
Expand file tree
/
Copy pathanalyzablesHistoryTableColumns.jsx
More file actions
172 lines (169 loc) · 4.66 KB
/
analyzablesHistoryTableColumns.jsx
File metadata and controls
172 lines (169 loc) · 4.66 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* eslint-disable react/prop-types */
import React from "react";
import { UncontrolledTooltip } from "reactstrap";
import {
DateHoverable,
DefaultColumnFilter,
SelectOptionsFilter,
} from "@certego/certego-ui";
import { format } from "date-fns-tz";
import TableCell from "../../common/TableCell";
import TagsCell from "../../common/TagsCell";
import { LastEvaluationComponent } from "../../common/engineBadges";
import {
JobResultSections,
AnalyzableHistoryTypes,
HistoryPages,
datetimeFormatStr,
} from "../../../constants/miscConst";
export const analyzablesHistoryTableColumns = [
{
Header: "ID",
id: "pk",
accessor: "id",
Cell: ({ value: id, row: { original } }) => {
const fromDate = new Date(original.date);
fromDate.setDate(fromDate.getDate() - 1);
return (
<div className="d-flex flex-column justify-content-center p-2">
<div>
<a
id={`analyzable-history__${original.type}-${id}`}
href={
original.type === AnalyzableHistoryTypes.JOB
? `/jobs/${id}/${JobResultSections.VISUALIZER}`
: `/history/${
HistoryPages[
Object.keys(AnalyzableHistoryTypes).find(
(key) =>
AnalyzableHistoryTypes[key] === original.type,
)
]
}?event_date__gte=${encodeURIComponent(
format(fromDate, datetimeFormatStr),
)}&event_date__lte=${encodeURIComponent(
format(new Date(), datetimeFormatStr),
)}&ordering=-date&id=${id}`
}
target="_blank"
rel="noreferrer"
>
#{id}
</a>
<UncontrolledTooltip
target={`analyzable-history__${original.type}-${id}`}
placement="top"
fade={false}
>
{original.type.replace("_", " ")} overview
</UncontrolledTooltip>
</div>
</div>
);
},
disableSortBy: true,
maxWidth: 60,
Filter: DefaultColumnFilter,
filterPlaceholder: "Search ID",
},
{
Header: "User",
id: "user",
accessor: "user",
Cell: ({ value, row: { original } }) => (
<TableCell
id={`table-cell-user__${original.id}`}
isCopyToClipboard
isTruncate
value={value}
/>
),
disableSortBy: true,
Filter: DefaultColumnFilter,
maxWidth: 90,
},
{
Header: "Date",
id: "date",
accessor: (analyzable) => analyzable.data_model.date,
Cell: ({ value }) =>
value ? (
<div className="py-2">
<DateHoverable ago value={value} format="hh:mm:ss a MMM do, yyyy" />
</div>
) : (
<div />
),
maxWidth: 110,
},
{
Header: "Type",
id: "type",
accessor: "type",
disableSortBy: true,
maxWidth: 90,
Filter: SelectOptionsFilter,
selectOptions: Object.values(AnalyzableHistoryTypes),
Cell: ({ value, row: { original } }) => (
<TableCell
id={`table-cell-type__${original.id}`}
value={value.replaceAll("_", " ")}
/>
),
},
{
Header: "Evaluation",
id: "evaluation",
accessor: (analyzable) => analyzable.data_model,
Cell: ({ value: dataModel, row }) =>
dataModel.evaluation ? (
<div className="d-flex justify-content-center py-2">
<LastEvaluationComponent
id={row.id}
reliability={dataModel.reliability}
evaluation={dataModel.evaluation}
/>
</div>
) : (
<div />
),
disableSortBy: true,
maxWidth: 120,
},
{
Header: "Tags",
id: "tags",
accessor: "data_model.tags",
Cell: ({ value, row }) => <TagsCell values={value} rowId={row.id} />,
disableSortBy: true,
maxWidth: 100,
Filter: DefaultColumnFilter,
filterValueAccessorFn: (tags) => tags.map((tag) => tag.label),
},
{
Header: "Description",
id: "descriptions",
accessor: (value) => {
let text = "";
if (value.type === AnalyzableHistoryTypes.JOB && value.playbook) {
text = `Playbook executed: ${value.playbook}`;
} else if (value.type === AnalyzableHistoryTypes.JOB) {
text = "Custom Analysis";
} else {
text = value.reason;
}
return text;
},
disableSortBy: true,
Cell: ({ value, row }) =>
value && (
<TableCell
id={`table-cell-description__${row.id}`}
isCopyToClipboard
isTruncate
value={value}
/>
),
minWidth: 200,
},
];