Commit 22390665 by ryan

don't include stuff from app/...

parent eed9a201
import _ from 'lodash'; import _ from 'lodash';
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, TableData } from '@grafana/ui/src/types';
import { getTheme } from '../../themes'; import { getTheme } from '../../themes';
import Table, { ColumnStyle } from './Table'; import Table, { ColumnStyle } from './Table';
...@@ -12,25 +11,25 @@ xdescribe('when rendering table', () => { ...@@ -12,25 +11,25 @@ xdescribe('when rendering table', () => {
const SemiDarkOrange = getColorDefinitionByName('semi-dark-orange'); const SemiDarkOrange = getColorDefinitionByName('semi-dark-orange');
describe('given 13 columns', () => { describe('given 13 columns', () => {
const table = new TableModel(); const table = {
table.columns = [ type: 'table',
{ text: 'Time' }, columns: [
{ text: 'Value' }, { text: 'Time' },
{ text: 'Colored' }, { text: 'Value' },
{ text: 'Undefined' }, { text: 'Colored' },
{ text: 'String' }, { text: 'Undefined' },
{ text: 'United', unit: 'bps' }, { text: 'String' },
{ text: 'Sanitized' }, { text: 'United', unit: 'bps' },
{ text: 'Link' }, { text: 'Sanitized' },
{ text: 'Array' }, { text: 'Link' },
{ text: 'Mapping' }, { text: 'Array' },
{ text: 'RangeMapping' }, { text: 'Mapping' },
{ text: 'MappingColored' }, { text: 'RangeMapping' },
{ text: 'RangeMappingColored' }, { text: 'MappingColored' },
]; { text: 'RangeMappingColored' },
table.rows = [ ],
[1388556366666, 1230, 40, undefined, '', '', 'my.host.com', 'host1', ['value1', 'value2'], 1, 2, 1, 2], rows: [[1388556366666, 1230, 40, undefined, '', '', 'my.host.com', 'host1', ['value1', 'value2'], 1, 2, 1, 2]],
]; } as TableData;
const styles: ColumnStyle[] = [ const styles: ColumnStyle[] = [
{ {
......
...@@ -13,16 +13,14 @@ import { Themeable } from '../../types/theme'; ...@@ -13,16 +13,14 @@ import { Themeable } from '../../types/theme';
import { sortTableData } from '../../utils/processTimeSeries'; import { sortTableData } from '../../utils/processTimeSeries';
import { sanitize } from 'app/core/utils/text';
import moment from 'moment'; import moment from 'moment';
import { getValueFormat, TableData, getColorFromHexRgbOrName, InterpolateFunction, Column } from '@grafana/ui'; import { getValueFormat, TableData, getColorFromHexRgbOrName, InterpolateFunction, Column } from '@grafana/ui';
import { Index } from 'react-virtualized'; import { Index } from 'react-virtualized';
import { ColumnStyle } from './Table'; import { ColumnStyle } from './Table';
// Types // APP Imports!!!
import kbn from 'app/core/utils/kbn'; // import kbn from 'app/core/utils/kbn';
// Made to match the existing (untyped) settings in the angular table // Made to match the existing (untyped) settings in the angular table
export interface ColumnStyle { export interface ColumnStyle {
...@@ -36,7 +34,7 @@ export interface ColumnStyle { ...@@ -36,7 +34,7 @@ export interface ColumnStyle {
type?: 'date' | 'number' | 'string' | 'hidden'; type?: 'date' | 'number' | 'string' | 'hidden';
unit?: string; unit?: string;
dateFormat?: string; dateFormat?: string;
sanitize?: boolean; sanitize?: boolean; // not used in react
mappingType?: any; mappingType?: any;
valueMaps?: any; valueMaps?: any;
rangeMaps?: any; rangeMaps?: any;
...@@ -126,7 +124,7 @@ export class Table extends Component<Props, State> { ...@@ -126,7 +124,7 @@ export class Table extends Component<Props, State> {
// Find the style based on the text // Find the style based on the text
for (let i = 0; i < styles.length; i++) { for (let i = 0; i < styles.length; i++) {
const s = styles[i]; const s = styles[i];
const regex = kbn.stringToJsRegex(s.pattern); const regex = 'XXX'; //kbn.stringToJsRegex(s.pattern);
if (title.match(regex)) { if (title.match(regex)) {
style = s; style = s;
if (s.alias) { if (s.alias) {
...@@ -172,11 +170,7 @@ export class Table extends Component<Props, State> { ...@@ -172,11 +170,7 @@ export class Table extends Component<Props, State> {
v = v.join(', '); v = v.join(', ');
} }
if (style && style.sanitize) { return v; // react will sanitize
return sanitize(v);
} else {
return _.escape(v);
}
} }
createColumnFormatter(schema: Column, style?: ColumnStyle): CellFormatter { createColumnFormatter(schema: Column, style?: ColumnStyle): CellFormatter {
......
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