<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Immutable from 'immutable';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import { showModal } from '../actions/activeModal';
import { fetchDataset, updateDatasetMeta, pollTxImportStatus, startTx, undoTx, endTx } from '../actions/dataset';
import { showNotification } from '../actions/notification';
import { getId, getTitle } from '../domain/entity';
import { getTransformations, getRows, getColumns, getIsLockedFromTransformations } from '../domain/dataset';
import * as api from '../utilities/api';
import LoadingSpinner from '../components/common/LoadingSpinner';
import { SAVE_COUNTDOWN_INTERVAL, SAVE_INITIAL_TIMEOUT } from '../constants/time';
import { TRANSFORM_DATASET } from '../constants/analytics';
import { trackEvent, trackPageView } from '../utilities/analytics';
import NavigationPrompt from '../components/common/NavigationPrompt';

require('../components/dataset/Dataset.scss');


class Dataset extends Component {

  constructor() {
    super();
    this.state = {
      asyncComponents: null,
      isUnsavedChanges: false,
      // Pending transformations are represented as
      // an oredered map from timestamp to transformation
      pendingTransformations: Immutable.OrderedMap(),
      timeToNextSave: SAVE_INITIAL_TIMEOUT,
      timeFromPreviousSave: 0,
    };
    this.handleShowDatasetSettings = this.handleShowDatasetSettings.bind(this);
    this.handleNavigateToVisualise = this.handleNavigateToVisualise.bind(this);
    this.handleChangeDatasetTitle = this.handleChangeDatasetTitle.bind(this);
    this.handleSave = this.handleSave.bind(this);
    this.handleSaveFailure = this.handleSaveFailure.bind(this);
    this.transform = this.transform.bind(this);
    this.undo = this.undo.bind(this);
  }

  componentDidMount() {
    const { params, dataset, dispatch } = this.props;
    const { datasetId } = params;

    this.isMountedFlag = true;

    this.handleTrackPageView(this.props);

    if (dataset == null || dataset.get('rows') == null) {
      dispatch(fetchDataset(datasetId));
    }

    require.ensure([], () => {
      /* eslint-disable global-require */
      const DatasetHeader = require('../components/dataset/DatasetHeader').default;
      const DatasetTable = require('../components/dataset/DatasetTable').default;
      /* eslint-enable global-require */

      this.setState({
        asyncComponents: {
          DatasetHeader,
          DatasetTable,
        },
      });
    }, 'Dataset');
  }

  UNSAFE_componentWillReceiveProps(nextProps) {
    this.handleTrackPageView(nextProps);
  }

  componentWillUnmount() {
    this.isMountedFlag = false;
  }

  setPendingTransformation(timestamp, transformation) {
    const { pendingTransformations } = this.state;
    this.setState({
      pendingTransformations: pendingTransformations.set(timestamp, transformation),
    });
  }

  setPendingUndo(timestamp) {
    const { pendingTransformations } = this.state;<commit_msg>[#2569] Adapt UNSAFE_componentWillReceiveProps<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Immutable from 'immutable';
import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import { showModal } from '../actions/activeModal';
import { fetchDataset, updateDatasetMeta, pollTxImportStatus, startTx, undoTx, endTx } from '../actions/dataset';
import { showNotification } from '../actions/notification';
import { getId, getTitle } from '../domain/entity';
import { getTransformations, getRows, getColumns, getIsLockedFromTransformations } from '../domain/dataset';
import * as api from '../utilities/api';
import LoadingSpinner from '../components/common/LoadingSpinner';
import { SAVE_COUNTDOWN_INTERVAL, SAVE_INITIAL_TIMEOUT } from '../constants/time';
import { TRANSFORM_DATASET } from '../constants/analytics';
import { trackEvent, trackPageView } from '../utilities/analytics';
import NavigationPrompt from '../components/common/NavigationPrompt';

require('../components/dataset/Dataset.scss');


class Dataset extends Component {

  constructor() {
    super();
    this.state = {
      asyncComponents: null,
      isUnsavedChanges: false,
      // Pending transformations are represented as
      // an oredered map from timestamp to transformation
      pendingTransformations: Immutable.OrderedMap(),
      timeToNextSave: SAVE_INITIAL_TIMEOUT,
      timeFromPreviousSave: 0,
      hasTrackedPageView: false,
    };
    this.handleShowDatasetSettings = this.handleShowDatasetSettings.bind(this);
    this.handleNavigateToVisualise = this.handleNavigateToVisualise.bind(this);
    this.handleChangeDatasetTitle = this.handleChangeDatasetTitle.bind(this);
    this.handleSave = this.handleSave.bind(this);
    this.handleSaveFailure = this.handleSaveFailure.bind(this);
    this.transform = this.transform.bind(this);
    this.undo = this.undo.bind(this);
  }

  componentDidMount() {
    const { params, dataset, dispatch } = this.props;
    const { datasetId } = params;

    this.isMountedFlag = true;

    this.handleTrackPageView(this.props);

    if (dataset == null || dataset.get('rows') == null) {
      dispatch(fetchDataset(datasetId));
    }

    require.ensure([], () => {
      /* eslint-disable global-require */
      const DatasetHeader = require('../components/dataset/DatasetHeader').default;
      const DatasetTable = require('../components/dataset/DatasetTable').default;
      /* eslint-enable global-require */

      this.setState({
        asyncComponents: {
          DatasetHeader,
          DatasetTable,
        },
      });
    }, 'Dataset');
  }

  // eslint-disable-next-line no-unused-vars
  componentDidUpdate(prevProps, prevState) {
    if (!this.state.hasTrackedPageView) {
      trackPageView(`Dataset: ${getTitle(this.props.dataset)}`);
    }
  }

  componentWillUnmount() {
    this.isMountedFlag = false;
  }

  setPendingTransformation(timestamp, transformation) {
    const { pendingTransformations } = this.state;
    this.setState({
      pendingTransformations: pendingTransformations.set(timestamp, transformation),
    });
  }

  setPendingUndo(timestamp) {
    const { pendingTransformations } = this.state;
{'fraction_non_alphanumeric': 0.12420685279187817, 'fraction_numerical': 0.0009517766497461929, 'mean_word_length': 3.880030959752322, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6866797', 'n_tokens_mistral': 1758, 'n_tokens_neox': 1763, 'n_words': 355}