ToolJet/frontend/src/Editor/QueryManager/QueryEditors/Redis.jsx

57 lines
1.3 KiB
React
Raw Normal View History

2021-04-19 16:49:57 +00:00
import React from 'react';
import CodeMirror from '@uiw/react-codemirror';
import 'codemirror/theme/duotone-light.css';
class Redis extends React.Component {
2021-04-30 06:31:32 +00:00
constructor(props) {
super(props);
2021-04-19 16:49:57 +00:00
2021-04-30 06:31:32 +00:00
this.state = {
options: this.props.options
2021-04-30 06:31:32 +00:00
};
}
2021-04-19 16:49:57 +00:00
2021-04-30 06:31:32 +00:00
componentDidMount() {
this.setState({
options: this.props.options
2021-04-30 06:31:32 +00:00
});
}
2021-04-19 16:49:57 +00:00
2021-04-30 06:31:32 +00:00
changeOption = (option, value) => {
const { options } = this.state;
const newOptions = { ...options, [option]: value };
this.setState({ options: newOptions });
this.props.optionsChanged(newOptions);
};
2021-04-19 16:49:57 +00:00
2021-04-30 06:31:32 +00:00
render() {
const { options } = this.state;
2021-04-19 16:49:57 +00:00
2021-04-30 06:31:32 +00:00
return (
<div>
{options && (
<div>
<div className="mb-3 mt-2">
2021-04-30 06:31:32 +00:00
<CodeMirror
height="auto"
2021-04-30 06:31:32 +00:00
fontSize="2"
value={options.query}
onChange={(instance) => this.changeOption('query', instance.getValue())}
2021-04-30 06:31:32 +00:00
placeholder="PING"
options={{
theme: 'duotone-light',
mode: 'sql',
lineWrapping: true,
scrollbarStyle: null
2021-04-30 06:31:32 +00:00
}}
/>
</div>
</div>
)}
</div>
);
}
2021-04-19 16:49:57 +00:00
}
export { Redis };