1
- import React from 'react' ;
1
+ import React , { ReactNode } from 'react' ;
2
2
import { inject , observer } from 'mobx-react' ;
3
3
import { LevelButton } from 'app/components/levelButton/LevelButton' ;
4
4
import { Button , Col , Row } from 'react-bootstrap' ;
5
5
import classnames from 'classnames' ;
6
6
import privateClient from 'app/shared/api/oncokbPrivateClientInstance' ;
7
- import { remoteData } from 'cbioportal-frontend-commons' ;
7
+ import { remoteData , DefaultTooltip } from 'cbioportal-frontend-commons' ;
8
8
import {
9
9
action ,
10
10
computed ,
@@ -43,6 +43,7 @@ import * as QueryString from 'query-string';
43
43
import OncoKBTable from 'app/components/oncokbTable/OncoKBTable' ;
44
44
import { AuthDownloadButton } from 'app/components/authDownloadButton/AuthDownloadButton' ;
45
45
import DocumentTitle from 'react-document-title' ;
46
+ import { COLOR_BLUE } from 'app/config/theme' ;
46
47
47
48
type Treatment = {
48
49
level : string ;
@@ -435,6 +436,52 @@ export default class ActionableGenesPage extends React.Component<
435
436
return Promise . resolve ( content . join ( '\n' ) ) ;
436
437
}
437
438
439
+ concatElementsByComma ( list : ReactNode [ ] ) {
440
+ return list . reduce ( ( prev , curr ) => [ prev , ', ' , curr ] ) ;
441
+ }
442
+
443
+ getAlterationCell ( hugoSymbol : string , alterations : string [ ] ) {
444
+ const linkedAlts = alterations . map < React . ReactNode > (
445
+ ( alteration , index : number ) => (
446
+ < AlterationPageLink
447
+ key = { index }
448
+ hugoSymbol = { hugoSymbol }
449
+ alteration = { alteration }
450
+ />
451
+ )
452
+ ) ;
453
+ if ( linkedAlts . length > 5 ) {
454
+ return (
455
+ < span >
456
+ { linkedAlts [ 0 ] } and{ ' ' }
457
+ < DefaultTooltip
458
+ overlay = {
459
+ < div style = { { maxWidth : '400px' } } >
460
+ { this . concatElementsByComma ( linkedAlts ) }
461
+ </ div >
462
+ }
463
+ overlayStyle = { {
464
+ opacity : 1
465
+ } }
466
+ placement = "right"
467
+ destroyTooltipOnHide = { true }
468
+ >
469
+ < span
470
+ style = { {
471
+ textDecoration : 'underscore' ,
472
+ color : COLOR_BLUE
473
+ } }
474
+ >
475
+ { linkedAlts . length - 1 } other alterations
476
+ </ span >
477
+ </ DefaultTooltip >
478
+ </ span >
479
+ ) ;
480
+ } else {
481
+ return this . concatElementsByComma ( linkedAlts ) ;
482
+ }
483
+ }
484
+
438
485
private columns = [
439
486
{
440
487
...getDefaultColumnDefinition ( TABLE_COLUMN_KEY . LEVEL )
@@ -454,19 +501,14 @@ export default class ActionableGenesPage extends React.Component<
454
501
style : { whiteSpace : 'normal' } ,
455
502
defaultSortDesc : false ,
456
503
sortMethod : defaultSortMethod ,
457
- Cell ( props : { original : Treatment } ) {
504
+ Cell : ( props : { original : Treatment } ) => {
458
505
return (
459
506
< div style = { { display : 'block' } } >
460
507
{ ' ' }
461
- { props . original . alterations
462
- . map < React . ReactNode > ( ( alteration , index : number ) => (
463
- < AlterationPageLink
464
- key = { index }
465
- hugoSymbol = { props . original . hugoSymbol }
466
- alteration = { alteration }
467
- />
468
- ) )
469
- . reduce ( ( prev , curr ) => [ prev , ', ' , curr ] ) }
508
+ { this . getAlterationCell (
509
+ props . original . hugoSymbol ,
510
+ props . original . alterations
511
+ ) }
470
512
</ div >
471
513
) ;
472
514
}
0 commit comments