Skip to content

Commit

Permalink
Merge pull request #1748 from sennetconsortium/tjmadonna/1731-collect…
Browse files Browse the repository at this point in the history
…ions-section

Tjmadonna/1731 collections section
  • Loading branch information
maxsibilla authored Nov 21, 2024
2 parents fae2280 + d7dc4eb commit b7572e8
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 28 deletions.
29 changes: 29 additions & 0 deletions src/components/custom/entities/Collections.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import SenNetAccordion from "@/components/custom/layout/SenNetAccordion";
import Card from 'react-bootstrap/Card';
import ClipboardCopy from "@/components//ClipboardCopy";
import {getEntityViewUrl} from "@/components/custom/js/functions";

function Collections({ entityType, data }) {
const titleType = data.length > 1 ? 'Collections' : 'Collection';

const collectionsView = data.map((collection) =>
<span key={collection.uuid}>
<a href={getEntityViewUrl('Collection', collection.uuid, {})}>{collection.sennet_id}</a><ClipboardCopy text={collection.sennet_id}/>
&nbsp;
</span>
);

return (
<SenNetAccordion title='Associated Collections'>
<Card border={'0'}>
<Card.Body>
<p className='fw-light fs-6'>This <code>{entityType}</code> is contained in the <code>{titleType}</code>&nbsp;
{collectionsView}
</p>
</Card.Body>
</Card>
</SenNetAccordion>
)
}

export default Collections
31 changes: 12 additions & 19 deletions src/components/custom/entities/dataset/Upload.jsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
import React, {useContext, useEffect, useState} from 'react'
import PropTypes from 'prop-types'
import SenNetAccordion from "../../layout/SenNetAccordion";
import SenNetAccordion from "@/components/custom/layout/SenNetAccordion";
import Card from 'react-bootstrap/Card';
import ClipboardCopy from "../../../ClipboardCopy";
import {getEntityViewUrl} from "../../js/functions";
import ClipboardCopy from "@/components//ClipboardCopy";
import {getEntityViewUrl} from "@/components/custom/js/functions";

function Upload({ data }) {
useEffect(() => {
}, [])

return (
<>
<SenNetAccordion title={'Associated Upload'}>
<Card border={'0'}>
<Card.Body>
<p className='fw-light fs-6'>This <code>Dataset</code> is contained in the data <code>Upload</code>
&nbsp;<a href={getEntityViewUrl('Upload', data.uuid, {})}>{data.sennet_id}</a><ClipboardCopy text={data.sennet_id}/></p>
</Card.Body>
</Card>
</SenNetAccordion>
</>
<SenNetAccordion title={'Associated Upload'}>
<Card border={'0'}>
<Card.Body>
<p className='fw-light fs-6'>This <code>Dataset</code> is contained in the data <code>Upload</code>
&nbsp;<a href={getEntityViewUrl('Upload', data.uuid, {})}>{data.sennet_id}</a><ClipboardCopy text={data.sennet_id}/></p>
</Card.Body>
</Card>
</SenNetAccordion>
)
}

export default Upload
export default Upload
3 changes: 2 additions & 1 deletion src/context/AppContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ export const AppProvider = ({ cache, banners, children }) => {
const hasPublicAccess = (data) => {
let publicAccess = false
if (data) {
publicAccess = (eq(data.data_access_level, 'public') || eq(data.status, 'published'))
publicAccess = (eq(data.data_access_level, 'public') || eq(data.status, 'published')
|| ((eq(data.entity_type, 'Collection') || eq(data.entity_type, 'Epicollection')) && data.doi_url))
&& !router.pathname.contains('edit')
}
return publicAccess
Expand Down
2 changes: 1 addition & 1 deletion src/pages/api/protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import log from "loglevel";

export default async function handler(req, res) {
let baseProtocolUrl = 'https://www.protocols.io/api/v4/protocols/'
let protocolId = getProtocolId(decodeURIComponent(req.query.uri))[0]
let protocolId = getProtocolId(decodeURIComponent(req.query.uri))
log.info(protocolId)

await fetch(baseProtocolUrl + protocolId, {
Expand Down
17 changes: 13 additions & 4 deletions src/pages/dataset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import WarningIcon from '@mui/icons-material/Warning'
const AppFooter = dynamic(() => import("@/components/custom/layout/AppFooter"))
const AppNavbar = dynamic(() => import("@/components/custom/layout/AppNavbar"))
const Attribution = dynamic(() => import("@/components/custom/entities/sample/Attribution"))
const Collections = dynamic(() => import("@/components/custom/entities/Collections"))
const ContributorsContacts = dynamic(() => import("@/components/custom/entities/ContributorsContacts"))
const CreationActionRelationship = dynamic(() => import("@/components/custom/entities/dataset/CreationActionRelationship"))
const DataProducts = dynamic(() => import("@/components/custom/entities/dataset/DataProducts"))
Expand Down Expand Up @@ -64,7 +65,7 @@ function ViewDataset() {
setPrimaryDatasetInfo(primary)
setDatasetCategories(getAssaySplitData(primary))
} else {
console.error('fetchEntityForMultiAssayInfo', primary.error)
log.error('fetchEntityForMultiAssayInfo', primary.error)
}
break;
}
Expand Down Expand Up @@ -107,7 +108,7 @@ function ViewDataset() {
setCitationData(citation)

for (const ancestor of ancestry.ancestors) {
console.log(ancestor)
log.debug(ancestor)
if ((ancestor.metadata && Object.keys(ancestor.metadata).length) || (ancestor.ingest_metadata && Object.keys(ancestor.ingest_metadata) && 'metadata' in ancestor.ingest_metadata)) {
setAncestorHasMetadata(true)
break
Expand Down Expand Up @@ -181,6 +182,13 @@ function ViewDataset() {
data-bs-parent="#sidebar">Upload</a>
</li>
}
{data.collections && data.collections.length > 0 &&
<li className="nav-item">
<a href="#Associated Collections"
className="nav-link"
data-bs-parent="#sidebar">Collections</a>
</li>
}
{showVitessce &&
<li className="nav-item">
<a href="#Vitessce"
Expand Down Expand Up @@ -254,6 +262,9 @@ function ViewDataset() {
{/*Upload*/}
{data.upload && data.upload.uuid && <Upload data={data.upload}/>}

{/*Collection*/}
{data.collections && data.collections.length > 0 && <Collections entityType='Dataset' data={data.collections}/>}

{/* Vitessce */}
<SennetVitessce data={data}/>

Expand All @@ -275,8 +286,6 @@ function ViewDataset() {
{/*Files*/}
<FileTreeView data={data}/>



{/*Contributors*/}
{!!(data.contributors && Object.keys(data.contributors).length) &&
<ContributorsContacts title={'Contributors'} data={data.contributors}/>
Expand Down
14 changes: 12 additions & 2 deletions src/pages/sample.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import dynamic from "next/dynamic";
import React, {useContext, useEffect, useState} from "react";
import {useRouter} from 'next/router';
import log from "loglevel";
import {getRequestHeaders} from "@/components/custom/js/functions";
import {get_write_privilege_for_group_uuid, getAncestryData, getEntityData} from "@/lib/services";
import AppContext from "@/context/AppContext";
import Alert from 'react-bootstrap/Alert';
Expand All @@ -12,6 +11,7 @@ import {APP_ROUTES} from "@/config/constants";
const AppFooter = dynamic(() => import("@/components/custom/layout/AppFooter"))
const AppNavbar = dynamic(() => import("@/components/custom/layout/AppNavbar"))
const Attribution = dynamic(() => import("@/components/custom/entities/sample/Attribution"))
const Collections = dynamic(() => import("@/components/custom/entities/Collections"))
const Description = dynamic(() => import("@/components/custom/entities/sample/Description"))
const Header = dynamic(() => import("@/components/custom/layout/Header"))
const Metadata = dynamic(() => import("@/components/custom/entities/Metadata"))
Expand Down Expand Up @@ -107,6 +107,13 @@ function ViewSample() {
className="nav-link"
data-bs-parent="#sidebar">Tissue</a>
</li>
{data.collections && data.collections.length > 0 &&
<li className="nav-item">
<a href="#Associated Collections"
className="nav-link"
data-bs-parent="#sidebar">Collections</a>
</li>
}
<li className="nav-item">
<a href="#Provenance"
className="nav-link"
Expand Down Expand Up @@ -157,6 +164,9 @@ function ViewSample() {
<Tissue data={data}/>
}

{/*Collection*/}
{data.collections && data.collections.length > 0 && <Collections entityType='Sample' data={data.collections}/>}

{/*Provenance*/}
{data &&
<Provenance nodeData={data}/>
Expand Down Expand Up @@ -193,4 +203,4 @@ function ViewSample() {
}


export default ViewSample
export default ViewSample
13 changes: 12 additions & 1 deletion src/pages/source.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import dynamic from "next/dynamic";
import React, {useContext, useEffect, useState} from "react";
import {useRouter} from 'next/router';
import log from "loglevel";
import {eq, extractSourceMappedMetadataInfo, getRequestHeaders} from "@/components/custom/js/functions";
import {eq, extractSourceMappedMetadataInfo} from "@/components/custom/js/functions";
import {get_write_privilege_for_group_uuid, getAncestryData, getEntityData} from "@/lib/services";
import AppContext from "@/context/AppContext";
import Alert from 'react-bootstrap/Alert';
Expand All @@ -11,6 +11,7 @@ import {EntityViewHeader} from "@/components/custom/layout/entity/ViewHeader";
const AppFooter = dynamic(() => import("@/components/custom/layout/AppFooter"))
const AppNavbar = dynamic(() => import("@/components/custom/layout/AppNavbar"))
const Attribution = dynamic(() => import("@/components/custom/entities/sample/Attribution"))
const Collections = dynamic(() => import("@/components/custom/entities/Collections"))
const Description = dynamic(() => import("@/components/custom/entities/sample/Description"))
const Header = dynamic(() => import("@/components/custom/layout/Header"))
const Metadata = dynamic(() => import("@/components/custom/entities/Metadata"))
Expand Down Expand Up @@ -103,6 +104,13 @@ function ViewSource() {
className="nav-link "
data-bs-parent="#sidebar">Summary</a>
</li>
{data.collections && data.collections.length > 0 &&
<li className="nav-item">
<a href="#Associated Collections"
className="nav-link"
data-bs-parent="#sidebar">Collections</a>
</li>
}
<li className="nav-item">
<a href="#Provenance"
className="nav-link"
Expand Down Expand Up @@ -146,6 +154,9 @@ function ViewSource() {
labId={data.lab_source_id}
/>

{/*Collection*/}
{data.collections && data.collections.length > 0 && <Collections entityType='Source' data={data.collections}/>}

{/*Provenance*/}
{data &&
<Provenance nodeData={data}/>
Expand Down

0 comments on commit b7572e8

Please sign in to comment.