Skip to content

Commit

Permalink
Merge branch 'develop' into 126-add-error-handling-mechanism-to-the-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengShi-1 committed Oct 10, 2024
2 parents d36b172 + 36c7b07 commit 0f573c0
Show file tree
Hide file tree
Showing 29 changed files with 272 additions and 101 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"dependencies": {
"@faker-js/faker": "7.6.0",
"@iqss/dataverse-client-javascript": "2.0.0-pr192.6406015",
"@iqss/dataverse-client-javascript": "2.0.0-alpha.1",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
1 change: 0 additions & 1 deletion public/locales/en/citationBlock.json

This file was deleted.

36 changes: 0 additions & 36 deletions public/locales/en/datasetMetadataForm.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/en/pageNotFound.json

This file was deleted.

4 changes: 0 additions & 4 deletions public/locales/en/pageNumberNotFound.json

This file was deleted.

10 changes: 0 additions & 10 deletions public/locales/en/pagination.json

This file was deleted.

60 changes: 59 additions & 1 deletion public/locales/en/shared.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
{
"asterisksIndicateRequiredFields": "Asterisks indicate required fields",
"remove": "Remove",
"add": "Add"
"add": "Add",
"pageNumberNotFound": {
"heading": "Page Number Not Found",
"message": "The page number you requested does not exist. Please try a different page number."
},
"pageNotFound": {
"heading": "Page Not Found",
"message": "The page you are looking for was not found."
},
"pagination": {
"results_one": "1 {{item}}",
"results_other": "{{start}} to {{end}} of {{formattedCount}} {{item}}s",
"accumulated": {
"one": "{{formattedCount}} {{item}}",
"lessThanPageSize": "{{formattedCount}} {{item}}s",
"moreThanPageSize": "{{accumulated}} of {{formattedCount}} {{item}}s displayed"
},
"pageSize": "{{item}}s per page"
},
"citationBlock": {
"learnAbout": "Learn About",
"standards": "Data Citation Standards"
},
"datasetMetadataForm": {
"metadataTip": {
"title": "Metadata Tip",
"content": "After adding the dataset, click the Edit Dataset button to add more metadata."
},
"validationAlert": {
"title": "Validation Error",
"content": "Required fields were missed or there was a validation error. Please scroll down to see details."
},
"requiredFields": "Asterisks indicate required fields",
"mayBecomeRequired": "One or more of these fields may become required if you add to one or more of these optional fields.",
"field": {
"required": "{{displayName}} is required",
"invalid": {
"url": "{{displayName}} is not a valid URL",
"email": "{{displayName}} is not a valid email",
"int": "{{displayName}} is not a valid integer",
"float": "{{displayName}} is not a valid float",
"date": "{{displayName}} is not a valid date. Please use the format {{dateFormat}}"
}
},
"status": {
"submitting": "Submitting...",
"success": "Form submitted successfully!",
"failed": "Error: Submission failed."
},
"states": {
"submitting": "Form Submitting",
"submissionSuccess": "Form submission successful"
},
"saveButton": {
"createMode": "Save Dataset",
"editMode": "Save Changes"
},
"cancelButton": "Cancel"
}
}
15 changes: 14 additions & 1 deletion src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,20 @@ void i18next
.init({
fallbackLng: 'en',
supportedLngs: ['en'],
ns: [],
ns: [
'shared',
'header',
'footer',
'file',
'astrophysics',
'biomedical',
'citation',
'codeMeta20',
'computationalworkflow',
'geospatial',
'journal',
'socialscience'
],
returnNull: false,
backend: {
loadPath:
Expand Down
3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import App from './App'
import './i18n'
import { LoadingProvider } from './sections/loading/LoadingProvider'
import { ThemeProvider } from '@iqss/dataverse-design-system'
import { AppLoader } from './sections/shared/layout/app-loader/AppLoader'

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement)
root.render(
<React.StrictMode>
<React.Suspense>
<React.Suspense fallback={<AppLoader fullViewport />}>
<LoadingProvider>
<ThemeProvider>
<App />
Expand Down
133 changes: 113 additions & 20 deletions src/router/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,70 @@
import { lazy, Suspense } from 'react'
import { RouteObject } from 'react-router-dom'
import { Route } from '../sections/Route.enum'
import { Layout } from '../sections/layout/Layout'
import { DatasetFactory } from '../sections/dataset/DatasetFactory'
import { CreateDatasetFactory } from '../sections/create-dataset/CreateDatasetFactory'
import { FileFactory } from '../sections/file/FileFactory'
import { CollectionFactory } from '../sections/collection/CollectionFactory'
import { UploadDatasetFilesFactory } from '../sections/upload-dataset-files/UploadDatasetFilesFactory'
import { EditDatasetMetadataFactory } from '../sections/edit-dataset-metadata/EditDatasetMetadataFactory'
import { CreateCollectionFactory } from '../sections/create-collection/CreateCollectionFactory'
import { AccountFactory } from '../sections/account/AccountFactory'
import { ProtectedRoute } from './ProtectedRoute'
import { HomepageFactory } from '../sections/homepage/HomepageFactory'
import { ErrorPage } from '../sections/error-page/ErrorPage'
import { ProtectedRoute } from './ProtectedRoute'
import { AppLoader } from '../sections/shared/layout/app-loader/AppLoader'

const Homepage = lazy(() =>
import('../sections/homepage/HomepageFactory').then(({ HomepageFactory }) => ({
default: () => HomepageFactory.create()
}))
)

const CollectionPage = lazy(() =>
import('../sections/collection/CollectionFactory').then(({ CollectionFactory }) => ({
default: () => CollectionFactory.create()
}))
)

const DatasetPage = lazy(() =>
import('../sections/dataset/DatasetFactory').then(({ DatasetFactory }) => ({
default: () => DatasetFactory.create()
}))
)

const FilePage = lazy(() =>
import('../sections/file/FileFactory').then(({ FileFactory }) => ({
default: () => FileFactory.create()
}))
)

const CreateCollectionPage = lazy(() =>
import('../sections/create-collection/CreateCollectionFactory').then(
({ CreateCollectionFactory }) => ({
default: () => CreateCollectionFactory.create()
})
)
)

const CreateDatasetPage = lazy(() =>
import('../sections/create-dataset/CreateDatasetFactory').then(({ CreateDatasetFactory }) => ({
default: () => CreateDatasetFactory.create()
}))
)

const UploadDatasetFilesPage = lazy(() =>
import('../sections/upload-dataset-files/UploadDatasetFilesFactory').then(
({ UploadDatasetFilesFactory }) => ({
default: () => UploadDatasetFilesFactory.create()
})
)
)

const EditDatasetMetadataPage = lazy(() =>
import('../sections/edit-dataset-metadata/EditDatasetMetadataFactory').then(
({ EditDatasetMetadataFactory }) => ({
default: () => EditDatasetMetadataFactory.create()
})
)
)

const AccountPage = lazy(() =>
import('../sections/account/AccountFactory').then(({ AccountFactory }) => ({
default: () => AccountFactory.create()
}))
)

export const routes: RouteObject[] = [
{
Expand All @@ -21,27 +74,47 @@ export const routes: RouteObject[] = [
children: [
{
path: Route.HOME,
element: HomepageFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<Homepage />
</Suspense>
),
errorElement: <ErrorPage />
},
{
path: Route.COLLECTIONS_BASE,
element: CollectionFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<CollectionPage />
</Suspense>
),
errorElement: <ErrorPage />
},
{
path: Route.COLLECTIONS,
element: CollectionFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<CollectionPage />
</Suspense>
),
errorElement: <ErrorPage />
},
{
path: Route.DATASETS,
element: DatasetFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<DatasetPage />
</Suspense>
),
errorElement: <ErrorPage />
},
{
path: Route.FILES,
element: FileFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<FilePage />
</Suspense>
),
errorElement: <ErrorPage />
},
// 🔐 Protected routes are only accessible to authenticated users
Expand All @@ -51,27 +124,47 @@ export const routes: RouteObject[] = [
children: [
{
path: Route.CREATE_COLLECTION,
element: CreateCollectionFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<CreateCollectionPage />
</Suspense>
),
errorElement: <ErrorPage />
},
{
path: Route.CREATE_DATASET,
element: CreateDatasetFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<CreateDatasetPage />
</Suspense>
),
errorElement: <ErrorPage />
},
{
path: Route.UPLOAD_DATASET_FILES,
element: UploadDatasetFilesFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<UploadDatasetFilesPage />
</Suspense>
),
errorElement: <ErrorPage />
},
{
path: Route.EDIT_DATASET_METADATA,
element: EditDatasetMetadataFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<EditDatasetMetadataPage />
</Suspense>
),
errorElement: <ErrorPage />
},
{
path: Route.ACCOUNT,
element: AccountFactory.create(),
element: (
<Suspense fallback={<AppLoader />}>
<AccountPage />
</Suspense>
),
errorElement: <ErrorPage />
}
]
Expand Down
Loading

0 comments on commit 0f573c0

Please sign in to comment.