@@ -4,6 +4,7 @@ const { Link } = require('react-router-dom');
44const queryString = require ( 'query-string' ) ;
55const _ = require ( 'lodash' ) ;
66
7+ const MIN_GENE_COUNT_ENRICHMENT = 5 ;
78const { NS_HGNC_SYMBOL , NS_GENECARDS , NS_NCBI_GENE , NS_UNIPROT } = require ( '../../../config' ) ;
89
910const SUPPORTED_COLLECTIONS = new Map ( [
@@ -37,24 +38,26 @@ class EntitySummaryBox extends React.Component {
3738}
3839
3940class GeneResultsView extends React . Component {
40- getEnrichmentAppInfo ( ) {
41+ getEnrichmentAppInfo ( geneResults ) {
4142 let label = `View` ;
4243 let linkPath = '/enrichment' ;
4344 let description = 'Explore a network of pathways that contain genes identified in your query.' ;
4445 let imageClass = 'enrichment-logo' ;
4546 let title = 'Enrichment' ;
47+ let show = geneResults . length >= MIN_GENE_COUNT_ENRICHMENT ;
4648
47- return { label, title, linkPath, description, imageClass } ;
49+ return { label, title, linkPath, description, imageClass, show } ;
4850 }
4951
50- getInteractionsAppInfo ( ) {
52+ getInteractionsAppInfo ( geneResults ) {
5153 let label = `View` ;
5254 let description = 'Visualize interactions between the genes identified in your query.' ;
5355 let linkPath = '/interactions' ;
5456 let imageClass = 'interactions-logo' ;
5557 let title = 'Interactions' ;
58+ let show = geneResults . length > 0 ;
5659
57- return { label, title, linkPath, description, imageClass } ;
60+ return { label, title, linkPath, description, imageClass, show } ;
5861 }
5962
6063 render ( ) {
@@ -65,9 +68,6 @@ class GeneResultsView extends React.Component {
6568 }
6669
6770 let sources = geneResults . map ( geneInfo => geneInfo . geneSymbol ) ;
68- let interactionsAppInfo = this . getInteractionsAppInfo ( ) ;
69- let enrichmentAppInfo = this . getEnrichmentAppInfo ( ) ;
70-
7171 let AppLinkout = appInfo => {
7272 let { linkPath, imageClass, title, description } = appInfo ;
7373
@@ -88,6 +88,13 @@ class GeneResultsView extends React.Component {
8888 ] ) ;
8989 } ;
9090
91+ const appsLinkouts = [
92+ this . getInteractionsAppInfo ( geneResults ) ,
93+ this . getEnrichmentAppInfo ( geneResults )
94+ ] . map ( info => {
95+ return info . show ? h ( AppLinkout , info ) : null ;
96+ } ) ;
97+
9198 return h ( 'div.search-genes-results' , [
9299 h ( 'h3.search-genes-header' , `Recognized genes (${ geneResults . length } )` ) ,
93100 h ( 'div.search-genes-list' , [
@@ -97,10 +104,7 @@ class GeneResultsView extends React.Component {
97104 ] ) ;
98105 } )
99106 ] ) ,
100- h ( 'div.app-linkouts' , [
101- h ( AppLinkout , interactionsAppInfo ) ,
102- h ( AppLinkout , enrichmentAppInfo )
103- ] )
107+ h ( 'div.app-linkouts' , appsLinkouts )
104108 ] ) ;
105109 }
106110}
0 commit comments