-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(DownloadFiles): add the No Selected Files modal
- Loading branch information
Showing
15 changed files
with
269 additions
and
59 deletions.
There are no files selected for viewing
This file contains 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 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
2 changes: 1 addition & 1 deletion
2
src/sections/dataset/dataset-files/files-table/file-actions/FileActionsHeader.module.scss
This file contains 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,5 +1,5 @@ | ||
.container { | ||
text-align: right; | ||
display: flex; | ||
justify-content: end; | ||
text-align: right; | ||
} |
This file contains 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 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 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: 38 additions & 8 deletions
46
...tions/dataset/dataset-files/files-table/file-actions/edit-files-menu/EditFilesOptions.tsx
This file contains 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,32 +1,62 @@ | ||
import { DropdownButtonItem } from '@iqss/dataverse-design-system' | ||
import { File } from '../../../../../../files/domain/models/File' | ||
import { useTranslation } from 'react-i18next' | ||
import { useState } from 'react' | ||
import { FileSelection } from '../../row-selection/useFileSelection' | ||
import { NoSelectedFilesModal } from '../no-selected-files-modal/NoSelectedFilesModal' | ||
|
||
interface EditFileOptionsProps { | ||
files: File[] | ||
fileSelection: FileSelection | ||
} | ||
export function EditFilesOptions({ files }: EditFileOptionsProps) { | ||
const SELECTED_FILES_EMPTY = 0 | ||
export function EditFilesOptions({ files, fileSelection }: EditFileOptionsProps) { | ||
const { t } = useTranslation('files') | ||
const [showNoFilesSelectedModal, setShowNoFilesSelectedModal] = useState(false) | ||
const settingsEmbargoAllowed = false // TODO - Ask Guillermo if this is included in the settings endpoint | ||
const provenanceEnabledByConfig = false // TODO - Ask Guillermo if this is included in the MVP and from which endpoint is coming from | ||
|
||
const onClick = () => { | ||
if (Object.keys(fileSelection).length === SELECTED_FILES_EMPTY) { | ||
setShowNoFilesSelectedModal(true) | ||
} | ||
} | ||
|
||
return ( | ||
<> | ||
<DropdownButtonItem>{t('actions.editFilesMenu.options.metadata')}</DropdownButtonItem> | ||
<DropdownButtonItem onClick={onClick}> | ||
{t('actions.editFilesMenu.options.metadata')} | ||
</DropdownButtonItem> | ||
{files.some((file) => file.access.restricted) && ( | ||
<DropdownButtonItem>{t('actions.editFilesMenu.options.unrestrict')}</DropdownButtonItem> | ||
<DropdownButtonItem onClick={onClick}> | ||
{t('actions.editFilesMenu.options.unrestrict')} | ||
</DropdownButtonItem> | ||
)} | ||
{files.some((file) => !file.access.restricted) && ( | ||
<DropdownButtonItem>{t('actions.editFilesMenu.options.restrict')}</DropdownButtonItem> | ||
<DropdownButtonItem onClick={onClick}> | ||
{t('actions.editFilesMenu.options.restrict')} | ||
</DropdownButtonItem> | ||
)} | ||
<DropdownButtonItem>{t('actions.editFilesMenu.options.replace')}</DropdownButtonItem> | ||
<DropdownButtonItem onClick={onClick}> | ||
{t('actions.editFilesMenu.options.replace')} | ||
</DropdownButtonItem> | ||
{settingsEmbargoAllowed && ( | ||
<DropdownButtonItem>{t('actions.editFilesMenu.options.embargo')}</DropdownButtonItem> | ||
<DropdownButtonItem onClick={onClick}> | ||
{t('actions.editFilesMenu.options.embargo')} | ||
</DropdownButtonItem> | ||
)} | ||
{provenanceEnabledByConfig && ( | ||
<DropdownButtonItem>{t('actions.editFilesMenu.options.provenance')}</DropdownButtonItem> | ||
<DropdownButtonItem onClick={onClick}> | ||
{t('actions.editFilesMenu.options.provenance')} | ||
</DropdownButtonItem> | ||
)} | ||
<DropdownButtonItem>{t('actions.editFilesMenu.options.delete')}</DropdownButtonItem> | ||
<DropdownButtonItem onClick={onClick}> | ||
{t('actions.editFilesMenu.options.delete')} | ||
</DropdownButtonItem> | ||
<NoSelectedFilesModal | ||
show={showNoFilesSelectedModal} | ||
handleClose={() => setShowNoFilesSelectedModal(false)} | ||
/> | ||
</> | ||
) | ||
} |
30 changes: 30 additions & 0 deletions
30
...t/dataset-files/files-table/file-actions/no-selected-files-modal/NoSelectedFilesModal.tsx
This file contains 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,30 @@ | ||
import { useTranslation } from 'react-i18next' | ||
import { Button, Modal } from '@iqss/dataverse-design-system' | ||
import styles from '../file-actions-cell/file-action-buttons/file-options-menu/FileAlreadyDeletedModal.module.scss' | ||
import { ExclamationCircleFill } from 'react-bootstrap-icons' | ||
|
||
interface NoSelectedFilesModalProps { | ||
show: boolean | ||
handleClose: () => void | ||
} | ||
|
||
export function NoSelectedFilesModal({ show, handleClose }: NoSelectedFilesModalProps) { | ||
const { t } = useTranslation('files') | ||
return ( | ||
<Modal show={show} onHide={handleClose} size="lg"> | ||
<Modal.Header> | ||
<Modal.Title>{t('actions.noSelectedFilesAlert.title')}</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<p className={styles.paragraph}> | ||
<ExclamationCircleFill /> {t('actions.noSelectedFilesAlert.message')} | ||
</p> | ||
</Modal.Body> | ||
<Modal.Footer> | ||
<Button variant="secondary" onClick={handleClose}> | ||
{t('actions.noSelectedFilesAlert.close')} | ||
</Button> | ||
</Modal.Footer> | ||
</Modal> | ||
) | ||
} |
This file contains 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 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 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 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.