Avoid props drilling for DatasetRepository#970
Open
ChengShi-1 wants to merge 6 commits intodevelopfrom
Open
Conversation
…ng-for-datasetrepository
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces DatasetRepository prop drilling by moving datasetRepository into the shared RepositoriesProvider context and updating components, tests, factories, and Storybook stories to consume it via a new useDatasetRepositories() hook.
Changes:
- Extend
RepositoriesProviderto includedatasetRepositoryand adduseDatasetRepositories(). - Refactor many UI components to stop receiving
datasetRepositoryvia props and instead read it from context. - Update Cypress component tests and Storybook stories to wrap renders with repository providers; bump app version to
0.3.0and@iqss/dataverse-client-javascriptto2.2.0.
Reviewed changes
Copilot reviewed 123 out of 124 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e-integration/integration/datasets/DatasetJSDataverseRepository.spec.ts | Strengthens dataset equality assertions in e2e integration coverage. |
| tests/component/sections/upload-dataset-files/UploadDatasetFiles.spec.tsx | Wraps test renders with repository context helper. |
| tests/component/sections/shared/file-uploader/FileUploader.spec.tsx | Switches to context-based repository injection in tests. |
| tests/component/sections/shared/citation/CitationDownloadButton.spec.tsx | Uses WithRepositories wrapper instead of passing datasetRepository prop. |
| tests/component/sections/replace-file/ReplaceFile.spec.tsx | Introduces repository wrapper helper (currently missing a dataset repo in one place). |
| tests/component/sections/file/File.spec.tsx | Updates file page tests to use context-provided dataset repository. |
| tests/component/sections/edit-dataset-terms/EditTermsOfAccess.spec.tsx | Removes datasetRepository prop usage; uses provider wrapper. |
| tests/component/sections/edit-dataset-terms/EditLicenseAndTerms.spec.tsx | Removes datasetRepository prop usage; uses provider wrapper. |
| tests/component/sections/edit-dataset-terms/EditDatasetTerms.spec.tsx | Adjusts tests to reflect new context injection. |
| tests/component/sections/edit-dataset-metadata/EditDatasetMetadata.spec.tsx | Updates tests for metadata edit page to rely on context for dataset repo. |
| tests/component/sections/dataset/dataset-versions/DatasetVersions.spec.tsx | Wraps dataset versions tests with repository provider. |
| tests/component/sections/dataset/dataset-metrics/DatasetMetrics.spec.tsx | Wraps metrics tests with repository provider and removes repo prop. |
| tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/file-options-menu/FileOptionsMenu.spec.tsx | Updates file options menu tests for context-based repository usage. |
| tests/component/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/FileActionButtons.spec.tsx | Removes dataset repo prop and uses provider wrapper. |
| tests/component/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesMenu.spec.tsx | Removes dataset repo prop and uses provider wrapper. |
| tests/component/sections/dataset/dataset-files/files-table/file-actions/FileActionsHeader.spec.tsx | Removes dataset repo prop and uses provider wrapper. |
| tests/component/sections/dataset/dataset-files/files-table/FilesTable.spec.tsx | Removes dataset repo prop and uses provider wrapper. |
| tests/component/sections/dataset/dataset-citation/DatasetCitation.spec.tsx | Removes dataset repo prop and uses provider wrapper. |
| tests/component/sections/dataset/dataset-action-buttons/unlink-dataset-button/UnlinkDatasetButton.spec.tsx | Uses provider wrapper to supply dataset repo via context. |
| tests/component/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.spec.tsx | Uses provider wrapper to supply dataset repo via context. |
| tests/component/sections/dataset/dataset-action-buttons/link-dataset-button/LinkDatasetButton.spec.tsx | Uses provider wrapper to supply dataset repo via context. |
| tests/component/sections/dataset/dataset-action-buttons/edit-dataset-menu/EditDatasetMenu.spec.tsx | Uses provider wrapper and removes dataset repo prop. |
| tests/component/sections/dataset/dataset-action-buttons/edit-dataset-menu/DeleteDraftDatasetButton.spec.tsx | Uses provider wrapper and removes dataset repo prop. |
| tests/component/sections/dataset/dataset-action-buttons/edit-dataset-menu/DeaccessionDatasetButton.spec.tsx | Uses provider wrapper and removes dataset repo prop. |
| tests/component/sections/dataset/dataset-action-buttons/DatasetActionButtons.spec.tsx | Removes dataset repo prop and relies on context. |
| tests/component/sections/dataset/Dataset.spec.tsx | Ensures dataset page tests provide dataset repo via repositories context. |
| tests/component/sections/create-dataset/CreateDataset.spec.tsx | Moves dataset repo injection to repository provider wrapper. |
| tests/component/WithRepositories.tsx | Extends test helper to include optional datasetRepository and passes it into context. |
| src/stories/upload-dataset-files/UploadDatasetFiles.stories.tsx | Uses story repository decorator instead of passing dataset repo prop. |
| src/stories/shared/file-uploader/FileUploader.stories.tsx | Provides dataset repo via story decorator; removes prop usage. |
| src/stories/shared/file-uploader/FileUploadInput.stories.tsx | Provides dataset repo via story decorator; removes prop usage. |
| src/stories/shared/dataset-metadata-form/DatasetMetadataForm.stories.tsx | Provides dataset repo via story decorator; removes prop usage. |
| src/stories/replace-file/ReplaceFile.stories.tsx | Wraps ReplaceFile story in repositories provider. |
| src/stories/file/file-action-buttons/edit-file-dropdown/EditFileTagsModal.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/file/file-action-buttons/edit-file-dropdown/EditFileDropdown.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/file/File.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/edit-dataset-terms/EditDatasetTerms.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/edit-dataset-metadata/EditDatasetMetadata.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/dataset/deaccession-dataset/DeaccessionDatasetModal.stories.tsx | Wraps modal stories in repositories provider. |
| src/stories/dataset/dataset-versions/DatasetVersions.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/dataset/dataset-metrics/DatasetMetrics.stories.tsx | Wraps metrics stories in repositories provider. |
| src/stories/dataset/dataset-files/files-table/file-actions/file-action-buttons/file-options-menu/FileOptionsMenu.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesMenu.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/dataset/dataset-files/DatasetFilesScrollable.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/dataset/dataset-files/DatasetFiles.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/dataset/dataset-citation/DatasetCitation.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/dataset/dataset-action-buttons/unlink-dataset-button/UnlinkDatasetButton.stories.tsx | Wraps stories with repositories provider and removes prop usage. |
| src/stories/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.stories.tsx | Wraps stories with repositories provider and removes prop usage. |
| src/stories/dataset/dataset-action-buttons/link-dataset-button/LinkDatasetButton.stories.tsx | Wraps stories with repositories provider and removes prop usage. |
| src/stories/dataset/dataset-action-buttons/edit-dataset-menu/EditDatasetMenu.stories.tsx | Supplies dataset repo via decorator; removes prop usage. |
| src/stories/dataset/dataset-action-buttons/DatasetActionButtons.stories.tsx | Wraps stories with repositories provider and removes prop usage. |
| src/stories/dataset/Dataset.stories.tsx | Wraps stories with repositories provider and removes prop usage. |
| src/stories/create-dataset/CreateDataset.stories.tsx | Wraps stories with repositories provider and removes prop usage. |
| src/stories/WithRepositories.tsx | Extends Storybook helpers to include dataset repository in context. |
| src/shared/contexts/repositories/RepositoriesProvider.tsx | Adds datasetRepository to context + useDatasetRepositories() hook. |
| src/sections/upload-dataset-files/UploadDatasetFilesFactory.tsx | Wraps page factory with repositories provider including dataset repo. |
| src/sections/upload-dataset-files/UploadDatasetFiles.tsx | Stops taking dataset repo prop; relies on context indirectly via children. |
| src/sections/shared/form/DatasetMetadataForm/index.tsx | Removes dataset repo prop from form surface. |
| src/sections/shared/form/DatasetMetadataForm/MetadataForm/index.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/shared/file-uploader/file-upload-input/FileUploadInput.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/shared/file-uploader/FileUploaderPanel.tsx | Removes dataset repo prop threading into upload input. |
| src/sections/shared/file-uploader/FileUploader.tsx | Removes dataset repo prop and relies on context via nested components. |
| src/sections/shared/citation/citation-download/CitationDownloadButton.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/replace-file/ReplaceFileFactory.tsx | Wraps page factory with repositories provider including dataset repo. |
| src/sections/replace-file/ReplaceFile.tsx | Removes dataset repo prop threading into uploader. |
| src/sections/layout/header/HeaderFactory.tsx | Ensures header factory provides dataset repo in repositories context. |
| src/sections/homepage/HomepageFactory.tsx | Ensures homepage factory provides dataset repo in repositories context. |
| src/sections/file/file-action-buttons/edit-file-menu/edit-file-tags/edit-file-tags-modal/EditFileTagsModal.tsx | Pulls dataset repo from context and uses it in categories hook. |
| src/sections/file/file-action-buttons/edit-file-menu/edit-file-tags/EditFileTagsButton.tsx | Removes dataset repo prop threading to modal. |
| src/sections/file/file-action-buttons/edit-file-menu/EditFileMenu.tsx | Removes dataset repo prop threading to tag editor. |
| src/sections/file/FileFactory.tsx | Wraps file page factory with repositories provider including dataset repo. |
| src/sections/file/File.tsx | Removes dataset repo prop threading to citation/menu components. |
| src/sections/featured-item/FeaturedItemFactory.tsx | Ensures featured item factory provides dataset repo in context. |
| src/sections/edit-dataset-terms/edit-terms-of-access/EditTermsOfAccess.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/edit-dataset-terms/edit-license-and-terms/EditLicenseAndTerms.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/edit-dataset-terms/EditDatasetTermsFactory.tsx | Wraps factory with repositories provider including dataset repo. |
| src/sections/edit-dataset-terms/EditDatasetTerms.tsx | Removes dataset repo prop threading to tab components. |
| src/sections/edit-dataset-metadata/EditDatasetMetadataFactory.tsx | Wraps factory with repositories provider including dataset repo. |
| src/sections/edit-dataset-metadata/EditDatasetMetadata.tsx | Removes dataset repo prop threading into metadata form. |
| src/sections/edit-collection/EditCollectionFactory.tsx | Ensures edit collection factory provides dataset repo in context. |
| src/sections/edit-collection-featured-items/EditFeaturedItemsFactory.tsx | Ensures edit featured items factory provides dataset repo in context. |
| src/sections/dataset/deaccession-dataset/DeaccessionDatasetModal.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-versions/view-difference/DatasetVersionViewDifferenceButton.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-versions/DatasetViewDetailButton.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-versions/DatasetVersions.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-metrics/DatasetMetrics.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/file-options-menu/FileOptionsMenu.tsx | Removes dataset repo prop threading through file actions UI. |
| src/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/file-action-buttons/FileActionButtons.tsx | Removes dataset repo prop threading. |
| src/sections/dataset/dataset-files/files-table/file-actions/file-actions-cell/FileActionsCell.tsx | Removes dataset repo prop threading. |
| src/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesOptions.tsx | Removes dataset repo prop threading to tag editor path. |
| src/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesMenu.tsx | Removes dataset repo prop threading. |
| src/sections/dataset/dataset-files/files-table/file-actions/edit-files-menu/DatasetEditFileTagsButton.tsx | Removes dataset repo prop threading; modal now consumes context. |
| src/sections/dataset/dataset-files/files-table/file-actions/FileActionsHeader.tsx | Removes dataset repo prop threading. |
| src/sections/dataset/dataset-files/files-table/FilesTableScrollable.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-files/files-table/FilesTableColumnsDefinition.tsx | Removes dataset repo prop threading into cells/headers. |
| src/sections/dataset/dataset-files/files-table/FilesTable.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-files/DatasetFilesScrollable.tsx | Removes dataset repo prop threading to table. |
| src/sections/dataset/dataset-files/DatasetFiles.tsx | Removes dataset repo prop threading to table. |
| src/sections/dataset/dataset-citation/DatasetCitation.tsx | Removes dataset repo prop threading to citation download button. |
| src/sections/dataset/dataset-action-buttons/publish-dataset-menu/PublishDatasetMenu.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-action-buttons/link-and-unlink-actions/unlink-dataset-button/UnlinkDatasetButton.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-action-buttons/link-and-unlink-actions/link-dataset-button/LinkDatasetButton.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-action-buttons/link-and-unlink-actions/LinkAndUnlinkActions.tsx | Removes dataset repo prop threading. |
| src/sections/dataset/dataset-action-buttons/edit-dataset-menu/delete-draft-dataset/DeleteDraftDatasetButton.tsx | Pulls dataset repo from context via useDatasetRepositories(). |
| src/sections/dataset/dataset-action-buttons/edit-dataset-menu/EditDatasetMenu.tsx | Removes dataset repo prop threading to submenu buttons. |
| src/sections/dataset/dataset-action-buttons/edit-dataset-menu/DeaccessionDatasetButton.tsx | Removes dataset repo prop threading to modal. |
| src/sections/dataset/dataset-action-buttons/DatasetActionButtons.tsx | Removes dataset repo prop threading and relies on context downstream. |
| src/sections/dataset/DatasetFactory.tsx | Ensures dataset page factory provides dataset repo in context. |
| src/sections/dataset/Dataset.tsx | Pulls dataset repo from context and stops passing it down. |
| src/sections/create-dataset/CreateDatasetFactory.tsx | Ensures create dataset factory provides dataset repo in context. |
| src/sections/create-dataset/CreateDataset.tsx | Removes dataset repo prop threading into metadata form. |
| src/sections/create-collection/CreateCollectionFactory.tsx | Ensures create collection factory provides dataset repo in context. |
| src/sections/collection/CollectionFactory.tsx | Ensures collection factory provides dataset repo in context. |
| src/sections/advanced-search/AdvancedSearchFactory.tsx | Ensures advanced search factory provides dataset repo in context. |
| src/sections/account/AccountFactory.tsx | Ensures account factory provides dataset repo in context. |
| package.json | Bumps app version and updates dataverse client dependency. |
| package-lock.json | Locks updated dependency versions and tarball sources. |
| CHANGELOG.md | Adds v0.3.0 section to changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
+17
| const withProviders = (component: ReactNode) => ( | ||
| <WithRepositories> | ||
| <LoadingProvider>{component}</LoadingProvider> | ||
| </WithRepositories> |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this PR does / why we need it:
Which issue(s) this PR closes:
Special notes for your reviewer:
Suggestions on how to test this:
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes or changelog update needed for this change?:
Additional documentation: