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

92 lines
1.8 KiB
React
Raw Normal View History

2021-05-04 06:45:04 +00:00
import React from 'react';
import 'codemirror/theme/duotone-light.css';
import SelectSearch, { fuzzySearch } from 'react-select-search';
class Slack extends React.Component {
constructor(props) {
super(props);
this.state = {
options: this.props.options
};
}
componentDidMount() {
this.setState({
options: this.props.options
});
}
changeOption = (option, value) => {
this.setState(
{
options: {
...this.state.options,
[option]: value
}
},
() => {
this.props.optionsChanged(this.state.options);
}
);
};
changeJsonOption(option, value) {
this.setState(
{
options: {
...this.state.options,
[option]: JSON.parse(value)
}
},
() => {
this.props.optionsChanged(this.state.options);
}
);
}
changeOperation = (operation) => {
this.setState(
{
options: {
...this.state.options,
operation
}
},
() => {
this.props.optionsChanged(this.state.options);
}
);
};
render() {
const { options } = this.state;
return (
<div>
{options && (
<div>
<div className="mb-3 mt-2">
<label className="form-label">Operation</label>
<SelectSearch
options={[
{ name: 'List members', value: 'list_users' },
]}
value={this.state.options.operation}
search={false}
onChange={(value) => {
this.changeOperation(value);
}}
filterOptions={fuzzySearch}
placeholder="Select.."
/>
</div>
</div>
)}
</div>
);
}
}
export { Slack };