Skip to content

Commit

Permalink
Improvise. Adapter. Overcome.
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardCzechowski committed Feb 5, 2020
1 parent cebf8ef commit aa9e7fc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import ReactDOM from 'react-dom';
import './index.css';
import * as serviceWorker from './serviceWorker';
import Grid from 'web/visualizations/components/Grid';
import { context } from './example_data';
import { config, queryResponse } from './example_data';
import { gridAdapter } from 'web/visualizations/components/Grid/adapters/grid_adapter';

ReactDOM.render(<Grid options={context} />, document.getElementById('root'));
const adapter = gridAdapter(config, queryResponse)

ReactDOM.render(<Grid {...adapter} />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
Expand Down
2 changes: 1 addition & 1 deletion src/web/visualizations/components/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const GRID_LICENSE_KEY = 'Looker_Looker_4Devs_3000Deployment_24_April_2020__MTU4

USSEnterprise.setLicenseKey(GRID_LICENSE_KEY)

interface GridProps {
export interface GridProps {
options: GridContext
trackRenderPerformance?: () => void
firstDataRendered?: () => void
Expand Down
19 changes: 19 additions & 0 deletions src/web/visualizations/components/Grid/adapters/grid_adapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { QueryResponse } from 'web/visualizations/types/query_response'
import { VisConfig } from 'web/visualizations/types/vis_config'
import { preprocessQueryResponse } from 'web/visualizations/components/Grid/utils/query_utils'
import { gridMapper } from '../mappers/grid_mapper'
import '../styles/grid_themes.scss'
import { GridProps } from '../Grid'

export const gridAdapter = (config: VisConfig, result: QueryResponse) => {
const processedResult = preprocessQueryResponse(result, config)
if (!processedResult) return {} as GridProps

const visTriggerCb = () => null
const done = () => null
const gridOptions = gridMapper(processedResult, config, visTriggerCb, done)

return {
options: gridOptions,
} as GridProps
}

0 comments on commit aa9e7fc

Please sign in to comment.