|
1 | 1 | import { NotificationRules } from "@flanksource-ui/api/types/notifications"; |
2 | 2 | import { Badge } from "@flanksource-ui/ui/Badge/Badge"; |
| 3 | +import { Modal } from "@flanksource-ui/ui/Modal"; |
3 | 4 | import MRTAvatarCell from "@flanksource-ui/ui/MRTDataTable/Cells/MRTAvataCell"; |
4 | 5 | import { MRTDateCell } from "@flanksource-ui/ui/MRTDataTable/Cells/MRTDateCells"; |
5 | 6 | import { MRTCellProps } from "@flanksource-ui/ui/MRTDataTable/MRTCellProps"; |
6 | 7 | import { formatDuration } from "@flanksource-ui/utils/date"; |
7 | 8 | import { atom, useAtom } from "jotai"; |
8 | 9 | import { MRT_ColumnDef } from "mantine-react-table"; |
9 | 10 | import { useState } from "react"; |
| 11 | +import { FaExclamationTriangle } from "react-icons/fa"; |
10 | 12 | import { Tooltip } from "react-tooltip"; |
11 | 13 | import JobHistoryStatusColumn from "../../JobsHistory/JobHistoryStatusColumn"; |
12 | 14 | import { JobsHistoryDetails } from "../../JobsHistory/JobsHistoryDetails"; |
@@ -181,8 +183,40 @@ export const notificationsRulesTableColumns: MRT_ColumnDef<NotificationRules>[] |
181 | 183 | accessorKey: "title", |
182 | 184 | Cell: ({ row, column }) => { |
183 | 185 | const value = row.getValue<string>(column.id); |
| 186 | + const error = row.original.error; |
| 187 | + |
| 188 | + const [showError, setShowError] = useState(false); |
| 189 | + |
184 | 190 | return ( |
185 | | - <div className="w-full overflow-hidden text-ellipsis">{value}</div> |
| 191 | + <div className="w-full overflow-hidden text-ellipsis"> |
| 192 | + {error && ( |
| 193 | + <> |
| 194 | + <span |
| 195 | + data-tooltip-id={`error-tooltip-${row.original.id}`} |
| 196 | + data-tooltip-content={error} |
| 197 | + onClick={(e) => { |
| 198 | + e.stopPropagation(); |
| 199 | + e.preventDefault(); |
| 200 | + setShowError(!showError); |
| 201 | + }} |
| 202 | + > |
| 203 | + <FaExclamationTriangle className="mr-1 inline h-4 w-4 text-red-500" /> |
| 204 | + </span> |
| 205 | + <Tooltip id={`error-tooltip-${row.original.id}`} /> |
| 206 | + |
| 207 | + <Modal |
| 208 | + open={showError} |
| 209 | + onClose={() => setShowError(false)} |
| 210 | + title={` ${value} Error Details`} |
| 211 | + > |
| 212 | + <div className="flex flex-col p-4"> |
| 213 | + <pre className="whitespace-pre-wrap text-sm">{error}</pre> |
| 214 | + </div> |
| 215 | + </Modal> |
| 216 | + </> |
| 217 | + )} |
| 218 | + {value} |
| 219 | + </div> |
186 | 220 | ); |
187 | 221 | } |
188 | 222 | }, |
|
0 commit comments