1
- import { connectModuleOptions } from 'components/module-settings/connect-module-options' ;
2
- import analytics from 'lib/analytics' ;
3
1
import { each , get , omit } from 'lodash' ;
4
2
import React from 'react' ;
3
+ import { connectModuleOptions } from 'components/module-settings/connect-module-options' ;
4
+ import analytics from 'lib/analytics' ;
5
5
6
6
/**
7
7
* High order component that provides a <form> with functionality
8
8
* to handle input values on the forms' own React component state.
9
9
*
10
- * @param {React.Component } InnerComponent The component with a top level form element
10
+ * @param {React.Component } InnerComponent - The component with a top level form element
11
11
* @return {[React.Component] } The component with new functionality
12
12
*/
13
13
export function withModuleSettingsFormHelpers ( InnerComponent ) {
@@ -34,8 +34,8 @@ export function withModuleSettingsFormHelpers( InnerComponent ) {
34
34
* Updates the list of form values to save, usually options to set or modules to activate.
35
35
* Receives an object with key => value pairs to set multiple options or a string and a value to set a single option.
36
36
*
37
- * @param {string|object } optionMaybeOptions options to update.
38
- * @param {* } optionValue value to set if it's a single option
37
+ * @param {string|object } optionMaybeOptions - options to update.
38
+ * @param {* } optionValue - value to set if it's a single option
39
39
* @return {boolean } Always true
40
40
*/
41
41
updateFormStateOptionValue = ( optionMaybeOptions , optionValue = undefined ) => {
@@ -69,9 +69,9 @@ export function withModuleSettingsFormHelpers( InnerComponent ) {
69
69
* If the module is active, only the option is added to the list of form values to send.
70
70
* If it's inactive, an additional option stating that the module must be activated is added to the list.
71
71
*
72
- * @param {String } module the module.
73
- * @param {String } moduleOption the option slug for the module.
74
- * @param {Boolean } deactivate whether to deactive the module too.
72
+ * @param {string } module - the module.
73
+ * @param {string } moduleOption - the option slug for the module.
74
+ * @param {boolean } deactivate - whether to deactive the module too.
75
75
*/
76
76
updateFormStateModuleOption = ( module , moduleOption , deactivate = false ) => {
77
77
this . trackSettingsToggle ( module , moduleOption , ! this . getOptionValue ( moduleOption ) ) ;
@@ -102,7 +102,7 @@ export function withModuleSettingsFormHelpers( InnerComponent ) {
102
102
/**
103
103
* Instantly activate or deactivate a module.
104
104
*
105
- * @param {String } module the module slug.
105
+ * @param {string } module - the module slug.
106
106
*/
107
107
toggleModuleNow = module => {
108
108
this . props . updateOptions ( { [ module ] : ! this . getOptionValue ( module ) } ) ;
@@ -141,8 +141,8 @@ export function withModuleSettingsFormHelpers( InnerComponent ) {
141
141
/**
142
142
* Retrieves an option from an existing module, or from an array of modules
143
143
* if the form was initialized with an array
144
- * @param {String } settingName the setting to get.
145
- * @param {String } module the module related to the setting.
144
+ * @param {string } settingName - the setting to get.
145
+ * @param {string } module - the module related to the setting.
146
146
* @param {boolean } ignoreDisabledModules - Whether to ignore settings for disabled modules.
147
147
* @return {* } the current value of the settings.
148
148
*/
@@ -162,7 +162,7 @@ export function withModuleSettingsFormHelpers( InnerComponent ) {
162
162
/**
163
163
* Check if there are unsaved settings in the card.
164
164
*
165
- * @return {Boolean } True if the form has unsaved changes.
165
+ * @return {boolean } True if the form has unsaved changes.
166
166
*/
167
167
isDirty = ( ) => {
168
168
return ! ! Object . keys ( this . state . options ) . length ;
@@ -171,27 +171,27 @@ export function withModuleSettingsFormHelpers( InnerComponent ) {
171
171
/**
172
172
* Checks if a setting is currently being saved.
173
173
*
174
- * @param {String| Array } settings The settings to check for a current saving in progress
174
+ * @param {string | Array } settings - The settings to check for a current saving in progress
175
175
*
176
- * @return {Boolean } True if specified settings are being saved, false otherwise.
176
+ * @return {boolean } True if specified settings are being saved, false otherwise.
177
177
*/
178
178
isSavingAnyOption = ( settings = '' ) => {
179
179
return this . props . isUpdating ( settings ) ;
180
180
} ;
181
181
182
182
/**
183
183
* Tracks form submissions
184
- * @param {Object } options options passed to recordEvent
184
+ * @param {object } options - options passed to recordEvent
185
185
*/
186
186
trackFormSubmission = options => {
187
187
analytics . tracks . recordEvent ( 'jetpack_wpa_settings_form_submit' , options ) ;
188
188
} ;
189
189
190
190
/**
191
191
* Tracks settings toggles
192
- * @param {String } module the module slug.
193
- * @param {String } setting the setting slug.
194
- * @param {Boolean } activated whether the settings is currently on
192
+ * @param {string } module - the module slug.
193
+ * @param {string } setting - the setting slug.
194
+ * @param {boolean } activated - whether the settings is currently on
195
195
*/
196
196
trackSettingsToggle = ( module , setting , activated ) => {
197
197
analytics . tracks . recordEvent ( 'jetpack_wpa_settings_toggle' , {
0 commit comments