mirror of
https://github.com/apache/superset.git
synced 2026-04-11 12:26:05 +00:00
* Fixing PropTypes warning message React recently started warning on the upcoming deprecation of React.PropTypes, the new approach is to use the `prop-types` npm package instead. * Fixing the tests
48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ModalTrigger from '../../components/ModalTrigger';
|
|
|
|
const propTypes = {
|
|
triggerNode: PropTypes.node.isRequired,
|
|
code: PropTypes.string,
|
|
codeCallback: PropTypes.func,
|
|
};
|
|
|
|
const defaultProps = {
|
|
codeCallback: () => {},
|
|
};
|
|
|
|
export default class CodeModal extends React.PureComponent {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = { code: props.code };
|
|
}
|
|
beforeOpen() {
|
|
let code = this.props.code;
|
|
if (this.props.codeCallback) {
|
|
code = this.props.codeCallback();
|
|
}
|
|
this.setState({ code });
|
|
}
|
|
render() {
|
|
return (
|
|
<ModalTrigger
|
|
triggerNode={this.props.triggerNode}
|
|
isButton
|
|
beforeOpen={this.beforeOpen.bind(this)}
|
|
modalTitle="Active Dashboard Filters"
|
|
modalBody={
|
|
<div className="CodeModal">
|
|
<pre>
|
|
{this.state.code}
|
|
</pre>
|
|
</div>
|
|
}
|
|
/>
|
|
);
|
|
}
|
|
}
|
|
CodeModal.propTypes = propTypes;
|
|
CodeModal.defaultProps = defaultProps;
|