@@ -6,17 +6,16 @@ import {
6
6
} from "../../../../../utils/sortButton" ;
7
7
8
8
interface FilesTableProps {
9
- all_files : any [ ] ;
9
+ allFiles : any [ ] ;
10
10
}
11
11
12
12
/**
13
13
* This function creates the schema for the file summary table,
14
14
* which is one of three tables in the dataset details view.
15
15
* @param props - Object containing the data and details.
16
- * @param fileSize - File size in bytes to be displayed on table
17
16
* @returns The table definition object that includes table content, button text and definitions.
18
17
*/
19
- export const FilesTable = ( props : FilesTableProps , fileSize : number ) => {
18
+ export const FilesTable = ( props : FilesTableProps ) => {
20
19
const [ sortDefinition , setSortDefinition ] = useState < {
21
20
key : number ;
22
21
order : number ;
@@ -25,25 +24,27 @@ export const FilesTable = (props: FilesTableProps, fileSize: number) => {
25
24
order : 0 ,
26
25
} ) ;
27
26
27
+ const allFiles = props . allFiles || [ ] ;
28
+
28
29
let filesTable : TableFields [ ] = [
29
30
{
30
31
header : "File ID" ,
31
- data : props . all_files . map ( ( x ) => x . accession ) ,
32
+ data : allFiles . map ( ( x ) => x . accession ) ,
32
33
cssClasses : "text-break" ,
33
34
} ,
34
35
{
35
36
header : "File name" ,
36
- data : props . all_files . map ( ( x ) => x . name ) ,
37
+ data : allFiles . map ( ( x ) => x . name ) ,
37
38
cssClasses : "text-break" ,
38
39
} ,
39
40
{
40
41
header : "File Type" ,
41
- data : props . all_files . map ( ( x ) => x . format ?. toUpperCase ( ) ) ,
42
+ data : allFiles . map ( ( x ) => x . format ?. toUpperCase ( ) ) ,
42
43
cssClasses : "" ,
43
44
} ,
44
45
{
45
46
header : "File Origin" ,
46
- data : props . all_files . map ( ( x ) => x . file_category ) ,
47
+ data : allFiles . map ( ( x ) => x . file_category ) ,
47
48
cssClasses : "" ,
48
49
} ,
49
50
] ;
@@ -54,10 +55,9 @@ export const FilesTable = (props: FilesTableProps, fileSize: number) => {
54
55
55
56
const filesTableDef : SDSVTableDefinition = {
56
57
table : filesTable ,
57
- buttonText :
58
- props . all_files !== null
59
- ? "File Summary (" + props . all_files . length + " files)"
60
- : "File Summary" ,
58
+ buttonText : allFiles
59
+ ? "File Summary (" + allFiles . length + " files)"
60
+ : "File Summary (0 files)" ,
61
61
sortDefinition : sortDefinition ,
62
62
setSortDefinition : setSortDefinition ,
63
63
sortedData : sortedData ,
0 commit comments