Skip to content

Commit f49b7d4

Browse files
authored
Merge pull request #164 from mgalesloot/feature/sort-inventory-age
flux: fix sorting on lastUpdated, source, age
2 parents b096ca6 + f2025f4 commit f49b7d4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

flux/src/common/Table.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ export function Table(props: TableProps) {
9494
case 'lastUpdated':
9595
return {
9696
header: 'Last Updated',
97-
accessorFn: item => <DateLabel format="mini" date={prepareLastUpdated(item)} />,
97+
accessorFn: item => prepareLastUpdated(item),
98+
Cell: ({ cell }: any) => <DateLabel format="mini" date={cell.getValue()} />,
9899
};
99100
case 'age':
100101
return {
@@ -116,6 +117,10 @@ export function Table(props: TableProps) {
116117
return {
117118
header: 'Source',
118119
accessorFn: item => {
120+
const { name } = getSourceNameAndType(item);
121+
return name;
122+
},
123+
Cell: ({ row: {original: item}}: any) => {
119124
const { name, type } = getSourceNameAndType(item);
120125
return (
121126
<Link

flux/src/inventory/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { K8s } from '@kinvolk/headlamp-plugin/lib';
22
import { DateLabel, Link } from '@kinvolk/headlamp-plugin/lib/components/common';
33
import { KubeObject } from '@kinvolk/headlamp-plugin/lib/lib/k8s/cluster';
4-
import React from 'react';
4+
import React, { cloneElement } from 'react';
55
import Table from '../common/Table';
66
import { prepareNameLink } from '../helpers/index';
77

@@ -99,7 +99,8 @@ export function GetResourcesFromInventory(props: {
9999
},
100100
{
101101
header: 'Age',
102-
accessorFn: item => <DateLabel date={item?.metadata?.creationTimestamp} />,
102+
accessorKey: 'metadata.creationTimestamp',
103+
Cell: ({ cell }: any) => <DateLabel date={cell.getValue()} />,
103104
},
104105
]}
105106
/>

0 commit comments

Comments
 (0)