@openneuro/app 5.1.1 → 5.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openneuro/app",
3
- "version": "5.1.1",
3
+ "version": "5.1.3",
4
4
  "description": "React JS web frontend for the OpenNeuro platform.",
5
5
  "license": "MIT",
6
6
  "main": "public/client.js",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "035b0b4544d4b287506ea00aff3b424ed816611a"
82
+ "gitHead": "b1059b286940adb3b60150217e691fe75a895d94"
83
83
  }
@@ -68,6 +68,7 @@ export interface DatasetSnapshot {
68
68
  DatasetDOI?: string | null
69
69
  Name: string
70
70
  }
71
+ readme?: string
71
72
  summary?: {
72
73
  primaryModality?: string
73
74
  }
@@ -81,7 +81,7 @@ const mockDataset = {
81
81
  describe("DatasetCard", () => {
82
82
  it("should render dataset information correctly", () => {
83
83
  render(<DatasetCard dataset={mockDataset} hasEdit={false} />)
84
- expect(screen.getByText("Test Dataset")).toBeInTheDocument()
84
+ expect(screen.getByText("Test Dataset Description")).toBeInTheDocument()
85
85
  expect(screen.getByText("ds000001")).toBeInTheDocument()
86
86
  })
87
87
 
@@ -96,7 +96,7 @@ describe("DatasetCard", () => {
96
96
  it("should show the dataset if not public but hasEdit is true", () => {
97
97
  const privateDataset = { ...mockDataset, public: false }
98
98
  render(<DatasetCard dataset={privateDataset} hasEdit={true} />)
99
- expect(screen.getByText("Test Dataset")).toBeInTheDocument()
99
+ expect(screen.getByText("Test Dataset Description")).toBeInTheDocument()
100
100
  })
101
101
 
102
102
  it("should render activity details correctly", () => {
@@ -98,7 +98,8 @@ export const DatasetCard: React.FC<DatasetCardProps> = (
98
98
  >
99
99
  <h4>
100
100
  <a href={`/datasets/${dataset.id}`}>
101
- {dataset.name ? dataset.name : dataset.id}
101
+ {dataset.latestSnapshot?.description?.Name || dataset.name ||
102
+ dataset.id}
102
103
  </a>
103
104
  </h4>
104
105
  <div className={styles.userDsBody}>
@@ -10,9 +10,19 @@ export function filterAndSortDatasets(
10
10
  { searchQuery, publicFilter, sortOrder }: FilterOptions,
11
11
  ): Dataset[] {
12
12
  const filteredDatasets = datasets.filter((dataset) => {
13
+ const datasetName = dataset.latestSnapshot?.description?.Name ||
14
+ dataset.name
15
+ const datasetAuthors = dataset.latestSnapshot?.description?.Authors || []
16
+ const datasetReadme = dataset.latestSnapshot?.readme || ""
17
+
13
18
  const matchesSearch = searchQuery === "" ||
14
- (dataset.name &&
15
- dataset.name.toLowerCase().includes(searchQuery.toLowerCase())) ||
19
+ (datasetName &&
20
+ datasetName.toLowerCase().includes(searchQuery.toLowerCase())) ||
21
+ datasetAuthors.some((author: string) =>
22
+ author.toLowerCase().includes(searchQuery.toLowerCase())
23
+ ) ||
24
+ (datasetReadme &&
25
+ datasetReadme.toLowerCase().includes(searchQuery.toLowerCase())) ||
16
26
  (dataset.id &&
17
27
  dataset.id.toLowerCase().includes(searchQuery.toLowerCase()))
18
28
 
@@ -30,13 +40,19 @@ export function filterAndSortDatasets(
30
40
  // Move declarations outside the switch block
31
41
  let aUpdated: Date | string
32
42
  let bUpdated: Date | string
43
+ let aName: string
44
+ let bName: string
33
45
 
34
46
  switch (sortOrder) {
35
47
  case "name-asc":
36
- comparisonResult = (a.name || "").localeCompare(b.name || "")
48
+ aName = a.latestSnapshot?.description?.Name || a.name || ""
49
+ bName = b.latestSnapshot?.description?.Name || b.name || ""
50
+ comparisonResult = aName.localeCompare(bName)
37
51
  break
38
52
  case "name-desc":
39
- comparisonResult = (b.name || "").localeCompare(a.name || "")
53
+ aName = a.latestSnapshot?.description?.Name || a.name || ""
54
+ bName = b.latestSnapshot?.description?.Name || b.name || ""
55
+ comparisonResult = bName.localeCompare(aName)
40
56
  break
41
57
  case "date-newest":
42
58
  comparisonResult =