<commit_before>import classnames from 'classnames'
import { parseActionInstruction } from 'common/action'
import _ from 'lodash'
import Mustache from 'mustache'
import React, { Component } from 'react'
import { OverlayTrigger, Popover } from 'react-bootstrap'
import Markdown from 'react-markdown'
import { connect } from 'react-redux'
import { fetchContentItem, refreshFlowsLinks } from '~/actions'

import withLanguage from '../../../components/Util/withLanguage'
import { textToItemId } from '../diagram/nodes_v2/utils'

import style from './style.scss'

interface Props {
  text: string
  fetchContentItem: any
  refreshFlowsLinks: any
  className: string
  items: any
  contentLang: string
  layoutv2?: boolean
}

class ActionItem extends Component<Props> {
  state = {
    itemId: null
  }

  componentDidMount() {
    this.loadElement()
  }

  componentDidUpdate(prevProps, prevState) {
    if (prevProps.text !== this.props.text) {
      this.loadElement()
    }

    if (prevState.itemId !== this.state.itemId && this.state.itemId) {
      this.props.fetchContentItem(this.state.itemId, { force: true, batched: true }).then(this.props.refreshFlowsLinks)
    }
  }

  loadElement() {
    this.setState({ itemId: textToItemId(this.props.text) })
  }

  renderAction() {
    const actionInstruction = parseActionInstruction(this.props.text.trim())

    const actionName = `${actionInstruction.actionName} (args)`
    const parameters = JSON.parse(actionInstruction.argsStr)
    const callPreview = JSON.stringify(parameters, null, 2)
<commit_msg>fix(flow): error with node execute crashes studio (#3117)<commit_after>import classnames from 'classnames'
import { parseActionInstruction } from 'common/action'
import _ from 'lodash'
import Mustache from 'mustache'
import React, { Component } from 'react'
import { OverlayTrigger, Popover } from 'react-bootstrap'
import Markdown from 'react-markdown'
import { connect } from 'react-redux'
import { fetchContentItem, refreshFlowsLinks } from '~/actions'

import withLanguage from '../../../components/Util/withLanguage'
import { textToItemId } from '../diagram/nodes_v2/utils'

import style from './style.scss'

interface Props {
  text: string
  fetchContentItem: any
  refreshFlowsLinks: any
  className: string
  items: any
  contentLang: string
  layoutv2?: boolean
}

class ActionItem extends Component<Props> {
  state = {
    itemId: null
  }

  componentDidMount() {
    this.loadElement()
  }

  componentDidUpdate(prevProps, prevState) {
    if (prevProps.text !== this.props.text) {
      this.loadElement()
    }

    if (prevState.itemId !== this.state.itemId && this.state.itemId) {
      this.props.fetchContentItem(this.state.itemId, { force: true, batched: true }).then(this.props.refreshFlowsLinks)
    }
  }

  loadElement() {
    this.setState({ itemId: textToItemId(this.props.text) })
  }

  renderAction() {
    const actionInstruction = parseActionInstruction(this.props.text.trim())

    const actionName = `${actionInstruction.actionName} (args)`

    let callPreview
    if (actionInstruction.argsStr) {
      try {
        const parameters = JSON.parse(actionInstruction.argsStr)
        callPreview = JSON.stringify(parameters, null, 2)
      } catch (err) {
        console.error(err)
      }
    }

{'fraction_non_alphanumeric': 0.1187937861711849, 'fraction_numerical': 0.003045994517209869, 'mean_word_length': 3.9161676646706587, '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': '4228486', 'n_tokens_mistral': 1004, 'n_tokens_neox': 994, 'n_words': 236}