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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user