@redhat-cloud-services/frontend-components-config-utilities 4.13.4 → 4.14.0
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/feo/feo-types.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ export type CRDObject = {
|
|
|
102
102
|
navigationSegments?: DirectNavItem[];
|
|
103
103
|
module: ChromeModule;
|
|
104
104
|
searchEntries?: ChromeStaticSearchEntry[];
|
|
105
|
+
locales?: Record<string, Record<string, string>>;
|
|
105
106
|
serviceTiles?: ServiceTile[];
|
|
106
107
|
widgetRegistry?: ChromeWidgetEntry[];
|
|
107
108
|
feoConfigEnabled?: boolean;
|
|
@@ -65,46 +65,45 @@ function findMatchingSegmentItem(navItems, matchId) {
|
|
|
65
65
|
}
|
|
66
66
|
return match;
|
|
67
67
|
}
|
|
68
|
+
function mergeNestedItems(localItems, remoteItems) {
|
|
69
|
+
var remoteById = new Map(remoteItems.map(function (item) { return [item.id, item]; }));
|
|
70
|
+
var sameSegmentRef = function (local, remote) {
|
|
71
|
+
return hasSegmentRef(local) &&
|
|
72
|
+
hasSegmentRef(remote) &&
|
|
73
|
+
local.segmentRef.segmentId === remote.segmentRef.segmentId &&
|
|
74
|
+
local.segmentRef.frontendName === remote.segmentRef.frontendName;
|
|
75
|
+
};
|
|
76
|
+
var merged = localItems.flatMap(function (local) {
|
|
77
|
+
if (hasSegmentRef(local)) {
|
|
78
|
+
var resolved = remoteItems.filter(function (remote) { return sameSegmentRef(local, remote); });
|
|
79
|
+
if (resolved.length > 0) {
|
|
80
|
+
return resolved.filter(function (remote) { return !remote.id || !localItems.some(function (item) { return !hasSegmentRef(item) && item.id === remote.id; }); });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (local.id && remoteById.has(local.id)) {
|
|
84
|
+
return [__assign(__assign({}, remoteById.get(local.id)), local)];
|
|
85
|
+
}
|
|
86
|
+
return [local];
|
|
87
|
+
});
|
|
88
|
+
remoteItems.forEach(function (remote) {
|
|
89
|
+
if (remote.id && !localItems.some(function (local) { return local.id === remote.id || sameSegmentRef(local, remote); })) {
|
|
90
|
+
merged.push(remote);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
return merged;
|
|
94
|
+
}
|
|
68
95
|
function handleNestedNav(segmentMatch, originalNavItem, bSegmentCache, nSegmentCache, bundleId, currentFrontendName, parentSegment) {
|
|
69
96
|
var routes = segmentMatch.routes, navItems = segmentMatch.navItems, segmentItem = __rest(segmentMatch, ["routes", "navItems"]);
|
|
70
97
|
var parsedRoutes = originalNavItem.routes;
|
|
71
98
|
var parsedNavItems = originalNavItem.navItems;
|
|
72
99
|
if (routes && routes.length > 0) {
|
|
73
|
-
|
|
74
|
-
var remoteRoutesMap_1 = new Map(remoteRoutes.map(function (route) { return [route.id, route]; }));
|
|
75
|
-
var mergedRoutes_1 = routes.map(function (localRoute) {
|
|
76
|
-
if (localRoute.id && remoteRoutesMap_1.has(localRoute.id)) {
|
|
77
|
-
var remoteRoute = remoteRoutesMap_1.get(localRoute.id);
|
|
78
|
-
return __assign(__assign({}, remoteRoute), localRoute);
|
|
79
|
-
}
|
|
80
|
-
return localRoute;
|
|
81
|
-
});
|
|
82
|
-
remoteRoutes.forEach(function (remoteRoute) {
|
|
83
|
-
if (remoteRoute.id && !routes.some(function (localRoute) { return localRoute.id === remoteRoute.id; })) {
|
|
84
|
-
mergedRoutes_1.push(remoteRoute);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
parsedRoutes = parseNavItems(mergedRoutes_1, bSegmentCache, nSegmentCache, bundleId, currentFrontendName);
|
|
100
|
+
parsedRoutes = parseNavItems(mergeNestedItems(routes, originalNavItem.routes || []), bSegmentCache, nSegmentCache, bundleId, currentFrontendName);
|
|
88
101
|
}
|
|
89
102
|
else if (parsedRoutes) {
|
|
90
103
|
parsedRoutes = parseNavItems(parsedRoutes, bSegmentCache, nSegmentCache, bundleId, currentFrontendName);
|
|
91
104
|
}
|
|
92
105
|
if (navItems && navItems.length > 0) {
|
|
93
|
-
|
|
94
|
-
var remoteNavItemsMap_1 = new Map(remoteNavItems.map(function (navItem) { return [navItem.id, navItem]; }));
|
|
95
|
-
var mergedNavItems_1 = navItems.map(function (localNavItem) {
|
|
96
|
-
if (localNavItem.id && remoteNavItemsMap_1.has(localNavItem.id)) {
|
|
97
|
-
var remoteNavItem = remoteNavItemsMap_1.get(localNavItem.id);
|
|
98
|
-
return __assign(__assign({}, remoteNavItem), localNavItem);
|
|
99
|
-
}
|
|
100
|
-
return localNavItem;
|
|
101
|
-
});
|
|
102
|
-
remoteNavItems.forEach(function (remoteNavItem) {
|
|
103
|
-
if (remoteNavItem.id && !navItems.some(function (localNavItem) { return localNavItem.id === remoteNavItem.id; })) {
|
|
104
|
-
mergedNavItems_1.push(remoteNavItem);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
parsedNavItems = parseNavItems(mergedNavItems_1, bSegmentCache, nSegmentCache, bundleId, currentFrontendName);
|
|
106
|
+
parsedNavItems = parseNavItems(mergeNestedItems(navItems, originalNavItem.navItems || []), bSegmentCache, nSegmentCache, bundleId, currentFrontendName);
|
|
108
107
|
}
|
|
109
108
|
else if (parsedNavItems) {
|
|
110
109
|
parsedNavItems = parseNavItems(parsedNavItems, bSegmentCache, nSegmentCache, bundleId, currentFrontendName);
|
|
@@ -729,6 +729,19 @@
|
|
|
729
729
|
"feoConfigEnabled": {
|
|
730
730
|
"type": "boolean"
|
|
731
731
|
},
|
|
732
|
+
"locales": {
|
|
733
|
+
"type": "object",
|
|
734
|
+
"description": "Generated translations keyed by locale and stable message ID",
|
|
735
|
+
"propertyNames": {
|
|
736
|
+
"format": "bcp47"
|
|
737
|
+
},
|
|
738
|
+
"additionalProperties": {
|
|
739
|
+
"type": "object",
|
|
740
|
+
"additionalProperties": {
|
|
741
|
+
"type": "string"
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
},
|
|
732
745
|
"akamaiCacheBustDisable": {
|
|
733
746
|
"type": "boolean"
|
|
734
747
|
},
|
|
@@ -21,6 +21,17 @@ function validateFrontendCrd(crd) {
|
|
|
21
21
|
var validator = new _2020_1.default({
|
|
22
22
|
strict: true,
|
|
23
23
|
});
|
|
24
|
+
validator.addFormat('bcp47', {
|
|
25
|
+
type: 'string',
|
|
26
|
+
validate: function (locale) {
|
|
27
|
+
try {
|
|
28
|
+
return Intl.getCanonicalLocales(locale).length === 1;
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
});
|
|
24
35
|
var crdInternal = typeof crd === 'string' ? readCrdYaml(crd) : crd;
|
|
25
36
|
delete frontend_crd_schema_json_1.default.$schema;
|
|
26
37
|
var validate = validator.compile(frontend_crd_schema_json_1.default);
|
package/package.json
CHANGED