1414 * along with this program. If not, see
1515 * <http://www.mongodb.com/licensing/server-side-public-license>.
1616 */
17- import React from 'react' ;
18- import PropTypes from 'prop-types' ;
1917
18+ import React from 'react' ;
2019import { ControlLabel , FormGroup , HelpBlock } from 'components/bootstrap' ;
2120import lodash from 'lodash' ;
2221// TODO this works, but should rather load the SourceCodeEditor from the index (it will then use lazy-loading)
@@ -46,50 +45,50 @@ class LoggingAlertForm extends React.Component<Props> {
4645 this . state = { } ;
4746 }
4847
49- componentDidMount ( ) {
48+ componentDidMount ( ) {
5049 ConfigurationsActions . list ( LOGGING_ALERT_CONFIG ) ;
51- }
52-
50+ }
51+
5352 propagateChange = ( key , value ) => {
54- const { config, onChange } = this . props ;
55- const nextConfig = lodash . cloneDeep ( config ) ;
56- nextConfig [ key ] = value ;
57- onChange ( nextConfig ) ;
53+ const { config, onChange } = this . props ;
54+ const nextConfig = lodash . cloneDeep ( config ) ;
55+ nextConfig [ key ] = value ;
56+ onChange ( nextConfig ) ;
5857 } ;
5958
6059 handleChange = ( event ) => {
61- const { name } = event . target ;
62- this . propagateChange ( name , FormsUtils . getValueFromInput ( event . target ) ) ;
60+ const { name } = event . target ;
61+ this . propagateChange ( name , FormsUtils . getValueFromInput ( event . target ) ) ;
6362 } ;
6463
6564 handleBodyTemplateChange = ( nextValue ) => {
66- this . propagateChange ( 'log_body' , nextValue ) ;
65+ this . propagateChange ( 'log_body' , nextValue ) ;
6766 } ;
6867
6968 handleFieldsChange = ( key ) => {
70- return nextValue => {
71- this . propagateChange ( key , nextValue === '' ? [ ] : nextValue . split ( ',' ) ) ;
72- } ;
69+ return nextValue => {
70+ this . propagateChange ( key , nextValue === '' ? [ ] : nextValue . split ( ',' ) ) ;
71+ } ;
7372 } ;
7473
7574 getAlertConfig = ( configuration ) => {
76- if ( configuration && configuration [ LOGGING_ALERT_CONFIG ] ) {
77- if ( this . props . config . log_body === undefined ) {
78- this . handleBodyTemplateChange ( configuration [ LOGGING_ALERT_CONFIG ] . log_body ) ;
79- }
80- if ( this . props . config . alert_tag === undefined ) {
81- this . propagateChange ( 'alert_tag' , configuration [ LOGGING_ALERT_CONFIG ] . alert_tag ) ;
82- }
83- return configuration [ LOGGING_ALERT_CONFIG ] ;
84- } else {
85- return {
86- log_body : DEFAULT_BODY_TEMPLATE ,
87- alert_tag : 'LoggingAlert' ,
88- single_notification : false ,
89- }
90- }
75+ if ( configuration && configuration [ LOGGING_ALERT_CONFIG ] ) {
76+ if ( this . props . config . log_body === undefined ) {
77+ this . handleBodyTemplateChange ( configuration [ LOGGING_ALERT_CONFIG ] . log_body ) ;
78+ }
79+ if ( this . props . config . alert_tag === undefined ) {
80+ this . propagateChange ( 'alert_tag' , configuration [ LOGGING_ALERT_CONFIG ] . alert_tag ) ;
81+ }
82+ return configuration [ LOGGING_ALERT_CONFIG ] ;
83+ } else {
84+ return {
85+ log_body : DEFAULT_BODY_TEMPLATE ,
86+ alert_tag : 'LoggingAlert' ,
87+ single_notification : false ,
88+ }
89+ }
9190 } ;
92-
91+
9392 render ( ) {
9493 const { config, validation } = this . props ;
9594
@@ -100,17 +99,18 @@ class LoggingAlertForm extends React.Component<Props> {
10099 < React . Fragment >
101100 < FormGroup controlId = "log_body" validationState = { validation . errors . log_body ? 'error' : null } >
102101 < ControlLabel > Body Template</ ControlLabel >
103- < SourceCodeEditor id = "log_body"
104- mode = "text"
105- theme = "light"
106- value = { config . log_body ? config . log_body : alertConfig . log_body }
107- onChange = { this . handleBodyTemplateChange } />
102+ < SourceCodeEditor
103+ id = "log_body"
104+ mode = "text"
105+ theme = "light"
106+ value = { config . log_body ? config . log_body : alertConfig . log_body }
107+ onChange = { this . handleBodyTemplateChange } />
108108 < HelpBlock >
109109 { lodash . get ( validation , 'errors.log_body[0]' , 'The template to generate the log content form' ) }
110110 </ HelpBlock >
111111 </ FormGroup >
112112
113- < ControlLabel > Alert Tag < small className = "text-muted" > (Optional)</ small > </ ControlLabel >
113+ < ControlLabel > Alert Tag < small className = "text-muted" > (Optional)</ small > </ ControlLabel >
114114 < Input
115115 id = "alert_tag"
116116 type = "text"
@@ -119,7 +119,7 @@ class LoggingAlertForm extends React.Component<Props> {
119119 value = { config . alert_tag ? config . alert_tag : alertConfig . alert_tag }
120120 onChange = { this . handleChange }
121121 />
122- < div >
122+ < div >
123123 < Input
124124 id = "single_notification"
125125 type = "checkbox"
@@ -132,12 +132,12 @@ class LoggingAlertForm extends React.Component<Props> {
132132 < HelpBlock >
133133 Check this box to send only one message by alert
134134 </ HelpBlock >
135- </ div >
136- </ React . Fragment >
135+ </ div >
136+ </ React . Fragment >
137137 ) ;
138138 }
139139}
140140
141141export default connect ( LoggingAlertForm , {
142142 configurationsStore : ConfigurationsStore
143- } ) ;
143+ } ) ;
0 commit comments