@openneuro/app 4.12.1 → 4.12.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 +4 -4
- package/src/scripts/datalad/dataset/dataset-query-fragments.js +2 -0
- package/src/scripts/dataset/files/file-tree-unloaded-directory.jsx +2 -0
- package/src/scripts/dataset/files/file-tree.tsx +3 -2
- package/src/scripts/search/__helpers__/search-render.tsx +15 -0
- package/src/scripts/search/__tests__/search-params-ctx.spec.tsx +26 -12
- package/src/scripts/search/inputs/__tests__/sort-by-select.spec.tsx +1 -1
- package/src/scripts/search/search-params-ctx.tsx +8 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/app",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.3",
|
|
4
4
|
"description": "React JS web frontend for the OpenNeuro platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "public/client.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@emotion/react": "11.6.0",
|
|
21
21
|
"@emotion/styled": "11.6.0",
|
|
22
22
|
"@niivue/niivue": "0.23.1",
|
|
23
|
-
"@openneuro/client": "^4.12.
|
|
24
|
-
"@openneuro/components": "^4.12.
|
|
23
|
+
"@openneuro/client": "^4.12.3",
|
|
24
|
+
"@openneuro/components": "^4.12.3",
|
|
25
25
|
"bids-validator": "1.9.9",
|
|
26
26
|
"bytes": "^3.0.0",
|
|
27
27
|
"comlink": "^4.0.5",
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
107
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "dbd0dfc1617d3782c00f225ae81fdf2cc1a88108"
|
|
108
108
|
}
|
|
@@ -37,10 +37,11 @@ export function fileTreeLevels(
|
|
|
37
37
|
if (path === '' ? f.filename.includes(':') : lowerPath.includes(':')) {
|
|
38
38
|
// At the top level, use the directory component (first segment)
|
|
39
39
|
// Below that, use all paths before the filename (sub-01:anat) for (sub-01:anat:sub-01_T1w.nii.gz)
|
|
40
|
+
const components = f.filename.split(':')
|
|
40
41
|
const childPath =
|
|
41
42
|
path === ''
|
|
42
|
-
?
|
|
43
|
-
:
|
|
43
|
+
? components[0]
|
|
44
|
+
: components.slice(0, path.split(':').length + 1).join(':')
|
|
44
45
|
if (childFiles.hasOwnProperty(childPath)) {
|
|
45
46
|
childFiles[childPath].push(f)
|
|
46
47
|
} else {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { SearchParamsCtx } from '../search-params-ctx'
|
|
3
|
+
import { render } from '@testing-library/react'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Render with SearchParamsCtx state
|
|
7
|
+
*/
|
|
8
|
+
export const searchRender = (ui, { providerProps, ...renderOptions }) => {
|
|
9
|
+
return render(
|
|
10
|
+
<SearchParamsCtx.Provider {...providerProps}>
|
|
11
|
+
{ui}
|
|
12
|
+
</SearchParamsCtx.Provider>,
|
|
13
|
+
renderOptions,
|
|
14
|
+
)
|
|
15
|
+
}
|
|
@@ -2,21 +2,10 @@ import React from 'react'
|
|
|
2
2
|
import { render, screen, fireEvent } from '@testing-library/react'
|
|
3
3
|
import { SearchParamsProvider, SearchParamsCtx } from '../search-params-ctx'
|
|
4
4
|
import AuthorInput from '../inputs/author-input'
|
|
5
|
+
import initialSearchParams from '../initial-search-params'
|
|
5
6
|
import { MemoryRouter } from 'react-router-dom'
|
|
6
7
|
import '@testing-library/jest-dom'
|
|
7
8
|
|
|
8
|
-
/**
|
|
9
|
-
* Render with SearchParamsCtx state
|
|
10
|
-
*/
|
|
11
|
-
export const searchRender = (ui, { providerProps, ...renderOptions }) => {
|
|
12
|
-
return render(
|
|
13
|
-
<SearchParamsCtx.Provider {...providerProps}>
|
|
14
|
-
{ui}
|
|
15
|
-
</SearchParamsCtx.Provider>,
|
|
16
|
-
renderOptions,
|
|
17
|
-
)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
9
|
describe('SearchParamsProvider', () => {
|
|
21
10
|
it('restores URL searchParams state', () => {
|
|
22
11
|
const route = '/search?query={"authors"%3A["Test+Author"]}'
|
|
@@ -61,4 +50,29 @@ describe('SearchParamsProvider', () => {
|
|
|
61
50
|
'Received: Test Author, New Author',
|
|
62
51
|
)
|
|
63
52
|
})
|
|
53
|
+
it('setSearchParams is callable with object argument', () => {
|
|
54
|
+
const route = '/search?query={"authors"%3A["Test+Author"]}'
|
|
55
|
+
const wrapper = ({ children }) => (
|
|
56
|
+
<MemoryRouter initialEntries={[route]}>
|
|
57
|
+
<SearchParamsProvider>{children}</SearchParamsProvider>
|
|
58
|
+
</MemoryRouter>
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
let setSearchParams
|
|
62
|
+
|
|
63
|
+
render(
|
|
64
|
+
<SearchParamsCtx.Consumer>
|
|
65
|
+
{value => {
|
|
66
|
+
setSearchParams = value.setSearchParams
|
|
67
|
+
return <span>Received: {value.searchParams.authors.pop()}</span>
|
|
68
|
+
}}
|
|
69
|
+
</SearchParamsCtx.Consumer>,
|
|
70
|
+
{ wrapper },
|
|
71
|
+
)
|
|
72
|
+
expect(screen.getByText(/^Received:/).textContent).toBe(
|
|
73
|
+
'Received: Test Author',
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
expect(() => setSearchParams(initialSearchParams)).not.toThrow()
|
|
77
|
+
})
|
|
64
78
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { screen } from '@testing-library/react'
|
|
3
|
-
import { searchRender } from '../../
|
|
3
|
+
import { searchRender } from '../../__helpers__/search-render'
|
|
4
4
|
import SortBySelect from '../sort-by-select'
|
|
5
5
|
import initialSearchParams from '../../initial-search-params'
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { createContext, useContext, FC, ReactNode } from 'react'
|
|
2
2
|
import { useSearchParams } from 'react-router-dom'
|
|
3
|
-
import initialSearchParams from './initial-search-params'
|
|
3
|
+
import initialSearchParams, { SearchParams } from './initial-search-params'
|
|
4
4
|
|
|
5
5
|
export const SearchParamsCtx = createContext(null)
|
|
6
6
|
|
|
@@ -23,8 +23,13 @@ export const SearchParamsProvider: FC<SearchParamsProviderProps> = ({
|
|
|
23
23
|
console.error(err)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const setSearchParams =
|
|
27
|
-
|
|
26
|
+
const setSearchParams = (
|
|
27
|
+
newParams: SearchParams | ((prevState: SearchParams) => SearchParams),
|
|
28
|
+
): void => {
|
|
29
|
+
const merged =
|
|
30
|
+
typeof newParams == 'function'
|
|
31
|
+
? { ...searchParams, ...newParams(searchParams) }
|
|
32
|
+
: { ...searchParams, ...newParams }
|
|
28
33
|
setSearch(
|
|
29
34
|
{
|
|
30
35
|
query: JSON.stringify(merged),
|