<commit_before>import React from 'react';
import { Map as IMap } from 'immutable';
import { statusConstants } from 'molecular-design-applications-shared';
import Canceled from './canceled';
import Errored from './errored';
import Snackbar from './snackbar';
import ThankYou from './thank_you';
import SelectionRecord from '../records/selection_record';
import UserMessageRecord from '../records/user_message_record';
import WorkflowRecord from '../records/workflow_record';
import Workflow from './workflow';

class WorkflowRouter extends React.Component {
  componentDidMount() {
    this.initialize(this.props.workflowId, this.props.runId);

    this.state = {
      snackbarClosed: true,
    };

    this.onRequestCloseSnackbar = this.onRequestCloseSnackbar.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    const fetching = nextProps.workflow.fetching;
    const changingWorkflowId = nextProps.workflowId &&
      this.props.workflowId !== nextProps.workflowId;
    const changingRunId = nextProps.runId !== this.props.runId;

    if (!fetching && (changingWorkflowId || changingRunId)) {
      this.initialize(nextProps.workflowId, nextProps.runId);
    }

    if (!this.props.workflow.fetchingError &&
      nextProps.workflow.fetchingError) {
      this.setState({
        snackbarClosed: false,
      });
    }
  }

  onRequestCloseSnackbar() {
    this.setState({
      snackbarClosed: true,
    });
  }

  // Set up page for workflow/run distinction
  initialize(workflowId, runId) {
    if (runId) {
      return this.props.initializeRun(workflowId, runId);
    }

    return this.props.initializeWorkflow(workflowId);
  }

  render() {
    if (this.props.runId) {
      document.title = `Workflow - Run of "${this.props.workflow.title}" - Molecular Simulation Tools`;
    } else {
      document.title = `Workflow - "${this.props.workflow.title}" - Molecular Simulation Tools`;
    }

    let routeEl;
    if (this.props.workflow.run.status === statusConstants.RUNNING) {
      routeEl = (
        <ThankYou
          canceling={this.props.workflow.run.canceling}
          email={this.props.workflow.run.email}
          onClickCancel={this.props.clickCancel}
        />
      );
    } else if (this.props.workflow.run.status === statusConstants.CANCELED) {
      routeEl = (<commit_msg>Fix eslint error on line lenght<commit_after>import React from 'react';
import { Map as IMap } from 'immutable';
import { statusConstants } from 'molecular-design-applications-shared';
import Canceled from './canceled';
import Errored from './errored';
import Snackbar from './snackbar';
import ThankYou from './thank_you';
import SelectionRecord from '../records/selection_record';
import UserMessageRecord from '../records/user_message_record';
import WorkflowRecord from '../records/workflow_record';
import Workflow from './workflow';

class WorkflowRouter extends React.Component {
  componentDidMount() {
    this.initialize(this.props.workflowId, this.props.runId);

    this.state = {
      snackbarClosed: true,
    };

    this.onRequestCloseSnackbar = this.onRequestCloseSnackbar.bind(this);
  }

  componentWillReceiveProps(nextProps) {
    const fetching = nextProps.workflow.fetching;
    const changingWorkflowId = nextProps.workflowId &&
      this.props.workflowId !== nextProps.workflowId;
    const changingRunId = nextProps.runId !== this.props.runId;

    if (!fetching && (changingWorkflowId || changingRunId)) {
      this.initialize(nextProps.workflowId, nextProps.runId);
    }

    if (!this.props.workflow.fetchingError &&
      nextProps.workflow.fetchingError) {
      this.setState({
        snackbarClosed: false,
      });
    }
  }

  onRequestCloseSnackbar() {
    this.setState({
      snackbarClosed: true,
    });
  }

  // Set up page for workflow/run distinction
  initialize(workflowId, runId) {
    if (runId) {
      return this.props.initializeRun(workflowId, runId);
    }

    return this.props.initializeWorkflow(workflowId);
  }

  render() {
    if (this.props.runId) {
      document.title = `Workflow - Run of "${this.props.workflow.title}" - Molecular Simulation Tools`; // eslint-disable-line max-len
    } else {
      document.title = `Workflow - "${this.props.workflow.title}" - Molecular Simulation Tools`;
    }

    let routeEl;
    if (this.props.workflow.run.status === statusConstants.RUNNING) {
      routeEl = (
        <ThankYou
          canceling={this.props.workflow.run.canceling}
          email={this.props.workflow.run.email}
          onClickCancel={this.props.clickCancel}
        />
      );
    } else if (this.props.workflow.run.status === statusConstants.CANCELED) {
      routeEl = (
{'fraction_non_alphanumeric': 0.12390327412796918, 'fraction_numerical': 0.0, 'mean_word_length': 3.288073394495413, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4256041', 'n_tokens_mistral': 1447, 'n_tokens_neox': 1414, 'n_words': 277}