@openneuro/app 4.45.2 → 4.45.4

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.45.2",
3
+ "version": "4.45.4",
4
4
  "description": "React JS web frontend for the OpenNeuro platform.",
5
5
  "license": "MIT",
6
6
  "main": "public/client.js",
@@ -78,5 +78,5 @@
78
78
  "publishConfig": {
79
79
  "access": "public"
80
80
  },
81
- "gitHead": "3746b832effd56d33edb1afe5d427e86b8bcf9c9"
81
+ "gitHead": "9566f3c8776dd550a0fe690f8e979a2d042dd0aa"
82
82
  }
@@ -1,54 +1,70 @@
1
- import React from "react"
1
+ import React, { Suspense } from "react"
2
2
  import PropTypes from "prop-types"
3
- import FileViewerText from "./viewers/file-viewer-text.jsx"
4
- import FileViewerNifti from "./viewers/file-viewer-nifti"
5
- import FileViewerJson from "./viewers/file-viewer-json.jsx"
6
- import FileViewerTsv from "./viewers/file-viewer-tsv.jsx"
7
- import FileViewerCsv from "./viewers/file-viewer-csv.jsx"
8
- import FileViewerHtml from "./viewers/file-viewer-html.jsx"
9
- import { FileViewerNeurosift } from "./viewers/file-viewer-neurosift"
3
+ import { Loading } from "../../components/loading/Loading"
10
4
  import { isNifti } from "./file-types"
11
- import FileViewerMarkdown from "./viewers/file-viewer-markdown"
5
+
6
+ const FileViewerText = React.lazy(() =>
7
+ import("./viewers/file-viewer-text.jsx")
8
+ )
9
+ const FileViewerNifti = React.lazy(() => import("./viewers/file-viewer-nifti"))
10
+ const FileViewerJson = React.lazy(() =>
11
+ import("./viewers/file-viewer-json.jsx")
12
+ )
13
+ const FileViewerTsv = React.lazy(() => import("./viewers/file-viewer-tsv.jsx"))
14
+ const FileViewerCsv = React.lazy(() => import("./viewers/file-viewer-csv.jsx"))
15
+ const FileViewerHtml = React.lazy(() =>
16
+ import("./viewers/file-viewer-html.jsx")
17
+ )
18
+ const FileViewerMarkdown = React.lazy(() =>
19
+ import("./viewers/file-viewer-markdown")
20
+ )
21
+ const FileViewerNeurosift = React.lazy(() =>
22
+ import("./viewers/file-viewer-neurosift").then((module) => ({
23
+ default: module.FileViewerNeurosift,
24
+ }))
25
+ )
12
26
 
13
27
  /**
14
28
  * Choose the right viewer for each file type
15
29
  */
16
30
  const FileViewerType = ({ path, url, data }) => {
17
- if (
18
- path.endsWith("README") ||
19
- path.endsWith("CHANGES") ||
20
- path.endsWith(".bidsignore") ||
21
- path.endsWith(".gitignore") ||
22
- path.endsWith(".txt") ||
23
- path.endsWith(".rst") ||
24
- path.endsWith(".yml") || path.endsWith(".yaml")
25
- ) {
26
- return <FileViewerText data={data} />
27
- } else if (
28
- isNifti(path)
29
- ) {
30
- return <FileViewerNifti imageUrl={url} />
31
- } else if (path.endsWith(".md")) {
32
- return <FileViewerMarkdown data={data} />
33
- } else if (path.endsWith(".json")) {
34
- return <FileViewerJson data={data} />
35
- } else if (path.endsWith(".tsv")) {
36
- return <FileViewerTsv data={data} />
37
- } else if (path.endsWith(".csv")) {
38
- return <FileViewerCsv data={data} />
39
- } else if (path.endsWith(".html")) {
40
- return <FileViewerHtml data={data} />
41
- } else if (path.endsWith(".edf")) {
42
- return <FileViewerNeurosift url={url} filetype="edf" />
43
- } else if (path.endsWith(".nwb")) {
44
- return <FileViewerNeurosift url={url} filetype="nwb" />
45
- } else {
46
- return (
47
- <div className="file-viewer-fallback">
48
- This file must be downloaded to view it.
49
- </div>
50
- )
51
- }
31
+ const viewer = (() => {
32
+ if (
33
+ path.endsWith("README") ||
34
+ path.endsWith("CHANGES") ||
35
+ path.endsWith(".bidsignore") ||
36
+ path.endsWith(".gitignore") ||
37
+ path.endsWith(".txt") ||
38
+ path.endsWith(".rst") ||
39
+ path.endsWith(".yml") ||
40
+ path.endsWith(".yaml")
41
+ ) {
42
+ return <FileViewerText data={data} />
43
+ } else if (isNifti(path)) {
44
+ return <FileViewerNifti imageUrl={url} />
45
+ } else if (path.endsWith(".md")) {
46
+ return <FileViewerMarkdown data={data} />
47
+ } else if (path.endsWith(".json")) {
48
+ return <FileViewerJson data={data} />
49
+ } else if (path.endsWith(".tsv")) {
50
+ return <FileViewerTsv data={data} />
51
+ } else if (path.endsWith(".csv")) {
52
+ return <FileViewerCsv data={data} />
53
+ } else if (path.endsWith(".html")) {
54
+ return <FileViewerHtml data={data} />
55
+ } else if (path.endsWith(".edf")) {
56
+ return <FileViewerNeurosift url={url} filetype="edf" />
57
+ } else if (path.endsWith(".nwb")) {
58
+ return <FileViewerNeurosift url={url} filetype="nwb" />
59
+ } else {
60
+ return (
61
+ <div className="file-viewer-fallback">
62
+ This file must be downloaded to view it.
63
+ </div>
64
+ )
65
+ }
66
+ })()
67
+ return <Suspense fallback={<Loading />}>{viewer}</Suspense>
52
68
  }
53
69
 
54
70
  FileViewerType.propTypes = {
@@ -1,61 +1,83 @@
1
- import React from "react"
1
+ import React, { lazy, Suspense } from "react"
2
2
  import { Navigate, Route, Routes } from "react-router-dom"
3
-
4
- // TODO - Re-enable code splitting these when we can
5
- import DatasetQuery from "./dataset/dataset-query"
6
- //import PreRefactorDatasetProps from './dataset/dataset-pre-refactor-container'
3
+ import { Loading } from "./components/loading/Loading"
7
4
  import { isAdmin } from "./authentication/admin-user.jsx"
8
- import FaqPage from "./pages/faq/faq"
9
- import FrontPageContainer from "./pages/front-page/front-page"
10
- import Admin from "./pages/admin/admin"
11
- import SearchRoutes from "./search/search-routes"
12
- import APIKey from "./pages/api"
13
- import ErrorRoute from "./errors/errorRoute"
14
- import { PETRedirect } from "./pages/pet-redirect"
15
- import Citation from "./pages/citation-page"
16
- import FourOFourPage from "./errors/404page"
17
- import { ImportDataset } from "./pages/import-dataset"
18
- import { DatasetMetadata } from "./pages/metadata/dataset-metadata"
19
- import { TermsPage } from "./pages/terms"
20
- import { ImageAttribution } from "./pages/image-attribution"
21
- import { UserQuery } from "./users/user-query"
22
- import { OrcidLinkPage } from "./pages/orcid-link"
23
- import FourOThreePage from "./errors/403page"
5
+
6
+ const DatasetQuery = lazy(() => import("./dataset/dataset-query"))
7
+ const FaqPage = lazy(() => import("./pages/faq/faq"))
8
+ const FrontPageContainer = lazy(() => import("./pages/front-page/front-page"))
9
+ const Admin = lazy(() => import("./pages/admin/admin"))
10
+ const SearchRoutes = lazy(() => import("./search/search-routes"))
11
+ const APIKey = lazy(() => import("./pages/api"))
12
+ const ErrorRoute = lazy(() => import("./errors/errorRoute"))
13
+ const PETRedirect = lazy(() =>
14
+ import("./pages/pet-redirect").then((module) => ({
15
+ default: module.PETRedirect,
16
+ }))
17
+ )
18
+ const Citation = lazy(() => import("./pages/citation-page"))
19
+ const FourOFourPage = lazy(() => import("./errors/404page"))
20
+ const ImportDataset = lazy(() =>
21
+ import("./pages/import-dataset").then((module) => ({
22
+ default: module.ImportDataset,
23
+ }))
24
+ )
25
+ const DatasetMetadata = lazy(() =>
26
+ import("./pages/metadata/dataset-metadata").then((module) => ({
27
+ default: module.DatasetMetadata,
28
+ }))
29
+ )
30
+ const TermsPage = lazy(() =>
31
+ import("./pages/terms").then((module) => ({ default: module.TermsPage }))
32
+ )
33
+ const ImageAttribution = lazy(() =>
34
+ import("./pages/image-attribution").then((module) => ({
35
+ default: module.ImageAttribution,
36
+ }))
37
+ )
38
+ const UserQuery = lazy(() =>
39
+ import("./users/user-query").then((module) => ({ default: module.UserQuery }))
40
+ )
41
+ const OrcidLinkPage = lazy(() =>
42
+ import("./pages/orcid-link").then((module) => ({
43
+ default: module.OrcidLinkPage,
44
+ }))
45
+ )
46
+ const FourOThreePage = lazy(() => import("./errors/403page"))
24
47
 
25
48
  const AppRoutes: React.VoidFunctionComponent = () => (
26
- <Routes>
27
- <Route path="/" element={<FrontPageContainer />} />
28
- <Route path="/faq" element={<FaqPage />} />
29
- <Route path="/keygen" element={<APIKey />} />
30
- <Route path="/datasets/:datasetId/*" element={<DatasetQuery />} />
31
- <Route path="/search/*" element={<SearchRoutes />} />
32
- <Route
33
- path="/admin/*"
34
- element={isAdmin() ? <Admin /> : <FourOThreePage />}
35
- />
36
- <Route path="/error/*" element={<ErrorRoute />} />
37
- <Route path="/pet" element={<PETRedirect />} />
38
- <Route path="/cite" element={<Citation />} />
39
- <Route path="/terms" element={<TermsPage />} />
40
- <Route path="/image-attribution" element={<ImageAttribution />} />
41
- <Route path="/import" element={<ImportDataset />} />
42
- <Route path="/metadata" element={<DatasetMetadata />} />
43
- <Route path="/public" element={<Navigate to="/search" replace />} />
44
- <Route path="/orcid-link" element={<OrcidLinkPage />} />
45
- <Route
46
- path="/user/:orcid/*"
47
- element={<UserQuery />}
48
- />
49
- <Route
50
- path="/saved"
51
- element={<Navigate to="/search?bookmarks" replace />}
52
- />
53
- <Route
54
- path="/dashboard"
55
- element={<Navigate to="/search?mydatasets" replace />}
56
- />
57
- <Route path="/*" element={<FourOFourPage />} />
58
- </Routes>
49
+ <Suspense fallback={<Loading />}>
50
+ <Routes>
51
+ <Route path="/" element={<FrontPageContainer />} />
52
+ <Route path="/faq" element={<FaqPage />} />
53
+ <Route path="/keygen" element={<APIKey />} />
54
+ <Route path="/datasets/:datasetId/*" element={<DatasetQuery />} />
55
+ <Route path="/search/*" element={<SearchRoutes />} />
56
+ <Route
57
+ path="/admin/*"
58
+ element={isAdmin() ? <Admin /> : <FourOThreePage />}
59
+ />
60
+ <Route path="/error/*" element={<ErrorRoute />} />
61
+ <Route path="/pet" element={<PETRedirect />} />
62
+ <Route path="/cite" element={<Citation />} />
63
+ <Route path="/terms" element={<TermsPage />} />
64
+ <Route path="/image-attribution" element={<ImageAttribution />} />
65
+ <Route path="/import" element={<ImportDataset />} />
66
+ <Route path="/metadata" element={<DatasetMetadata />} />
67
+ <Route path="/public" element={<Navigate to="/search" replace />} />
68
+ <Route path="/orcid-link" element={<OrcidLinkPage />} />
69
+ <Route path="/user/:orcid/*" element={<UserQuery />} />
70
+ <Route
71
+ path="/saved"
72
+ element={<Navigate to="/search?bookmarks" replace />}
73
+ />
74
+ <Route
75
+ path="/dashboard"
76
+ element={<Navigate to="/search?mydatasets" replace />}
77
+ />
78
+ <Route path="/*" element={<FourOFourPage />} />
79
+ </Routes>
80
+ </Suspense>
59
81
  )
60
82
 
61
83
  export default AppRoutes
@@ -3,7 +3,6 @@ import pluralize from "pluralize"
3
3
  import { Loading } from "../components/loading/Loading"
4
4
  import { ValidationResultsDisplay } from "../validation/validation-results"
5
5
  import UploaderContext from "./uploader-context.js"
6
- import { validation } from "../workers/schema.js"
7
6
  import type { ValidationResult } from "@bids/validator/main"
8
7
  import { DatasetIssues } from "@bids/validator/issues"
9
8
 
@@ -80,12 +79,17 @@ class UploadValidator
80
79
  extends React.Component<UploadValidatorProps, UploadValidatorState> {
81
80
  constructor(props) {
82
81
  super(props)
82
+ const schemaValidator = import("../workers/schema.js")
83
83
  this.state = {
84
84
  validating: true,
85
85
  issues: new DatasetIssues(),
86
86
  summary: {},
87
87
  }
88
- validation(Array.from(this.props.files)).then(this.done)
88
+ schemaValidator.then((schemaValidatorModule) => {
89
+ schemaValidatorModule.validation(Array.from(this.props.files)).then(
90
+ this.done,
91
+ )
92
+ })
89
93
  }
90
94
 
91
95
  /**