Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions keep-ui/types/react-table.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "@tanstack/react-table";
import { TimeFormatOption } from "@/widgets/alerts-table/lib/alert-table-time-format";

declare module "@tanstack/table-core" {
interface ColumnMeta<TData extends RowData, TValue> {
Expand All @@ -7,4 +8,9 @@ declare module "@tanstack/table-core" {
sticky?: boolean;
align?: "left" | "right" | "center";
}

interface TableMeta<TData extends RowData> {
columnTimeFormats?: Record<string, TimeFormatOption>;
setColumnTimeFormats?: (formats: Record<string, TimeFormatOption>) => void;
}
}
15 changes: 11 additions & 4 deletions keep-ui/widgets/alerts-table/lib/alert-table-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,12 @@ export const useAlertTableCols = (
? value
: new Date(value as string | number);
const isoString = date.toISOString();
// Get the format from column format settings or use default
// Get the format from table meta (backend-synced for custom feeds) or
// fall back to local column time formats, defaulting to "timeago"
const activeColumnTimeFormats =
context.table.options.meta?.columnTimeFormats ?? columnTimeFormats;
const formatOption =
columnTimeFormats[context.column.id] || "timeago";
activeColumnTimeFormats[context.column.id] || "timeago";
return (
<span title={isoString}>
{formatDateTime(date, formatOption)}
Expand Down Expand Up @@ -624,8 +627,12 @@ export const useAlertTableCols = (
const date = value instanceof Date ? value : new Date(value);
const isoString = date.toISOString();

// Get the format from column format settings or use default
const formatOption = columnTimeFormats[context.column.id] || "timeago";
// Get the format from table meta (backend-synced for custom feeds) or
// fall back to local column time formats, defaulting to "timeago"
const activeColumnTimeFormats =
context.table.options.meta?.columnTimeFormats ?? columnTimeFormats;
const formatOption =
activeColumnTimeFormats[context.column.id] || "timeago";

return (
<span title={isoString}>{formatDateTime(date, formatOption)}</span>
Expand Down
Loading