From 89af8b986f5eb3df6096026be91f992f2ef0bebd Mon Sep 17 00:00:00 2001 From: Henry Zhao Date: Thu, 17 Jan 2019 11:03:57 -0500 Subject: [PATCH 1/3] Hide Survival selectable columns from arrangecolumn button in case entity page and gene entity page --- .../@ncigdc/components/ArrangeColumns.tsx | 17 +- .../components/ArrangeColumnsButton.js | 11 +- .../@ncigdc/components/TableActions.tsx | 3 + .../GenesTable/GenesTable.model.tsx | 146 +++++++++--------- .../modern_components/SsmsTable/SsmsTable.js | 1 + 5 files changed, 99 insertions(+), 79 deletions(-) diff --git a/src/packages/@ncigdc/components/ArrangeColumns.tsx b/src/packages/@ncigdc/components/ArrangeColumns.tsx index 9de03c75a..88937a807 100644 --- a/src/packages/@ncigdc/components/ArrangeColumns.tsx +++ b/src/packages/@ncigdc/components/ArrangeColumns.tsx @@ -41,6 +41,7 @@ interface IArrangeColumnsProps { state: IState; searchTerm: string; entityType: string; + hideColumns?: string[]; } const ArrangeColumns = compose( connect( @@ -52,11 +53,19 @@ const ArrangeColumns = compose( }; [x: string]: any; }, - props: { entityType: string; searchTerm: string; [x: string]: any } + props: { + entityType: string; + searchTerm: string; + [x: string]: any; + hideColumns: string[]; + } ) => ({ - localTableColumns: state.tableColumns[props.entityType], + localTableColumns: state.tableColumns[props.entityType].filter( + (t: IColumnProps) => !props.hideColumns.includes(t.id) + ), filteredTableColumns: state.tableColumns[props.entityType].filter( - (t: IColumnProps) => !t.subHeading + (t: IColumnProps) => + !props.hideColumns.includes(t.id) && !t.subHeading ), }) ), @@ -84,10 +93,12 @@ const ArrangeColumns = compose( state, searchTerm, entityType, + hideColumns, }) => { const subHeadings = localTableColumns.filter((t: IColumnProps) => t.subHeading) || []; + return (
{filteredTableColumns.map( diff --git a/src/packages/@ncigdc/components/ArrangeColumnsButton.js b/src/packages/@ncigdc/components/ArrangeColumnsButton.js index 6155016d4..a10ab9c73 100644 --- a/src/packages/@ncigdc/components/ArrangeColumnsButton.js +++ b/src/packages/@ncigdc/components/ArrangeColumnsButton.js @@ -32,7 +32,7 @@ const RestoreDefaults = styled(Row, { const ArrangeColumnsButton = compose( connect(), - withState('searchTerm', 'setSearchTerm', ''), + withState('searchTerm', 'setSearchTerm', '') )( class extends React.Component { searchInput; @@ -43,6 +43,7 @@ const ArrangeColumnsButton = compose( dispatch, entityType, style = {}, + hideColumns, } = this.props; return ( Restore Defaults - + ); } - }, + } ); export default ArrangeColumnsButton; diff --git a/src/packages/@ncigdc/components/TableActions.tsx b/src/packages/@ncigdc/components/TableActions.tsx index 199351f4f..ce157f7ea 100644 --- a/src/packages/@ncigdc/components/TableActions.tsx +++ b/src/packages/@ncigdc/components/TableActions.tsx @@ -80,6 +80,7 @@ interface IProps { AppendSetButton?: React.ComponentClass; downloadClinical?: boolean; downloadBiospecimen?: boolean; + hideColumns?: string[]; } const TableActions: React.SFC = ({ @@ -110,6 +111,7 @@ const TableActions: React.SFC = ({ downloadBiospecimen, theme, totalCases, + hideColumns, }: IProps) => { const fieldContains = ({ filters, @@ -128,6 +130,7 @@ const TableActions: React.SFC = ({ )} {sortOptions && ( diff --git a/src/packages/@ncigdc/modern_components/GenesTable/GenesTable.model.tsx b/src/packages/@ncigdc/modern_components/GenesTable/GenesTable.model.tsx index 22a471893..f952b93ce 100644 --- a/src/packages/@ncigdc/modern_components/GenesTable/GenesTable.model.tsx +++ b/src/packages/@ncigdc/modern_components/GenesTable/GenesTable.model.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { scaleOrdinal, schemeCategory10 } from 'd3'; +// import { scaleOrdinal, schemeCategory10 } from 'd3'; import { Th, Td, ThNum, TdNum } from '@ncigdc/uikit/Table'; import { makeFilter, @@ -10,16 +10,16 @@ import { } from '@ncigdc/utils/filters'; import GeneLink from '@ncigdc/components/Links/GeneLink'; import { tableToolTipHint } from '@ncigdc/theme/mixins'; -import SurvivalIcon from '@ncigdc/theme/icons/SurvivalIcon'; +// import SurvivalIcon from '@ncigdc/theme/icons/SurvivalIcon'; import ExploreLink from '@ncigdc/components/Links/ExploreLink'; import { Tooltip } from '@ncigdc/uikit/Tooltip'; -import { SpinnerIcon } from '@ncigdc/theme/icons'; +// import { SpinnerIcon } from '@ncigdc/theme/icons'; import ProjectBreakdown from '@ncigdc/modern_components/ProjectBreakdown'; import MutationsCount from '@ncigdc/components/MutationsCount'; import CosmicIcon from '@ncigdc/theme/icons/Cosmic'; -import Hidden from '@ncigdc/components/Hidden'; -import { getSurvivalCurves } from '@ncigdc/utils/survivalplot'; -import Button from '@ncigdc/uikit/Button'; +// import Hidden from '@ncigdc/components/Hidden'; +// import { getSurvivalCurves } from '@ncigdc/utils/survivalplot'; +// import Button from '@ncigdc/uikit/Button'; import ExploreSSMLink from '@ncigdc/components/Links/ExploreSSMLink'; import { ForTsvExport } from '@ncigdc/components/DownloadTableToTsvButton'; @@ -55,7 +55,7 @@ export interface ISelectedSurvivalDataProps { legend?: Array<{ key: string; value: string | JSX.Element }>; } -const colors = scaleOrdinal(schemeCategory10); +// const colors = scaleOrdinal(schemeCategory10); const GenesTableModel = [ createSelectColumn({ idField: 'gene_id' }), @@ -483,72 +483,72 @@ const GenesTableModel = [ ), }, - { - name: 'Survival', - id: 'survival_plot', - th: () => Survival, - td: ({ - node, - hasEnoughSurvivalDataOnPrimaryCurve, - selectedSurvivalData, - setSurvivalLoadingId, - setSelectedSurvivalData, - survivalLoadingId, - defaultFilters, - }: { - node: INodeProps['node']; - hasEnoughSurvivalDataOnPrimaryCurve: boolean; - selectedSurvivalData: ISelectedSurvivalDataProps; - setSurvivalLoadingId: (id: string) => void; - setSelectedSurvivalData: (data: ISelectedSurvivalDataProps) => void; - survivalLoadingId: string; - defaultFilters: IGroupFilter; - }) => ( - - - - - - ), - }, + // { + // name: 'Survival', + // id: 'survival_plot', + // th: () => Survival, + // td: ({ + // node, + // hasEnoughSurvivalDataOnPrimaryCurve, + // selectedSurvivalData, + // setSurvivalLoadingId, + // setSelectedSurvivalData, + // survivalLoadingId, + // defaultFilters, + // }: { + // node: INodeProps['node']; + // hasEnoughSurvivalDataOnPrimaryCurve: boolean; + // selectedSurvivalData: ISelectedSurvivalDataProps; + // setSurvivalLoadingId: (id: string) => void; + // setSelectedSurvivalData: (data: ISelectedSurvivalDataProps) => void; + // survivalLoadingId: string; + // defaultFilters: IGroupFilter; + // }) => ( + // + // + // + // + // + // ), + // }, ]; export default GenesTableModel; diff --git a/src/packages/@ncigdc/modern_components/SsmsTable/SsmsTable.js b/src/packages/@ncigdc/modern_components/SsmsTable/SsmsTable.js index 368da3a94..8447bb4ad 100644 --- a/src/packages/@ncigdc/modern_components/SsmsTable/SsmsTable.js +++ b/src/packages/@ncigdc/modern_components/SsmsTable/SsmsTable.js @@ -152,6 +152,7 @@ export default compose( RemoveFromSetButton={RemoveFromExploreSsmSetButton} idField="ssms.ssm_id" selectedIds={selectedIds} + hideColumns={hideSurvival ? ['survival_plot'] : []} /> From 17031a6fdffc9b7d32b467e160aee61f5122313e Mon Sep 17 00:00:00 2001 From: Henry Zhao Date: Thu, 17 Jan 2019 11:09:53 -0500 Subject: [PATCH 2/3] Removed useless comment. --- .../GenesTable/GenesTable.model.tsx | 146 +++++++++--------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/src/packages/@ncigdc/modern_components/GenesTable/GenesTable.model.tsx b/src/packages/@ncigdc/modern_components/GenesTable/GenesTable.model.tsx index f952b93ce..22a471893 100644 --- a/src/packages/@ncigdc/modern_components/GenesTable/GenesTable.model.tsx +++ b/src/packages/@ncigdc/modern_components/GenesTable/GenesTable.model.tsx @@ -1,5 +1,5 @@ import React from 'react'; -// import { scaleOrdinal, schemeCategory10 } from 'd3'; +import { scaleOrdinal, schemeCategory10 } from 'd3'; import { Th, Td, ThNum, TdNum } from '@ncigdc/uikit/Table'; import { makeFilter, @@ -10,16 +10,16 @@ import { } from '@ncigdc/utils/filters'; import GeneLink from '@ncigdc/components/Links/GeneLink'; import { tableToolTipHint } from '@ncigdc/theme/mixins'; -// import SurvivalIcon from '@ncigdc/theme/icons/SurvivalIcon'; +import SurvivalIcon from '@ncigdc/theme/icons/SurvivalIcon'; import ExploreLink from '@ncigdc/components/Links/ExploreLink'; import { Tooltip } from '@ncigdc/uikit/Tooltip'; -// import { SpinnerIcon } from '@ncigdc/theme/icons'; +import { SpinnerIcon } from '@ncigdc/theme/icons'; import ProjectBreakdown from '@ncigdc/modern_components/ProjectBreakdown'; import MutationsCount from '@ncigdc/components/MutationsCount'; import CosmicIcon from '@ncigdc/theme/icons/Cosmic'; -// import Hidden from '@ncigdc/components/Hidden'; -// import { getSurvivalCurves } from '@ncigdc/utils/survivalplot'; -// import Button from '@ncigdc/uikit/Button'; +import Hidden from '@ncigdc/components/Hidden'; +import { getSurvivalCurves } from '@ncigdc/utils/survivalplot'; +import Button from '@ncigdc/uikit/Button'; import ExploreSSMLink from '@ncigdc/components/Links/ExploreSSMLink'; import { ForTsvExport } from '@ncigdc/components/DownloadTableToTsvButton'; @@ -55,7 +55,7 @@ export interface ISelectedSurvivalDataProps { legend?: Array<{ key: string; value: string | JSX.Element }>; } -// const colors = scaleOrdinal(schemeCategory10); +const colors = scaleOrdinal(schemeCategory10); const GenesTableModel = [ createSelectColumn({ idField: 'gene_id' }), @@ -483,72 +483,72 @@ const GenesTableModel = [ ), }, - // { - // name: 'Survival', - // id: 'survival_plot', - // th: () => Survival, - // td: ({ - // node, - // hasEnoughSurvivalDataOnPrimaryCurve, - // selectedSurvivalData, - // setSurvivalLoadingId, - // setSelectedSurvivalData, - // survivalLoadingId, - // defaultFilters, - // }: { - // node: INodeProps['node']; - // hasEnoughSurvivalDataOnPrimaryCurve: boolean; - // selectedSurvivalData: ISelectedSurvivalDataProps; - // setSurvivalLoadingId: (id: string) => void; - // setSelectedSurvivalData: (data: ISelectedSurvivalDataProps) => void; - // survivalLoadingId: string; - // defaultFilters: IGroupFilter; - // }) => ( - // - // - // - // - // - // ), - // }, + { + name: 'Survival', + id: 'survival_plot', + th: () => Survival, + td: ({ + node, + hasEnoughSurvivalDataOnPrimaryCurve, + selectedSurvivalData, + setSurvivalLoadingId, + setSelectedSurvivalData, + survivalLoadingId, + defaultFilters, + }: { + node: INodeProps['node']; + hasEnoughSurvivalDataOnPrimaryCurve: boolean; + selectedSurvivalData: ISelectedSurvivalDataProps; + setSurvivalLoadingId: (id: string) => void; + setSelectedSurvivalData: (data: ISelectedSurvivalDataProps) => void; + survivalLoadingId: string; + defaultFilters: IGroupFilter; + }) => ( + + + + + + ), + }, ]; export default GenesTableModel; From 2da13e896da78167ece3cf023151f7541cf91171 Mon Sep 17 00:00:00 2001 From: Henry Zhao Date: Thu, 17 Jan 2019 11:38:17 -0500 Subject: [PATCH 3/3] Prevented hideColumns to be undefined. --- src/packages/@ncigdc/components/ArrangeColumns.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/@ncigdc/components/ArrangeColumns.tsx b/src/packages/@ncigdc/components/ArrangeColumns.tsx index 88937a807..69f658fd1 100644 --- a/src/packages/@ncigdc/components/ArrangeColumns.tsx +++ b/src/packages/@ncigdc/components/ArrangeColumns.tsx @@ -61,11 +61,11 @@ const ArrangeColumns = compose( } ) => ({ localTableColumns: state.tableColumns[props.entityType].filter( - (t: IColumnProps) => !props.hideColumns.includes(t.id) + (t: IColumnProps) => !(props.hideColumns || []).includes(t.id) ), filteredTableColumns: state.tableColumns[props.entityType].filter( (t: IColumnProps) => - !props.hideColumns.includes(t.id) && !t.subHeading + !(props.hideColumns || []).includes(t.id) && !t.subHeading ), }) ),