<commit_before>import React from 'react';
import { Table, Column, Cell } from 'fixed-data-table';
import { DateCell, NotionalCell } from './';
import Dimensions from 'react-dimensions';
import { Trade } from '../../../services/model';
import { ViewBase } from '../../common';
import { router, logger } from '../../../system';
import classNames from 'classnames';
import { BlotterModel } from '../model';
import 'fixed-data-table/dist/fixed-data-table.css';
import './blotter.scss';

@Dimensions()
export default class BlotterView extends ViewBase {

  constructor(props, context) {
    super(props, context);
    this.state = {
      model: null
    };
  }

  render() {
    let model:BlotterModel = this.state.model;
    if (!model) {
      return null;
    }
    let columns = this._createGridColumns(model.trades);
    let className = classNames(
      'blotter', {
        'blotter--online': model.isConnected,
        'blotter--offline': !model.isConnected
      });
    let newWindowClassName = classNames(
      'glyphicon glyphicon-new-window',
      {
        'blotter__controls--hidden': model.canPopout
      }
    );

    let containerWidth = this.props.containerWidth; // comes from the @Dimensions annotation
    let containerHeight = this.props.containerHeight; // comes from the @Dimensions annotation
    return (
      <div className={className}>
        <div className='blotter-wrapper'>
          <div className='blotter__controls popout__controls'>
            <i className={newWindowClassName}
               onClick={() => router.publishEvent(this.props.modelId, 'tearOffBlotter', {})} />
          </div>
          <Table
            rowHeight={30}
            headerHeight={30}
            rowsCount={model.trades.length}
            width={containerWidth}
            height={containerHeight}
            rowClassNameGetter={(index) => this._getRowClass(model.trades[index])}>
            {columns}
          </Table>
        </div>
      </div>
    );
  }

  _createGridColumns():Array<Column> {
    return [
      <Column<commit_msg>check blotter dimensions before rendering<commit_after>import React from 'react';
import { Table, Column, Cell } from 'fixed-data-table';
import { DateCell, NotionalCell } from './';
import Dimensions from 'react-dimensions';
import { Trade } from '../../../services/model';
import { ViewBase } from '../../common';
import { router, logger } from '../../../system';
import classNames from 'classnames';
import { BlotterModel } from '../model';
import 'fixed-data-table/dist/fixed-data-table.css';
import './blotter.scss';

@Dimensions()
export default class BlotterView extends ViewBase {

  constructor(props, context) {
    super(props, context);
    this.state = {
      model: null
    };
  }

  render() {
    let model:BlotterModel = this.state.model;
    if (!model) {
      return null;
    }
    let columns = this._createGridColumns(model.trades);
    let containerWidth;
    let containerHeight;
    let className = classNames(
      'blotter', {
        'blotter--online': model.isConnected,
        'blotter--offline': !model.isConnected
      });
    let newWindowClassName = classNames(
      'glyphicon glyphicon-new-window',
      {
        'blotter__controls--hidden': model.canPopout
      }
    );
    
    this.props.updateDimensions();
    containerWidth = this.props.containerWidth; // comes from the @Dimensions annotation
    containerHeight = this.props.containerHeight; // comes from the @Dimensions annotation
    return (
      <div className={className}>
        <div className='blotter-wrapper'>
          <div className='blotter__controls popout__controls'>
            <i className={newWindowClassName}
               onClick={() => router.publishEvent(this.props.modelId, 'tearOffBlotter', {})} />
          </div>
          <Table
            rowHeight={30}
            headerHeight={30}
            rowsCount={model.trades.length}
            width={containerWidth}
            height={containerHeight}
            rowClassNameGetter={(index) => this._getRowClass(model.trades[index])}>
            {columns}
          </Table>
        </div>
      </div>
    );
  }

  _createGridColumns():Array<Column> {
    return [
      <Column
{'fraction_non_alphanumeric': 0.13687943262411348, 'fraction_numerical': 0.0018912529550827422, 'mean_word_length': 2.585593220338983, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '5758185', 'n_tokens_mistral': 1208, 'n_tokens_neox': 1201, 'n_words': 262}