Skip to content

Commit

Permalink
EDA: standalone downloads (#1134)
Browse files Browse the repository at this point in the history
* Update banner verbiage and hide buttons when data is not integrated

* Add download tab

* Indicate loading state, and no files available

* Add min height
  • Loading branch information
dmfalke committed Jul 11, 2024
1 parent f2a73f9 commit f1d28e6
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 36 deletions.
67 changes: 36 additions & 31 deletions packages/libs/eda/src/lib/workspace/DownloadTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { parsePath } from 'history';

type DownloadsTabProps = {
downloadClient: DownloadClient;
analysisState: AnalysisState;
analysisState: AnalysisState | undefined;
totalCounts: EntityCounts | undefined;
filteredCounts: EntityCounts | undefined;
};
Expand Down Expand Up @@ -137,7 +137,7 @@ export default function DownloadTab({
* you have two different variables for study releases here.
*/
const [downloadServiceStudyReleases, setDownloadServiceStudyReleases] =
useState<Array<string>>([]);
useState<Array<string> | undefined>(undefined);
const WDKStudyReleases = useWdkStudyReleases();

// Only fetch study releases if they are expected to be available
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -236,43 +235,49 @@ export default function DownloadTab({
{projectDisplayName === 'ClinEpiDB' &&
!isUserStudy &&
(dataAccessDeclaration ?? '')}
{mergedReleaseData[0] && (
{mergedReleaseData?.[0] && (
<StudyCitation
partialCitationData={partialCitationData}
// use current release
release={mergedReleaseData[0]}
/>
)}
{
{analysisState && (
<MySubset
datasetId={datasetId}
entities={enhancedEntityData}
analysisState={analysisState}
/>
}
{mergedReleaseData.map((release, index) =>
index === 0 ? (
<CurrentRelease
key={release.releaseNumber}
datasetId={datasetId}
studyId={studyMetadata.id}
release={release}
downloadClient={downloadClient}
/>
) : (
<PastRelease
key={release.releaseNumber}
datasetId={datasetId}
studyId={studyMetadata.id}
release={release}
downloadClient={downloadClient}
citationString={stripHTML(
getCitationString({
partialCitationData,
release,
})
)}
/>
)}
{mergedReleaseData == null ? (
'Loading...'
) : mergedReleaseData.length === 0 ? (
<div>This study does not contain any download files.</div>
) : (
mergedReleaseData.map((release, index) =>
index === 0 ? (
<CurrentRelease
key={release.releaseNumber}
datasetId={datasetId}
studyId={studyMetadata.id}
release={release}
downloadClient={downloadClient}
/>
) : (
<PastRelease
key={release.releaseNumber}
datasetId={datasetId}
studyId={studyMetadata.id}
release={release}
downloadClient={downloadClient}
citationString={stripHTML(
getCitationString({
partialCitationData,
release,
})
)}
/>
)
)
)}
</div>
Expand Down
8 changes: 5 additions & 3 deletions packages/libs/eda/src/lib/workspace/EDAWorkspaceHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export function EDAWorkspaceHeading({
permissionsValue.permissions.perDataset[
studyRecord.attributes.dataset_id as string
]?.actionAuthorization.subsetting
);
) &&
!isStubEntity(studyMetadata.rootEntity);

useEffect(() => {
setDialogIsOpen(false);
Expand Down Expand Up @@ -166,8 +167,9 @@ export function EDAWorkspaceHeading({
isStubEntity(studyMetadata.rootEntity) && (
<Banner
banner={{
type: 'error',
message: 'Data for this study is not currently available.',
type: 'info',
message:
'This study has not been integrated into the analysis workspace, but data files are available on the Download tab.',
}}
/>
)}
Expand Down
35 changes: 33 additions & 2 deletions packages/libs/eda/src/lib/workspace/StandaloneStudyPage.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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'
Expand All @@ -32,12 +36,39 @@ export function StandaloneStudyPage(props: Props) {
.studyMetadata
? 'approved'
: 'not-approved';
const [activeTab, setActiveTab] = useState('details');
return (
<RestrictedPage approvalStatus={approvalStatus}>
<EDAWorkspaceHeading
isStudyExplorerWorkspace={isStudyExplorerWorkspace}
/>
<RecordController recordClass="dataset" primaryKey={studyId} />
<Tabs
tabs={[
{
key: 'details',
display: 'Study details',
content: (
<div style={{ minHeight: '10em' }}>
<RecordController recordClass="dataset" primaryKey={studyId} />
</div>
),
},
{
key: 'downloads',
display: 'Download',
content: (
<DownloadTab
downloadClient={downloadClient}
analysisState={undefined}
totalCounts={undefined}
filteredCounts={undefined}
/>
),
},
]}
activeTab={activeTab}
onTabSelected={setActiveTab}
/>
</RestrictedPage>
);
}

0 comments on commit f1d28e6

Please sign in to comment.