@openneuro/app 4.12.0 → 4.12.2

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": "4.12.0",
3
+ "version": "4.12.2",
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.0",
24
- "@openneuro/components": "^4.12.0",
23
+ "@openneuro/client": "^4.12.2",
24
+ "@openneuro/components": "^4.12.2",
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": "611c84329ef63f730878f701aafaa1bc4c703ea4"
107
+ "gitHead": "d36002753b049a7d4d2fc8edd904c57a0bd35596"
108
108
  }
@@ -59,6 +59,7 @@ export const DRAFT_FILES_FRAGMENT = gql`
59
59
  size
60
60
  directory
61
61
  annexed
62
+ urls
62
63
  }
63
64
  }
64
65
  }
@@ -162,6 +163,7 @@ export const SNAPSHOT_FIELDS = gql`
162
163
  size
163
164
  directory
164
165
  annexed
166
+ urls
165
167
  }
166
168
  summary {
167
169
  modalities
@@ -15,6 +15,7 @@ export const DRAFT_FILES_QUERY = gql`
15
15
  size
16
16
  directory
17
17
  annexed
18
+ urls
18
19
  }
19
20
  }
20
21
  }
@@ -31,6 +32,7 @@ export const SNAPSHOT_FILES_QUERY = gql`
31
32
  size
32
33
  directory
33
34
  annexed
35
+ urls
34
36
  }
35
37
  }
36
38
  }
@@ -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
- ? f.filename.split(':')[0]
43
- : f.filename.split(':').slice(0, -1).join(':')
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 '../../__tests__/search-params-ctx.spec'
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 = newParamsCall => {
27
- const merged = { ...searchParams, ...newParamsCall(searchParams) }
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),