refactor(settings)!: pass path to getSettingsRecursively using an array instead of a string

Tests and all files the utility is used in are also updated.

Warning: This change is breaking!
This commit is contained in:
2026-07-28 20:10:27 +02:00
parent e18c066629
commit e0e2033fdf
3 changed files with 18 additions and 18 deletions
@@ -116,14 +116,14 @@ const veryNestedSettingsList = [
]; ];
test.for([ test.for([
({ settings: [], path: 'a', expected: undefined }), ({ settings: [], path: ['a'], expected: undefined }),
({ settings: [ ({ settings: [
{ {
type: 'bool', type: 'bool',
name: '1a', name: '1a',
i18n: '1a' i18n: '1a'
} }
], path: '1a', expected: { ], path: ['1a'], expected: {
type: 'bool', type: 'bool',
name: '1a', name: '1a',
i18n: '1a' i18n: '1a'
@@ -146,7 +146,7 @@ test.for([
} }
] ]
} }
], path: '1a', expected: { ], path: ['1a'], expected: {
type: 'bool', type: 'bool',
name: '1a', name: '1a',
i18n: '1a' i18n: '1a'
@@ -169,7 +169,7 @@ test.for([
} }
] ]
} }
], path: '1b.2a', expected: { ], path: ['1b', '2a'], expected: {
type: 'bool', type: 'bool',
name: '2a', name: '2a',
i18n: '2a' i18n: '2a'
@@ -198,7 +198,7 @@ test.for([
} }
] ]
} }
], path: '1b.2b', expected: { ], path: ['1b', '2b'], expected: {
type: 'number', type: 'number',
name: '2b', name: '2b',
i18n: '2b', i18n: '2b',
@@ -234,7 +234,7 @@ test.for([
} }
] ]
} }
], path: '1b.2b.3a', expected: { ], path: ['1b', '2b', '3a'], expected: {
type: 'string', type: 'string',
name: '3a', name: '3a',
i18n: '3a' i18n: '3a'
@@ -269,7 +269,7 @@ test.for([
} }
] ]
} }
], path: '1b', expected: { ], path: ['1b'], expected: {
type: 'section', type: 'section',
name: '1b', name: '1b',
i18n: '1b', i18n: '1b',
@@ -323,7 +323,7 @@ test.for([
} }
] ]
} }
], path: '1b.2b', expected: { ], path: ['1b', '2b'], expected: {
type: 'section', type: 'section',
name: '2b', name: '2b',
i18n: '2b', i18n: '2b',
@@ -366,7 +366,7 @@ test.for([
} }
] ]
} }
], path: '1b.2b.3b', expected: undefined }), ], path: ['1b', '2b', '3b'], expected: undefined }),
({ settings: [ ({ settings: [
{ {
type: 'bool', type: 'bool',
@@ -397,7 +397,7 @@ test.for([
} }
] ]
} }
], path: '1b.2a.3a', expected: undefined }), ], path: ['1b', '2a', '3a'], expected: undefined }),
({ settings: [ ({ settings: [
{ {
type: 'bool', type: 'bool',
@@ -428,7 +428,7 @@ test.for([
} }
] ]
} }
], path: '1b.2c.3a', expected: undefined }), ], path: ['1b', '2c', '3a'], expected: undefined }),
({ settings: [ ({ settings: [
{ {
type: 'bool', type: 'bool',
@@ -459,7 +459,7 @@ test.for([
} }
] ]
} }
], path: '1a.2b.3a', expected: undefined }), ], path: ['1a', '2b', '3a'], expected: undefined }),
({ settings: [ ({ settings: [
{ {
type: 'bool', type: 'bool',
@@ -490,13 +490,13 @@ test.for([
} }
] ]
} }
], path: '1c.2b.3a', expected: undefined }), ], path: ['1c', '2b', '3a'], expected: undefined }),
({ settings: veryNestedSettingsList, path: '1b.2b.3b.4b.5b.6b.7a', expected: { ({ settings: veryNestedSettingsList, path: ['1b', '2b', '3b', '4b', '5b', '6b', '7a'], expected: {
type: 'bool', type: 'bool',
name: '7a', name: '7a',
i18n: '7a' i18n: '7a'
} }), } }),
({ settings: veryNestedSettingsList, path: '1b.2b.3b.4b.5b', expected: { ({ settings: veryNestedSettingsList, path: ['1b', '2b', '3b', '4b', '5b'], expected: {
type: 'section', type: 'section',
name: '5b', name: '5b',
i18n: '5b', i18n: '5b',
@@ -520,7 +520,7 @@ test.for([
} }
] ]
} }), } }),
({ settings: veryNestedSettingsList, path: '1b.2b.3b.4ba.5b.6b.7a', expected: undefined }) ({ settings: veryNestedSettingsList, path: ['1b', '2b', '3b', '4ba', '5b', '6b', '7a'], expected: undefined })
])('returns $expected', ({ settings, path, expected }) => { ])('returns $expected', ({ settings, path, expected }) => {
expect(getSettingRecursively(path, settings)).toStrictEqual(expected); expect(getSettingRecursively(path, settings)).toStrictEqual(expected);
}); });
+1 -1
View File
@@ -38,5 +38,5 @@ export const getSettingRecursively = function getSettingRecursively (sectionPath
return; return;
}; };
}; };
return oneSettingsLevel(sectionPath.split('.'), { content: settings }); return oneSettingsLevel(sectionPath, { content: settings });
}; };
+1 -1
View File
@@ -43,7 +43,7 @@ watchEffect(() => {
const updateSettings = function updateSettings () { const updateSettings = function updateSettings () {
if (activeSection.value) { if (activeSection.value) {
const setting = getSettingRecursively(activeSection.value, settings.value); const setting = getSettingRecursively(activeSection.value.split('.'), settings.value);
if (!setting) { if (!setting) {
router.push('/settings'); router.push('/settings');
} else { } else {