Skip to content
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

EDA: standalone downloads #1134

Merged
merged 5 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
);
}
Loading