2019-09-04 14:39:35 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { withNamespaces, Trans } from 'react-i18next';
|
|
|
|
import debounce from 'lodash/debounce';
|
|
|
|
|
|
|
|
import { DEBOUNCE_TIMEOUT } from '../../../helpers/constants';
|
|
|
|
import Card from '../../ui/Card';
|
|
|
|
import Form from './Form';
|
|
|
|
|
|
|
|
class LogsConfig extends Component {
|
|
|
|
handleFormChange = debounce((values) => {
|
|
|
|
this.props.setLogsConfig(values);
|
|
|
|
}, DEBOUNCE_TIMEOUT);
|
|
|
|
|
2019-09-04 15:06:09 +00:00
|
|
|
handleClear = () => {
|
2019-09-04 14:39:35 +00:00
|
|
|
const { t, clearLogs } = this.props;
|
|
|
|
// eslint-disable-next-line no-alert
|
|
|
|
if (window.confirm(t('query_log_confirm_clear'))) {
|
|
|
|
clearLogs();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
t, enabled, interval, processing, processingClear,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card
|
|
|
|
title={t('query_log_configuration')}
|
|
|
|
bodyType="card-body box-body--settings"
|
2019-09-04 15:06:09 +00:00
|
|
|
id="logs-config"
|
2019-09-04 14:39:35 +00:00
|
|
|
>
|
|
|
|
<div className="form">
|
|
|
|
<Form
|
|
|
|
initialValues={{
|
|
|
|
enabled,
|
|
|
|
interval,
|
|
|
|
}}
|
|
|
|
onSubmit={this.handleFormChange}
|
|
|
|
onChange={this.handleFormChange}
|
|
|
|
processing={processing}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="btn btn-outline-secondary btn-sm"
|
2019-09-04 15:06:09 +00:00
|
|
|
onClick={this.handleClear}
|
2019-09-04 14:39:35 +00:00
|
|
|
disabled={processingClear}
|
|
|
|
>
|
|
|
|
<Trans>query_log_clear</Trans>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
LogsConfig.propTypes = {
|
|
|
|
interval: PropTypes.number.isRequired,
|
|
|
|
enabled: PropTypes.bool.isRequired,
|
|
|
|
processing: PropTypes.bool.isRequired,
|
|
|
|
processingClear: PropTypes.bool.isRequired,
|
|
|
|
setLogsConfig: PropTypes.func.isRequired,
|
|
|
|
clearLogs: PropTypes.func.isRequired,
|
|
|
|
t: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withNamespaces()(LogsConfig);
|