diff --git a/ui-participant/src/hub/documents/DocumentLibrary.test.tsx b/ui-participant/src/hub/documents/DocumentLibrary.test.tsx index 4b0e5d7be..70a17f125 100644 --- a/ui-participant/src/hub/documents/DocumentLibrary.test.tsx +++ b/ui-participant/src/hub/documents/DocumentLibrary.test.tsx @@ -61,7 +61,7 @@ describe('DocumentLibrary', () => { expect(screen.getByText('{documentDownloadButton}')).toBeInTheDocument() }) - it('renders no associated tasks message', async () => { + it('does not render any associated tasks', async () => { asMockedFn(Api.listParticipantFiles).mockResolvedValue([ mockParticipantFile('file1.pdf', []) ]) @@ -72,7 +72,7 @@ describe('DocumentLibrary', () => { expect(screen.getByText('file1.pdf')).toBeInTheDocument() }) - expect(screen.getByText('not associated with any tasks')).toBeInTheDocument() + expect(screen.queryByText('shared in response to')).not.toBeInTheDocument() }) it('renders associated tasks', async () => { diff --git a/ui-participant/src/hub/documents/DocumentLibrary.tsx b/ui-participant/src/hub/documents/DocumentLibrary.tsx index e4b03575c..ff5a38a0c 100644 --- a/ui-participant/src/hub/documents/DocumentLibrary.tsx +++ b/ui-participant/src/hub/documents/DocumentLibrary.tsx @@ -12,10 +12,12 @@ import React, { useEffect, useState } from 'react' import { useActiveUser } from 'providers/ActiveUserProvider' import Api from 'api/api' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faDownload, faFile, faFileImage, faFileLines, faFilePdf } from '@fortawesome/free-solid-svg-icons' +import { faFile, faFileImage, faFileLines, faFilePdf } from '@fortawesome/free-solid-svg-icons' import { usePortalEnv } from 'providers/PortalProvider' import { Link } from 'react-router-dom' import { getTaskPath } from '../task/taskUtils' +import Modal from 'react-bootstrap/Modal' +import ThemedModal from 'components/ThemedModal' export default function DocumentLibrary() { const { i18n } = useI18n() @@ -106,16 +108,11 @@ const DocumentsList = ({ studyName, studyEnvParams, enrollee }: {
- +
@@ -138,7 +135,7 @@ const surveyResponseIdsToTaskNames = ( }).filter((task): task is ParticipantTask => task !== undefined) if (associatedTasks.length === 0) { - return
not associated with any tasks
+ return null } return ( @@ -170,3 +167,72 @@ const fileTypeToIcon = (fileType: string) => { return } } + +const FileOptionsDropdown = ({ studyEnvParams, participantFile, enrollee, loadDocuments }: { + studyEnvParams: StudyEnvParams, participantFile: ParticipantFile, enrollee: Enrollee, loadDocuments: () => void +}) => { + const [showConfirmDelete, setShowConfirmDelete] = useState(false) + const { i18n } = useI18n() + return (<> +
  • + + +
  • + {showConfirmDelete && setShowConfirmDelete(false)} size={'lg'} animation={true}> + + +

    Are you sure?

    +
    +
    + + {participantFile.associatedAnswers.length === 0 ? +

    Are you sure you want to delete this document? This cannot be undone.

    : +

    This document is currently shared in response to at least one survey. Please remove it + from the survey response(s) before deleting it.

    + } +
    + +
    + + +
    +
    +
    } + + ) +}