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

Austenem/CAT-793 unified datasets attribution #3551

Merged
merged 11 commits into from
Oct 2, 2024
1 change: 1 addition & 0 deletions CHANGELOG-unified-datasets-attribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Remove "Contact" section and add Attribution table with contributors for EPICs and Lab Processed datasets.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const tooltips = {
contact: 'This is the contact for this data.',
};

const DatasetAttribution = (
export const DatasetAttributionDescription = (
<SectionDescription>
Below is the information for the individuals who provided this dataset. For questions about this dataset, reach out
to the individuals listed as contacts, either via the email address listed in the table or via contact information
Expand Down Expand Up @@ -44,7 +44,7 @@ function Attribution({ children }: PropsWithChildren) {
return (
<CollapsibleDetailPageSection id="attribution" title="Attribution" icon={sectionIconMap.attribution}>
<Stack spacing={1}>
{isDataset && DatasetAttribution}
{isDataset && DatasetAttributionDescription}
<SummaryPaper>
<Stack direction="row" spacing={10}>
{sections.map((props) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function HelperPanelBody() {
</HelperPanelBodyItem>
)}
<HelperPanelBodyItem label="Pipeline">{currentDataset.pipeline}</HelperPanelBodyItem>
<HelperPanelBodyItem label="Consortium">{currentDataset.group_name}</HelperPanelBodyItem>
<HelperPanelBodyItem label="Group">{currentDataset.group_name}</HelperPanelBodyItem>
<HelperPanelBodyItem label={dateLabel}>{date && formatDate(date, 'yyyy-MM-dd')}</HelperPanelBodyItem>
</>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
import React, { useState } from 'react';
import LabelledSectionText from 'js/shared-styles/sections/LabelledSectionText';
import { formatDate } from 'date-fns/format';
import { Tabs, Tab, TabPanel } from 'js/shared-styles/tabs';

import FactCheckRounded from '@mui/icons-material/FactCheckRounded';
import SummarizeRounded from '@mui/icons-material/SummarizeRounded';
import AttributionRoundedIcon from '@mui/icons-material/AttributionRounded';
import InsertDriveFileRounded from '@mui/icons-material/InsertDriveFileRounded';
import Skeleton from '@mui/material/Skeleton';
import Stack from '@mui/material/Stack';

import LabelledSectionText from 'js/shared-styles/sections/LabelledSectionText';
import { Tabs, Tab, TabPanel } from 'js/shared-styles/tabs';
import { VisualizationIcon } from 'js/shared-styles/icons';
import { useVitessceConf } from 'js/pages/Dataset/hooks';
import { isSupport } from 'js/components/types';
import { useFlaskDataContext } from 'js/components/Contexts';
import Skeleton from '@mui/material/Skeleton';
import ContactUsLink from 'js/shared-styles/Links/ContactUsLink';
import Files from '../../files/Files';
import DataProducts from '../../files/DataProducts';
import VisualizationWrapper from '../../visualization/VisualizationWrapper';
import AnalysisDetails from '../../AnalysisDetails';
import Protocol from '../../Protocol';
import ContributorsTable from 'js/components/detailPage/ContributorsTable';
import { DatasetAttributionDescription } from 'js/components/detailPage/Attribution/Attribution';
import Files from 'js/components/detailPage/files/Files';
import DataProducts from 'js/components/detailPage/files/DataProducts';
import VisualizationWrapper from 'js/components/detailPage/visualization/VisualizationWrapper';
import AnalysisDetails from 'js/components/detailPage/AnalysisDetails';
import Protocol from 'js/components/detailPage/Protocol';
import { getDateLabelAndValue } from 'js/components/detailPage/utils';
import { useSelectedVersionStore } from 'js/components/detailPage/VersionSelect/SelectedVersionStore';
import { useVersions } from 'js/components/detailPage/VersionSelect/hooks';
import { useTrackEntityPageEvent } from 'js/components/detailPage/useTrackEntityPageEvent';

import { DatasetTitle } from './DatasetTitle';
import { ProcessedDatasetAccordion } from './ProcessedDatasetAccordion';
import { Subsection } from './Subsection';
import { SectionDescription } from './SectionDescription';
import useProcessedDataStore from '../store';
import { getDateLabelAndValue } from '../../utils';
import {
ProcessedDatasetContextProvider,
useProcessedDatasetContext,
ProcessedDataVisualizationProps,
} from './ProcessedDatasetContext';
import { useSelectedVersionStore } from '../../VersionSelect/SelectedVersionStore';
import { useProcessedDatasetDetails } from './hooks';
import { useVersions } from '../../VersionSelect/hooks';
import { useTrackEntityPageEvent } from '../../useTrackEntityPageEvent';
import { OldVersionAlert } from './OldVersionAlert';

function ProcessedDatasetDescription() {
Expand All @@ -47,12 +54,13 @@ function ProcessedDatasetDescription() {

function Contact() {
const {
dataset: { mapped_consortium },
dataset: { creation_action },
} = useProcessedDatasetContext();

if (mapped_consortium !== 'HuBMAP') {
if (creation_action !== 'Central Process') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a constant here as well.

return null;
}

return (
<LabelledSectionText label="Contact" iconTooltipText="This is the contact for this data.">
<ContactUsLink>HuBMAP Help Desk</ContactUsLink>
Expand All @@ -65,12 +73,15 @@ function SummaryAccordion() {
const [dateLabel, dateValue] = getDateLabelAndValue(dataset);
return (
<Subsection title="Summary" icon={<SummarizeRounded />}>
<ProcessedDatasetDescription />
<LabelledSectionText label="Consortium">{dataset.group_name}</LabelledSectionText>
<Contact />
<LabelledSectionText label={dateLabel}>
{dateValue ? formatDate(new Date(dateValue), 'yyyy-MM-dd') : 'N/A'}
</LabelledSectionText>
<Stack spacing={1}>
<ProcessedDatasetDescription />
<LabelledSectionText label="Group">{dataset.group_name}</LabelledSectionText>
<LabelledSectionText label="Consortium">{dataset.mapped_consortium}</LabelledSectionText>
<Contact />
<LabelledSectionText label={dateLabel}>
{dateValue ? formatDate(new Date(dateValue), 'yyyy-MM-dd') : 'N/A'}
</LabelledSectionText>
</Stack>
</Subsection>
);
}
Expand Down Expand Up @@ -182,6 +193,23 @@ function AnalysisDetailsAccordion() {
);
}

function AttributionAccordion() {
const {
dataset: { creation_action, contributors, contacts },
} = useProcessedDatasetContext();

if (creation_action === 'Central Process' || !contributors?.length) {
return null;
}

return (
<Subsection title="Attribution" idTitleOverride="attribution" icon={<AttributionRoundedIcon />}>
{DatasetAttributionDescription}
<ContributorsTable contributors={contributors} contacts={contacts} />
</Subsection>
);
}

export default function ProcessedDataset({ sectionDataset }: ProcessedDataVisualizationProps) {
const selectedDatasetVersionUUID =
useSelectedVersionStore((state) => state.selectedVersions.get(sectionDataset.uuid))?.uuid ?? sectionDataset.uuid;
Expand Down Expand Up @@ -213,6 +241,7 @@ export default function ProcessedDataset({ sectionDataset }: ProcessedDataVisual
<VisualizationAccordion />
<FilesAccordion />
<AnalysisDetailsAccordion />
<AttributionAccordion />
</ProcessedDatasetAccordion>
</ProcessedDatasetContextProvider>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export type ProcessedDatasetDetails = ProcessedDatasetInfo &
| 'metadata'
| 'protocol_url' // TODO: This is present for non-dataset entities, but not for datasets.
| 'dataset_type'
| 'creation_action'
| 'mapped_consortium'
>;

Expand Down Expand Up @@ -53,6 +52,8 @@ export function useProcessedDatasetDetails(uuid: string) {
'dataset_type',
'creation_action',
'mapped_consortium',
'contributors',
'contacts',
],
size: 10000,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import { CreationAction } from 'js/components/types';
import { renderHook } from 'test-utils/functions';
import { useSortedSearchHits, createdByCentralProcess, datasetIsPublished } from './hooks';

const testDatasets = [
const testDatasets: {
_id: string;
_index: string;
_score: number;
_source: {
assay_display_name: string[];
created_timestamp: number;
creation_action: CreationAction;
entity_type: string;
hubmap_id: string;
pipeline: string;
status: string;
uuid: string;
visualization: boolean;
};
_type: string;
}[] = [
{
_id: 'c1fc38a4a6139a4830b8b2aec7227a8e',
_index: 'hm_prod_consortium_portal',
Expand Down
9 changes: 9 additions & 0 deletions context/app/static/js/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ export interface Sample extends Entity {
origin_samples: Sample[];
}

export type CreationAction =
| 'Create Dataset Activity'
| 'Central Process'
| 'Multi-Assay Split'
| 'Lab Process'
| 'Create Publication Activity'
| 'External Process';

export interface Dataset extends Entity {
entity_type: 'Dataset';
processing: 'raw' | 'processed';
Expand All @@ -93,6 +101,7 @@ export interface Dataset extends Entity {
assay_modality: 'single' | 'multiple';
donor: Donor;
mapped_data_access_level: 'Public' | 'Protected' | 'Consortium';
creation_action: CreationAction;
origin_samples: Sample[];
origin_samples_unique_mapped_organs: string[];
mapped_data_types: string[];
Expand Down
8 changes: 6 additions & 2 deletions context/app/static/js/pages/Dataset/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ export type ProcessedDatasetInfo = Pick<
| 'dbgap_sra_experiment_url'
| 'is_component'
| 'visualization'
| 'contributors'
| 'contacts'
>;

type VitessceConf = object | undefined;
Expand Down Expand Up @@ -106,6 +108,7 @@ function useProcessedDatasets(includeComponents?: boolean) {
'dbgap_sra_experiment_url',
'is_component',
'visualization',
'contributors',
],
size: 10000,
};
Expand All @@ -128,13 +131,14 @@ function getProcessedDatasetSection({
hit: Required<SearchHit<ProcessedDatasetInfo>>;
conf?: VitessceConf;
}) {
const { pipeline, hubmap_id, files, metadata, visualization } = hit._source;
const { pipeline, hubmap_id, files, metadata, visualization, creation_action, contributors } = hit._source;

const shouldDisplaySection = {
summary: true,
visualization: visualization || Boolean(conf && 'data' in conf && conf?.data),
files: Boolean(files),
files: Boolean(files?.length),
analysis: Boolean(metadata?.dag_provenance_list),
attribution: creation_action !== 'Central Process' && Boolean(contributors?.length),
};

const sectionsToDisplay = Object.entries(shouldDisplaySection).filter(([_k, v]) => v === true);
Expand Down
Loading