@admin-layout/client 12.0.16-alpha.44 → 12.0.16-alpha.46
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/colors/presets/black.js +0 -3
- package/lib/colors/presets/black.js.map +1 -1
- package/lib/colors/presets/white.js +0 -3
- package/lib/colors/presets/white.js.map +1 -1
- package/lib/components/LayoutCookieProvider.d.ts.map +1 -1
- package/lib/components/LayoutCookieProvider.js +0 -10
- package/lib/components/LayoutCookieProvider.js.map +1 -1
- package/lib/components/UpdateSettings/UpdateSettings.server.d.ts +6 -13
- package/lib/components/UpdateSettings/UpdateSettings.server.d.ts.map +1 -1
- package/lib/components/UpdateSettings/UpdateSettings.server.js +67 -40
- package/lib/components/UpdateSettings/UpdateSettings.server.js.map +1 -1
- package/lib/utils/settingsDifference.d.ts +1 -0
- package/lib/utils/settingsDifference.d.ts.map +1 -1
- package/lib/utils/settingsDifference.js +15 -4
- package/lib/utils/settingsDifference.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"black.js","sources":["../../../src/colors/presets/black.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAS,MAAA,KAAO,GAAA;AAEhB,IAAA,OAAA,EAAA,MAAO
|
|
1
|
+
{"version":3,"file":"black.js","sources":["../../../src/colors/presets/black.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAS,MAAA,KAAO,GAAA;AAEhB,IAAA,OAAA,EAAA,MAAO;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"white.js","sources":["../../../src/colors/presets/white.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAS,MAAA,KAAO,GAAA;AAEhB,IAAA,OAAA,EAAA,MAAO
|
|
1
|
+
{"version":3,"file":"white.js","sources":["../../../src/colors/presets/white.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAS,MAAA,KAAO,GAAA;AAEhB,IAAA,OAAA,EAAA,MAAO;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutCookieProvider.d.ts","sourceRoot":"","sources":["../../src/components/LayoutCookieProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAIlE,UAAU,yBAAyB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,EAAE,yBAAyB,GAAG,KAAK,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"LayoutCookieProvider.d.ts","sourceRoot":"","sources":["../../src/components/LayoutCookieProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAIlE,UAAU,yBAAyB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAED,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,EAAE,yBAAyB,GAAG,KAAK,CAAC,YAAY,CA2BhG"}
|
|
@@ -3,19 +3,9 @@ import {jsx,Fragment}from'react/jsx-runtime';import {useRouteLoaderData}from'@re
|
|
|
3
3
|
const settings = routeData?.settings?.settings || routeData?.settings;
|
|
4
4
|
const dispatch = useDispatch();
|
|
5
5
|
const hasDispatched = useRef(false);
|
|
6
|
-
// Debug logging
|
|
7
|
-
if (typeof window !== 'undefined') {
|
|
8
|
-
console.log('🎨 LayoutCookieProvider - Client Side:', {
|
|
9
|
-
hasRouteData: !!routeData,
|
|
10
|
-
hasSettings: !!settings,
|
|
11
|
-
settingsKeys: settings ? Object.keys(settings).slice(0, 10) : 'null',
|
|
12
|
-
settingsData: settings, // Full settings object
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
6
|
// Handle both server and client side
|
|
16
7
|
useEffect(() => {
|
|
17
8
|
if (settings && !hasDispatched.current) {
|
|
18
|
-
console.log('🎨 LayoutCookieProvider - Dispatching settings to Redux');
|
|
19
9
|
dispatch({
|
|
20
10
|
type: CHANGE_SETTINGS_ACTION,
|
|
21
11
|
payload: settings,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayoutCookieProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LayoutCookieProvider.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import { IAppLoadContext } from '@common-stack/client-core';
|
|
2
|
-
import { IResourceParams } from '@common-stack/core';
|
|
3
|
-
import { IGetPageSettingsQuery } from 'common';
|
|
4
|
-
import type { ApolloClient } from '@apollo/client';
|
|
5
|
-
import { ProSettings } from '../../interfaces';
|
|
6
1
|
export declare const settingsCookie: import("@remix-run/server-runtime").Cookie;
|
|
7
|
-
export declare function
|
|
8
|
-
export declare function fetchPageSettingsWithFetch(request: Request, graphqlUrl?: string): Promise<{
|
|
2
|
+
export declare function fetchPageSettingsWithFetch(request: Request, overrideIdentifier?: string): Promise<{
|
|
9
3
|
data: any;
|
|
10
4
|
}>;
|
|
11
|
-
export declare function settingsLoaderUtil({ request, context, params
|
|
12
|
-
request:
|
|
13
|
-
context
|
|
14
|
-
params
|
|
15
|
-
useFetch?: boolean;
|
|
5
|
+
export declare function settingsLoaderUtil({ request, context, params }: {
|
|
6
|
+
request: any;
|
|
7
|
+
context: any;
|
|
8
|
+
params: any;
|
|
16
9
|
}): Promise<{
|
|
17
|
-
settings:
|
|
10
|
+
settings: any;
|
|
18
11
|
setCookie: string;
|
|
19
12
|
}>;
|
|
20
13
|
//# sourceMappingURL=UpdateSettings.server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateSettings.server.d.ts","sourceRoot":"","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UpdateSettings.server.d.ts","sourceRoot":"","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,cAAc,4CAMzB,CAAC;AAGH,wBAAsB,0BAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,kBAAkB,CAAC,EAAE,MAAM;;GAmF7F;AAED,wBAAsB,kBAAkB,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE;;;;CAAA;;;GA0IpE"}
|
|
@@ -5,48 +5,41 @@ import {createCookie}from'@remix-run/node';import {ConfigCollectionName,ConfigFr
|
|
|
5
5
|
path: '/', // Ensure cookie is available for all paths
|
|
6
6
|
domain: config.isProd ? config.APP_DOMAIN : undefined,
|
|
7
7
|
});
|
|
8
|
-
// Helper to fetch page settings from Apollo
|
|
9
|
-
async function fetchPageSettings(apolloClient) {
|
|
10
|
-
const resource = generateCdecodeUri(DEFAULT_TENANT_ID, {
|
|
11
|
-
resourceType: ConfigCollectionName.Applications,
|
|
12
|
-
resourceId: config.APPLICATION_ID,
|
|
13
|
-
idField: 'appId',
|
|
14
|
-
}, {}, ConfigFragmentName.UiSettings);
|
|
15
|
-
const result = await apolloClient.query({
|
|
16
|
-
query: GetPageSettingsDocument,
|
|
17
|
-
variables: {
|
|
18
|
-
resourceUri: resource,
|
|
19
|
-
options: {
|
|
20
|
-
schemaId: ConfigurationSchemaId.UiLayout,
|
|
21
|
-
target: 2 /* ConfigurationTarget.APPLICATION */,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
fetchPolicy: 'no-cache', // Bypass cache completely - always fetch fresh from server
|
|
25
|
-
});
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
8
|
// Alternative: Direct fetch-based implementation (for testing/comparison)
|
|
29
|
-
async function fetchPageSettingsWithFetch(request,
|
|
9
|
+
async function fetchPageSettingsWithFetch(request, overrideIdentifier) {
|
|
30
10
|
const resource = generateCdecodeUri(DEFAULT_TENANT_ID, {
|
|
31
11
|
resourceType: ConfigCollectionName.Applications,
|
|
32
12
|
resourceId: config.APPLICATION_ID,
|
|
33
13
|
idField: 'appId',
|
|
34
14
|
}, {}, ConfigFragmentName.UiSettings);
|
|
35
|
-
const url =
|
|
15
|
+
const url = process.env.GRAPHQL_URL || 'http://localhost:8080/graphql';
|
|
36
16
|
// Convert GraphQL DocumentNode to string
|
|
37
17
|
const query = print(GetPageSettingsDocument);
|
|
18
|
+
// Prepare options with optional overrides
|
|
19
|
+
const options = {
|
|
20
|
+
schemaId: ConfigurationSchemaId.UiLayout,
|
|
21
|
+
target: 2 /* ConfigurationTarget.APPLICATION */,
|
|
22
|
+
};
|
|
23
|
+
// Add overrides if provided
|
|
24
|
+
if (overrideIdentifier) {
|
|
25
|
+
options.overrides = {
|
|
26
|
+
overrideIdentifier,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
// Add timestamp to force cache invalidation
|
|
38
30
|
const variables = {
|
|
39
31
|
resourceUri: resource,
|
|
40
|
-
options
|
|
41
|
-
|
|
42
|
-
target: 2 /* ConfigurationTarget.APPLICATION */,
|
|
43
|
-
},
|
|
32
|
+
options,
|
|
33
|
+
_timestamp: Date.now(), // Force cache bust
|
|
44
34
|
};
|
|
45
35
|
console.log('🔍 Fetching settings with direct fetch to:', url);
|
|
46
36
|
console.log('🔍 Query variables:', JSON.stringify(variables, null, 2));
|
|
47
37
|
// Forward cookies from the incoming request
|
|
48
38
|
const headers = {
|
|
49
39
|
'Content-Type': 'application/json',
|
|
40
|
+
'Cache-Control': 'no-cache, no-store, must-revalidate',
|
|
41
|
+
Pragma: 'no-cache',
|
|
42
|
+
Expires: '0',
|
|
50
43
|
};
|
|
51
44
|
const cookieHeader = request.headers.get('Cookie');
|
|
52
45
|
if (cookieHeader) {
|
|
@@ -82,27 +75,60 @@ async function fetchPageSettingsWithFetch(request, graphqlUrl) {
|
|
|
82
75
|
throw error;
|
|
83
76
|
}
|
|
84
77
|
}
|
|
85
|
-
async function settingsLoaderUtil({ request, context, params
|
|
86
|
-
}) {
|
|
78
|
+
async function settingsLoaderUtil({ request, context, params }) {
|
|
87
79
|
const cookieHeader = request.headers.get('Cookie');
|
|
88
|
-
|
|
80
|
+
// Detect device type from User-Agent (simplified detection)
|
|
81
|
+
const userAgent = request.headers.get('User-Agent') || '';
|
|
82
|
+
const isMobile = /mobile|android|iphone|ipad|ipod/i.test(userAgent);
|
|
83
|
+
const deviceType = isMobile ? 'mobile' : 'desktop';
|
|
84
|
+
// Fetch ALL settings for this device upfront (includes all route overrides)
|
|
85
|
+
// Pass device-level override to get all route-specific overrides for this device
|
|
86
|
+
const overrideIdentifier = `[${deviceType}]`;
|
|
87
|
+
// Fetch settings with device override - this will include ALL route overrides for this device
|
|
89
88
|
// Fetch settings from backend - choose method based on flag
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
result = await fetchPageSettingsWithFetch(request);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
console.log('🚀 Using Apollo Client to get settings');
|
|
97
|
-
result = await fetchPageSettings(apolloClient);
|
|
98
|
-
}
|
|
89
|
+
console.log('📡 Using direct fetch to get settings');
|
|
90
|
+
const result = await fetchPageSettingsWithFetch(request, overrideIdentifier);
|
|
91
|
+
console.log('RESULT=========>', JSON.stringify(result));
|
|
99
92
|
const pageSettings = result?.data?.pageSettings?.settings
|
|
100
93
|
? JSON.parse(JSON.stringify(result?.data?.pageSettings?.settings))
|
|
101
94
|
: null;
|
|
102
|
-
//
|
|
95
|
+
// pageSettings now contains:
|
|
96
|
+
// {
|
|
97
|
+
// uilayout: { base config },
|
|
98
|
+
// [/dashboard][mobile]: { overrides for /dashboard on mobile },
|
|
99
|
+
// [/profile][mobile]: { overrides for /profile on mobile },
|
|
100
|
+
// ... etc
|
|
101
|
+
// }
|
|
102
|
+
// Extract uilayout settings and preserve all other settings
|
|
103
103
|
const uilayout = pageSettings?.uilayout;
|
|
104
104
|
const hasUilayoutData = uilayout && typeof uilayout === 'object' && Object.keys(uilayout).length > 0;
|
|
105
|
+
// Extract bracket pattern overrides (keys that start with [)
|
|
106
|
+
const bracketOverrides = {};
|
|
107
|
+
// Extract other top-level settings (like organization, etc.)
|
|
108
|
+
const otherSettings = {};
|
|
109
|
+
Object.keys(pageSettings || {}).forEach((key) => {
|
|
110
|
+
if (key.startsWith('[') && key.endsWith(']')) {
|
|
111
|
+
bracketOverrides[key] = pageSettings[key];
|
|
112
|
+
}
|
|
113
|
+
else if (key !== 'uilayout') {
|
|
114
|
+
// Preserve other top-level settings like organization
|
|
115
|
+
otherSettings[key] = pageSettings[key];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
105
118
|
let pageDefaultSettings = hasUilayoutData ? uilayout : pageSettings || {};
|
|
119
|
+
console.log('🔍 DEBUG - bracketOverrides:', JSON.stringify(bracketOverrides, null, 2));
|
|
120
|
+
console.log('🔍 DEBUG - otherSettings:', JSON.stringify(otherSettings, null, 2));
|
|
121
|
+
// Structure the settings properly for the frontend
|
|
122
|
+
// The frontend expects uiSettings.overrides to contain the bracket pattern overrides
|
|
123
|
+
pageDefaultSettings = {
|
|
124
|
+
...pageDefaultSettings,
|
|
125
|
+
...otherSettings, // Add other top-level settings like organization
|
|
126
|
+
uiSettings: {
|
|
127
|
+
...pageDefaultSettings.uiSettings,
|
|
128
|
+
overrides: bracketOverrides, // Put bracket overrides in uiSettings.overrides
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
console.log('🔍 DEBUG - final pageDefaultSettings:', JSON.stringify(pageDefaultSettings, null, 2));
|
|
106
132
|
// Add required keys that might not be in backend
|
|
107
133
|
pageDefaultSettings = {
|
|
108
134
|
...pageDefaultSettings,
|
|
@@ -159,5 +185,6 @@ async function settingsLoaderUtil({ request, context, params, useFetch = true, /
|
|
|
159
185
|
});
|
|
160
186
|
// Refresh the cookie to keep it active
|
|
161
187
|
const cookie = await settingsCookie.serialize(settings);
|
|
188
|
+
console.log('FULL_SETTINGS', fullSettings);
|
|
162
189
|
return { settings: fullSettings, setCookie: cookie };
|
|
163
|
-
}export{
|
|
190
|
+
}export{fetchPageSettingsWithFetch,settingsCookie,settingsLoaderUtil};//# sourceMappingURL=UpdateSettings.server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UpdateSettings.server.js","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UpdateSettings.server.js","sources":["../../../src/components/UpdateSettings/UpdateSettings.server.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAkPC,IAAA,QAAA,EAAA,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compares settings objects and saves only the differences
|
|
3
|
+
* @returns An object containing only the differences, or an empty object on error
|
|
3
4
|
*/
|
|
4
5
|
export declare const compareAndSaveSettingsDifferences: (currentSettings: any, defaultSettings: any) => any;
|
|
5
6
|
//# sourceMappingURL=settingsDifference.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsDifference.d.ts","sourceRoot":"","sources":["../../src/utils/settingsDifference.ts"],"names":[],"mappings":"
|
|
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,QAqD3F,CAAC"}
|
|
@@ -16,17 +16,26 @@ const getDifference = (obj1, obj2) => {
|
|
|
16
16
|
return source;
|
|
17
17
|
}
|
|
18
18
|
// Handle non-object comparisons (primitives, functions, etc.)
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// IMPORTANT: Check for string BEFORE isObject check, because strings are technically objects
|
|
20
|
+
if (typeof source === 'string' || typeof target === 'string') {
|
|
21
21
|
if (typeof source === 'string' && typeof target === 'string') {
|
|
22
|
+
// Case-insensitive string comparison
|
|
22
23
|
return source.toLowerCase() !== target.toLowerCase() ? source : undefined;
|
|
23
24
|
}
|
|
25
|
+
// If types differ, return the source value
|
|
26
|
+
return source;
|
|
27
|
+
}
|
|
28
|
+
if (!isObject(source) || !isObject(target)) {
|
|
24
29
|
return !isEqual(source, target) ? source : undefined;
|
|
25
30
|
}
|
|
26
31
|
// For arrays, do a simple equality check and return the full array if different
|
|
27
32
|
if (Array.isArray(source) && Array.isArray(target)) {
|
|
28
33
|
return !isEqual(source, target) ? source : undefined;
|
|
29
34
|
}
|
|
35
|
+
// Prevent string from being treated as an object with numeric keys
|
|
36
|
+
if (Array.isArray(source) !== Array.isArray(target)) {
|
|
37
|
+
return source;
|
|
38
|
+
}
|
|
30
39
|
// For objects, do deep comparison
|
|
31
40
|
const result = transform(source, (result, value, key) => {
|
|
32
41
|
// Skip keys that are in source but have the exact same value in target
|
|
@@ -134,12 +143,13 @@ const getRouteSettingsDifferences = (currentRouteSettings, defaultRouteSettings)
|
|
|
134
143
|
};
|
|
135
144
|
/**
|
|
136
145
|
* Compares settings objects and saves only the differences
|
|
146
|
+
* @returns An object containing only the differences, or an empty object on error
|
|
137
147
|
*/
|
|
138
148
|
const compareAndSaveSettingsDifferences = (currentSettings, defaultSettings) => {
|
|
139
149
|
try {
|
|
140
150
|
if (!currentSettings || !defaultSettings) {
|
|
141
151
|
console.warn('Missing settings objects for comparison');
|
|
142
|
-
return
|
|
152
|
+
return {};
|
|
143
153
|
}
|
|
144
154
|
// Make deep clones to avoid modifying the original objects
|
|
145
155
|
const current = cloneDeep(currentSettings);
|
|
@@ -176,7 +186,8 @@ const compareAndSaveSettingsDifferences = (currentSettings, defaultSettings) =>
|
|
|
176
186
|
}
|
|
177
187
|
catch (error) {
|
|
178
188
|
console.error('Error comparing settings differences:', error);
|
|
179
|
-
|
|
189
|
+
// Return empty object instead of null to avoid downstream errors
|
|
190
|
+
return {};
|
|
180
191
|
}
|
|
181
192
|
};
|
|
182
193
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settingsDifference.js","sources":["../../src/utils/settingsDifference.ts"],"sourcesContent":[null],"names":[],"mappings":";
|
|
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.46",
|
|
4
4
|
"description": "Sample client for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"typescript": {
|
|
45
45
|
"definition": "lib/index.d.ts"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "ce30e2742a315175f9ec774fe3422976b5d7110f"
|
|
48
48
|
}
|