From 6812ffa140fe06c5cc01b65ea1071d5ffde1ddff Mon Sep 17 00:00:00 2001 From: Alejandro De Maria Antolinos <demariaa@esrf.fr> Date: Fri, 31 Jan 2025 05:02:31 +0100 Subject: [PATCH] Resolve "Selected datasets should be displayed as within an investigation" --- .../src/components/selection/SelectionPage.tsx | 6 +++++- .../selection/SelectionPanelForType.tsx | 10 +++++++++- .../src/components/viewers/DatasetViewer.tsx | 5 +++++ package.json | 3 ++- .../components/dataset/generic/DatasetList.tsx | 18 +++++++++++++++--- packages/core/src/context/viewers.tsx | 1 + 6 files changed, 37 insertions(+), 6 deletions(-) diff --git a/apps/portal/src/components/selection/SelectionPage.tsx b/apps/portal/src/components/selection/SelectionPage.tsx index 07dd89692..5d680ccb0 100644 --- a/apps/portal/src/components/selection/SelectionPage.tsx +++ b/apps/portal/src/components/selection/SelectionPage.tsx @@ -14,6 +14,10 @@ export default function SelectionPage() { const hideReprocess = !config.ui.features.reprocessing; return ( - <SelectionPanelForType type={'dataset'} hideReprocess={hideReprocess} /> + <SelectionPanelForType + type={'dataset'} + hideReprocess={hideReprocess} + datasetViewerType="generic" // This forces the viewer type independently of their remote configuration + /> ); } diff --git a/apps/portal/src/components/selection/SelectionPanelForType.tsx b/apps/portal/src/components/selection/SelectionPanelForType.tsx index eb676650d..507d54942 100644 --- a/apps/portal/src/components/selection/SelectionPanelForType.tsx +++ b/apps/portal/src/components/selection/SelectionPanelForType.tsx @@ -5,6 +5,7 @@ import { useUser, SelectEntityType, useSelection, + DatasetViewerType, } from '@edata-portal/core'; import { useEndpointURL, @@ -20,19 +21,26 @@ export function SelectionPanelForType({ linkToSelectionPage, hideDownload, hideMintDOI, + datasetViewerType, }: { type: SelectEntityType; hideReprocess?: boolean; linkToSelectionPage?: boolean; hideDownload?: boolean; hideMintDOI?: boolean; + datasetViewerType?: DatasetViewerType; // This forces the viewer type independently of their remote configuration }) { const { value: selection, clearSelection } = useSelection(type); const content = !selection.length ? ( <NoData /> ) : type === 'dataset' ? ( - <DatasetList groupBy="dataset" datasetIds={selection} showInvestigation /> + <DatasetList + groupBy="dataset" + datasetIds={selection} + showInvestigation + datasetViewerType={datasetViewerType} + /> ) : ( <DatasetList groupBy="sample" sampleIds={selection} showInvestigation /> ); diff --git a/apps/portal/src/components/viewers/DatasetViewer.tsx b/apps/portal/src/components/viewers/DatasetViewer.tsx index 83b5baa1a..5a47c56cb 100644 --- a/apps/portal/src/components/viewers/DatasetViewer.tsx +++ b/apps/portal/src/components/viewers/DatasetViewer.tsx @@ -113,6 +113,11 @@ export function DatasetViewer({ const viewerForType = viewer?.render[type]; + // This forces the display of the viewer despite its remote configuration + if (type === 'generic') { + return <GenericDatasetDetailsViewer dataset={dataset} {...props} />; + } + if (viewerForType?.type === 'remote') { return ( <RemoteComponent diff --git a/package.json b/package.json index dd4138770..7bb0f35cd 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "lint:tsc": "pnpm --filter @edata-portal/core lint:tsc && pnpm --filter @edata-portal/h5 lint:tsc && pnpm -r --parallel --filter './apps/**' lint:tsc", "lint:prettier": "pnpm -r --parallel lint:prettier", "fix:eslint": "pnpm -r --parallel fix:eslint", - "fix:prettier": "pnpm -r --parallel fix:prettier" + "fix:prettier": "pnpm -r --parallel fix:prettier", + "validate": "pnpm lint:eslint && pnpm lint:tsc && pnpm lint:prettier" }, "dependencies": { "eslint": "^8.57.0", diff --git a/packages/core/src/components/dataset/generic/DatasetList.tsx b/packages/core/src/components/dataset/generic/DatasetList.tsx index b7289ecdc..aedcb4e97 100644 --- a/packages/core/src/components/dataset/generic/DatasetList.tsx +++ b/packages/core/src/components/dataset/generic/DatasetList.tsx @@ -10,7 +10,7 @@ import { } from '@edata-portal/icat-plus-api'; import { useQueryClient } from '@tanstack/react-query'; import { Loading, NoData } from 'components/utils'; -import { useViewers } from 'context'; +import { DatasetViewerType, useViewers } from 'context'; import { formatDateToDay } from 'helpers'; import { PaginationMenu, useEndpointPagination, useParam } from 'hooks'; import React, { @@ -29,6 +29,7 @@ export function DatasetList( investigationId?: string; showInvestigation?: boolean; parameterFilter?: string; + datasetViewerType?: DatasetViewerType; } & ( | { groupBy: 'dataset'; @@ -54,7 +55,13 @@ export function DatasetList( switch (args.groupBy) { case 'dataset': if (args.datasets) { - return <DatasetObjectList datasets={args.datasets} {...args} />; + return ( + <DatasetObjectList + datasetViewerType={args.datasetViewerType} + datasets={args.datasets} + {...args} + /> + ); } return ( <Suspense fallback={<Loading />}> @@ -259,6 +266,7 @@ function LoadDatasetListByDataset({ search, sampleId, showInvestigation, + datasetViewerType, }: { instrumentName?: string; investigationId?: string; @@ -268,6 +276,7 @@ function LoadDatasetListByDataset({ search?: string; sampleId?: string; showInvestigation?: boolean; + datasetViewerType?: DatasetViewerType; }) { const datasets = useEndpointPagination({ endpoint: DATASET_LIST_ENDPOINT, @@ -295,6 +304,7 @@ function LoadDatasetListByDataset({ <DatasetObjectList datasets={datasets.data} showInvestigation={showInvestigation} + datasetViewerType={datasetViewerType} /> </Row> @@ -306,9 +316,11 @@ function LoadDatasetListByDataset({ function DatasetObjectList({ datasets, showInvestigation = false, + datasetViewerType = 'details', }: { datasets: Dataset[]; showInvestigation?: boolean; + datasetViewerType?: DatasetViewerType; }) { const viewers = useViewers(); @@ -336,7 +348,7 @@ function DatasetObjectList({ /> )} <Row key={dataset.id} className="mb-4"> - <Col>{viewers.viewDataset(dataset, 'details')}</Col> + <Col>{viewers.viewDataset(dataset, datasetViewerType)}</Col> </Row> </React.Fragment> ); diff --git a/packages/core/src/context/viewers.tsx b/packages/core/src/context/viewers.tsx index f16928efe..dfdac2f3c 100644 --- a/packages/core/src/context/viewers.tsx +++ b/packages/core/src/context/viewers.tsx @@ -10,6 +10,7 @@ export const DATASET_VIEWER_TYPES = [ 'details', 'snapshot', 'tableCell', + 'generic', ] as const; export type DatasetViewerType = (typeof DATASET_VIEWER_TYPES)[number]; -- GitLab