-
Notifications
You must be signed in to change notification settings - Fork 20
Link Collection & Link Dataset #835
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
Open
g-saracca
wants to merge
43
commits into
develop
Choose a base branch
from
feat/361-link-collection-and-link-dataset
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,924
−79
Open
Changes from 35 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
4bc1be8
feat: initial link collection DDD
g-saracca dbea949
feat(DesignSystem): add className prop
g-saracca dfab469
feat: CollectionLinkSelect
g-saracca 76395b7
feat(Design System): add size prop
g-saracca af42829
feat: improve styles
g-saracca 4d39c75
feat: show select only for super user and non root collection
g-saracca 87ecdaf
feat: no collections and only one cases
g-saracca 41831d3
fix: increase right padding to avoid toast content to overlap with to…
g-saracca bac58f6
feat: link collection done
g-saracca 04aacf8
refactor: simplify LinkDatasetButton rendering logic and remove unnec…
g-saracca 40c18f2
feat: link and unlink methods
g-saracca b5123ae
feat: add getCollection Links method
g-saracca c7b6a1b
feat: add getDatasetLinkedCollections method
g-saracca 2dac067
feat: link dataset functionality done
g-saracca 3ace175
fix: add wrapper in toast for responsiveness
g-saracca 8b62c8b
refactor: languages location for linking
g-saracca 1da131c
some tweaks
g-saracca 90efd7a
fix: rename hook
g-saracca 2b1dca9
refactor: remove unused collection links functionality
g-saracca 589b797
feat: link collection stories
g-saracca 8b3e8b9
feat: add stories for link dataset
g-saracca dbc2d99
test: add unit cases for linking collection
g-saracca c197b79
test: add unit cases for linking dataset
g-saracca ce2216f
chore: change js-dv version
g-saracca 650f1ab
feat: add get collections for unlinking to repos
g-saracca 921878a
feat: unlink dataset functionaility
g-saracca 47efad0
feat: unlink dataset btn
g-saracca 176c0ae
test: unlink dataset btn unit tests and refactor link dataset btn tests
g-saracca 9460643
feat: add stories, and move components
g-saracca 7f9f8de
test: try fixing flaky test
g-saracca b095684
feat: get collection links method added, unused
g-saracca 9e23783
feat: add icon to collection and dataset cards, update tests and stor…
g-saracca 1b1f4b7
fix: little tweak to one collection only wording
g-saracca adcd0ae
Merge branch 'develop' into feat/361-link-collection-and-link-dataset
g-saracca 2000392
docs: add to changelog
g-saracca 667762c
Merge branch 'develop' into feat/361-link-collection-and-link-dataset
g-saracca 9f7673f
fix: update package and fix stories
g-saracca f19347f
chore: use pr version
g-saracca 883e780
chore: use js-dv alpha version
g-saracca 764bbed
fix typos and change wording
g-saracca 151ad79
tests: fix after wording change
g-saracca 4821797
Merge branch 'develop' into feat/361-link-collection-and-link-dataset
g-saracca 20fd016
fix lint
g-saracca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline | |
- **DropdownButtonItem:** | ||
- Add `type` prop to allow specifying the type of the element. | ||
- **SelectAdvanced:** Fix word wrapping in options list to prevent overflow and ensure long text is displayed correctly. | ||
- **FormText:** Add `className` prop to allow custom styling. | ||
- **FormInput:** Add `size` prop to allow different input sizes (e.g., 'sm', 'lg'). Defaults to standard size if not specified. | ||
|
||
# [2.0.2](https://github.com/IQSS/dataverse-frontend/compare/@iqss/[email protected]...@iqss/[email protected]) (2024-06-23) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
packages/design-system/src/lib/components/form/form-group/form-element/FormText.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import { ReactNode } from 'react' | ||
import { Form as FormBS } from 'react-bootstrap' | ||
|
||
export function FormText({ children }: { children: ReactNode }) { | ||
return <FormBS.Text muted>{children}</FormBS.Text> | ||
export function FormText({ children, className }: { children: ReactNode; className?: string }) { | ||
return ( | ||
<FormBS.Text muted className={className}> | ||
{children} | ||
</FormBS.Text> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { CollectionSummary } from './CollectionSummary' | ||
|
||
export interface CollectionLinks { | ||
linkedCollections: CollectionSummary[] | ||
collectionsLinkingToThis: CollectionSummary[] | ||
linkedDatasets: { persistentId: string; title: string }[] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface CollectionSummary { | ||
id: number | ||
alias: string | ||
displayName: string | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { CollectionLinks } from '../models/CollectionLinks' | ||
import { CollectionRepository } from '../repositories/CollectionRepository' | ||
|
||
export async function getCollectionLinks( | ||
collectionRepository: CollectionRepository, | ||
collectionIdOrAlias: string | number | ||
): Promise<CollectionLinks> { | ||
return collectionRepository.getLinks(collectionIdOrAlias) | ||
} |
13 changes: 13 additions & 0 deletions
13
src/collection/domain/useCases/getCollectionsForLinking.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { CollectionRepository } from '../repositories/CollectionRepository' | ||
import { CollectionSummary } from '../models/CollectionSummary' | ||
|
||
export type LinkingObjectType = 'collection' | 'dataset' | ||
|
||
export async function getCollectionsForLinking( | ||
collectionRepository: CollectionRepository, | ||
objectType: LinkingObjectType, | ||
id: number | string, | ||
searchTerm?: string | ||
): Promise<CollectionSummary[]> { | ||
return collectionRepository.getForLinking(objectType, id, searchTerm) | ||
} |
12 changes: 12 additions & 0 deletions
12
src/collection/domain/useCases/getCollectionsForUnlinking.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { CollectionRepository } from '../repositories/CollectionRepository' | ||
import { CollectionSummary } from '../models/CollectionSummary' | ||
import { LinkingObjectType } from './getCollectionsForLinking' | ||
|
||
export async function getCollectionsForUnlinking( | ||
collectionRepository: CollectionRepository, | ||
objectType: LinkingObjectType, | ||
id: number | string, | ||
searchTerm?: string | ||
): Promise<CollectionSummary[]> { | ||
return collectionRepository.getForUnlinking(objectType, id, searchTerm) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { CollectionRepository } from '../repositories/CollectionRepository' | ||
|
||
export async function linkCollection( | ||
collectionRepository: CollectionRepository, | ||
linkedCollectionIdOrAlias: number | string, | ||
linkingCollectionIdOrAlias: number | string | ||
): Promise<void> { | ||
return collectionRepository.link(linkedCollectionIdOrAlias, linkingCollectionIdOrAlias) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/dataset/domain/hooks/useGetDatasetLinkedCollections.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { useCallback, useEffect, useState } from 'react' | ||
import { ReadError } from '@iqss/dataverse-client-javascript' | ||
import { JSDataverseReadErrorHandler } from '@/shared/helpers/JSDataverseReadErrorHandler' | ||
import { CollectionSummary } from '@/collection/domain/models/CollectionSummary' | ||
import { DatasetRepository } from '../repositories/DatasetRepository' | ||
import { getDatasetLinkedCollections } from '../useCases/getDatasetLinkedCollections' | ||
|
||
interface useGetDatasetLinkedCollectionsProps { | ||
datasetRepository: DatasetRepository | ||
datasetId: string | number | ||
autoFetch?: boolean | ||
} | ||
|
||
export const useGetDatasetLinkedCollections = ({ | ||
datasetRepository, | ||
datasetId, | ||
autoFetch = true | ||
}: useGetDatasetLinkedCollectionsProps) => { | ||
const [datasetLinkedCollections, setDatasetLinkedCollections] = useState<CollectionSummary[]>([]) | ||
const [isLoadingDatasetLinkedCollections, setIsLoadingDatasetLinkedCollections] = | ||
useState<boolean>(autoFetch) | ||
const [errorGetDatasetLinkedCollections, setErrorGetDatasetLinkedCollections] = useState< | ||
string | null | ||
>(null) | ||
|
||
const fetchDatasetLinkedCollections = useCallback(async () => { | ||
setIsLoadingDatasetLinkedCollections(true) | ||
setErrorGetDatasetLinkedCollections(null) | ||
|
||
try { | ||
const linkedCollections = await getDatasetLinkedCollections(datasetRepository, datasetId) | ||
|
||
setDatasetLinkedCollections(linkedCollections) | ||
} catch (err) { | ||
if (err instanceof ReadError) { | ||
const error = new JSDataverseReadErrorHandler(err) | ||
const formattedError = | ||
error.getReasonWithoutStatusCode() ?? /* istanbul ignore next */ error.getErrorMessage() | ||
|
||
setErrorGetDatasetLinkedCollections(formattedError) | ||
} else { | ||
setErrorGetDatasetLinkedCollections( | ||
'Something went wrong getting the dataset linked collections. Try again later.' | ||
) | ||
} | ||
} finally { | ||
setIsLoadingDatasetLinkedCollections(false) | ||
} | ||
}, [datasetRepository, datasetId]) | ||
|
||
useEffect(() => { | ||
if (autoFetch) { | ||
void fetchDatasetLinkedCollections() | ||
} | ||
}, [autoFetch, fetchDatasetLinkedCollections]) | ||
|
||
return { | ||
datasetLinkedCollections, | ||
isLoadingDatasetLinkedCollections, | ||
errorGetDatasetLinkedCollections, | ||
fetchDatasetLinkedCollections | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.