-
Notifications
You must be signed in to change notification settings - Fork 22
Add StorageDriver select component to CollectionForm.tsx #997
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
ekraffmiller
wants to merge
12
commits into
develop
Choose a base branch
from
929-collection-storage-driver
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.
Open
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fa63877
Add StorageDriver select component to CollectionForm.tsx
ekraffmiller 153e258
fix unit tests
ekraffmiller f64d95f
set error to null after successfully fetching data
ekraffmiller 9fce2fa
set error to null after successfully fetching data
ekraffmiller 2e3faae
handle storage update failure separately
ekraffmiller 7f4e17c
Merge branch '929-collection-storage-driver' of https://github.com/IQ…
ekraffmiller 33eafde
Merge branch 'develop' into 929-collection-storage-driver
ekraffmiller d72a06a
remove test JVM_ARGS from docker-compose-dev.yml
ekraffmiller 3863cd8
update storage driver options to include a default/inherited option
ekraffmiller 1b2eda3
Always show use inherited storage driver option
ekraffmiller 32a5f30
add unit tests for hooks
ekraffmiller bb6f846
increase code coverage
ekraffmiller 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type AllowedStorageDrivers = Record<string, 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,8 @@ | ||
| export interface StorageDriver { | ||
| name: string | ||
| type?: string | ||
| label?: string | ||
| directUpload: boolean | ||
| directDownload: boolean | ||
| uploadOutOfBand: boolean | ||
| } |
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
9 changes: 9 additions & 0 deletions
9
src/collection/domain/useCases/getCollectionAllowedStorageDrivers.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,9 @@ | ||
| import { AllowedStorageDrivers } from '../models/AllowedStorageDrivers' | ||
| import { CollectionRepository } from '../repositories/CollectionRepository' | ||
|
|
||
| export async function getCollectionAllowedStorageDrivers( | ||
| collectionRepository: CollectionRepository, | ||
| collectionIdOrAlias: number | string | ||
| ): Promise<AllowedStorageDrivers> { | ||
| return collectionRepository.getAllowedStorageDrivers(collectionIdOrAlias) | ||
| } |
10 changes: 10 additions & 0 deletions
10
src/collection/domain/useCases/getCollectionStorageDriver.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,10 @@ | ||
| import { StorageDriver } from '../models/StorageDriver' | ||
| import { CollectionRepository } from '../repositories/CollectionRepository' | ||
|
|
||
| export async function getCollectionStorageDriver( | ||
| collectionRepository: CollectionRepository, | ||
| collectionIdOrAlias: number | string, | ||
| getEffective?: boolean | ||
| ): Promise<StorageDriver> { | ||
| return collectionRepository.getStorageDriver(collectionIdOrAlias, getEffective) | ||
| } |
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 setCollectionDriver( | ||
| collectionRepository: CollectionRepository, | ||
| collectionIdOrAlias: number | string, | ||
| driverLabel: string | ||
| ): Promise<string> { | ||
| return collectionRepository.setStorageDriver(collectionIdOrAlias, driverLabel) | ||
| } |
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
46 changes: 46 additions & 0 deletions
46
.../shared/form/EditCreateCollectionForm/collection-form/top-fields-section/StorageField.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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { Controller, useFormContext } from 'react-hook-form' | ||
| import { useTranslation } from 'react-i18next' | ||
| import { Col, Form } from '@iqss/dataverse-design-system' | ||
| import { AllowedStorageDrivers } from '@/collection/domain/models/AllowedStorageDrivers' | ||
|
|
||
| interface StorageFieldProps { | ||
| allowedStorageDrivers: AllowedStorageDrivers | ||
| } | ||
|
|
||
| export const StorageField = ({ allowedStorageDrivers }: StorageFieldProps) => { | ||
| const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' }) | ||
| const { control } = useFormContext() | ||
| const storageDriverOptions = Object.entries(allowedStorageDrivers) | ||
|
|
||
| if (storageDriverOptions.length === 0) { | ||
| return null | ||
| } | ||
|
|
||
| return ( | ||
| <Form.Group controlId="storage" as={Col} md={6}> | ||
| <Form.Group.Label message={t('fields.storage.description')}> | ||
| {t('fields.storage.label')} | ||
| </Form.Group.Label> | ||
| <Controller | ||
| name="storage" | ||
| control={control} | ||
| render={({ field: { onChange, ref, value }, fieldState: { invalid, error } }) => ( | ||
| <Col> | ||
| <Form.Group.Select | ||
| onChange={onChange} | ||
| value={value as string} | ||
| isInvalid={invalid} | ||
| ref={ref}> | ||
| {storageDriverOptions.map(([driverLabel, displayName]) => ( | ||
| <option value={driverLabel} key={driverLabel}> | ||
| {displayName} | ||
| </option> | ||
| ))} | ||
| </Form.Group.Select> | ||
| <Form.Group.Feedback type="invalid">{error?.message}</Form.Group.Feedback> | ||
| </Col> | ||
| )} | ||
| /> | ||
| </Form.Group> | ||
| ) | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update to
2.2.0-alpha.9as our latest js-dataverse alpha ver.?