• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CSCfi / metadata-submitter-frontend / 15132822209

20 May 2025 08:35AM UTC coverage: 47.784% (-0.08%) from 47.859%
15132822209

push

github

Hang Le
Feature/fix formatting (merge commit)

Merge branch 'feature/fix-formatting' into 'main'
* Format all files missed by incorrect format script

* Update precommit for husky v9

* Fix formatting script to include all files

Closes #1033
See merge request https://gitlab.ci.csc.fi/sds-dev/sd-submit/metadata-submitter-frontend/-/merge_requests/1114

Approved-by: Hang Le <lhang@csc.fi>
Co-authored-by: Monika Radaviciute <mradavic@csc.fi>
Merged by Hang Le <lhang@csc.fi>

656 of 963 branches covered (68.12%)

Branch coverage included in aggregate %.

150 of 326 new or added lines in 48 files covered. (46.01%)

5 existing lines in 4 files now uncovered.

6353 of 13705 relevant lines covered (46.36%)

4.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.24
/src/components/SubmissionWizard/WizardComponents/WizardFilesTable.tsx
1
import React, { useState } from "react"
1✔
2

3
import FolderIcon from "@mui/icons-material/Folder"
1✔
4
import Box from "@mui/material/Box"
1✔
5
import Typography from "@mui/material/Typography"
1✔
6
import { GridColDef } from "@mui/x-data-grid"
7
import type { GridSortDirection } from "@mui/x-data-grid"
8
import { uniqBy, upperFirst } from "lodash"
1✔
9
import { useTranslation } from "react-i18next"
1✔
10

11
import DataTable from "components/DataTable"
1✔
12
import type { DataFileRow, File } from "types"
13
import { isFile } from "utils"
1✔
14

15
type FilesTableProps = {
16
  currentFilePath: string
17
  files: File[]
18
  handleClickFileRow: (path: string, name: string) => void
19
}
20

21
const FilesTable: React.FC<FilesTableProps> = props => {
1✔
22
  const { currentFilePath, files, handleClickFileRow } = props
×
23
  const { t } = useTranslation()
×
24

25
  const [page, setPage] = useState<number>(0)
×
26

27
  const sortingModel = [
×
28
    {
×
29
      field: "name",
×
30
      sort: "asc" as GridSortDirection,
×
31
    },
×
32
  ]
33

34
  const columns: GridColDef[] = [
×
35
    {
×
36
      field: "name",
×
37
      headerName: t("dataTable.name"),
×
38
      sortable: true,
×
39
      renderCell: params => {
×
40
        return (
×
41
          <Box
×
42
            display="flex"
×
43
            alignItems="center"
×
44
            height="100%"
×
45
            onClick={() => handleClickFileRow(params.row.id, params.row.name)}
×
46
          >
47
            {!isFile(files, params.row.id) && (
×
48
              <FolderIcon color="primary" fontSize="medium" sx={{ mr: "0.5rem" }} />
×
49
            )}
50
            <Typography component="span">{upperFirst(params.row.name)}</Typography>
×
51
          </Box>
×
52
        )
53
      },
×
54
    },
×
55
    {
×
56
      field: "size",
×
57
      headerName: t("dataTable.size"),
×
58
      type: "number",
×
59
      sortable: true, // TODO: need to convert sizes to humanreadable bytes
×
60
    },
×
61
    {
×
62
      field: "lastModified",
×
63
      headerName: t("dataTable.lastModified"),
×
64
      sortable: true, // TODO when backend is ready
×
65
    },
×
66
  ]
67

68
  const getDisplayingFiles = () => {
×
69
    const displayingFiles = currentFilePath
×
70
      ? files
×
71
          .filter(file => file.path.includes(currentFilePath))
×
72
          .map(file => {
×
73
            let newName = ""
×
74
            let newPath = ""
×
75
            if (file.path.length > currentFilePath.length) {
×
76
              newName = file.path.split(currentFilePath)[1].split("/")[1]
×
77
              newPath = `${currentFilePath}/${newName}`
×
78
            } else {
×
79
              newName = file.name
×
80
              newPath = file.path
×
81
            }
×
82
            return { ...file, path: newPath, name: newName }
×
83
          })
×
84
      : files
×
85
    return uniqBy(displayingFiles, "path")
×
86
  }
×
87

88
  const getRows = (): DataFileRow[] => {
×
89
    const displayingFiles = getDisplayingFiles()
×
NEW
90
    return displayingFiles.map(file => {
×
NEW
91
      return {
×
NEW
92
        id: file.path,
×
NEW
93
        name: file.name,
×
NEW
94
        size: file.bytes,
×
NEW
95
        lastModified: "",
×
NEW
96
      }
×
NEW
97
    })
×
UNCOV
98
  }
×
99

100
  const fetchPageOnChange = (page: number) => {
×
101
    setPage(page)
×
102
  }
×
103

104
  return (
×
105
    <DataTable
×
106
      rows={getRows()}
×
107
      columns={columns}
×
108
      page={page}
×
109
      sortingModel={sortingModel}
×
110
      totalItems={getDisplayingFiles().length}
×
111
      fetchPageOnChange={fetchPageOnChange}
×
112
    />
113
  )
114
}
×
115

116
export default FilesTable
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc