Commit ca5d7c35 by ryan

fix type errors

parent d7b1fd75
......@@ -86,7 +86,8 @@ export class DataTable extends Component<Props, State> {
// Update the data when data or sort changes
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';
import { getColorDefinitionByName } from '@grafana/ui';
import { ScopedVars } from '@grafana/ui/src/types';
import moment from 'moment';
import { TableRenderer } from './renderer';
import { Index } from 'react-virtualized';
import { ColumnStyle } from './DataTable';
......
......@@ -98,7 +98,7 @@ export class TableRenderer {
}
}
createColumnFormatter(header: Column, style?: ColumnStyle): CellFormatter {
createColumnFormatter(schema: Column, style?: ColumnStyle): CellFormatter {
if (!style) {
return this.defaultCellFormatter;
}
......@@ -181,7 +181,7 @@ export class TableRenderer {
}
if (style.type === 'number') {
const valueFormatter = getValueFormat(style.unit || header.unit);
const valueFormatter = getValueFormat(style.unit || schema.unit || 'none');
return v => {
if (v === null || v === void 0) {
......
......@@ -174,8 +174,8 @@ export function processTimeSeries({ timeSeries, nullValueMode }: Options): TimeS
return vmSeries;
}
export function sortTableData(data?: TableData, sortIndex?: number, reverse = false): TableData {
if (data && isNumber(sortIndex)) {
export function sortTableData(data: TableData, sortIndex?: number, reverse = false): TableData {
if (isNumber(sortIndex)) {
const copy = {
...data,
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