All files / javascripts/explorev2 index.jsx

0% Statements 0/14
100% Branches 0/0
0% Functions 0/1
0% Lines 0/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                                                                                   
import React from 'react';
import ReactDOM from 'react-dom';
import ExploreViewContainer from './components/ExploreViewContainer';
import { createStore, applyMiddleware, compose } from 'redux';
import { Provider } from 'react-redux';
import thunk from 'redux-thunk';
 
import { initialState } from './stores/store';
 
const exploreViewContainer = document.getElementById('js-explore-view-container');
const bootstrapData = JSON.parse(exploreViewContainer.getAttribute('data-bootstrap'));
 
import { exploreReducer } from './reducers/exploreReducer';
 
const bootstrappedState = Object.assign(initialState, {
  datasources: bootstrapData.datasources,
  datasourceId: parseInt(bootstrapData.datasource_id, 10),
  datasourceType: bootstrapData.datasource_type,
  sliceName: bootstrapData.viz.form_data.slice_name,
  viz: {
    jsonEndPoint: bootstrapData.viz.json_endpoint,
    data: bootstrapData.viz.data,
    columnFormats: bootstrapData.viz.column_formats,
    formData: {
      sliceId: bootstrapData.viz.form_data.slice_id,
      vizType: bootstrapData.viz.form_data.viz_type,
      timeColumn: bootstrapData.viz.form_data.granularity_sqla,
      timeGrain: bootstrapData.viz.form_data.time_grain_sqla,
      metrics: [bootstrapData.viz.form_data.metrics].map((m) => ({ value: m, label: m })),
      since: bootstrapData.viz.form_data.since,
      until: bootstrapData.viz.form_data.until,
      having: bootstrapData.viz.form_data.having,
      where: bootstrapData.viz.form_data.where,
      rowLimit: bootstrapData.viz.form_data.row_limit,
      timeStampFormat: bootstrapData.viz.form_data.table_timestamp_format,
    },
  },
});
const store = createStore(exploreReducer, bootstrappedState,
  compose(applyMiddleware(thunk))
);
 
ReactDOM.render(
  <Provider store={store}>
    <ExploreViewContainer />
  </Provider>,
  exploreViewContainer
);