import React, { PropTypes } from 'react'; import ModalTrigger from './../../components/ModalTrigger'; import SyntaxHighlighter from 'react-syntax-highlighter'; import { github } from 'react-syntax-highlighter/dist/styles'; const $ = window.$ = require('jquery'); const propTypes = { queryEndpoint: PropTypes.string.isRequired, }; export default class DisplayQueryButton extends React.PureComponent { constructor(props) { super(props); this.state = { modalBody:
, }; } beforeOpen() { this.setState({ modalBody: (
),
});
$.ajax({
type: 'GET',
url: this.props.queryEndpoint,
success: (data) => {
const modalBody = data.language ?
{data.query};
this.setState({ modalBody });
},
error(data) {
this.setState({ modalBody: ({data.error}) });
},
});
}
render() {
return (