import * as React from 'react'; import { calcProteinChangeSortValue } from 'cbioportal-utils'; import { CosmicMutation } from 'cbioportal-ts-api-client'; import { Column, default as LazyMobXTable, } from '../lazyMobXTable/LazyMobXTable'; // TODO interface ICosmicTableProps extends IMSKTableProps // To avoid duplication, it would be nice here to have an extendable interface for LazyMobXTableProps export interface ICosmicTableProps { data: CosmicMutation[]; columns?: Array>; initialSortColumn?: string; initialSortDirection?: 'asc' | 'desc'; initialItemsPerPage?: number; } // LazyMobXTable is a generic component which requires data type argument class CosmicTable extends LazyMobXTable {} /** * @author Selcuk Onur Sumer */ export default class CosmicMutationTable extends React.Component< ICosmicTableProps, {} > { public static defaultProps = { data: [], columns: [ { name: 'COSMIC ID', order: 1.0, render: (d: CosmicMutation) => ( {d.cosmicMutationId} ), sortBy: (d: CosmicMutation) => d.cosmicMutationId, }, { name: 'Protein Change', order: 2.0, render: (d: CosmicMutation) => {d.proteinChange}, sortBy: (d: CosmicMutation) => calcProteinChangeSortValue(d.proteinChange), }, { name: 'Occurrence', order: 3.0, render: (d: CosmicMutation) => {d.count}, sortBy: (d: CosmicMutation) => d.count, }, ], initialSortColumn: 'Occurrence', initialSortDirection: 'desc', initialItemsPerPage: 10, }; constructor(props: ICosmicTableProps) { super(props); this.state = {}; } public render() { const { data, columns, initialSortColumn, initialSortDirection, initialItemsPerPage, } = this.props; const showPagination = data.length > (this.props.initialItemsPerPage || CosmicMutationTable.defaultProps.initialItemsPerPage); return (
); } }