Commit ca5d7c35 by ryan

fix type errors

parent d7b1fd75
...@@ -86,7 +86,8 @@ export class DataTable extends Component<Props, State> { ...@@ -86,7 +86,8 @@ export class DataTable extends Component<Props, State> {
// Update the data when data or sort changes // Update the data when data or sort changes
if (dataChanged || sortBy !== prevState.sortBy || sortDirection !== prevState.sortDirection) { if (dataChanged || sortBy !== prevState.sortBy || sortDirection !== prevState.sortDirection) {
this.setState({ data: sortTableData(data, sortBy, sortDirection === 'DESC') }); const sorted = data ? sortTableData(data, sortBy, sortDirection === 'DESC') : data;
this.setState({ data: sorted });
} }
} }
......
...@@ -3,7 +3,6 @@ import TableModel from 'app/core/table_model'; ...@@ -3,7 +3,6 @@ import TableModel from 'app/core/table_model';
import { getColorDefinitionByName } from '@grafana/ui'; import { getColorDefinitionByName } from '@grafana/ui';
import { ScopedVars } from '@grafana/ui/src/types'; import { ScopedVars } from '@grafana/ui/src/types';
import moment from 'moment';
import { TableRenderer } from './renderer'; import { TableRenderer } from './renderer';
import { Index } from 'react-virtualized'; import { Index } from 'react-virtualized';
import { ColumnStyle } from './DataTable'; import { ColumnStyle } from './DataTable';
......
...@@ -98,7 +98,7 @@ export class TableRenderer { ...@@ -98,7 +98,7 @@ export class TableRenderer {
} }
} }
createColumnFormatter(header: Column, style?: ColumnStyle): CellFormatter { createColumnFormatter(schema: Column, style?: ColumnStyle): CellFormatter {
if (!style) { if (!style) {
return this.defaultCellFormatter; return this.defaultCellFormatter;
} }
...@@ -181,7 +181,7 @@ export class TableRenderer { ...@@ -181,7 +181,7 @@ export class TableRenderer {
} }
if (style.type === 'number') { if (style.type === 'number') {
const valueFormatter = getValueFormat(style.unit || header.unit); const valueFormatter = getValueFormat(style.unit || schema.unit || 'none');
return v => { return v => {
if (v === null || v === void 0) { if (v === null || v === void 0) {
......
...@@ -174,8 +174,8 @@ export function processTimeSeries({ timeSeries, nullValueMode }: Options): TimeS ...@@ -174,8 +174,8 @@ export function processTimeSeries({ timeSeries, nullValueMode }: Options): TimeS
return vmSeries; return vmSeries;
} }
export function sortTableData(data?: TableData, sortIndex?: number, reverse = false): TableData { export function sortTableData(data: TableData, sortIndex?: number, reverse = false): TableData {
if (data && isNumber(sortIndex)) { if (isNumber(sortIndex)) {
const copy = { const copy = {
...data, ...data,
rows: [...data.rows].sort((a, b) => { rows: [...data.rows].sort((a, b) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment