@openneuro/app 3.37.1 → 3.38.0

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": "3.37.1",
3
+ "version": "3.38.0",
4
4
  "description": "React JS web frontend for the OpenNeuro platform.",
5
5
  "license": "MIT",
6
6
  "main": "public/client.js",
@@ -21,8 +21,8 @@
21
21
  "@emotion/react": "^11.4.0",
22
22
  "@emotion/styled": "^10.0.4",
23
23
  "@loadable/component": "^5.7.0",
24
- "@openneuro/client": "^3.37.1",
25
- "@openneuro/components": "^3.37.1",
24
+ "@openneuro/client": "^3.38.0",
25
+ "@openneuro/components": "^3.38.0",
26
26
  "babel-runtime": "^6.26.0",
27
27
  "bids-validator": "1.8.4",
28
28
  "bytes": "^3.0.0",
@@ -130,5 +130,5 @@
130
130
  "publishConfig": {
131
131
  "access": "public"
132
132
  },
133
- "gitHead": "2c1264c00c50a92de2418d91b1436892016c3a6f"
133
+ "gitHead": "7b65148258ba502c562b53665a165a6cdcfca0b2"
134
134
  }
@@ -20,6 +20,8 @@ import ErrorBoundary, {
20
20
  ErrorBoundaryAssertionFailureException,
21
21
  } from '../../errors/errorBoundary.jsx'
22
22
  import DatasetRedirect from '../routes/dataset-redirect'
23
+ import FourOThreePage from '../../errors/403page'
24
+ import FourOFourPage from '../../errors/404page'
23
25
 
24
26
  /**
25
27
  * Generate the dataset page query
@@ -110,7 +112,6 @@ export const DatasetQueryHook = ({ datasetId, draft, history }) => {
110
112
  draft ? getDraftPage : getDatasetPage,
111
113
  {
112
114
  variables: { datasetId },
113
- errorPolicy: 'all',
114
115
  fetchPolicy: 'cache-and-network',
115
116
  nextFetchPolicy: 'cache-first',
116
117
  },
@@ -125,18 +126,19 @@ export const DatasetQueryHook = ({ datasetId, draft, history }) => {
125
126
  })
126
127
  useDraftSubscription(datasetId)
127
128
 
128
- useEffect(() => {
129
- if (error) {
130
- if (data.dataset) {
131
- // show dataset page
129
+ if (loading) return <Spinner text="Loading Dataset" active />
130
+ if (error) {
131
+ if (error.message === 'You do not have access to read this dataset.') {
132
+ return <FourOThreePage />
133
+ } else {
134
+ try {
132
135
  apm.captureError(error)
133
- } else {
134
- // direct to freshdesk
135
- throw error
136
+ } catch (err) {
137
+ // Ignore failure to write to APM
136
138
  }
139
+ return <FourOFourPage />
137
140
  }
138
- }, [error, data])
139
- if (loading) return <Spinner text="Loading Dataset" active />
141
+ }
140
142
 
141
143
  return (
142
144
  <DatasetContext.Provider value={data.dataset}>
@@ -146,7 +148,8 @@ export const DatasetQueryHook = ({ datasetId, draft, history }) => {
146
148
  datasetId,
147
149
  fetchMore,
148
150
  error,
149
- }}>
151
+ }}
152
+ >
150
153
  <DatasetPage dataset={data.dataset} />
151
154
  <FilesSubscription datasetId={datasetId} />
152
155
  </DatasetQueryContext.Provider>
@@ -0,0 +1,45 @@
1
+ import React, { FC } from 'react'
2
+ import { Link } from 'react-router-dom'
3
+ import styled from '@emotion/styled'
4
+
5
+ type ContainerProps = {
6
+ styleContext: string
7
+ }
8
+ const Container = styled.div<ContainerProps>(({ styleContext }) => {
9
+ switch (styleContext) {
10
+ case 'topLevel':
11
+ return {
12
+ margin: '50px 25px',
13
+ }
14
+ case 'dataset':
15
+ return {
16
+ margin: '20px 0',
17
+ }
18
+ }
19
+ })
20
+
21
+ interface FourOThreePageProps {
22
+ redirectRoute?: string
23
+ redirectRouteName?: string
24
+ theme?: string
25
+ }
26
+
27
+ const FourOThreePage: FC<FourOThreePageProps> = ({
28
+ redirectRoute = '/',
29
+ redirectRouteName = 'the home page',
30
+ theme = 'topLevel',
31
+ }) => {
32
+ return (
33
+ <Container styleContext={theme}>
34
+ <h3>
35
+ 403: You do not have access to this page, you may need to sign in.
36
+ </h3>
37
+ <p>
38
+ Click <Link to={redirectRoute}>here</Link> to go to
39
+ {' ' + redirectRouteName}.
40
+ </p>
41
+ </Container>
42
+ )
43
+ }
44
+
45
+ export default FourOThreePage
@@ -21,8 +21,8 @@ import ErrorBoundary, {
21
21
  } from '../../errors/errorBoundary.jsx'
22
22
  import DatasetRedirect from '../../datalad/routes/dataset-redirect'
23
23
  import { trackAnalytics } from '../../utils/datalad'
24
-
25
- //TODO imports
24
+ import FourOFourPage from '../../errors/404page'
25
+ import FourOThreePage from '../../errors/403page'
26
26
 
27
27
  /**
28
28
  * Generate the dataset page query
@@ -126,7 +126,6 @@ export const DatasetQueryHook = ({ datasetId, draft, history }) => {
126
126
  draft ? getDraftPage : getDatasetPage,
127
127
  {
128
128
  variables: { datasetId },
129
- errorPolicy: 'all',
130
129
  fetchPolicy: 'cache-and-network',
131
130
  nextFetchPolicy: 'cache-first',
132
131
  },
@@ -141,17 +140,6 @@ export const DatasetQueryHook = ({ datasetId, draft, history }) => {
141
140
  })
142
141
  useDraftSubscription(datasetId)
143
142
 
144
- useEffect(() => {
145
- if (error) {
146
- if (data.dataset) {
147
- // show dataset page
148
- apm.captureError(error)
149
- } else {
150
- // direct to freshdesk
151
- throw error
152
- }
153
- }
154
- }, [error, data])
155
143
  if (loading)
156
144
  return (
157
145
  <div className="loading-dataset">
@@ -159,6 +147,18 @@ export const DatasetQueryHook = ({ datasetId, draft, history }) => {
159
147
  Loading Dataset
160
148
  </div>
161
149
  )
150
+ if (error) {
151
+ if (error.message === 'You do not have access to read this dataset.') {
152
+ return <FourOThreePage />
153
+ } else {
154
+ try {
155
+ apm.captureError(error)
156
+ } catch (err) {
157
+ // Ignore failure to write to APM
158
+ }
159
+ return <FourOFourPage />
160
+ }
161
+ }
162
162
 
163
163
  return (
164
164
  <DatasetContext.Provider value={data.dataset}>
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import PropTypes from 'prop-types'
3
- import UploaderContext from '../../../uploader/uploader-context.js'
3
+ import UploaderContext from '../../uploader/uploader-context.js'
4
4
  import Tooltip from '../../../common/partials/tooltip.jsx'
5
5
 
6
6
  const UpdateFile = ({
@@ -59,14 +59,6 @@ const searchQuery = gql`
59
59
  ages
60
60
  }
61
61
  latestSnapshot {
62
- summary {
63
- subjectMetadata {
64
- age
65
- }
66
- }
67
- }
68
- draft {
69
- id
70
62
  summary {
71
63
  modalities
72
64
  secondaryModalities