@@ -39,22 +39,26 @@ import {
3939 HealthUnknownIcon,
4040} from '../../utils/components/Icons/Icons';
4141
42- const getGeneratorType = (appSet: ApplicationSetKind): string => {
43- if (!appSet.spec?.generators || appSet.spec.generators.length === 0) {
44- return 'None';
45- }
46-
47- const firstGenerator = appSet.spec.generators[0];
48- if (firstGenerator.list) return 'List';
49- if (firstGenerator.clusters) return 'Clusters';
50- if (firstGenerator.git) return 'Git';
51- if (firstGenerator.matrix) return 'Matrix';
52- if (firstGenerator.merge) return 'Merge';
53- if (firstGenerator.union) return 'Union';
54- if (firstGenerator.scmProvider) return 'SCM Provider';
55- if (firstGenerator.pullRequest) return 'Pull Request';
42+
43+
44+ const formatCreationTimestamp = (timestamp: string): string => {
45+ if (!timestamp) return '-';
46+ const date = new Date(timestamp);
47+ const now = new Date();
48+ const diffInMinutes = (now.getTime() - date.getTime()) / (1000 * 60);
5649
57- return 'Unknown';
50+ if (diffInMinutes < 60) {
51+ return `${Math.floor(diffInMinutes)}m ago`;
52+ } else if (diffInMinutes < 60 * 24) {
53+ const hours = Math.floor(diffInMinutes / 60);
54+ const minutes = Math.floor(diffInMinutes % 60);
55+ return minutes > 0 ? `${hours}h ${minutes}m ago` : `${hours}h ago`;
56+ } else if (diffInMinutes < 60 * 24 * 7) {
57+ const days = Math.floor(diffInMinutes / (60 * 24));
58+ return `${days}d ago`;
59+ } else {
60+ return date.toLocaleDateString();
61+ }
5862};
5963
6064// Helper function to get generated applications count
@@ -267,10 +271,10 @@ const useApplicationSetRowsDV = (applicationSetsList, namespace, applications, a
267271 id: getAppSetGeneratorCount(appSet).toString(),
268272 cell: getAppSetGeneratorCount(appSet).toString(),
269273 },
270- {
271- id: 'generator-type -' + index,
272- cell: getGeneratorType (appSet),
273- },
274+ {
275+ id: 'created-at -' + index,
276+ cell: formatCreationTimestamp (appSet.metadata.creationTimestamp ),
277+ },
274278 {
275279 id: 'actions-' + index,
276280 cell: <ApplicationSetActionsCell appSet={appSet} />,
@@ -339,16 +343,16 @@ const useColumnsDV = (namespace, getSortParams) => {
339343 sort: getSortParams('generators', 3 + i),
340344 },
341345 },
342- {
343- id: 'generator-type ',
344- cell: 'Generator Type ',
345- props: {
346- key: 'generator-type ',
347- 'aria-label': 'generator type ',
348- className: 'pf-m-width-20 ',
349- sort: getSortParams('generator-type ', 4 + i),
350- },
351- },
346+ {
347+ id: 'created-at ',
348+ cell: 'Created At ',
349+ props: {
350+ key: 'created-at ',
351+ 'aria-label': 'created at ',
352+ className: 'pf-m-width-15 ',
353+ sort: getSortParams('created-at ', 4 + i),
354+ },
355+ },
352356 {
353357 id: 'actions',
354358 cell: '',
@@ -410,10 +414,10 @@ export const sortData = (
410414 aValue = getAppSetGeneratorCount(a);
411415 bValue = getAppSetGeneratorCount(b);
412416 break;
413- case 'generator-type ':
414- aValue = getGeneratorType(a );
415- bValue = getGeneratorType(b );
416- break;
417+ case 'created-at ':
418+ aValue = new Date(a.metadata?.creationTimestamp || 0).getTime( );
419+ bValue = new Date(b.metadata?.creationTimestamp || 0).getTime( );
420+ break;
417421 default:
418422 return 0;
419423 }
0 commit comments