diff --git a/packages/data-portal-explore/src/components/FileTable.tsx b/packages/data-portal-explore/src/components/FileTable.tsx index 680db74d..76b1ab74 100644 --- a/packages/data-portal-explore/src/components/FileTable.tsx +++ b/packages/data-portal-explore/src/components/FileTable.tsx @@ -50,6 +50,7 @@ import { const CDS_MANIFEST_FILENAME = 'cds_manifest.csv'; const GEN3_MANIFEST_FILENAME = 'gen3_manifest.json'; +const TERRA_MANIFEST_FILENAME = 'terra_manifest.tsv'; interface IFileDownloadModalProps { files: Entity[]; @@ -108,6 +109,26 @@ function generateGen3ManifestFile(files: Entity[]): string | undefined { return data.length > 0 ? JSON.stringify(data, null, 2) : undefined; } +function generateTerraManifestFile(files: Entity[]): string | undefined { + const columns = [ + 'entity:filename', + 'drs_uri' + ]; + const data = _(files) + .filter((f) => !!f.viewers?.cds) + .map((f) => [ + f.viewers?.cds?.name, // Use `name` property for the filename + f.viewers?.cds?.drs_uri + ]) + .value(); + + if (data.length > 0) { + return [columns, ...data].map((row) => row.join('\t')).join('\n'); // Join with tabs for TSV format + } else { + return undefined; + } +} + const FilenameWithAccessIcon: React.FunctionComponent<{ file: Entity; }> = ({ file }) => { @@ -264,6 +285,32 @@ const gen3ManifestInstructions = (gen3manifestFile: string | undefined) => { ); }; +const terra3ManifestInstructions = (terra3manifestFile: string | undefined) => { + if (!terra3manifestFile) return null; + + return ( +
+

+

+ Access files in Terra:{' '} + First link your Terra account to NCI CRDC Framework Services from your{' '} + + Terra profile External Identities + page.{' '} + You can then add these files to Terra using the following manifest file. +

+

+ +

+
+ ); +}; + const CDSInstructions: React.FunctionComponent<{ files: Entity[] }> = ({ files, }) => { @@ -276,6 +323,7 @@ const CDSInstructions: React.FunctionComponent<{ files: Entity[] }> = ({ const manifestFile = generateCdsManifestFile(files); const gen3manifestFile = generateGen3ManifestFile(files); + const terra3manifestFile = generateTerraManifestFile(files); return (
@@ -322,6 +370,7 @@ const CDSInstructions: React.FunctionComponent<{ files: Entity[] }> = ({ {/* CDS and Gen3 manifest instructions */} {cdsManifestInstructions(manifestFile)} + {terra3ManifestInstructions(terra3manifestFile)} {gen3ManifestInstructions(gen3manifestFile)}
);