<commit_before>/* eslint-disable import/first */
import React, { Component } from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import Immutable from 'immutable';
import fetch from 'isomorphic-fetch';
import IntlWrapper from './containers/IntlWrapper';
import PrintProvider from './containers/PrintProvider';
import VisualisationViewerContainer from './components/visualisation/VisualisationViewerContainer';
import DashboardViewer from './components/dashboard/shared/DashboardViewer';
import LumenBranding from './components/common/LumenBranding';
import ErrorScreen from './components/common/ErrorScreen';
import configureStore from './store/configureStore';
import { init as initAnalytics, trackPageView } from './utilities/analytics';
import * as auth from './utilities/auth';
import queryString from 'querystringify';

require('./styles/reset.global.scss');
require('./styles/style.global.scss');

const rootElement = document.querySelector('#root');
const filteredDashboardCondition = () => queryString.parse(location.search)['filter-dashboard'] === '1';

function renderSuccessfulShare(data, filterColumnsFetched, initialState, onChangeFilter) {
  const datasets = data.datasets;
  const immutableDatasets = {};

  // Transform datasets into immutable objects
  if (datasets != null) {
    Object.keys(datasets).forEach((key) => {
      let dataset = Immutable.fromJS(datasets[key]);
      if (filteredDashboardCondition()) {
        const datasetId = data.dashboards[data.dashboardId].filter.datasetId;
        if (key === datasetId) {
          dataset = filterColumnsFetched.reduce((d, { columnName, values }) => d.setIn(['columnsFetched', columnName], values), dataset);
        }
      }
      immutableDatasets[key] = dataset;
    });
  }

  initAnalytics(initialState);

  const entity = data.dashboards ?
    data.dashboards[data.dashboardId] :
    data.visualisations[data.visualisationId];

  const entityType = data.dashboards ? 'dashboard' : 'visualisation';

  trackPageView(`Share ${entityType}: ${entity.name || `Untitled ${entityType}`}`);

  render(
    <Provider store={configureStore()}>
      <PrintProvider>
        <IntlWrapper>
          <div className="viewer" style={{ display: 'flex' }}>
            {data.dashboards ? (
              <DashboardViewer
                dashboard={data.dashboards[data.dashboardId]}
                visualisations={data.visualisations}
                datasets={immutableDatasets}
                metadata={data.metadata ? data.metadata : null}
                filteredDashboard={filteredDashboardCondition()}
                onChangeFilter={onChangeFilter}
              />
            ) : (<commit_msg>[#1656] Prevent changeing store of Provider<commit_after>/* eslint-disable import/first */
import React, { Component } from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import Immutable from 'immutable';
import fetch from 'isomorphic-fetch';
import IntlWrapper from './containers/IntlWrapper';
import PrintProvider from './containers/PrintProvider';
import VisualisationViewerContainer from './components/visualisation/VisualisationViewerContainer';
import DashboardViewer from './components/dashboard/shared/DashboardViewer';
import LumenBranding from './components/common/LumenBranding';
import ErrorScreen from './components/common/ErrorScreen';
import configureStore from './store/configureStore';
import { init as initAnalytics, trackPageView } from './utilities/analytics';
import * as auth from './utilities/auth';
import queryString from 'querystringify';

require('./styles/reset.global.scss');
require('./styles/style.global.scss');

const rootElement = document.querySelector('#root');
const store = configureStore();
const filteredDashboardCondition = () => queryString.parse(location.search)['filter-dashboard'] === '1';

function renderSuccessfulShare(data, filterColumnsFetched, initialState, onChangeFilter) {
  const datasets = data.datasets;
  const immutableDatasets = {};

  // Transform datasets into immutable objects
  if (datasets != null) {
    Object.keys(datasets).forEach((key) => {
      let dataset = Immutable.fromJS(datasets[key]);
      if (filteredDashboardCondition()) {
        const datasetId = data.dashboards[data.dashboardId].filter.datasetId;
        if (key === datasetId) {
          dataset = filterColumnsFetched.reduce((d, { columnName, values }) => d.setIn(['columnsFetched', columnName], values), dataset);
        }
      }
      immutableDatasets[key] = dataset;
    });
  }

  initAnalytics(initialState);

  const entity = data.dashboards ?
    data.dashboards[data.dashboardId] :
    data.visualisations[data.visualisationId];

  const entityType = data.dashboards ? 'dashboard' : 'visualisation';

  trackPageView(`Share ${entityType}: ${entity.name || `Untitled ${entityType}`}`);

  render(
    <Provider store={store}>
      <PrintProvider>
        <IntlWrapper>
          <div className="viewer" style={{ display: 'flex' }}>
            {data.dashboards ? (
              <DashboardViewer
                dashboard={data.dashboards[data.dashboardId]}
                visualisations={data.visualisations}
                datasets={immutableDatasets}
                metadata={data.metadata ? data.metadata : null}
                filteredDashboard={filteredDashboardCondition()}
                onChangeFilter={onChangeFilter}
              />
            ) : (
{'fraction_non_alphanumeric': 0.12753888380603842, 'fraction_numerical': 0.0010978956999085087, 'mean_word_length': 3.803163444639719, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '475696', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1473, 'n_words': 314}