Skip to content

Commit 303efb7

Browse files
committed
Merge branch 'development' into 3.0.0
2 parents 11d5a4e + 67eb02c commit 303efb7

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

src/client/features/enrichment/index.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@ const classNames = require('classnames');
66
const queryString = require('query-string');
77

88
const EnrichmentToolbar = require('./enrichment-toolbar');
9-
const { EmptyNetwork, PcLogoLink, CytoscapeNetwork, Popover } = require('../../common/components/');
9+
const { PcLogoLink, CytoscapeNetwork, Popover } = require('../../common/components/');
1010

1111
const CytoscapeService = require('../../common/cy/');
1212
const { ServerAPI } = require('../../services');
1313

1414
const { enrichmentLayout, enrichmentStylesheet, bindEvents } = require('./cy');
15+
const { TimeoutError } = require('../../../util');
16+
const { ErrorMessage } = require('../../common/components/error-message');
17+
1518
class Enrichment extends React.Component {
1619
constructor(props){
1720
super(props);
1821

1922
this.state = {
2023
cySrv: new CytoscapeService({ style: enrichmentStylesheet, onMount: bindEvents }),
2124
sources: _.uniq(queryString.parse(props.location.search).source.split(',')),
22-
errored: false,
25+
error: null,
2326
loading: true,
2427
networkEmpty: false
2528
};
@@ -57,7 +60,7 @@ class Enrichment extends React.Component {
5760
});
5861
} catch( e ){
5962
this.setState({
60-
errored: true,
63+
error: e,
6164
loading: false
6265
});
6366
}
@@ -67,9 +70,18 @@ class Enrichment extends React.Component {
6770
}
6871

6972
render(){
70-
let { loading, cySrv, networkEmpty, sources } = this.state;
73+
let { loading, cySrv, networkEmpty, sources, error } = this.state;
7174
let titleContent = [];
7275

76+
let errorMessage;
77+
if( networkEmpty ) {
78+
errorMessage = h(ErrorMessage, { title: 'No results to display.', body: 'Try different genes in your search.' , footer: null, logo: true } );
79+
} else if( error instanceof TimeoutError ) {
80+
errorMessage = h( ErrorMessage, { title: 'This is taking longer that we expected', body: 'Try again later.', logo: true } );
81+
} else if( error ) {
82+
errorMessage = h( ErrorMessage, { logo: true } );
83+
}
84+
7385
if( sources.length === 1 ){
7486
titleContent.push(h('span', `Pathways enriched for ${sources[0]}`));
7587
}
@@ -95,17 +107,15 @@ class Enrichment extends React.Component {
95107
h(EnrichmentToolbar, { cySrv, sources: this.state.sources, controller: this })
96108
]);
97109

98-
return h('div.enrichment', [
99-
110+
return !errorMessage ? [ h('div.enrichment', [
100111
h(Loader, { loaded: !loading, options: { left: '50%', color: '#16a085' }}, [
101112
appBar
102113
]),
103-
networkEmpty ? h(EmptyNetwork, { msg: 'No results to display', showPcLink: false} ) : null,
104114
h(CytoscapeNetwork, {
105115
cySrv,
106116
className: classNames({'network-loading': loading})
107117
})
108-
]);
118+
]) ]: [errorMessage];
109119
}
110120
}
111121

src/client/features/search/gene-results-view.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { Link } = require('react-router-dom');
44
const queryString = require('query-string');
55
const _ = require('lodash');
66

7+
const MIN_GENE_COUNT_ENRICHMENT = 5;
78
const { NS_HGNC_SYMBOL, NS_GENECARDS, NS_NCBI_GENE, NS_UNIPROT } = require('../../../config');
89

910
const SUPPORTED_COLLECTIONS = new Map([
@@ -37,24 +38,26 @@ class EntitySummaryBox extends React.Component {
3738
}
3839

3940
class 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

Comments
 (0)