Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/406 add edit dataset metadata form #422

Merged
merged 51 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9bc5bce
chore: remove log of web vitals
g-saracca Jun 10, 2024
055b63e
feat: routing
g-saracca Jun 10, 2024
7b02217
feat: basic view
g-saracca Jun 10, 2024
fe3959d
:Merge branch '407-create-dataset-prefill' into feat/406-add-edit-dat…
g-saracca Jun 10, 2024
f20697e
feat: basic layout
g-saracca Jun 10, 2024
d012e80
feat: improve host collection
g-saracca Jun 12, 2024
52fdc4f
feat: rename and move some elements
g-saracca Jun 12, 2024
0cefebe
feat: rendering form fields
g-saracca Jun 12, 2024
c3b91a6
feat: use own component translations
g-saracca Jun 12, 2024
2036cd5
feat: add page skeleton
g-saracca Jun 13, 2024
9450bf3
feat: Add prefilling of specific fields with user data in MetadataForm
g-saracca Jun 13, 2024
bf22d7b
feat: adding values to metadata blocks info object
g-saracca Jun 13, 2024
2c70c28
feat: form default values on edit mode working :)
g-saracca Jun 14, 2024
8911e5f
feat(DesignSystem): new value prop
g-saracca Jun 14, 2024
63ac8b4
feat: field inputs value
g-saracca Jun 14, 2024
86ae74b
feat: all fields with values rendered in the form
g-saracca Jun 14, 2024
b819a9f
test: fix test, add new missing property
g-saracca Jun 18, 2024
f1dd8a0
feat: refactor props to handle required properly based on rules applied
g-saracca Jun 18, 2024
ee80fe5
feat: fix lint error
g-saracca Jun 18, 2024
7eaa167
Merge branch 'develop' into feat/406-add-edit-dataset-metadata-form
g-saracca Jun 18, 2024
9eed820
feat: domain and infra setup use case
g-saracca Jun 18, 2024
f1f571d
feat: update metadata and show alert
g-saracca Jun 18, 2024
650ca00
feat: update to new naming of imports and add method to mocks repos
g-saracca Jun 19, 2024
16b132f
test: fix date failing on local date
g-saracca Jun 19, 2024
ea8c017
feat: simulate scroll restoring position behaviour
g-saracca Jun 19, 2024
713af46
feat: labels grows height of its content only
g-saracca Jun 19, 2024
888922c
feat: remove scroll restoration
g-saracca Jun 19, 2024
a9cc429
feat: css tweaks
g-saracca Jun 19, 2024
f121953
feat: use reusable form in create dataset, remove old files
g-saracca Jun 19, 2024
16f3cde
chore: update js-dataverse version and css in skeleton
g-saracca Jun 19, 2024
d828dfb
feat: avoid escape interpolation
g-saracca Jun 19, 2024
ca05b6a
feat: tweak skeleton and move error loading outside
g-saracca Jun 19, 2024
4de5fb0
feat: stories in progress
g-saracca Jun 19, 2024
7a0cb03
feat: basic citation creat and edit mode form
g-saracca Jun 19, 2024
b05b0ce
feat: stories done
g-saracca Jun 20, 2024
3eebf76
test: adding specs
g-saracca Jun 20, 2024
68043c3
test: asserting all fields
g-saracca Jun 21, 2024
d353bb0
feat: remove unused locales from create dataset
g-saracca Jun 21, 2024
bc533a7
test: dataset metadata form tests done
g-saracca Jun 21, 2024
2737ea5
test: metadata fields helper tests
g-saracca Jun 24, 2024
54aa2b7
test: add cases for int and float fields
g-saracca Jun 24, 2024
fa45cf8
test: host collection for root coll
g-saracca Jun 24, 2024
1b589b2
Merge branch 'develop' into feat/406-add-edit-dataset-metadata-form
g-saracca Jun 24, 2024
7d0e169
test: improve branches coverage
g-saracca Jun 24, 2024
5ab22cc
chore: remove repeated react-loading-skeleton css imports
g-saracca Jun 24, 2024
df83b50
test: editDatasetMetadata section unit test
g-saracca Jun 24, 2024
bc93ba4
feat: sub field that may become required
g-saracca Jun 26, 2024
efb61d4
test: specs for dependant required fields
g-saracca Jun 26, 2024
2bba5bb
chore: fix lint errors
g-saracca Jun 26, 2024
ae79aac
chore: fix lint warning
g-saracca Jun 26, 2024
6dc38f9
chore: upgrade to latest js-dataverse version and back to unstable tag
g-saracca Jul 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Preview } from '@storybook/react'
import { ThemeProvider } from '@iqss/dataverse-design-system'
import { MemoryRouter } from 'react-router-dom'
import { FakerHelper } from '../tests/component/shared/FakerHelper'
import 'react-loading-skeleton/dist/skeleton.css'

const preview: Preview = {
parameters: {
Expand Down
59 changes: 35 additions & 24 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions 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-pr141.153a56a",
"@iqss/dataverse-client-javascript": "2.0.0-pr155.be01a3f",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand All @@ -38,7 +38,7 @@
"react-infinite-scroll-hook": "4.1.1",
"react-loader-spinner": "5.3.4",
"react-markdown": "8.0.7",
"react-router-dom": "6.8.1",
"react-router-dom": "6.23.1",
"react-topbar-progress-indicator": "4.1.1",
"sass": "1.58.1",
"typescript": "4.9.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ import * as React from 'react'

export interface FormSelectProps
extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
value?: string
isInvalid?: boolean
isValid?: boolean
disabled?: boolean
}

export const FormSelect = React.forwardRef(function FormSelect(
{ isInvalid, isValid, disabled, children, ...props }: PropsWithChildren<FormSelectProps>,
{ value, isInvalid, isValid, disabled, children, ...props }: PropsWithChildren<FormSelectProps>,
ref
) {
return (
<FormBS.Select
value={value}
isInvalid={isInvalid}
isValid={isValid}
disabled={disabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ export interface FormTextAreaProps extends Omit<React.HTMLAttributes<FormInputEl
disabled?: boolean
isValid?: boolean
isInvalid?: boolean
value?: string
}

export const FormTextArea = React.forwardRef(function FormTextArea(
{ name, disabled, isValid, isInvalid, ...props }: FormTextAreaProps,
{ name, disabled, isValid, isInvalid, value, ...props }: FormTextAreaProps,
ref
) {
return (
Expand All @@ -21,6 +22,7 @@ export const FormTextArea = React.forwardRef(function FormTextArea(
name={name}
isValid={isValid}
isInvalid={isInvalid}
value={value}
ref={ref as React.ForwardedRef<HTMLTextAreaElement>}
{...props}
/>
Expand Down
36 changes: 1 addition & 35 deletions public/locales/en/createDataset.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,9 @@
{
"pageTitle": "Create Dataset",
"metadataTip": {
"title": "Metadata Tip",
"content": "After adding the dataset, click the Edit Dataset button to add more metadata."
},
"hostCollection": {
"label": "Host Collection",
"description": "The collection which contains this data.",
"helpText": "Changing the host collection will clear any fields you may have entered data into.",
"buttonLabel": "Edit Host Collection"
},
"requiredFields": "Asterisks indicate required fields",
"validationAlert": {
"title": "Validation Error",
"content": "Required fields were missed or there was a validation error. Please scroll down to see details."
},
"datasetForm": {
"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."
},
"addRowButton": "Add",
"deleteRowButton": "Delete"
},
"datasetFormStates": {
"submitting": "Form Submitting",
"submissionSuccess": "Form submission successful"
},
"saveButton": "Save Dataset",
"cancelButton": "Cancel"
}
}
38 changes: 38 additions & 0 deletions public/locales/en/datasetMetadataForm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"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"
},
"addRowButton": "Add",
"deleteRowButton": "Delete",
"saveButton": {
"createMode": "Save Dataset",
"editMode": "Save Changes"
},
"cancelButton": "Cancel"
}
12 changes: 12 additions & 0 deletions public/locales/en/editDatasetMetadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"breadcrumbActionItem": "Edit Dataset Metadata",
"infoAlert": {
"heading": "Edit Dataset Metadata",
"text": "Add more metadata about this dataset to help others easily find it."
},
"hostCollection": {
"label": "Host Collection",
"description": "The collection which contains this data."
},
"metadata": "Metadata"
}
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { SessionProvider } from './sections/session/SessionProvider'
import { UserJSDataverseRepository } from './users/infrastructure/repositories/UserJSDataverseRepository'
import { DataverseApiAuthMechanism } from '@iqss/dataverse-client-javascript/dist/core/infra/repositories/ApiConfig'
import { BASE_URL } from './config'
import 'react-loading-skeleton/dist/skeleton.css'

if (BASE_URL === '') {
throw Error('VITE_DATAVERSE_BACKEND_URL environment variable should be specified.')
Expand Down
5 changes: 5 additions & 0 deletions src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CreateDatasetFactory } from './sections/create-dataset/CreateDatasetFac
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 { DatasetNonNumericVersion } from './dataset/domain/models/Dataset'

const router = createBrowserRouter(
Expand Down Expand Up @@ -36,6 +37,10 @@ const router = createBrowserRouter(
path: Route.UPLOAD_DATASET_FILES,
element: UploadDatasetFilesFactory.create()
},
{
path: Route.EDIT_DATASET_METADATA,
element: EditDatasetMetadataFactory.create()
},
{
path: Route.FILES,
element: FileFactory.create()
Expand Down
1 change: 1 addition & 0 deletions src/dataset/domain/repositories/DatasetRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface DatasetRepository {
getByPersistentId: (persistentId: string, version?: string) => Promise<Dataset | undefined>
getByPrivateUrlToken: (privateUrlToken: string) => Promise<Dataset | undefined>
create: (dataset: DatasetDTO, collectionId?: string) => Promise<{ persistentId: string }>
updateMetadata: (datasetId: string | number, datasetDTO: DatasetDTO) => Promise<void>
getAllWithCount: (
collectionId: string,
paginationInfo: DatasetPaginationInfo
Expand Down
12 changes: 12 additions & 0 deletions src/dataset/domain/useCases/updateDatasetMetadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DatasetRepository } from '../repositories/DatasetRepository'
import { DatasetDTO } from './DTOs/DatasetDTO'

export function updateDatasetMetadata(
datasetRepository: DatasetRepository,
datasetId: string | number,
updatedDataset: DatasetDTO
): Promise<void> {
return datasetRepository.updateMetadata(datasetId, updatedDataset).catch((error: Error) => {
throw new Error(error.message)
})
}
4 changes: 2 additions & 2 deletions src/dataset/infrastructure/mappers/DatasetDTOMapper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DatasetDTO } from '../../domain/useCases/DTOs/DatasetDTO'
import {
NewDataset as JSDatasetDTO,
NewDatasetMetadataBlockValues as JSMetadataBlocksDTO
DatasetDTO as JSDatasetDTO,
DatasetMetadataBlockValuesDTO as JSMetadataBlocksDTO
} from '@iqss/dataverse-client-javascript'

export class DatasetDTOMapper {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
DatasetPreviewSubset,
createDataset,
CreatedDatasetIdentifiers as JSDatasetIdentifiers,
WriteError
WriteError,
updateDataset
} from '@iqss/dataverse-client-javascript'
import { JSDatasetMapper } from '../mappers/JSDatasetMapper'
import { DatasetPaginationInfo } from '../../domain/models/DatasetPaginationInfo'
Expand Down Expand Up @@ -193,4 +194,12 @@ export class DatasetJSDataverseRepository implements DatasetRepository {
throw new Error(error.message)
})
}

updateMetadata(datasetId: string | number, updatedDataset: DatasetDTO): Promise<void> {
return updateDataset
.execute(datasetId, DatasetDTOMapper.toJSDatasetDTO(updatedDataset))
.catch((error: WriteError) => {
throw new Error(error.message)
})
}
}
6 changes: 0 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import reportWebVitals from './reportWebVitals'
import './i18n'
import { LoadingProvider } from './sections/loading/LoadingProvider'
import { ThemeProvider } from '@iqss/dataverse-design-system'
Expand All @@ -18,8 +17,3 @@ root.render(
</React.Suspense>
</React.StrictMode>
)

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals(console.log)
Loading
Loading