<commit_before>import React from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { destroy, reduxForm, getValues } from 'redux-form'
import { _ } from 'underscore'

import apiFetch from '../utils/apiFetch.js';
import { reduxFormFields } from '../utils/formHelpers.js';

import ControlActions from '../actions/ControlActions.js'
import composeRecipeContainer from './RecipeContainer.jsx'
import ActionForm from './ActionForm.jsx'

export class RecipeForm extends React.Component {
  constructor(props) {
    super(props);
    this.submitForm = this.submitForm.bind(this);
    this.getAvailableActions = this.getAvailableActions.bind(this);
    this.changeAction = this.changeAction.bind(this);

    this.state = {
      availableActions: [],
      selectedAction: null,
    };
  }

  getAvailableActions(recipeId) {
    apiFetch('/api/v1/action/')
    .then(availableActions => {
      let selectedActionName = (this.props.recipe ? this.props.recipe.action_name : null);

      availableActions.map(action => {
        action.fields = reduxFormFields[action.name];

        if (selectedActionName === action.name) {
          this.setState({
            selectedAction: action
          });
        }

        return action;
      });

      this.setState({
        availableActions
      });
    });
  }<commit_msg>Fix array methods<commit_after>import React from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { destroy, reduxForm, getValues } from 'redux-form'
import { _ } from 'underscore'

import apiFetch from '../utils/apiFetch.js';
import { reduxFormFields } from '../utils/formHelpers.js';

import ControlActions from '../actions/ControlActions.js'
import composeRecipeContainer from './RecipeContainer.jsx'
import ActionForm from './ActionForm.jsx'

export class RecipeForm extends React.Component {
  constructor(props) {
    super(props);
    this.submitForm = this.submitForm.bind(this);
    this.getAvailableActions = this.getAvailableActions.bind(this);
    this.changeAction = this.changeAction.bind(this);

    this.state = {
      availableActions: [],
      selectedAction: null,
    };
  }

  getAvailableActions(recipeId) {
    apiFetch('/api/v1/action/')
    .then(availableActions => {
      let selectedActionName = (this.props.recipe ? this.props.recipe.action_name : null);

      for (let action of availableActions) {
        action.fields = reduxFormFields[action.name];

        if (selectedActionName === action.name) {
          this.setState({
            selectedAction: action
          });
        }
      };

      this.setState({
        availableActions
      });
    });
  }
{'fraction_non_alphanumeric': 0.12384130515387468, 'fraction_numerical': 0.0007415647015202076, 'mean_word_length': 3.0755287009063443, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '4553528', 'n_tokens_mistral': 780, 'n_tokens_neox': 769, 'n_words': 162}