Skip to content

Commit eb36cf8

Browse files
jkyawChris Jonesclaude
authored
feat(autorag): add Started column to runs table (opendatahub-io#6563)
* feat(autorag): add Started column to runs table - Add Started column (created_at) with relative time and date tooltip - Add utilities/time.ts for formatDateForTooltip and relativeTime - Place Started column before Status - Update AutoragRunsTable.md documentation * chore(autorag): fix documentation and add test for Started column - Remove duplicate "## Props" header in AutoragRunsTable.md - Add unit test to verify Started column renders with relative time - All tests passing (4/4) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> --------- Co-authored-by: Chris Jones <chrisj@ca.ibm.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 7ccc1a6 commit eb36cf8

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

packages/autorag/frontend/src/__mocks__/mod-arch-shared.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ export const TypeaheadSelect: React.FC<TypeaheadSelectProps> = ({
111111
);
112112
};
113113

114+
/** Mock for relative time display in tests. */
115+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- mock accepts same signature as real
116+
export const relativeTime = (current: number, previous: number): string => '1 day ago';
117+
114118
// Re-export everything else that might be needed
115119
// Note: We can't actually re-export from the real module in a mock
116120
// so we'll just export a basic set of components

packages/autorag/frontend/src/app/components/AutoragRunsTable/AutoragRunsTable.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ const pageSize = 20;
3333
/>
3434
```
3535

36+
## Columns
37+
38+
Name, Description, **Started** (relative time with tooltip showing full date), Status.
39+
3640
## Props
3741

3842
| Prop | Type | Required | Description |

packages/autorag/frontend/src/app/components/AutoragRunsTable/AutoragRunsTableRow.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
2-
import { Label, type LabelProps } from '@patternfly/react-core';
2+
import { Label, Timestamp, TimestampTooltipVariant, type LabelProps } from '@patternfly/react-core';
33
import { Td, Tr } from '@patternfly/react-table';
4+
import { relativeTime } from 'mod-arch-shared';
45
import type { PipelineRun } from '~/app/types';
56
import { autoragRunsColumns } from './columns';
67

@@ -44,6 +45,20 @@ const AutoragRunsTableRow: React.FC<AutoragRunsTableRowProps> = ({ run }) => (
4445
</Td>
4546
<Td dataLabel={autoragRunsColumns[1].label}>{run.description ?? '—'}</Td>
4647
<Td dataLabel={autoragRunsColumns[2].label}>
48+
{run.created_at ? (
49+
<Timestamp
50+
date={new Date(run.created_at)}
51+
tooltip={{
52+
variant: TimestampTooltipVariant.default,
53+
}}
54+
>
55+
{relativeTime(Date.now(), new Date(run.created_at).getTime())}
56+
</Timestamp>
57+
) : (
58+
'—'
59+
)}
60+
</Td>
61+
<Td dataLabel={autoragRunsColumns[3].label}>
4762
{run.state ? (
4863
<Label isCompact {...getStatusLabelProps(run.state)}>
4964
{run.state}

packages/autorag/frontend/src/app/components/AutoragRunsTable/__tests__/AutoragRunsTable.spec.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,21 @@ describe('AutoragRunsTable', () => {
113113
expect(screen.getByTestId('empty-view')).toBeInTheDocument();
114114
expect(screen.getByTestId('empty-view')).toHaveTextContent('Empty');
115115
});
116+
117+
it('should render Started column with relative time', () => {
118+
render(
119+
<AutoragRunsTable
120+
runs={mockRuns}
121+
totalSize={defaultPaginationProps.totalSize}
122+
page={defaultPaginationProps.page}
123+
pageSize={defaultPaginationProps.pageSize}
124+
onPageChange={defaultPaginationProps.onPageChange}
125+
onPerPageChange={defaultPaginationProps.onPerPageChange}
126+
/>,
127+
);
128+
129+
// The mock relativeTime function returns '1 day ago'
130+
const relativeTimeElements = screen.getAllByText('1 day ago');
131+
expect(relativeTimeElements.length).toBeGreaterThan(0);
132+
});
116133
});

packages/autorag/frontend/src/app/components/AutoragRunsTable/columns.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export const autoragRunsColumns: SortableData<PipelineRun>[] = [
1818
.localeCompare((b.description ?? '').toLocaleLowerCase()),
1919
width: 25,
2020
},
21+
{
22+
label: 'Started',
23+
field: 'created_at',
24+
sortable: (a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime(),
25+
width: 20,
26+
},
2127
{
2228
label: 'Status',
2329
field: 'state',

0 commit comments

Comments
 (0)