Explore: reuse table merge from table panel

- Extracted table panel's merge logic to combine multiple tables into one
- Put the merge logic into the table model as it merges multiple table
  models
- make use of merge in Explore's table query response handler
- copied tests over to table model spec, kept essential tests in
  transformer spec
This commit is contained in:
David Kaltschmidt
2018-10-19 15:29:58 +02:00
parent 34ef5e77b7
commit 374fe9dcb4
6 changed files with 237 additions and 146 deletions

View File

@@ -5,6 +5,8 @@ import ReactTable from 'react-table';
import TableModel from 'app/core/table_model';
const EMPTY_TABLE = new TableModel();
// Identify columns that contain values
const VALUE_REGEX = /^[Vv]alue #\d+/;
interface TableProps {
data: TableModel;
@@ -34,6 +36,7 @@ export default class Table extends PureComponent<TableProps> {
const columns = tableModel.columns.map(({ filterable, text }) => ({
Header: text,
accessor: text,
className: VALUE_REGEX.test(text) ? 'text-right' : '',
show: text !== 'Time',
Cell: row => <span className={filterable ? 'link' : ''}>{row.value}</span>,
}));