@openneuro/app 4.12.4 → 4.12.5
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/__mocks__/config.ts +3 -0
- package/src/scripts/__utils__/mock-app-shell.tsx +22 -0
- package/src/scripts/common/containers/__tests__/header.spec.tsx +34 -0
- package/src/scripts/common/containers/header.tsx +5 -14
- package/src/scripts/dataset/routes/__tests__/deprecate-snapshot-page.spec.tsx +12 -0
- package/src/scripts/dataset/routes/deprecate-snapshot-page.tsx +9 -2
- package/src/scripts/dataset/routes/tab-routes-snapshot.tsx +9 -1
- package/src/scripts/uploader/uploader-view.jsx +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openneuro/app",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.5",
|
|
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.5",
|
|
24
|
+
"@openneuro/components": "^4.12.5",
|
|
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": "0c79489a3f2e040dc07966c888fe49aba5b1c4b4"
|
|
108
108
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
3
|
+
import { MockedProvider } from '@apollo/client/testing'
|
|
4
|
+
import { SearchParamsCtx } from '../search/search-params-ctx'
|
|
5
|
+
import { UserModalOpenCtx } from '../utils/user-login-modal-ctx'
|
|
6
|
+
import initialSearchParams from '../search/initial-search-params'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Reusable shell component that provides any context required by major component trees
|
|
10
|
+
*/
|
|
11
|
+
export const MockAppShell = ({ children, route = '/' }) => (
|
|
12
|
+
<MockedProvider>
|
|
13
|
+
<SearchParamsCtx.Provider
|
|
14
|
+
value={{
|
|
15
|
+
searchParams: initialSearchParams,
|
|
16
|
+
}}>
|
|
17
|
+
<UserModalOpenCtx.Provider value={false}>
|
|
18
|
+
<MemoryRouter initialEntries={[route]}>{children}</MemoryRouter>
|
|
19
|
+
</UserModalOpenCtx.Provider>
|
|
20
|
+
</SearchParamsCtx.Provider>
|
|
21
|
+
</MockedProvider>
|
|
22
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { MockAppShell } from '../../../__utils__/mock-app-shell'
|
|
3
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react'
|
|
4
|
+
import { HeaderContainer } from '../header'
|
|
5
|
+
|
|
6
|
+
jest.mock(
|
|
7
|
+
'../../../uploader/uploader-view.jsx',
|
|
8
|
+
() => () => 'mocked UploaderView',
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
const mockNavigate = jest.fn()
|
|
12
|
+
|
|
13
|
+
jest.mock('react-router-dom', () => {
|
|
14
|
+
const reactRouterDom = jest.requireActual('react-router-dom')
|
|
15
|
+
return {
|
|
16
|
+
...reactRouterDom,
|
|
17
|
+
useNavigate: () => mockNavigate,
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
describe('HeaderContainer component', () => {
|
|
22
|
+
it('navigates prepopulated search when you use the home page search box', async () => {
|
|
23
|
+
render(<HeaderContainer />, { wrapper: MockAppShell })
|
|
24
|
+
const searchbox = screen.getByRole('textbox')
|
|
25
|
+
const button = screen.getByLabelText('Search')
|
|
26
|
+
await fireEvent.change(searchbox, { target: { value: 'test argument' } })
|
|
27
|
+
await fireEvent.click(button)
|
|
28
|
+
await waitFor(() =>
|
|
29
|
+
expect(mockNavigate).toHaveBeenCalledWith(
|
|
30
|
+
'/search?query={"keywords":["test argument"]}',
|
|
31
|
+
),
|
|
32
|
+
)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -5,8 +5,6 @@ import UploadProgress from '../../uploader/upload-progress.jsx'
|
|
|
5
5
|
import { Header, LandingExpandedHeader } from '@openneuro/components/header'
|
|
6
6
|
import { Input } from '@openneuro/components/input'
|
|
7
7
|
import ModalitySelect from '../../search/inputs/modality-select'
|
|
8
|
-
import { SearchParamsCtx } from '../../search/search-params-ctx'
|
|
9
|
-
import initialSearchParams from '../../search/initial-search-params'
|
|
10
8
|
import { UserModalOpenCtx } from '../../utils/user-login-modal-ctx'
|
|
11
9
|
import { useLocation, useNavigate } from 'react-router-dom'
|
|
12
10
|
import { useCookies } from 'react-cookie'
|
|
@@ -18,7 +16,8 @@ import loginUrls from '../../authentication/loginUrls'
|
|
|
18
16
|
import UploaderView from '../../uploader/uploader-view.jsx'
|
|
19
17
|
import UploadButton from '../../uploader/upload-button.jsx'
|
|
20
18
|
import UploadProgressButton from '../../uploader/upload-progress-button.jsx'
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
export const HeaderContainer: FC = () => {
|
|
22
21
|
const navigate = useNavigate()
|
|
23
22
|
|
|
24
23
|
const { pathname: currentPath } = useLocation()
|
|
@@ -27,23 +26,18 @@ const HeaderContainer: FC = () => {
|
|
|
27
26
|
const [cookies] = useCookies()
|
|
28
27
|
const profile = getUnexpiredProfile(cookies)
|
|
29
28
|
|
|
30
|
-
const { setSearchParams } = useContext(SearchParamsCtx)
|
|
31
29
|
const { userModalOpen, setUserModalOpen } = useContext(UserModalOpenCtx)
|
|
32
30
|
|
|
33
31
|
const [newKeyword, setNewKeyword, newKeywordRef] = useState('')
|
|
34
32
|
|
|
35
33
|
const handleSubmit = () => {
|
|
36
|
-
|
|
37
|
-
setSearchParams(() => ({
|
|
38
|
-
...initialSearchParams,
|
|
34
|
+
const query = JSON.stringify({
|
|
39
35
|
keywords: newKeywordRef.current ? [newKeywordRef.current] : [],
|
|
40
|
-
})
|
|
36
|
+
})
|
|
41
37
|
setNewKeyword('')
|
|
42
|
-
navigate(
|
|
38
|
+
navigate(`/search?query=${query}`)
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
const clearSearchParams = () => setSearchParams(initialSearchParams)
|
|
46
|
-
|
|
47
41
|
const toggleLoginModal = (): void => {
|
|
48
42
|
setUserModalOpen(prevState => ({
|
|
49
43
|
...prevState,
|
|
@@ -134,9 +128,6 @@ const HeaderContainer: FC = () => {
|
|
|
134
128
|
onSearch={() => {
|
|
135
129
|
handleSubmit()
|
|
136
130
|
}}
|
|
137
|
-
clearSearchParams={() => {
|
|
138
|
-
clearSearchParams()
|
|
139
|
-
}}
|
|
140
131
|
/>
|
|
141
132
|
)}
|
|
142
133
|
/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
import { DeprecateSnapshotPage } from '../deprecate-snapshot-page'
|
|
4
|
+
|
|
5
|
+
describe('DeprecateSnapshotPage component', () => {
|
|
6
|
+
it('renders accession number and tag', () => {
|
|
7
|
+
render(<DeprecateSnapshotPage datasetId="ds000001" snapshotTag="1.0.0" />)
|
|
8
|
+
expect(
|
|
9
|
+
screen.getByText(/Deprecate ds000001 version 1\.0\.0/),
|
|
10
|
+
).toBeInTheDocument()
|
|
11
|
+
})
|
|
12
|
+
})
|
|
@@ -6,8 +6,15 @@ import LoggedIn from '../../authentication/logged-in.jsx'
|
|
|
6
6
|
import { DatasetPageBorder } from './styles/dataset-page-border'
|
|
7
7
|
import { HeaderRow3 } from './styles/header-row'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
interface DeprecateSnapshotProps {
|
|
10
|
+
datasetId: string
|
|
11
|
+
snapshotTag: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const DeprecateSnapshotPage = ({
|
|
15
|
+
datasetId,
|
|
16
|
+
snapshotTag,
|
|
17
|
+
}: DeprecateSnapshotProps): React.ReactElement => {
|
|
11
18
|
const [reason, setReason] = useState('')
|
|
12
19
|
|
|
13
20
|
return (
|
|
@@ -27,7 +27,15 @@ export const TabRoutesSnapshot = ({ dataset, snapshot }) => {
|
|
|
27
27
|
path="derivatives"
|
|
28
28
|
element={<Derivatives derivatives={dataset.derivatives} />}
|
|
29
29
|
/>
|
|
30
|
-
<Route
|
|
30
|
+
<Route
|
|
31
|
+
path="deprecate"
|
|
32
|
+
element={
|
|
33
|
+
<DeprecateSnapshotPage
|
|
34
|
+
datasetId={dataset.id}
|
|
35
|
+
snapshotTag={snapshot.tag}
|
|
36
|
+
/>
|
|
37
|
+
}
|
|
38
|
+
/>
|
|
31
39
|
<Route path="file-display/:filePath" element={<FileDisplayRoute />} />
|
|
32
40
|
<Route path="metadata" element={<AddMetadata dataset={dataset} />} />
|
|
33
41
|
</Routes>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import BlockNavigation from '../common/partials/block-navigation.jsx'
|
|
3
|
-
import UploaderContext from './uploader-context.js'
|
|
4
3
|
import UploaderSetupRoutes from './uploader-setup-routes.jsx'
|
|
5
4
|
import UploaderStatusRoutes from './uploader-status-routes.jsx'
|
|
6
5
|
|