Skip to content

Commit 36338f6

Browse files
authored
fix (admin settings): ensure that the props are not being edited (#3495)
1 parent 8a7241b commit 36338f6

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/welcome/admin.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,8 +1171,11 @@ const GlobalSettings = props => {
11711171

11721172
const RoleManager = props => {
11731173
const groups = props.filteredSearchTree.find( tab => tab.id === 'role-manager' ).groups
1174-
props.roleManager = groups.find( group => group.id === 'role-manager' )
11751174
const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 )
1175+
const propsToPass = {
1176+
...props,
1177+
roleManager: groups.find( group => group.id === 'role-manager' ),
1178+
}
11761179

11771180
const EditorModeSettings = applyFilters( 'stackable.admin.settings.editorModeSettings', Fragment )
11781181

@@ -1182,7 +1185,7 @@ const RoleManager = props => {
11821185
<h3>{ __( 'No matching settings', i18n ) }</h3>
11831186
) : (
11841187
<>
1185-
{ props.roleManager.children.length > 0 &&
1188+
{ propsToPass.roleManager.children.length > 0 &&
11861189
<div className="s-setting-group">
11871190
<h2>{ __( 'Role Manager', i18n ) }</h2>
11881191
<p className="s-settings-subtitle">
@@ -1200,7 +1203,7 @@ const RoleManager = props => {
12001203
{ isPro
12011204
? <Suspense fallback={ <Spinner /> }>
12021205
<div className="s-editing-mode-settings">
1203-
<EditorModeSettings { ...props } />
1206+
<EditorModeSettings { ...propsToPass } />
12041207
</div>
12051208
</Suspense>
12061209
: <p className="s-settings-pro">
@@ -1220,8 +1223,11 @@ const RoleManager = props => {
12201223

12211224
const CustomFields = props => {
12221225
const groups = props.filteredSearchTree.find( tab => tab.id === 'custom-fields-settings' ).groups
1223-
props.customFields = groups.find( group => group.id === 'custom-fields-settings' )
12241226
const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 )
1227+
const propsToPass = {
1228+
...props,
1229+
customFields: groups.find( group => group.id === 'custom-fields-settings' ),
1230+
}
12251231

12261232
const CustomFieldsEnableSettings = applyFilters( 'stackable.admin.settings.customFieldsEnableSettings', Fragment )
12271233
const CustomFieldsManagerSettings = applyFilters( 'stackable.admin.settings.customFieldsManagerSettings', Fragment )
@@ -1232,14 +1238,14 @@ const CustomFields = props => {
12321238
<h3>{ __( 'No matching settings', i18n ) }</h3>
12331239
) : (
12341240
<>
1235-
{ props.customFields.children.length > 0 &&
1241+
{ propsToPass.customFields.children.length > 0 &&
12361242
<div className="s-setting-group">
12371243
<div className="s-custom-fields-settings-header">
12381244
<h2>{ __( 'Custom Fields', i18n ) }</h2>
12391245
{ isPro &&
12401246
<Suspense fallback={ <Spinner /> }>
12411247
<div className="s-custom-fields-enable">
1242-
<CustomFieldsEnableSettings { ...props } />
1248+
<CustomFieldsEnableSettings { ...propsToPass } />
12431249
</div>
12441250
</Suspense>
12451251
}
@@ -1253,7 +1259,7 @@ const CustomFields = props => {
12531259
{ isPro
12541260
? <Suspense fallback={ <Spinner /> }>
12551261
<div className="s-custom-fields-manager">
1256-
<CustomFieldsManagerSettings { ...props } />
1262+
<CustomFieldsManagerSettings { ...propsToPass } />
12571263
</div>
12581264
</Suspense>
12591265
: <p className="s-settings-pro">
@@ -1279,8 +1285,11 @@ const Integrations = props => {
12791285
} = props
12801286

12811287
const groups = filteredSearchTree.find( tab => tab.id === 'integrations' ).groups
1282-
props.integrations = groups.find( group => group.id === 'integrations' )
12831288
const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 )
1289+
const propsToPass = {
1290+
...props,
1291+
integrations: groups.find( group => group.id === 'integrations' ),
1292+
}
12841293

12851294
const IconSettings = applyFilters( 'stackable.admin.settings.iconSettings', Fragment )
12861295

@@ -1290,13 +1299,13 @@ const Integrations = props => {
12901299
<h3>{ __( 'No matching settings', i18n ) }</h3>
12911300
) : (
12921301
<>
1293-
{ props.integrations.children.length > 0 &&
1302+
{ propsToPass.integrations.children.length > 0 &&
12941303
<div className="s-setting-group">
12951304
<h2>{ __( 'Integrations', i18n ) }</h2>
12961305
<p className="s-settings-subtitle">{ __( 'Here are settings for the different integrations available in Stackable.', i18n ) }</p>
12971306
<AdminTextSetting
12981307
label={ __( 'Google Maps API Key', i18n ) }
1299-
searchedSettings={ props.integrations.children }
1308+
searchedSettings={ propsToPass.integrations.children }
13001309
value={ settings.stackable_google_maps_api_key }
13011310
type="text"
13021311
onChange={ value => {
@@ -1316,7 +1325,7 @@ const Integrations = props => {
13161325
{ isPro
13171326
? <Suspense fallback={ <Spinner /> }>
13181327
<div className="ugb-admin-setting">
1319-
<IconSettings { ...props } />
1328+
<IconSettings { ...propsToPass } />
13201329
</div>
13211330
</Suspense>
13221331
: <>
@@ -1347,7 +1356,7 @@ const Integrations = props => {
13471356
<div className="s-icon-settings-fa-free-version">
13481357
<AdminSelectSetting
13491358
label={ __( 'FontAwesome Icon Library Version', i18n ) }
1350-
searchedSettings={ props.integrations.children }
1359+
searchedSettings={ propsToPass.integrations.children }
13511360
value={ settings.stackable_icons_fa_free_version }
13521361
options={ [
13531362
{

0 commit comments

Comments
 (0)