mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: Fix formatting of custom resource sidebar items
- The titles should better handle being line wrapped Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
d37a765ac2
commit
eb78edb226
3 files changed
+41
-25
No files matched your search
+8
-2
@@ -17,6 +17,12 @@ import routePathParametersInjectable from "../../routes/route-path-parameters.in
|
||||
import customResourcesSidebarItemInjectable from "./custom-resources-sidebar-item.injectable";
|
||||
import customResourceDefinitionsInjectable from "./custom-resources.injectable";
|
||||
|
||||
const titleCaseSplitRegex = /(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/;
|
||||
|
||||
const formatResourceKind = (resourceKind: string) => (
|
||||
resourceKind.split(titleCaseSplitRegex).join(" ")
|
||||
);
|
||||
|
||||
const customResourceDefinitionGroupsSidebarItemsComputedInjectable = getInjectable({
|
||||
id: "custom-resource-definition-groups-sidebar-items-computed",
|
||||
instantiate: (di) => {
|
||||
@@ -31,7 +37,7 @@ const customResourceDefinitionGroupsSidebarItemsComputedInjectable = getInjectab
|
||||
instantiate: (): SidebarItemRegistration => ({
|
||||
parentId: customResourcesSidebarItemInjectable.id,
|
||||
onClick: noop,
|
||||
title: group,
|
||||
title: group.replaceAll(".", "\u200b."), // Replace dots with zero-width spaces to allow line breaks
|
||||
orderNumber: 10 * index,
|
||||
}),
|
||||
injectionToken: sidebarItemInjectionToken,
|
||||
@@ -47,7 +53,7 @@ const customResourceDefinitionGroupsSidebarItemsComputedInjectable = getInjectab
|
||||
instantiate: (di): SidebarItemRegistration => ({
|
||||
parentId: customResourceGroupSidebarItem.id,
|
||||
onClick: () => navigateToCustomResources(parameters),
|
||||
title: definition.getResourceKind(),
|
||||
title: formatResourceKind(definition.getResourceKind()),
|
||||
isActive: computedAnd(
|
||||
di.inject(routeIsActiveInjectable, customResourcesRoute),
|
||||
computed(() => matches(parameters)(pathParameters.get())),
|
||||
|
||||
Reference in new issue
Block a user