equal
deleted
inserted
replaced
|
1 import React from 'react'; |
|
2 import { Trans } from 'react-i18next'; |
|
3 import { connect } from 'react-redux'; |
|
4 import { bindActionCreators } from 'redux'; |
|
5 |
|
6 import { getAutoSubmit } from '../../selectors/authSelectors'; |
|
7 import * as userActions from '../../actions/userActions'; |
|
8 |
|
9 function mapStateToProps(state, props) { |
|
10 |
|
11 const autoSubmit = getAutoSubmit(state); |
|
12 |
|
13 return { |
|
14 autoSubmit, |
|
15 }; |
|
16 } |
|
17 |
|
18 function mapDispatchToProps(dispatch) { |
|
19 return { |
|
20 userActions: bindActionCreators(userActions, dispatch) |
|
21 } |
|
22 } |
|
23 |
|
24 // see https://github.com/facebook/react/issues/3005 for explanation about the timeout. |
|
25 const ToolbarCheckbox = connect(mapStateToProps, mapDispatchToProps)(({ autoSubmit, userActions }) => ( |
|
26 <div className="checkbox float-right"> |
|
27 <label className="mr-2"> |
|
28 <input type="checkbox" checked={autoSubmit} onChange={(e) => { setTimeout(userActions.setAutoSubmit, 0, e.target.checked) }} value="enterBox" /><small className="text-muted ml-1"><Trans i18nKey="slate_editor.press_enter_msg">Appuyer sur <kbd className="bg-irinotes-form text-muted ml-1">Entrée</kbd> pour ajouter une note</Trans></small> |
|
29 </label> |
|
30 </div> |
|
31 )); |
|
32 |
|
33 export default ({ hasNote, isButtonDisabled, submitNote }) => ( |
|
34 <div> |
|
35 <button type="button" id="btn-editor" className="btn btn-primary btn-sm text-secondary font-weight-bold float-right text-capitalize" disabled={isButtonDisabled} onClick={submitNote}> |
|
36 { hasNote ? <Trans i18nKey="common.save">Save</Trans> : <Trans i18nKey="common.add">Add</Trans> } |
|
37 </button> |
|
38 { !hasNote && <ToolbarCheckbox /> } |
|
39 </div> |
|
40 ); |
|
41 |