Skip to content
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
33 changes: 26 additions & 7 deletions src/components/PublicProjects/sections/Artifacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,33 @@ import { ShowCaseProjectQueryType } from '../type';
import ArtifactsTabNav from './artifact/artifacts-tab-nav';
import LinkAndDownloadList from './blocs/LinkAndDownloadList';

const getActiveArtifactsCount = (
activeArtifactType: string | null,
content: ShowCaseProjectQueryType
): number => {
if (!activeArtifactType || !content) {
return 0;
}

switch (activeArtifactType) {
case 'eModelsTable':
return Array.isArray(content.eModelTable) ? content.eModelTable.length : 0;
case 'meModelsTable':
return Array.isArray(content.meModelTable) ? content.meModelTable.length : 0;
case 'synaptomesTable':
return Array.isArray(content.synaptomeTable) ? content.synaptomeTable.length : 0;
case 'downloadsLinks':
return Array.isArray(content.artifact) ? content.artifact.length : 0;
default:
return 0;
}
};

export default function ArtifactsSection({ content }: { content: ShowCaseProjectQueryType }) {
const [activeArtifactType, setActiveArtifactType] = useState<string | null>(
content.artifactType[0] ?? null
);

const totalDataCount =
(content?.artifact?.length ?? 0) +
(content?.meModelsList?.length ?? 0) +
(content?.minimalMeModel?.length ?? 0) +
(content?.eModelTable?.length ?? 0);

let activeTable;

if (content !== null) {
Expand Down Expand Up @@ -67,7 +83,10 @@ export default function ArtifactsSection({ content }: { content: ShowCaseProject
<div className="relative flex w-full flex-col gap-y-6 scroll-smooth" id="artifacts">
<header className="sticky top-0 z-50 flex w-full flex-row items-center justify-between bg-white">
<div className="relative flex flex-row text-base">
Total artifacts: <span className="ml-2 block font-bold">{totalDataCount}</span>
Total artifacts:{' '}
<span className="ml-2 block font-bold">
{getActiveArtifactsCount(activeArtifactType, content)}
</span>
</div>
{content.artifactType.length > 1 && (
<ArtifactsTabNav
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export default function ArtifactsTabNav({

switch (item) {
case 'meModelsTable':
title = 'ME Models';
title = 'ME-Models';
break;
case 'eModelsTable':
title = 'E Models';
title = 'E-Models';
break;
case 'synaptomesTable':
title = 'Synaptome';
Expand Down
18 changes: 12 additions & 6 deletions src/components/PublicProjects/tables/me-model-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ export default function MEModelTable({ content }: { content: MEModelsProps[] })
},
};

// const handleDownload = () => {
// if (selectedRow?.download) {
// const link = document.createElement('a');
// link.href = selectedRow.download;
// link.download = selectedRow.name || 'model';
// document.body.appendChild(link);
// link.click();
// document.body.removeChild(link);
// }
// };

const handleDownload = () => {
if (selectedRow?.download) {
const link = document.createElement('a');
link.href = selectedRow.download;
link.download = selectedRow.name || 'model';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.open(selectedRow.download, '_blank');
}
};

Expand Down