core-components,catalog: switch back paths to being required on routed tabs

Co-authored-by: blam <ben@blam.sh>
Co-authored-by: Johan Haals <johan.haals@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-08-24 14:25:27 +02:00
parent bbdefa2038
commit c3ea619480
3 changed files with 5 additions and 5 deletions
@@ -29,7 +29,7 @@ export function useSelectedSubRoute(subRoutes: SubRoute[]): {
const routes = subRoutes.map(({ path, children }) => ({
caseSensitive: false,
path: path ? `${path}/*` : '.',
path: `${path}/*`,
element: children,
}));
@@ -68,7 +68,7 @@ export function RoutedTabs(props: { routes: SubRoute[] }) {
const headerTabs = useMemo(
() =>
routes.map(t => ({
id: t.path ?? '.',
id: t.path,
label: t.title,
tabProps: t.tabProps,
})),
@@ -76,7 +76,7 @@ export function RoutedTabs(props: { routes: SubRoute[] }) {
);
const onTabChange = (tabIndex: number) => {
let { path = '.' } = routes[tabIndex];
let { path } = routes[tabIndex];
// Remove trailing /*
path = path.replace(/\/\*$/, '');
// And remove leading / for relative navigation
@@ -18,7 +18,7 @@ import { TabProps } from '@material-ui/core/Tab';
import * as React from 'react';
export type SubRoute = {
path?: string;
path: string;
title: string;
children: JSX.Element;
tabProps?: TabProps<React.ElementType, { component?: React.ElementType }>;
@@ -52,7 +52,7 @@ import { EntityContextMenu } from '../EntityContextMenu/EntityContextMenu';
/** @public */
export type EntityLayoutRouteProps = {
path?: string;
path: string;
title: string;
children: JSX.Element;
if?: (entity: Entity) => boolean;