Skip to content

Commit

Permalink
NickAkhmetov/CAT-949 Remove provenance section, convert donor page to…
Browse files Browse the repository at this point in the history
… TypeScript (#3571)
  • Loading branch information
NickAkhmetov authored Oct 16, 2024
1 parent 454e23b commit 56d8012
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-cat-949.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Remove Provenance section from donor page in favor of using derived data tables.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ContactUsLink from 'js/shared-styles/Links/ContactUsLink';
import Divider from '@mui/material/Divider';
import { CollapsibleDetailPageSection } from 'js/components/detailPage/DetailPageSection';
import { sectionIconMap } from 'js/shared-styles/icons/sectionIconMap';
import withShouldDisplay from 'js/helpers/withShouldDisplay';
import { StyledPaper } from './style';
import SectionItem from '../SectionItem';
import { useTrackEntityPageEvent } from '../useTrackEntityPageEvent';
Expand Down Expand Up @@ -96,4 +97,4 @@ function Protocol({ protocol_url, showHeader }: ProtocolProps) {
return contents;
}

export default React.memo(Protocol);
export default React.memo(withShouldDisplay(Protocol));
2 changes: 2 additions & 0 deletions context/app/static/js/components/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export interface Donor extends Entity {
race: string[];
body_mass_index_value: string;
}>;
group_name: string;
protocol_url: string;
}

export interface Sample extends Entity {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useMemo } from 'react';

import { useFlaskDataContext } from 'js/components/Contexts';
import ProvSection from 'js/components/detailPage/provenance/ProvSection';
import Summary from 'js/components/detailPage/summary/Summary';
import Attribution from 'js/components/detailPage/Attribution';
import Protocol from 'js/components/detailPage/Protocol';
Expand All @@ -10,57 +9,40 @@ import { DetailContext } from 'js/components/detailPage/DetailContext';
import DerivedEntitiesSection from 'js/components/detailPage/derivedEntities/DerivedEntitiesSection';
import useTrackID from 'js/hooks/useTrackID';
import MetadataSection from 'js/components/detailPage/MetadataSection';
import { isDonor } from 'js/components/types';

function DonorDetail() {
const { entity } = useFlaskDataContext();
const {
uuid,
protocol_url,
hubmap_id,
entity_type,
mapped_metadata = {},
created_timestamp,
last_modified_timestamp,
description,
group_name,
created_by_user_displayname,
created_by_user_email,
} = entity;

if (!isDonor(entity)) {
throw new Error('Entity is not a donor');
}

const { uuid, protocol_url, hubmap_id, entity_type, mapped_metadata = {}, mapped_data_access_level } = entity;

const shouldDisplaySection = {
summary: true,
metadata: Boolean(Object.keys(mapped_metadata).length),
'derived-data': true,
provenance: true,
protocols: Boolean(protocol_url),
attribution: true,
};

useTrackID({ entity_type, hubmap_id });

const detailContext = useMemo(() => ({ hubmap_id, uuid }), [hubmap_id, uuid]);
const detailContext = useMemo(
() => ({ hubmap_id, uuid, mapped_data_access_level }),
[hubmap_id, uuid, mapped_data_access_level],
);

return (
<DetailContext.Provider value={detailContext}>
<DetailLayout sections={shouldDisplaySection}>
<Summary
uuid={uuid}
entity_type={entity_type}
title={hubmap_id}
created_timestamp={created_timestamp}
last_modified_timestamp={last_modified_timestamp}
description={description}
group_name={group_name}
/>
{shouldDisplaySection.metadata && <MetadataSection entities={[entity]} hubmap_id={hubmap_id} />}
<Summary title={hubmap_id} />
<MetadataSection entities={[entity]} shouldDisplay={shouldDisplaySection.metadata} />
<DerivedEntitiesSection />
<ProvSection />
{shouldDisplaySection.protocols && <Protocol protocol_url={protocol_url} showHeader />}
<Attribution
group_name={group_name}
created_by_user_displayname={created_by_user_displayname}
created_by_user_email={created_by_user_email}
/>
<Protocol protocol_url={protocol_url} showHeader shouldDisplay={shouldDisplaySection.protocols} />
<Attribution />
</DetailLayout>
</DetailContext.Provider>
);
Expand Down
File renamed without changes.

0 comments on commit 56d8012

Please sign in to comment.