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

Edit Collection page #549

Merged
merged 46 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
61f1d38
chore: upgrade js-dataverse version
g-saracca Nov 7, 2024
ada39ff
feat: dropdown ready
g-saracca Nov 7, 2024
aa9a575
feat: navigation
g-saracca Nov 7, 2024
aef90f1
feat: infra and domain
g-saracca Nov 7, 2024
d69359c
feat: dropdown css tweaks
g-saracca Nov 8, 2024
9cd8bea
feat: edit/create collection form reusable
g-saracca Nov 8, 2024
b21977b
refactor: change general info for just edit collection
g-saracca Nov 11, 2024
b8d127b
feat: update locales hooks
g-saracca Nov 11, 2024
776513b
Merge branch 'develop' into feat/545-edit-collection-page
g-saracca Nov 11, 2024
a98e0fa
feat: more useTranslation changes
g-saracca Nov 11, 2024
5aa8f69
chore: change to js-dataverse pr version
g-saracca Nov 11, 2024
8a75f30
feat: update extended collection model and set default values
g-saracca Nov 11, 2024
cfd2e80
feat: update collection in form
g-saracca Nov 11, 2024
3ab4295
test: update tests in progress
g-saracca Nov 11, 2024
ad3a2e3
chore: update js-dataverse version
g-saracca Nov 12, 2024
6b08cdb
feat: change naming
g-saracca Nov 12, 2024
73c25aa
feat: edited alert
g-saracca Nov 12, 2024
a429db8
feat: add stories
g-saracca Nov 12, 2024
19f95eb
feat: add isRootCollection helper
g-saracca Nov 12, 2024
17a0c52
feat: add function to define the default value of the useFromParent c…
g-saracca Nov 12, 2024
1018dbd
feat: control dirty state of blocknames and input levesls unchecked
g-saracca Nov 12, 2024
f5b174b
feat: add getParentCollection utility
g-saracca Nov 13, 2024
ff82b12
feat: more utilities for collection form helper
g-saracca Nov 13, 2024
584f876
feat: dont show host if editing root and correct host collection name
g-saracca Nov 13, 2024
17aef5c
feat: more changes on collection form helper
g-saracca Nov 13, 2024
caf8ce2
feat: check dirty state on every set value of fields
g-saracca Nov 13, 2024
61235fe
feat: check when or not to send block names, input levels and facets
g-saracca Nov 13, 2024
b1adff9
feat: validate that selected facets are not empty
g-saracca Nov 13, 2024
1afcaa8
test: tests in progress
g-saracca Nov 13, 2024
6502c80
tests: complete most of the test cases
g-saracca Nov 14, 2024
21a6eee
test: test dropdown
g-saracca Nov 14, 2024
cf7bb26
test: assert the error getting user permissions
g-saracca Nov 14, 2024
c3146c0
test: improve test coverage
g-saracca Nov 14, 2024
6aec641
test: improve other tests
g-saracca Nov 15, 2024
2b6e9c5
test: update local merged coverage for testing what happens
g-saracca Nov 15, 2024
900f8aa
test: extend get by id comparison
g-saracca Nov 15, 2024
05b9bad
chore: remove todos and logs
g-saracca Nov 15, 2024
5bf0175
lint: ignore hooks deps, add todos to fix them later
g-saracca Nov 15, 2024
ae3f612
fix: use correct boolean
g-saracca Nov 19, 2024
d2ba8ce
chore: update to latest js-dataverse alpha version
g-saracca Nov 22, 2024
3b6e3ee
feat: move CollectionInputLevel to its own file
g-saracca Nov 22, 2024
e7c54f4
feat: add error element to edit collection page
g-saracca Nov 22, 2024
1e1b34d
feat: remove user in condition as collectionUserPermissions already …
g-saracca Nov 22, 2024
c836d0e
test: remove testid and find by text instead
g-saracca Nov 22, 2024
95601e2
feat: add non root editing storybook
g-saracca Nov 25, 2024
b6306f2
test: fix test
g-saracca Nov 25, 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
6,468 changes: 6,400 additions & 68 deletions merged-coverage/lcov.info

Large diffs are not rendered by default.

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-alpha.4",
"@iqss/dataverse-client-javascript": "2.0.0-pr215.f3747d3",
"@iqss/dataverse-design-system": "*",
"@istanbuljs/nyc-config-typescript": "1.0.2",
"@tanstack/react-table": "8.9.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { PropsWithChildren } from 'react'
import { Dropdown } from 'react-bootstrap'

export function DropdownHeader({ children }: PropsWithChildren) {
return <Dropdown.Header>{children}</Dropdown.Header>
interface DropdownHeaderProps {
className?: string
children: React.ReactNode
}

export function DropdownHeader({ className, children }: DropdownHeaderProps) {
return <Dropdown.Header className={className}>{children}</Dropdown.Header>
}
7 changes: 6 additions & 1 deletion public/locales/en/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@
"question": "Are you sure you want to publish your collection? Once you do so it must remain published.",
"error": "There was an error publishing your collection."
},
"publishedAlert": "Your collection is now public."
"publishedAlert": "Your collection is now public.",
"editedAlert": "You have successfully updated your collection!",
"editCollection": {
"edit": "Edit",
"generalInfo": "General Information"
}
}
79 changes: 0 additions & 79 deletions public/locales/en/createCollection.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,4 @@
{
"pageTitle": "Create Collection",
"fields": {
"hostCollection": {
"label": "Host Collection",
"description": "The collection which contains this data.",
"required": "Host Collection is required"
},
"name": {
"label": "Collection Name",
"description": "The project, department, university, professor, or journal this collection will contain data for.",
"required": "Collection Name is required"
},
"affiliation": {
"label": "Affiliation",
"description": "The organization with which this collection is affiliated."
},
"alias": {
"label": "Identifier",
"description": "Short name used for the URL of this collection.",
"required": "Identifier is required",
"invalid": {
"format": "Identifier is not valid. Valid characters are a-Z, 0-9, '_', and '-'.",
"maxLength": "Identifier must be at most {{maxLength}} characters."
},
"suggestion": "Psst... try this"
},
"storage": {
"label": "Storage",
"description": "A storage service to be used for datasets in this collection."
},
"type": {
"label": "Category",
"description": "The type that most closely reflects this collection.",
"required": "Category is required"
},
"description": {
"label": "Description",
"description": "A summary describing the purpose, nature or scope of this collection.",
"subLabel": "This field supports only certain <htmlTooltip>HTML tags</htmlTooltip>.",
"htmlAllowedTags": "<a>, <b>, <blockquote>, <br>, <code>, <del>, <dd>, <dl>, <dt>, <em>, <hr>, <h1>-<h3>, <i>, <img>, <kbd>, <li>, <ol>, <p>, <pre>, <s>, <sup>, <sub>, <strong>, <strike>, <u>, <ul>"
},
"contacts": {
"label": "Email",
"description": "The email address(es) of the contact(s) for the collection.",
"required": "Email is required",
"invalid": "Email is not a valid email"
},
"metadataFields": {
"sectionLabel": "Metadata Fields",
"helperText": "Choose the metadata fields to use in dataset templates and when adding a dataset to this collection.",
"useMetadataFieldsFrom": "Use metadata fields from",
"inputLevelsTable": {
"hideTableAriaLabel": "Hide input levels table",
"requiredByDataverse": "Required by Dataverse",
"hidden": "Hidden",
"optional": "Optional",
"required": "Required",
"conditionallyRequired": "Conditionally Required"
}
},
"browseSearchFacets": {
"label": "Browse/Search Facets",
"helperText": "Choose and order the metadata fields to use as facets when browsing this collection.",
"useBrowseSearchFacetsFrom": "Use browse/search facets from",
"selectedFacets": "Selected"
}
},
"confirmResetModal": {
"title": "Reset Modifications",
"warning": "Are you sure you want to reset the selected metadata fields? If you do this, any customizations (hidden, required, optional) you have done will no longer appear.",
"continue": "Continue",
"cancel": "Cancel"
},
"submitStatus": {
"success": "Collection created successfully."
},
"formButtons": {
"save": "Create Collection",
"cancel": "Cancel"
},
"notAllowedToCreateCollection": "You do not have permissions to create a collection within this collection."
}
8 changes: 8 additions & 0 deletions public/locales/en/editCollection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pageTitle": "Edit Collection",
"notAllowedToEditCollection": "You do not have permissions to edit this collection.",
"infoAlert": {
"heading": "Edit Collection",
"text": "Edit your collection and click Save Changes. Asterisks indicate required fields."
}
}
86 changes: 86 additions & 0 deletions public/locales/en/shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,91 @@
"editMode": "Save Changes"
},
"cancelButton": "Cancel"
},
"collectionForm": {
"fields": {
"hostCollection": {
"label": "Host Collection",
"description": "The collection which contains this data.",
"required": "Host Collection is required"
},
"name": {
"label": "Collection Name",
"description": "The project, department, university, professor, or journal this collection will contain data for.",
"required": "Collection Name is required"
},
"affiliation": {
"label": "Affiliation",
"description": "The organization with which this collection is affiliated."
},
"alias": {
"label": "Identifier",
"description": "Short name used for the URL of this collection.",
"required": "Identifier is required",
"invalid": {
"format": "Identifier is not valid. Valid characters are a-Z, 0-9, '_', and '-'.",
"maxLength": "Identifier must be at most {{maxLength}} characters."
},
"suggestion": "Psst... try this"
},
"storage": {
"label": "Storage",
"description": "A storage service to be used for datasets in this collection."
},
"type": {
"label": "Category",
"description": "The type that most closely reflects this collection.",
"required": "Category is required"
},
"description": {
"label": "Description",
"description": "A summary describing the purpose, nature or scope of this collection.",
"subLabel": "This field supports only certain <htmlTooltip>HTML tags</htmlTooltip>.",
"htmlAllowedTags": "<a>, <b>, <blockquote>, <br>, <code>, <del>, <dd>, <dl>, <dt>, <em>, <hr>, <h1>-<h3>, <i>, <img>, <kbd>, <li>, <ol>, <p>, <pre>, <s>, <sup>, <sub>, <strong>, <strike>, <u>, <ul>"
},
"contacts": {
"label": "Email",
"description": "The email address(es) of the contact(s) for the collection.",
"required": "Email is required",
"invalid": "Email is not a valid email"
},
"metadataFields": {
"sectionLabel": "Metadata Fields",
"helperText": "Choose the metadata fields to use in dataset templates and when adding a dataset to this collection.",
"useMetadataFieldsFrom": "Use metadata fields from",
"inputLevelsTable": {
"hideTableAriaLabel": "Hide input levels table",
"requiredByDataverse": "Required by Dataverse",
"hidden": "Hidden",
"optional": "Optional",
"required": "Required",
"conditionallyRequired": "Conditionally Required"
}
},
"browseSearchFacets": {
"label": "Browse/Search Facets",
"helperText": "Choose and order the metadata fields to use as facets when browsing this collection.",
"useBrowseSearchFacetsFrom": "Use browse/search facets from",
"selectedFacets": "Selected",
"invalid": {
"minLength": "At least one facet must be selected."
}
}
},
"confirmResetModal": {
"title": "Reset Modifications",
"warning": "Are you sure you want to reset the selected metadata fields? If you do this, any customizations (hidden, required, optional) you have done will no longer appear.",
"continue": "Continue",
"cancel": "Cancel"
},
"submitStatus": {
"createSuccess": "Collection created successfully.",
"editSuccess": "Collection updated successfully."
},
"saveButton": {
"createMode": "Create Collection",
"editMode": "Save Changes"
},
"cancelButton": "Cancel"
}
}
6 changes: 6 additions & 0 deletions src/collection/domain/models/Collection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { UpwardHierarchyNode } from '../../../shared/hierarchy/domain/models/UpwardHierarchyNode'
import { CollectionContact } from './CollectionContact'
import { CollectionType } from './CollectionType'

export interface Collection {
id: string
Expand All @@ -8,6 +10,10 @@ export interface Collection {
description?: string
affiliation?: string
inputLevels?: CollectionInputLevel[]
type: CollectionType
contacts: CollectionContact[]
isMetadataBlockRoot: boolean
isFacetRoot: boolean
}

g-saracca marked this conversation as resolved.
Show resolved Hide resolved
export interface CollectionInputLevel {
Expand Down
4 changes: 4 additions & 0 deletions src/collection/domain/models/CollectionContact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface CollectionContact {
email: string
displayOrder: number
}
11 changes: 11 additions & 0 deletions src/collection/domain/models/CollectionType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export enum CollectionType {
RESEARCHERS = 'RESEARCHERS',
RESEARCH_PROJECTS = 'RESEARCH_PROJECTS',
JOURNALS = 'JOURNALS',
ORGANIZATIONS_INSTITUTIONS = 'ORGANIZATIONS_INSTITUTIONS',
TEACHING_COURSES = 'TEACHING_COURSES',
UNCATEGORIZED = 'UNCATEGORIZED',
LABORATORY = 'LABORATORY',
RESEARCH_GROUP = 'RESEARCH_GROUP',
DEPARTMENT = 'DEPARTMENT'
}
1 change: 1 addition & 0 deletions src/collection/domain/repositories/CollectionRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export interface CollectionRepository {
paginationInfo: CollectionItemsPaginationInfo,
searchCriteria?: CollectionSearchCriteria
): Promise<CollectionItemSubset>
edit(collectionIdOrAlias: string, updatedCollection: CollectionDTO): Promise<void>
}
14 changes: 2 additions & 12 deletions src/collection/domain/useCases/DTOs/CollectionDTO.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { CollectionType } from '../../models/CollectionType'

export interface CollectionDTO {
alias: string
name: string
Expand All @@ -10,18 +12,6 @@ export interface CollectionDTO {
inputLevels?: CollectionInputLevelDTO[]
}

export enum CollectionType {
RESEARCHERS = 'RESEARCHERS',
RESEARCH_PROJECTS = 'RESEARCH_PROJECTS',
JOURNALS = 'JOURNALS',
ORGANIZATIONS_INSTITUTIONS = 'ORGANIZATIONS_INSTITUTIONS',
TEACHING_COURSES = 'TEACHING_COURSES',
UNCATEGORIZED = 'UNCATEGORIZED',
LABORATORY = 'LABORATORY',
RESEARCH_GROUP = 'RESEARCH_GROUP',
DEPARTMENT = 'DEPARTMENT'
}

export interface CollectionInputLevelDTO {
datasetFieldName: string
include: boolean
Expand Down
13 changes: 13 additions & 0 deletions src/collection/domain/useCases/editCollection.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { WriteError } from '@iqss/dataverse-client-javascript'
import { CollectionRepository } from '../repositories/CollectionRepository'
import { CollectionDTO } from './DTOs/CollectionDTO'

export async function editCollection(
collectionRepository: CollectionRepository,
updatedCollection: CollectionDTO,
collectionId: string
): Promise<void> {
return collectionRepository.edit(collectionId, updatedCollection).catch((error: WriteError) => {
throw error
})
}
6 changes: 5 additions & 1 deletion src/collection/infrastructure/mappers/JSCollectionMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export class JSCollectionMapper {
jsCollection.alias,
jsCollection.isPartOf
),
inputLevels: jsCollection.inputLevels
inputLevels: jsCollection.inputLevels,
type: jsCollection.type,
contacts: jsCollection.contacts ?? [],
isMetadataBlockRoot: jsCollection.isMetadataBlockRoot,
isFacetRoot: jsCollection.isFacetRoot
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
getCollectionFacets,
getCollectionUserPermissions,
getCollectionItems,
publishCollection
publishCollection,
updateCollection
} from '@iqss/dataverse-client-javascript'
import { JSCollectionMapper } from '../mappers/JSCollectionMapper'
import { CollectionDTO } from '../../domain/useCases/DTOs/CollectionDTO'
Expand Down Expand Up @@ -61,4 +62,8 @@ export class CollectionJSDataverseRepository implements CollectionRepository {
publish(collectionIdOrAlias: number | string): Promise<void> {
return publishCollection.execute(collectionIdOrAlias)
}

edit(collectionIdOrAlias: string, updatedCollection: CollectionDTO): Promise<void> {
return updateCollection.execute(collectionIdOrAlias, updatedCollection)
}
}
2 changes: 1 addition & 1 deletion src/files/domain/models/FilePreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface FilePreview {
ingest: FileIngest
metadata: FileMetadata
permissions: FilePermissions
datasetVersionNumber?: DatasetVersionNumber
datasetVersionNumber: DatasetVersionNumber
releaseOrCreateDate?: Date
someDatasetVersionHasBeenReleased?: boolean
datasetPersistentId?: string
Expand Down
14 changes: 14 additions & 0 deletions src/router/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ const CreateCollectionPage = lazy(() =>
)
)

const EditCollectionPage = lazy(() =>
import('../sections/edit-collection/EditCollectionFactory').then(({ EditCollectionFactory }) => ({
default: () => EditCollectionFactory.create()
}))
)

const CreateDatasetPage = lazy(() =>
import('../sections/create-dataset/CreateDatasetFactory').then(({ CreateDatasetFactory }) => ({
default: () => CreateDatasetFactory.create()
Expand Down Expand Up @@ -130,6 +136,14 @@ export const routes: RouteObject[] = [
),
errorElement: <ErrorPage />
},
{
path: Route.EDIT_COLLECTION,
element: (
<Suspense fallback={<AppLoader />}>
<EditCollectionPage />
</Suspense>
)
},
g-saracca marked this conversation as resolved.
Show resolved Hide resolved
{
path: Route.CREATE_DATASET,
element: (
Expand Down
Loading
Loading