Commit 3206600e authored by Nicolas Frandeboeuf's avatar Nicolas Frandeboeuf Committed by Benjamin Bouvier
Browse files

Ask for confirmation before clearing logs

parent 95e870b5
......@@ -4,6 +4,35 @@ import { connect } from 'react-redux';
import { translate as $t } from '../../../helpers';
import { get, actions } from '../../../store';
import { registerModal } from '../../ui/modal';
import CancelAndDelete from '../../ui/modal/cancel-and-delete-buttons';
import ModalContent from '../../ui/modal/content';
export const MODAL_SLUG = 'confirm-logs-clear';
const ConfirmClearModal = connect(
null,
dispatch => {
return {
handleDelete: () => {
actions.clearLogs(dispatch);
actions.hideModal(dispatch);
}
};
}
)(props => {
let footer = <CancelAndDelete onDelete={props.handleDelete} />;
return (
<ModalContent
title={$t('client.settings.logs.clear')}
body={$t('client.settings.logs.confirm_clear')}
footer={footer}
/>
);
});
registerModal(MODAL_SLUG, () => <ConfirmClearModal />);
class LogsSection extends React.PureComponent {
handleRefresh = () => {
this.props.resetLogs();
......@@ -11,7 +40,7 @@ class LogsSection extends React.PureComponent {
};
handleClear = () => {
this.props.clearLogs();
this.props.showClearModal();
};
handleCopy = () => {
......@@ -94,8 +123,8 @@ const dispatchToProps = dispatch => {
fetchLogs() {
actions.fetchLogs(dispatch);
},
clearLogs() {
actions.clearLogs(dispatch);
showClearModal() {
actions.showModal(dispatch, MODAL_SLUG);
},
resetLogs() {
actions.resetLogs(dispatch);
......
......@@ -351,7 +351,8 @@
"refresh": "Refresh",
"copy": "Copy to clipboard",
"copied": "Logs copied to clipboard",
"clear": "Clear logs"
"clear": "Clear logs",
"confirm_clear": "This will reset your logs. Do you wish to continue?"
}
},
"similarity": {
......
......@@ -351,7 +351,8 @@
"refresh": "Rafraîchir",
"copy": "Copier dans le presse-papiers",
"copied": "Journaux copiés dans le presse-papiers",
"clear": "Effacer les journaux"
"clear": "Effacer les journaux",
"confirm_clear": "Cela effacera tous vos journaux. Voulez-vous continuer ?"
}
},
"similarity": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment