@admin-layout/client 12.0.16-alpha.58 → 12.0.16-alpha.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/UpdateSettings/UpdateSettings.server.d.ts.map +1 -1
- package/lib/components/UpdateSettings/UpdateSettings.server.js +23 -36
- package/lib/components/UpdateSettings/UpdateSettings.server.js.map +1 -1
- package/lib/utils/settingsDifference.d.ts.map +1 -1
- package/lib/utils/settingsDifference.js +29 -100
- package/lib/utils/settingsDifference.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateSettings.server.d.ts","sourceRoot":"","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,cAAc,4CAMzB,CAAC;AAIH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,MAAM;;GAqF7F;AAED,wBAAsB,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE;;;;CAAA;;;
|
|
1
|
+
{"version":3,"file":"UpdateSettings.server.d.ts","sourceRoot":"","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,cAAc,4CAMzB,CAAC;AAIH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,MAAM;;GAqF7F;AAED,wBAAsB,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE;;;;CAAA;;;GAqGpE"}
|
|
@@ -92,41 +92,18 @@ async function settingsLoaderUtil({ request, context, params }) {
|
|
|
92
92
|
const pageSettings = result?.data?.pageSettings?.settings
|
|
93
93
|
? JSON.parse(JSON.stringify(result?.data?.pageSettings?.settings))
|
|
94
94
|
: null;
|
|
95
|
-
//
|
|
96
|
-
//
|
|
97
|
-
//
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
// });
|
|
103
|
-
// let pageDefaultSettings = hasUilayoutData ? uilayout : pageSettings || {};
|
|
104
|
-
let pageDefaultSettings = pageSettings;
|
|
105
|
-
// console.log('🔍 DEBUG - bracketOverrides:', JSON.stringify(bracketOverrides, null, 2));
|
|
106
|
-
// console.log('🔍 DEBUG - otherSettings:', JSON.stringify(otherSettings, null, 2));
|
|
95
|
+
// pageSettings now contains flat structure:
|
|
96
|
+
// {
|
|
97
|
+
// logo: '...', theme: '...', ...base settings,
|
|
98
|
+
// [desktop]: { overrides for desktop },
|
|
99
|
+
// [/dashboard][mobile]: { overrides for /dashboard on mobile },
|
|
100
|
+
// ... etc
|
|
101
|
+
// }
|
|
107
102
|
// Add required keys that might not be in backend
|
|
108
|
-
pageDefaultSettings = {
|
|
109
|
-
...
|
|
110
|
-
hiddenMenuKeys: [],
|
|
111
|
-
hiddenMenuCategories: [],
|
|
103
|
+
let pageDefaultSettings = {
|
|
104
|
+
...pageSettings,
|
|
112
105
|
};
|
|
113
|
-
// Structure the settings properly for the frontend
|
|
114
|
-
// The frontend expects uiSettings.overrides to contain the bracket pattern overrides
|
|
115
|
-
// pageDefaultSettings = {
|
|
116
|
-
// ...pageDefaultSettings,
|
|
117
|
-
// ...otherSettings, // Add other top-level settings like organization
|
|
118
|
-
// uiSettings: {
|
|
119
|
-
// ...pageDefaultSettings.uiSettings,
|
|
120
|
-
// overrides: bracketOverrides, // Put bracket overrides in uiSettings.overrides
|
|
121
|
-
// },
|
|
122
|
-
// };
|
|
123
106
|
console.log('🔍 DEBUG - final pageDefaultSettings:', JSON.stringify(pageDefaultSettings, null, 2));
|
|
124
|
-
// Add required keys that might not be in backend
|
|
125
|
-
// pageDefaultSettings = {
|
|
126
|
-
// ...pageDefaultSettings,
|
|
127
|
-
// hiddenMenuKeys: [],
|
|
128
|
-
// hiddenMenuCategories: [],
|
|
129
|
-
// };
|
|
130
107
|
// Fallback to config.LAYOUT_SETTINGS if backend returns empty
|
|
131
108
|
const settingsKeys = Object.keys(pageDefaultSettings);
|
|
132
109
|
const hasOnlyDefaultKeys = settingsKeys.length === 2 &&
|
|
@@ -138,8 +115,6 @@ async function settingsLoaderUtil({ request, context, params }) {
|
|
|
138
115
|
: { ...config.LAYOUT_SETTINGS };
|
|
139
116
|
pageDefaultSettings = {
|
|
140
117
|
...fallbackSettings,
|
|
141
|
-
hiddenMenuKeys: [],
|
|
142
|
-
hiddenMenuCategories: [],
|
|
143
118
|
};
|
|
144
119
|
}
|
|
145
120
|
// Parse cookie settings
|
|
@@ -166,8 +141,20 @@ async function settingsLoaderUtil({ request, context, params }) {
|
|
|
166
141
|
const cookie = await settingsCookie.serialize(diffSettings);
|
|
167
142
|
return { settings: fullSettings, setCookie: cookie };
|
|
168
143
|
}
|
|
169
|
-
//
|
|
170
|
-
const
|
|
144
|
+
// Extract base settings (non-bracket keys) from pageDefaultSettings
|
|
145
|
+
const baseSettings = {};
|
|
146
|
+
const bracketOverrides = {};
|
|
147
|
+
Object.keys(pageDefaultSettings).forEach((key) => {
|
|
148
|
+
if (key.startsWith('[') && key.endsWith(']')) {
|
|
149
|
+
bracketOverrides[key] = pageDefaultSettings[key];
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
baseSettings[key] = pageDefaultSettings[key];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
// Merge: base settings + config + cookie overrides, then add bracket overrides
|
|
156
|
+
const mergedBaseSettings = merge({}, baseSettings, config.LAYOUT_SETTINGS, settings);
|
|
157
|
+
const fullSettings = merge({}, mergedBaseSettings, bracketOverrides);
|
|
171
158
|
// Refresh the cookie to keep it active
|
|
172
159
|
const cookie = await settingsCookie.serialize(settings);
|
|
173
160
|
console.log('FULL_SETTINGS', fullSettings);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateSettings.server.js","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"sourcesContent":[null],"names":[],"mappings":"qhBAiHqE,MAAA,cAAA,GAAA,YAAA,CAAA,UAAA,EAAA;;;
|
|
1
|
+
{"version":3,"file":"UpdateSettings.server.js","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"sourcesContent":[null],"names":[],"mappings":"qhBAiHqE,MAAA,cAAA,GAAA,YAAA,CAAA,UAAA,EAAA;;;AAqGpE,IAAA,QAAA,EAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsDifference.d.ts","sourceRoot":"","sources":["../../src/utils/settingsDifference.ts"],"names":[],"mappings":"AAkLA;;;GAGG;AACH,eAAO,MAAM,iCAAiC,GAAI,iBAAiB,GAAG,EAAE,iBAAiB,GAAG,
|
|
1
|
+
{"version":3,"file":"settingsDifference.d.ts","sourceRoot":"","sources":["../../src/utils/settingsDifference.ts"],"names":[],"mappings":"AAkLA;;;GAGG;AACH,eAAO,MAAM,iCAAiC,GAAI,iBAAiB,GAAG,EAAE,iBAAiB,GAAG,QA6D3F,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {cloneDeep,
|
|
1
|
+
import {cloneDeep,isObject,isEqual,transform}from'lodash-es';/**
|
|
2
2
|
* Gets the deep differences between two objects
|
|
3
3
|
* Returns only the values that differ from obj2
|
|
4
4
|
*/
|
|
@@ -63,84 +63,6 @@ const getDifference = (obj1, obj2) => {
|
|
|
63
63
|
// Return undefined if the resulting object is empty
|
|
64
64
|
return Object.keys(result).length > 0 ? result : undefined;
|
|
65
65
|
};
|
|
66
|
-
/**
|
|
67
|
-
* Special handler for route settings differences with improved nested comparison
|
|
68
|
-
*/
|
|
69
|
-
const getRouteSettingsDifferences = (currentRouteSettings, defaultRouteSettings) => {
|
|
70
|
-
const differences = {};
|
|
71
|
-
// Get the default route template (typically from '/')
|
|
72
|
-
const defaultRouteTemplate = defaultRouteSettings['/'] || Object.values(defaultRouteSettings)[0];
|
|
73
|
-
if (!defaultRouteTemplate) {
|
|
74
|
-
console.warn('No default route template found for comparison');
|
|
75
|
-
return currentRouteSettings;
|
|
76
|
-
}
|
|
77
|
-
// Compare each route's settings
|
|
78
|
-
Object.keys(currentRouteSettings).forEach((route) => {
|
|
79
|
-
const currentRouteConfig = currentRouteSettings[route];
|
|
80
|
-
// Use the specific route config if it exists, otherwise use the default template
|
|
81
|
-
const defaultRouteConfig = defaultRouteSettings[route] || defaultRouteTemplate;
|
|
82
|
-
// Compare each section separately (layout, regions, etc)
|
|
83
|
-
const routeDiff = {};
|
|
84
|
-
Object.keys(currentRouteConfig).forEach((section) => {
|
|
85
|
-
if (section === 'layout' || section === 'regions') {
|
|
86
|
-
const sectionDiff = {};
|
|
87
|
-
// Compare desktop and mobile separately
|
|
88
|
-
['desktop', 'mobile'].forEach((device) => {
|
|
89
|
-
if (!currentRouteConfig[section][device]) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
// For regions section with header/footer/background
|
|
93
|
-
if (section === 'regions') {
|
|
94
|
-
const regionsDiff = {};
|
|
95
|
-
['header', 'footer', 'background'].forEach((region) => {
|
|
96
|
-
if (!currentRouteConfig[section][device][region]) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
// Get default path for comparison
|
|
100
|
-
const defaultRegionPath = `${section}.${device}.${region}`;
|
|
101
|
-
const defaultRegion = get(defaultRouteConfig, defaultRegionPath);
|
|
102
|
-
if (defaultRegion) {
|
|
103
|
-
const regionDiff = getDifference(currentRouteConfig[section][device][region], defaultRegion);
|
|
104
|
-
if (regionDiff !== undefined &&
|
|
105
|
-
(Array.isArray(regionDiff) || Object.keys(regionDiff).length > 0)) {
|
|
106
|
-
regionsDiff[region] = regionDiff;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
if (Object.keys(regionsDiff).length > 0) {
|
|
111
|
-
sectionDiff[device] = regionsDiff;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
// For other sections (like layout)
|
|
116
|
-
const defaultDevicePath = `${section}.${device}`;
|
|
117
|
-
const defaultDevice = get(defaultRouteConfig, defaultDevicePath);
|
|
118
|
-
if (defaultDevice) {
|
|
119
|
-
const deviceDiff = getDifference(currentRouteConfig[section][device], defaultDevice);
|
|
120
|
-
if (deviceDiff !== undefined && Object.keys(deviceDiff).length > 0) {
|
|
121
|
-
sectionDiff[device] = deviceDiff;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
if (Object.keys(sectionDiff).length > 0) {
|
|
127
|
-
routeDiff[section] = sectionDiff;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
const sectionDiff = getDifference(currentRouteConfig[section], defaultRouteConfig[section]);
|
|
132
|
-
if (sectionDiff !== undefined && Object.keys(sectionDiff).length > 0) {
|
|
133
|
-
routeDiff[section] = sectionDiff;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
// Only include the route if there are actual differences
|
|
138
|
-
if (Object.keys(routeDiff).length > 0) {
|
|
139
|
-
differences[route] = routeDiff;
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return Object.keys(differences).length > 0 ? differences : undefined;
|
|
143
|
-
};
|
|
144
66
|
/**
|
|
145
67
|
* Compares settings objects and saves only the differences
|
|
146
68
|
* @returns An object containing only the differences, or an empty object on error
|
|
@@ -154,39 +76,46 @@ const compareAndSaveSettingsDifferences = (currentSettings, defaultSettings) =>
|
|
|
154
76
|
// Make deep clones to avoid modifying the original objects
|
|
155
77
|
const current = cloneDeep(currentSettings);
|
|
156
78
|
const defaults = cloneDeep(defaultSettings);
|
|
157
|
-
//
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
79
|
+
// Extract overrides (bracket keys) from current settings
|
|
80
|
+
const overrides = {};
|
|
81
|
+
Object.keys(current).forEach((key) => {
|
|
82
|
+
if (key.startsWith('[') && key.endsWith(']')) {
|
|
83
|
+
overrides[key] = current[key];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
// Get differences for non-override settings (base settings)
|
|
87
|
+
const currentBase = { ...current };
|
|
88
|
+
const defaultBase = { ...defaults };
|
|
89
|
+
// Remove all bracket keys from both objects
|
|
90
|
+
Object.keys(currentBase).forEach((key) => {
|
|
91
|
+
if (key.startsWith('[') && key.endsWith(']')) {
|
|
92
|
+
delete currentBase[key];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
Object.keys(defaultBase).forEach((key) => {
|
|
96
|
+
if (key.startsWith('[') && key.endsWith(']')) {
|
|
97
|
+
delete defaultBase[key];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
const baseSettingsDiff = getDifference(currentBase, defaultBase);
|
|
101
|
+
// Combine base settings differences with overrides
|
|
169
102
|
const diffSettings = {};
|
|
170
|
-
// Add
|
|
171
|
-
if (
|
|
172
|
-
Object.assign(diffSettings,
|
|
173
|
-
}
|
|
174
|
-
// Add route settings differences if any exist
|
|
175
|
-
if (routeSettingsDiff && Object.keys(routeSettingsDiff).length > 0) {
|
|
176
|
-
diffSettings.routeSettings = routeSettingsDiff;
|
|
103
|
+
// Add base settings differences if any exist
|
|
104
|
+
if (baseSettingsDiff && Object.keys(baseSettingsDiff).length > 0) {
|
|
105
|
+
Object.assign(diffSettings, baseSettingsDiff);
|
|
177
106
|
}
|
|
107
|
+
// Add all overrides (they are always different from defaults)
|
|
108
|
+
Object.assign(diffSettings, overrides);
|
|
178
109
|
// If there are no differences at all, return early
|
|
179
110
|
if (Object.keys(diffSettings).length === 0) {
|
|
180
111
|
return {};
|
|
181
112
|
}
|
|
182
113
|
// Remove empty objects from the diff
|
|
183
|
-
// This helps prevent unnecessary properties in the payload
|
|
184
114
|
const cleanDiffSettings = removeEmptyObjects(diffSettings);
|
|
185
115
|
return cleanDiffSettings;
|
|
186
116
|
}
|
|
187
117
|
catch (error) {
|
|
188
118
|
console.error('Error comparing settings differences:', error);
|
|
189
|
-
// Return empty object instead of null to avoid downstream errors
|
|
190
119
|
return {};
|
|
191
120
|
}
|
|
192
121
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsDifference.js","sources":["../../src/utils/settingsDifference.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAqLG;AACH
|
|
1
|
+
{"version":3,"file":"settingsDifference.js","sources":["../../src/utils/settingsDifference.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAqLG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@admin-layout/client",
|
|
3
|
-
"version": "12.0.16-alpha.
|
|
3
|
+
"version": "12.0.16-alpha.62",
|
|
4
4
|
"description": "Sample client for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"serialize-error": "^8.0.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"common": "12.0.16-alpha.
|
|
29
|
+
"common": "12.0.16-alpha.59",
|
|
30
30
|
"rc-menu": "^9.16.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"typescript": {
|
|
45
45
|
"definition": "lib/index.d.ts"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "0f34e34fa56ef415cd32998b67df42ab784af9a1"
|
|
48
48
|
}
|