<commit_before>import createReactClass from 'create-react-class'
import QRCode from 'qrcode.react'
import React from 'react'
import Spinner from 'react-spinkit'
import {Button, Modal, ModalBody, ModalHeader} from 'reactstrap'

import {getDDOUri} from '/imports/bitcoin/resolveDID'

const ShowDDO = createReactClass({

  getInitialState: () => ({
    modal: false,
    ddoLoading: false,
    ddo: null
  }),

  toggle: function () {
    this.setState({
      modal: !this.state.modal
    })
    if (!this.state.modal) {
      this.getDDO()
    }
  },

  getDDO: async function () {
    this.setState({
      ddoLoading: true
    })
    const ddo = await getDDOUri(this.props.did)
    this.setState({
      ddoLoading: false,
      ddo
    })
  },

  render: function () {
    return (
      <div>
        <Button color='primary' onClick={this.toggle} block> Show DDO </Button>
        <Modal isOpen={this.state.modal} toggle={this.toggle}>
          <ModalHeader toggle={this.toggle}>
            {this.state.ddoLoading
              ? null
              : '/ipfs/' + this.state.ddo
            }
          </ModalHeader>
          <ModalBody>
            <div className='d-flex justify-content-center'>
              {this.state.ddoLoading
                  ? <Spinner name='double-bounce' />
                  : this.state.ddo
                  ? <QRCode value={'/ipfs/' + this.state.ddo} size={256} className='mx-auto' />
                    : null
              }
            </div>
          </ModalBody>
        </Modal>
      </div>
    )
  }
})

export default ShowDDO<commit_msg>Use truncated text to show the DDO<commit_after>import createReactClass from 'create-react-class'
import QRCode from 'qrcode.react'
import React from 'react'
import Spinner from 'react-spinkit'
import {Button, Modal, ModalBody, ModalHeader} from 'reactstrap'

import {getDDOUri} from '/imports/bitcoin/resolveDID'
import ShowTruncatedText from '/imports/ui/ShowTruncatedText'

const ShowDDO = createReactClass({

  getInitialState: () => ({
    modal: false,
    ddoLoading: false,
    ddo: null
  }),

  toggle: function () {
    this.setState({
      modal: !this.state.modal
    })
    if (!this.state.modal) {
      this.getDDO()
    }
  },

  getDDO: async function () {
    this.setState({
      ddoLoading: true
    })
    const ddo = await getDDOUri(this.props.did)
    this.setState({
      ddoLoading: false,
      ddo
    })
  },

  render: function () {
    return (
      <div>
        <Button color='primary' onClick={this.toggle} block> Show DDO </Button>
        <Modal isOpen={this.state.modal} toggle={this.toggle}>
          <ModalHeader toggle={this.toggle}>
            {this.state.ddoLoading
              ? null
              : <ShowTruncatedText text={'/ipfs/' + this.state.ddo} />
            }
          </ModalHeader>
          <ModalBody>
            <div className='d-flex justify-content-center'>
              {this.state.ddoLoading
                  ? <Spinner name='double-bounce' />
                  : this.state.ddo
                  ? <QRCode value={'/ipfs/' + this.state.ddo} size={256} className='mx-auto' />
                    : null
              }
            </div>
          </ModalBody>
        </Modal>
      </div>
    )
  }
})

export default ShowDDO
{'fraction_non_alphanumeric': 0.1317711503347535, 'fraction_numerical': 0.0018259281801582471, 'mean_word_length': 1.9585958595859585, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 34, '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': '3356890', 'n_tokens_mistral': 1039, 'n_tokens_neox': 1021, 'n_words': 212}