From b80c773ebe0f1b30f150c8b84dccab25531b88d1 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 10 Mar 2019 15:34:02 -0700 Subject: [PATCH] attach themes to table story --- .../grafana-ui/src/components/Table/Table.story.tsx | 8 ++++++-- packages/grafana-ui/src/components/Table/Table.tsx | 2 ++ .../src/components/Table/TableCellBuilder.tsx | 3 +-- packages/grafana-ui/src/utils/stringUtils.ts | 13 ------------- 4 files changed, 9 insertions(+), 17 deletions(-) delete mode 100644 packages/grafana-ui/src/utils/stringUtils.ts diff --git a/packages/grafana-ui/src/components/Table/Table.story.tsx b/packages/grafana-ui/src/components/Table/Table.story.tsx index 240c7def7f3..a9a32eb29f4 100644 --- a/packages/grafana-ui/src/components/Table/Table.story.tsx +++ b/packages/grafana-ui/src/components/Table/Table.story.tsx @@ -1,9 +1,10 @@ // import React from 'react'; import { storiesOf } from '@storybook/react'; import { Table } from './Table'; +import { getTheme } from '../../themes'; import { migratedTestTable, migratedTestStyles, simpleTable } from './examples'; -import { ScopedVars, TableData } from '../../types/index'; +import { ScopedVars, TableData, GrafanaThemeType } from '../../types/index'; import { withFullSizeStory } from '../../utils/storybook/withFullSizeStory'; import { number, boolean } from '@storybook/addon-knobs'; @@ -48,10 +49,11 @@ storiesOf('Alpha/Table', module) fixedRowCount, fixedColumnCount, showHeader, + theme: getTheme(GrafanaThemeType.Light), }); }) .add('variable size', () => { - const columnCount = number('Column Count', 10, { min: 2, max: 50, step: 1, range: false }); + const columnCount = number('Column Count', 20, { min: 2, max: 50, step: 1, range: false }); const rowCount = number('Row Count', 20, { min: 0, max: 100, step: 1, range: false }); const showHeader = boolean('Show Header', true); @@ -65,6 +67,7 @@ storiesOf('Alpha/Table', module) fixedRowCount, fixedColumnCount, showHeader, + theme: getTheme(GrafanaThemeType.Light), }); }) .add('Old tests configuration', () => { @@ -73,5 +76,6 @@ storiesOf('Alpha/Table', module) data: migratedTestTable, replaceVariables, showHeader: true, + theme: getTheme(GrafanaThemeType.Light), }); }); diff --git a/packages/grafana-ui/src/components/Table/Table.tsx b/packages/grafana-ui/src/components/Table/Table.tsx index ee0a90c4bc4..8f2e3d7058b 100644 --- a/packages/grafana-ui/src/components/Table/Table.tsx +++ b/packages/grafana-ui/src/components/Table/Table.tsx @@ -72,6 +72,8 @@ export class Table extends Component { const dataChanged = data !== prevProps.data; const configsChanged = showHeader !== prevProps.showHeader; + console.log('TABLE', this.props.theme); + // Reset the size cache if (dataChanged || configsChanged) { this.measurer.clearAll(); diff --git a/packages/grafana-ui/src/components/Table/TableCellBuilder.tsx b/packages/grafana-ui/src/components/Table/TableCellBuilder.tsx index 75668a7e042..9e0a111aba1 100644 --- a/packages/grafana-ui/src/components/Table/TableCellBuilder.tsx +++ b/packages/grafana-ui/src/components/Table/TableCellBuilder.tsx @@ -86,8 +86,6 @@ export function getCellBuilder(schema: Column, style: ColumnStyle | null, props: } if (style.type === 'date') { - console.log('MAKE DATE Column', schema, style); - return new CellBuilderWithStyle( (v: any) => { if (v === undefined || v === null) { @@ -160,6 +158,7 @@ class CellBuilderWithStyle { private fmt?: ValueFormatter ) { // + console.log('COLUMN', column.text, theme); } getColorForValue = (value: any): string | null => { diff --git a/packages/grafana-ui/src/utils/stringUtils.ts b/packages/grafana-ui/src/utils/stringUtils.ts deleted file mode 100644 index 12433623a6a..00000000000 --- a/packages/grafana-ui/src/utils/stringUtils.ts +++ /dev/null @@ -1,13 +0,0 @@ -export function stringToJsRegex(str: string): RegExp { - if (str[0] !== '/') { - return new RegExp('^' + str + '$'); - } - - const match = str.match(new RegExp('^/(.*?)/(g?i?m?y?)$')); - - if (!match) { - throw new Error(`'${str}' is not a valid regular expression.`); - } - - return new RegExp(match[1], match[2]); -}