@@ -50,6 +50,7 @@ import {
50
50
FadeProps as MFadeProps ,
51
51
} from "@mui/material" ;
52
52
import { ColumnDef } from "@tanstack/react-table" ;
53
+ import { NETWORK_KEYS } from "app/components/Index/common/constants" ;
53
54
import React , { ElementType , Fragment , ReactElement } from "react" ;
54
55
import {
55
56
HCA_DCP_CATEGORY_KEY ,
@@ -79,7 +80,10 @@ import {
79
80
} from "../../../../apis/azul/hca-dcp/common/responses" ;
80
81
import * as C from "../../../../components" ;
81
82
import * as MDX from "../../../../components/common/MDXContent/hca-dcp" ;
82
- import { METADATA_KEY } from "../../../../components/Index/common/entities" ;
83
+ import {
84
+ METADATA_KEY ,
85
+ NetworkKey ,
86
+ } from "../../../../components/Index/common/entities" ;
83
87
import { getPluralizedMetadataLabel } from "../../../../components/Index/common/indexTransformer" ;
84
88
import { humanFileSize } from "../../../../utils/fileSize" ;
85
89
import { DATE_TIME_FORMAT_OPTIONS } from "../../../common/contants" ;
@@ -537,6 +541,22 @@ export const buildBatchCorrectionWarning = (): React.ComponentProps<
537
541
} ;
538
542
} ;
539
543
544
+ /**
545
+ * Build props for the bio network cell component.
546
+ * @param projectsResponse - Response model return from projects API.
547
+ * @returns model to be used as props to be used for the BionetworkCell component.
548
+ */
549
+ export const buildBioNetwork = (
550
+ projectsResponse : ProjectsResponse
551
+ ) : React . ComponentProps < typeof C . BioNetworkCell > => {
552
+ const project = getProjectResponse ( projectsResponse ) ;
553
+ const networkKeys = filterBioNetworks ( project . bionetworkName ?? [ ] ) ;
554
+ return {
555
+ label : getPluralizedMetadataLabel ( METADATA_KEY . BIONETWORK_NAME ) ,
556
+ networkKeys : networkKeys ,
557
+ } ;
558
+ } ;
559
+
540
560
/**
541
561
* Build props for project Citation component from the given projects response.
542
562
* @param projectsResponse - Response model return from projects API.
@@ -1453,6 +1473,17 @@ function calculateEstimatedCellCount(
1453
1473
return rollUpTotalCells ( projectsResponse ) ;
1454
1474
}
1455
1475
1476
+ /**
1477
+ * Returns an array of bionetworks with null values and non-bionetworks filtered out.
1478
+ * @param responseValues - an array containing bionetworks and null values
1479
+ * @returns a filtered array containing only bionetworks
1480
+ */
1481
+ export function filterBioNetworks (
1482
+ responseValues : ( NetworkKey | null ) [ ]
1483
+ ) : NetworkKey [ ] {
1484
+ return responseValues . filter ( isBioNetwork ) ;
1485
+ }
1486
+
1456
1487
/**
1457
1488
* Returns age and age unit object values.
1458
1489
* @param donorOrganisms - Donor organisms.
@@ -2183,6 +2214,15 @@ function isAccessibleTransitionIn(projectsResponse: ProjectsResponse): boolean {
2183
2214
return isAccessible || isReady ;
2184
2215
}
2185
2216
2217
+ /**
2218
+ * Returns true if the given value is a bionetwork, otherwise returns false.
2219
+ * @param value - a value that may or may not be a bionetwork
2220
+ * @returns a boolean indicating whether the value is a bionetwork
2221
+ */
2222
+ export function isBioNetwork ( value : unknown ) : value is NetworkKey {
2223
+ return NETWORK_KEYS . includes ( value as NetworkKey ) ;
2224
+ }
2225
+
2186
2226
/**
2187
2227
* Returns true if the "accessible" file facet has a term value of "true".
2188
2228
* @param fileManifestState - File manifest state.
0 commit comments