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

51 lines
1.1 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';
import { changeOption } from './utils';
2021-04-19 16:49:57 +00:00
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
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) => changeOption(this, 'query', instance.getValue())}
2021-04-30 06:31:32 +00:00
placeholder="PING"
options={{
theme: this.props.darkMode ? 'monokai' : 'duotone-light',
2021-04-30 06:31:32 +00:00
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 };