11import React from 'react' ;
2+ import { format } from 'date-fns' ;
23
3- import { useLeafyGreenTable } from '@leafygreen-ui/table' ;
4+ import {
5+ CellContext ,
6+ LGColumnDef ,
7+ LGTableDataType ,
8+ useLeafyGreenTable ,
9+ } from '@leafygreen-ui/table' ;
410import { Description } from '@leafygreen-ui/typography' ;
511
612import { BasicTable } from '../../HELPERS/BasicTable' ;
713import { useFetchRequiredActionTableData } from '../hooks/useFetchRequiredActionTableData' ;
814import { RequiredActionCard , TitleEm } from '../RequiredActionCard' ;
915
10- const modelApiKeysColumns = [
11- { accessorKey : 'name' , header : 'Key Name' } ,
12- { accessorKey : 'created' , header : 'Created' } ,
16+ const DateCell = (
17+ cellData : CellContext <
18+ LGTableDataType < ModelAPIKeyTableData > ,
19+ Date | undefined
20+ > ,
21+ ) => {
22+ const val = cellData . getValue ( ) as Date | undefined ;
23+
24+ if ( ! val ) return < > Never</ > ;
25+
26+ return < > { format ( val , 'yyyy-MM-dd' ) } </ > ;
27+ } ;
28+
29+ interface ModelAPIKeyTableData {
30+ keyName : string ;
31+ createdDate : Date ;
32+ lastUsedDate ?: Date ;
33+ createdBy : string ;
34+ }
35+
36+ const modelApiKeysColumns : Array < LGColumnDef < ModelAPIKeyTableData > > = [
37+ { accessorKey : 'keyName' , header : 'Key Name' } ,
38+ { accessorKey : 'key' , header : 'Secret key' , cell : ( ) => < > ********</ > } ,
39+ {
40+ accessorKey : 'createdDate' ,
41+ header : 'Created on (UTC)' ,
42+ cell : DateCell ,
43+ } ,
44+ {
45+ accessorKey : 'lastUsedDate' ,
46+ header : 'Last used (UTC)' ,
47+ cell : DateCell ,
48+ } ,
49+ { accessorKey : 'createdBy' , header : 'Created by' } ,
1350] ;
1451
15- const demoModelApiKeysData = [
16- { name : 'api-key-1' , created : '01/15/2025' } ,
17- { name : 'api-key-2' , created : '01/20/2025' } ,
18- { name : 'api-key-3' , created : '01/22/2025' } ,
52+ const demoModelApiKeysData : Array < LGTableDataType < ModelAPIKeyTableData > > = [
53+ {
54+ keyName : 'voyage-api-key-1' ,
55+ createdDate : new Date ( '2019-04-22' ) ,
56+ lastUsedDate : new Date ( ) ,
57+ createdBy : 'Mike Waltzer' ,
58+ } ,
59+ {
60+ keyName : 'voyage-api-key-2' ,
61+ createdDate : new Date ( '2022-08-29' ) ,
62+ lastUsedDate : new Date ( ) ,
63+ createdBy : 'Lauren Fox' ,
64+ } ,
65+ {
66+ keyName : 'voyage-api-key-3' ,
67+ createdDate : new Date ( '2021-06-07' ) ,
68+ createdBy : 'Adam Thompson' ,
69+ } ,
1970] ;
2071
2172export const ModelApiKeysCard = ( ) => {
@@ -30,9 +81,11 @@ export const ModelApiKeysCard = () => {
3081
3182 return (
3283 < RequiredActionCard
84+ isLoading = { isLoading }
85+ loadingTitle = "Checking for Model API keys"
3386 title = {
3487 < >
35- Delete < TitleEm > 3 </ TitleEm > Model API keys
88+ Delete < TitleEm > { tableData ?. length } </ TitleEm > Model API keys
3689 </ >
3790 }
3891 description = {
0 commit comments