@openneuro/app 4.30.2 → 4.31.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.
Files changed (58) hide show
  1. package/package.json +5 -5
  2. package/src/assets/activity-icon.png +0 -0
  3. package/src/assets/icon-archived.png +0 -0
  4. package/src/assets/icon-saved.png +0 -0
  5. package/src/assets/icon-unread.png +0 -0
  6. package/src/client.jsx +1 -1
  7. package/src/scripts/datalad/dataset/dataset-query-fragments.js +4 -14
  8. package/src/scripts/dataset/__tests__/__snapshots__/snapshot-container.spec.tsx.snap +4 -304
  9. package/src/scripts/dataset/components/ValidationBlock.tsx +13 -15
  10. package/src/scripts/dataset/components/__tests__/ValidationBlock.spec.tsx +2 -0
  11. package/src/scripts/dataset/draft-container.tsx +2 -1
  12. package/src/scripts/dataset/files/__tests__/__snapshots__/file-tree.spec.jsx.snap +1 -9
  13. package/src/scripts/dataset/fragments/__tests__/{dataset-alert-draft.spec.tsx → dataset-alert.spec.tsx} +33 -1
  14. package/src/scripts/dataset/fragments/{dataset-alert-draft.tsx → dataset-alert.tsx} +30 -18
  15. package/src/scripts/dataset/routes/delete-page.tsx +72 -39
  16. package/src/scripts/dataset/routes/snapshot.tsx +23 -17
  17. package/src/scripts/dataset/routes/tab-routes-draft.tsx +5 -2
  18. package/src/scripts/dataset/snapshot-container.tsx +11 -0
  19. package/src/scripts/search/__tests__/search-params-ctx.spec.tsx +3 -0
  20. package/src/scripts/search/initial-search-params.tsx +2 -0
  21. package/src/scripts/search/inputs/__tests__/nihselect.spec.tsx +36 -0
  22. package/src/scripts/search/inputs/index.ts +2 -0
  23. package/src/scripts/search/inputs/nih-select.tsx +63 -0
  24. package/src/scripts/search/search-container.tsx +20 -12
  25. package/src/scripts/search/search-params-ctx.tsx +2 -0
  26. package/src/scripts/search/search-routes.tsx +14 -6
  27. package/src/scripts/search/use-search-results.tsx +15 -0
  28. package/src/scripts/types/user-types.ts +72 -0
  29. package/src/scripts/uploader/upload-issues.tsx +2 -2
  30. package/src/scripts/users/__tests__/datasest-card.spec.tsx +201 -0
  31. package/src/scripts/users/__tests__/user-card.spec.tsx +30 -3
  32. package/src/scripts/users/__tests__/user-query.spec.tsx +6 -0
  33. package/src/scripts/users/__tests__/user-routes.spec.tsx +42 -18
  34. package/src/scripts/users/components/user-dataset-filters.tsx +157 -0
  35. package/src/scripts/users/dataset-card.tsx +121 -0
  36. package/src/scripts/users/fragments/query.js +42 -0
  37. package/src/scripts/users/scss/datasetcard.module.scss +153 -0
  38. package/src/scripts/users/scss/usernotifications.module.scss +159 -0
  39. package/src/scripts/users/user-account-view.tsx +1 -12
  40. package/src/scripts/users/user-card.tsx +1 -14
  41. package/src/scripts/users/user-container.tsx +1 -17
  42. package/src/scripts/users/user-datasets-view.tsx +58 -43
  43. package/src/scripts/users/user-notification-accordion.tsx +160 -0
  44. package/src/scripts/users/user-notification-list.tsx +27 -0
  45. package/src/scripts/users/user-notifications-tab-content.tsx +85 -0
  46. package/src/scripts/users/user-notifications-view.tsx +102 -4
  47. package/src/scripts/users/user-query.tsx +6 -14
  48. package/src/scripts/users/user-routes.tsx +18 -19
  49. package/src/scripts/utils/__tests__/user-datasets.spec.tsx +86 -0
  50. package/src/scripts/utils/gtag.js +3 -2
  51. package/src/scripts/utils/user-datasets.tsx +60 -0
  52. package/src/scripts/validation/__tests__/__snapshots__/validation-issues.spec.tsx.snap +1 -122
  53. package/src/scripts/validation/validation-results-query.ts +44 -0
  54. package/src/scripts/validation/validation-results.tsx +31 -7
  55. package/src/scripts/validation/validation.tsx +58 -49
  56. package/src/scripts/workers/schema.worker.ts +2 -7
  57. package/tsconfig.json +1 -2
  58. package/vite.config.js +1 -0
@@ -2,8 +2,10 @@ import React from "react"
2
2
  import { AccordionTab, AccordionWrap } from "@openneuro/components/accordion"
3
3
  import { Issues } from "./validation-issues"
4
4
  import { RadioGroup } from "@openneuro/components/radio"
5
- import type { DatasetIssues } from "@bids/validator/issues"
5
+ import { Loading } from "@openneuro/components/loading"
6
6
  import styled from "@emotion/styled"
7
+ import type { DatasetIssues } from "@bids/validator/issues"
8
+ import { useValidationResults } from "./validation-results-query"
7
9
 
8
10
  const RadioSpan = styled.span`
9
11
  display: flex;
@@ -18,16 +20,18 @@ const RadioSpan = styled.span`
18
20
  `
19
21
 
20
22
  interface ValidationResultsProps {
21
- issues: DatasetIssues
23
+ datasetId: string
24
+ version: string
22
25
  }
23
26
 
24
27
  type ValidationGroupBy = "code" | "location"
25
28
 
26
- /**
27
- * Display ValidationResults with collapsing panels
28
- */
29
- export function ValidationResults(
30
- { issues }: ValidationResultsProps,
29
+ interface ValidationResultsDisplayProps {
30
+ issues: DatasetIssues
31
+ }
32
+
33
+ export function ValidationResultsDisplay(
34
+ { issues }: ValidationResultsDisplayProps,
31
35
  ) {
32
36
  const [groupBy, setGroupBy] = React.useState<ValidationGroupBy>("code")
33
37
  const groupedIssues = issues.groupBy("severity")
@@ -93,4 +97,24 @@ export function ValidationResults(
93
97
  )
94
98
  }
95
99
 
100
+ /**
101
+ * Display ValidationResults with collapsing panels
102
+ */
103
+ export function ValidationResults(
104
+ { datasetId, version }: ValidationResultsProps,
105
+ ) {
106
+ const { issues, loading } = useValidationResults(datasetId, version)
107
+
108
+ if (loading) {
109
+ return (
110
+ <>
111
+ <Loading />
112
+ <span className="message">Loading validation results...</span>
113
+ </>
114
+ )
115
+ } else {
116
+ return <ValidationResultsDisplay issues={issues} />
117
+ }
118
+ }
119
+
96
120
  export default ValidationResults
@@ -2,12 +2,6 @@ import React from "react"
2
2
  import pluralize from "pluralize"
3
3
  import { ValidationPanel } from "./validation-panel"
4
4
  import Results from "./validation-results"
5
- import type { DatasetIssues } from "@bids/validator/issues"
6
-
7
- /**
8
- * These can't be React components due to legacy react-bootstrap
9
- * validHeader, warningHeader, errorHeader
10
- */
11
5
 
12
6
  const validHeader = () => (
13
7
  <div className="super-valid">
@@ -53,79 +47,94 @@ const Valid = () => (
53
47
  )
54
48
 
55
49
  interface WarningsProps {
56
- issues: DatasetIssues
57
- warnings: DatasetIssues
50
+ datasetId: string
51
+ version: string
52
+ warnings: number
58
53
  }
59
54
 
60
- const Warnings = ({ issues, warnings }: WarningsProps) => (
61
- <ValidationPanel heading={warningHeader(warnings.size)}>
55
+ const Warnings = ({ datasetId, version, warnings }: WarningsProps) => (
56
+ <ValidationPanel heading={warningHeader(warnings)}>
62
57
  <div>
63
58
  <span className="message error fade-in">
64
59
  We found{" "}
65
60
  <strong>
66
- {warnings.size + " " + pluralize("Warning", warnings.size)}
61
+ {warnings + " " + pluralize("warning", warnings)}
67
62
  </strong>{" "}
68
63
  in your dataset. You are not required to fix warnings, but doing so will
69
64
  make your dataset more BIDS compliant.
70
65
  </span>
71
66
  </div>
72
67
  <br />
73
- <Results issues={issues} />
68
+ <Results datasetId={datasetId} version={version} />
74
69
  </ValidationPanel>
75
70
  )
76
71
 
77
72
  interface ErrorsProps {
78
- issues: DatasetIssues
79
- errors: DatasetIssues
80
- warnings: DatasetIssues
73
+ datasetId: string
74
+ version: string
75
+ errors: number
76
+ warnings: number
81
77
  }
82
78
 
83
- const Errors = ({ issues, errors }: ErrorsProps) => (
84
- <ValidationPanel heading={errorHeader(errors.size)}>
79
+ const Errors = ({ datasetId, version, errors }: ErrorsProps) => (
80
+ <ValidationPanel heading={errorHeader(errors)}>
85
81
  <span className="message error fade-in">
86
82
  Your dataset is no longer valid. You must fix the{" "}
87
- <strong>{errors.size + " " + pluralize("Error", errors.size)}</strong>
88
- {" "}
83
+ <strong>{errors + " " + pluralize("error", errors)}</strong>{" "}
89
84
  to use all of the site features.
90
85
  </span>
91
86
  <br />
92
- <Results issues={issues} />
87
+ <Results datasetId={datasetId} version={version} />
93
88
  </ValidationPanel>
94
89
  )
95
90
 
96
91
  interface ValidationProps {
97
- issues: DatasetIssues
92
+ datasetId: string
93
+ version?: string
94
+ errors: number
95
+ warnings: number
98
96
  }
99
97
 
100
- export const Validation = ({ issues }: ValidationProps) => {
101
- if (issues) {
102
- const grouped = issues.groupBy("severity")
103
- const warnings = grouped.get("warning")
104
- const errors = grouped.get("error")
105
- if (errors?.size) {
106
- return <Errors issues={issues} errors={errors} warnings={warnings} />
107
- } else if (warnings?.size) {
108
- return <Warnings issues={issues} warnings={warnings} />
109
- } else {
110
- return <Valid />
111
- }
112
- } else {
98
+ export const Validation = (
99
+ { datasetId, version, errors, warnings }: ValidationProps,
100
+ ) => {
101
+ if (errors > 0) {
102
+ return (
103
+ <Errors
104
+ datasetId={datasetId}
105
+ version={version}
106
+ errors={errors}
107
+ warnings={warnings}
108
+ />
109
+ )
110
+ } else if (warnings > 0) {
113
111
  return (
114
- <ValidationPanel
115
- heading={
116
- <div>
117
- <span className="dataset-status ds-warning ds-validation-pending">
118
- <i className="fa fa-circle-o-notch fa-spin" />
119
- Validation Pending
120
- </span>
121
- </div>
122
- }
123
- >
124
- <br />
125
- <p className="ds-validation-pending-message">
126
- The BIDS validator is running. This may take several minutes.
127
- </p>
128
- </ValidationPanel>
112
+ <Warnings datasetId={datasetId} version={version} warnings={warnings} />
129
113
  )
114
+ } else {
115
+ return <Valid />
130
116
  }
131
117
  }
118
+
119
+ /**
120
+ * Display validation as pending
121
+ */
122
+ export function ValidationPending() {
123
+ return (
124
+ <ValidationPanel
125
+ heading={
126
+ <div>
127
+ <span className="dataset-status ds-warning ds-validation-pending">
128
+ <i className="fa fa-circle-o-notch fa-spin" />
129
+ Validation Pending
130
+ </span>
131
+ </div>
132
+ }
133
+ >
134
+ <br />
135
+ <p className="ds-validation-pending-message">
136
+ The BIDS validator is running. This may take several minutes.
137
+ </p>
138
+ </ValidationPanel>
139
+ )
140
+ }
@@ -2,14 +2,9 @@
2
2
  import { fileListToTree, validate } from "@bids/validator/main"
3
3
  import type { ValidationResult } from "@bids/validator/main"
4
4
  import type { Config, ValidatorOptions } from "@bids/validator/options"
5
+ import validatorConfig from "./validator-config.json"
5
6
 
6
- const config: Config = {
7
- error: [
8
- { code: "NO_AUTHORS" },
9
- { code: "SUBJECT_FOLDERS" }, // bids-standard/bids-specification#1928 downgrades to warning
10
- { code: "EMPTY_DATASET_NAME" },
11
- ],
12
- }
7
+ const config: Config = validatorConfig
13
8
 
14
9
  const options: ValidatorOptions = {
15
10
  datasetPath: "browser",
package/tsconfig.json CHANGED
@@ -6,9 +6,8 @@
6
6
  "tsBuildInfoFile": "../../.build-cache/app.tsbuildinfo"
7
7
  },
8
8
  "include": ["./src"],
9
- "files": ["./src/lerna.json"],
9
+ "files": ["./src/lerna.json", "./src/scripts/workers/validator-config.json"],
10
10
  "references": [
11
- { "path": "../openneuro-client" },
12
11
  { "path": "../openneuro-components" }
13
12
  ]
14
13
  }
package/vite.config.js CHANGED
@@ -27,6 +27,7 @@ export default defineConfig({
27
27
  port: 80,
28
28
  host: "0.0.0.0",
29
29
  cors: true,
30
+ allowedHosts: ["app"],
30
31
  },
31
32
  build: {
32
33
  sourcemap: true,