<commit_before>import { NodeComponent } from 'substance'
import { renderEntity } from '../../entities/entityHelpers'
import Button from './Button'

export default class RefComponent extends NodeComponent {

  render($$) {
    const db = this.context.pubMetaDbSession.getDocument()
    const ref = this.props.node
    const entityId = ref.getAttribute('rid')
    let label = _getReferenceLabel(ref)
    let entityHtml = renderEntity(_getEntity(ref, db))

    // TODO: do we want to display something like this
    // if so, use the label provider
    entityHtml = entityHtml || '<i>Not available</i>'

    return $$('div').addClass('sc-ref-component').append(
      $$('div').addClass('se-label').append(label),
      $$('div').addClass('se-text').html(entityHtml),
      $$('div').addClass('se-actions').append(
        $$(Button, {icon: 'pencil', tooltip: 'Edit'})
          .on('click', this._onEdit.bind(this, entityId)),
        $$(Button, {icon: 'trash', tooltip: 'Remove'})
          .on('click', this._onRemove.bind(this, entityId))
      )
    )
  }<commit_msg>Don't render actions for ref preview.<commit_after>import { NodeComponent } from 'substance'
import { renderEntity } from '../../entities/entityHelpers'
import Button from './Button'

export default class RefComponent extends NodeComponent {

  render($$) {
    const db = this.context.pubMetaDbSession.getDocument()
    const ref = this.props.node
    const entityId = ref.getAttribute('rid')
    let label = _getReferenceLabel(ref)
    let entityHtml = renderEntity(_getEntity(ref, db))

    // TODO: do we want to display something like this
    // if so, use the label provider
    entityHtml = entityHtml || '<i>Not available</i>'

    let el = $$('div').addClass('sc-ref-component').append(
      $$('div').addClass('se-label').append(label),
      $$('div').addClass('se-text').html(entityHtml)
    )

    if(this.props.mode === 'back') {
      el.append(
        $$('div').addClass('se-actions').append(
          $$(Button, {icon: 'pencil', tooltip: 'Edit'})
            .on('click', this._onEdit.bind(this, entityId)),
          $$(Button, {icon: 'trash', tooltip: 'Remove'})
            .on('click', this._onRemove.bind(this, entityId))
        )
      )
    }

    return el
  }
{'fraction_non_alphanumeric': 0.1691013722886233, 'fraction_numerical': 0.0, 'mean_word_length': 3.2085661080074486, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3853483', 'n_tokens_mistral': 672, 'n_tokens_neox': 671, 'n_words': 161}