From f1d28e6e2a814a8c74cc56b274b5649de05e02db Mon Sep 17 00:00:00 2001 From: Dave Falke Date: Thu, 11 Jul 2024 13:37:15 -0400 Subject: [PATCH] EDA: standalone downloads (#1134) * Update banner verbiage and hide buttons when data is not integrated * Add download tab * Indicate loading state, and no files available * Add min height --- .../src/lib/workspace/DownloadTab/index.tsx | 67 ++++++++++--------- .../src/lib/workspace/EDAWorkspaceHeading.tsx | 8 ++- .../src/lib/workspace/StandaloneStudyPage.tsx | 35 +++++++++- 3 files changed, 74 insertions(+), 36 deletions(-) diff --git a/packages/libs/eda/src/lib/workspace/DownloadTab/index.tsx b/packages/libs/eda/src/lib/workspace/DownloadTab/index.tsx index 718c4ad7e1..175ca143d6 100644 --- a/packages/libs/eda/src/lib/workspace/DownloadTab/index.tsx +++ b/packages/libs/eda/src/lib/workspace/DownloadTab/index.tsx @@ -34,7 +34,7 @@ import { parsePath } from 'history'; type DownloadsTabProps = { downloadClient: DownloadClient; - analysisState: AnalysisState; + analysisState: AnalysisState | undefined; totalCounts: EntityCounts | undefined; filteredCounts: EntityCounts | undefined; }; @@ -137,7 +137,7 @@ export default function DownloadTab({ * you have two different variables for study releases here. */ const [downloadServiceStudyReleases, setDownloadServiceStudyReleases] = - useState>([]); + useState | undefined>(undefined); const WDKStudyReleases = useWdkStudyReleases(); // Only fetch study releases if they are expected to be available @@ -171,8 +171,7 @@ export default function DownloadTab({ * that doesn't have a match in the WDKService, it gets disregarded. * */ const mergedReleaseData = useMemo(() => { - if (!WDKStudyReleases.length || !downloadServiceStudyReleases.length) - return []; + if (!WDKStudyReleases || !downloadServiceStudyReleases) return undefined; /** * It turns out there are many "releases" for which the files @@ -201,7 +200,7 @@ export default function DownloadTab({ const partialCitationData = useMemo(() => { let citationUrl; - if (analysisState.analysis && 'analysisId' in analysisState.analysis) { + if (analysisState?.analysis && 'analysisId' in analysisState.analysis) { citationUrl = window.location.href.replace( `${analysisState.analysis.analysisId}/download`, 'new' @@ -236,43 +235,49 @@ export default function DownloadTab({ {projectDisplayName === 'ClinEpiDB' && !isUserStudy && (dataAccessDeclaration ?? '')} - {mergedReleaseData[0] && ( + {mergedReleaseData?.[0] && ( )} - { + {analysisState && ( - } - {mergedReleaseData.map((release, index) => - index === 0 ? ( - - ) : ( - + )} + {mergedReleaseData == null ? ( + 'Loading...' + ) : mergedReleaseData.length === 0 ? ( +
This study does not contain any download files.
+ ) : ( + mergedReleaseData.map((release, index) => + index === 0 ? ( + + ) : ( + + ) ) )} diff --git a/packages/libs/eda/src/lib/workspace/EDAWorkspaceHeading.tsx b/packages/libs/eda/src/lib/workspace/EDAWorkspaceHeading.tsx index 8aa2dd41ee..64a6f56f9f 100644 --- a/packages/libs/eda/src/lib/workspace/EDAWorkspaceHeading.tsx +++ b/packages/libs/eda/src/lib/workspace/EDAWorkspaceHeading.tsx @@ -57,7 +57,8 @@ export function EDAWorkspaceHeading({ permissionsValue.permissions.perDataset[ studyRecord.attributes.dataset_id as string ]?.actionAuthorization.subsetting - ); + ) && + !isStubEntity(studyMetadata.rootEntity); useEffect(() => { setDialogIsOpen(false); @@ -166,8 +167,9 @@ export function EDAWorkspaceHeading({ isStubEntity(studyMetadata.rootEntity) && ( )} diff --git a/packages/libs/eda/src/lib/workspace/StandaloneStudyPage.tsx b/packages/libs/eda/src/lib/workspace/StandaloneStudyPage.tsx index 141aaa211b..8e295b416f 100644 --- a/packages/libs/eda/src/lib/workspace/StandaloneStudyPage.tsx +++ b/packages/libs/eda/src/lib/workspace/StandaloneStudyPage.tsx @@ -1,8 +1,11 @@ import { ApprovalStatus } from '@veupathdb/study-data-access/lib/data-restriction/dataRestrictionHooks'; import { usePermissions } from '@veupathdb/study-data-access/lib/data-restriction/permissionsHooks'; import { RestrictedPage } from '@veupathdb/study-data-access/lib/data-restriction/RestrictedPage'; +import { Tabs } from '@veupathdb/wdk-client/lib/Components'; import { RecordController } from '@veupathdb/wdk-client/lib/Controllers'; -import { useStudyRecord } from '../core'; +import { useState } from 'react'; +import { useDownloadClient, useStudyRecord } from '../core'; +import DownloadTab from './DownloadTab'; import { EDAWorkspaceHeading } from './EDAWorkspaceHeading'; interface Props { @@ -22,6 +25,7 @@ export function StandaloneStudyPage(props: Props) { isStudyExplorerWorkspace = false, } = props; const studyRecord = useStudyRecord(); + const downloadClient = useDownloadClient(); const permissionsValue = usePermissions(); const approvalStatus: ApprovalStatus = permissionsValue.loading ? 'loading' @@ -32,12 +36,39 @@ export function StandaloneStudyPage(props: Props) { .studyMetadata ? 'approved' : 'not-approved'; + const [activeTab, setActiveTab] = useState('details'); return ( - + + + + ), + }, + { + key: 'downloads', + display: 'Download', + content: ( + + ), + }, + ]} + activeTab={activeTab} + onTabSelected={setActiveTab} + /> ); }