Skip to content

Commit 38d1229

Browse files
Georgi2704acidjunk
andauthored
Fix breadcrumb link of metadata (#222)
* Fix breadcrumb link of metadata * Added middleware for redirect * Added changeset * Removed app from changeset * Redirect instead of rewrite --------- Co-authored-by: René Dohmen <[email protected]>
1 parent 5838bf5 commit 38d1229

File tree

10 files changed

+46
-16
lines changed

10 files changed

+46
-16
lines changed

.changeset/fresh-pets-eat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@orchestrator-ui/orchestrator-ui-components': patch
3+
---
4+
5+
Fixed handling navigation for pages with sidebar submenu items

apps/wfo-ui/middleware.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { NextResponse } from 'next/server';
2+
import type { NextRequest } from 'next/server';
3+
4+
export function middleware(request: NextRequest) {
5+
return NextResponse.redirect(new URL('/metadata/products', request.url));
6+
}
7+
8+
// Supports both a single string value or an array of matchers
9+
export const config = {
10+
matcher: ['/metadata'],
11+
};

apps/wfo-ui/pages/_app.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
OrchestratorConfig,
1111
OrchestratorConfigProvider,
1212
WFOPageTemplate,
13-
WFOBreadcrumbs,
1413
} from '@orchestrator-ui/orchestrator-ui-components';
1514

1615
import '@elastic/eui/dist/eui_theme_light.min.css';
@@ -80,7 +79,6 @@ function CustomApp({ Component, pageProps }: AppProps) {
8079
enableBatching: true,
8180
}}
8281
>
83-
<WFOBreadcrumbs />
8482
<Component {...pageProps} />
8583
</QueryParamProvider>
8684
</WFOPageTemplate>

packages/orchestrator-ui-components/src/components/WFOBreadcrumbs/WFOBreadcrumbs.tsx renamed to packages/orchestrator-ui-components/src/components/WFOPageTemplate/WFOBreadcrumbs/WFOBreadcrumbs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { EuiBreadcrumb, EuiBreadcrumbs, EuiSpacer } from '@elastic/eui';
33
import { useRouter } from 'next/router';
4-
import { isUuid4, removeSuffix, upperCaseFirstChar } from '../../utils';
4+
import { isUuid4, removeSuffix, upperCaseFirstChar } from '../../../utils';
55

66
export const WFOBreadcrumbs = () => {
77
const router = useRouter();

packages/orchestrator-ui-components/src/components/WFOPageTemplate/WFOPageTemplate/WFOPageTemplate.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { EuiPageTemplate } from '@elastic/eui';
33
import { WFOPageHeader } from '../WFOPageHeader';
44
import { WFOSidebar } from '../WFOSidebar';
55
import { useOrchestratorTheme } from '../../../hooks/useOrchestratorTheme';
6+
import { WFOBreadcrumbs } from '../WFOBreadcrumbs';
67

78
export interface WFOPageTemplateProps {
89
getAppLogo: (navigationHeight: number) => ReactElement;
@@ -50,6 +51,7 @@ export const WFOPageTemplate: FC<WFOPageTemplateProps> = ({
5051
backgroundColor: theme.colors.emptyShade,
5152
}}
5253
>
54+
<WFOBreadcrumbs />
5355
{children}
5456
</EuiPageTemplate.Section>
5557
</EuiPageTemplate>

packages/orchestrator-ui-components/src/components/WFOPageTemplate/WFOSidebar/WFOSidebar.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import React, { FC } from 'react';
22
import { EuiButton, EuiSideNav, EuiSpacer } from '@elastic/eui';
33
import { useRouter } from 'next/router';
4-
5-
const PATH_START = '/';
6-
const PATH_NEW_PROCESS = '/new-process';
7-
const PATH_PROCESSES = '/processes';
8-
const PATH_SUBSCRIPTIONS = '/subscriptions';
9-
const PATH_METADATA_PRODUCTS = '/metadata/products';
10-
const PATH_METADATA_PRODUCT_BLOCKS = '/metadata/productblocks';
11-
const PATH_METADATA_RESOURCE_TYPES = '/metadata/resource-types';
12-
const PATH_METADATA_WORKFLOWS = '/metadata/workflows';
13-
const PATH_TASKS = '/tasks';
14-
const PATH_SETTINGS = '/settings';
4+
import {
5+
PATH_METADATA,
6+
PATH_METADATA_PRODUCT_BLOCKS,
7+
PATH_METADATA_PRODUCTS,
8+
PATH_METADATA_RESOURCE_TYPES,
9+
PATH_METADATA_WORKFLOWS,
10+
PATH_NEW_PROCESS,
11+
PATH_PROCESSES,
12+
PATH_SETTINGS,
13+
PATH_START,
14+
PATH_SUBSCRIPTIONS,
15+
PATH_TASKS,
16+
} from '../paths';
1517

1618
export const WFOSidebar: FC = () => {
1719
const router = useRouter();
@@ -78,7 +80,7 @@ export const WFOSidebar: FC = () => {
7880
name: 'Metadata',
7981
id: '5',
8082
onClick: () => {
81-
router.push(PATH_METADATA_PRODUCTS);
83+
router.push(PATH_METADATA);
8284
},
8385
items: [
8486
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './WFOPageHeader';
22
export * from './WFOPageTemplate';
33
export * from './WFOSidebar';
4+
export * from './paths';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const PATH_START = '/';
2+
export const PATH_NEW_PROCESS = '/new-process';
3+
export const PATH_PROCESSES = '/processes';
4+
export const PATH_SUBSCRIPTIONS = '/subscriptions';
5+
export const PATH_METADATA = '/metadata';
6+
export const PATH_METADATA_PRODUCTS = '/metadata/products';
7+
export const PATH_METADATA_PRODUCT_BLOCKS = '/metadata/productblocks';
8+
export const PATH_METADATA_RESOURCE_TYPES = '/metadata/resource-types';
9+
export const PATH_METADATA_WORKFLOWS = '/metadata/workflows';
10+
export const PATH_TASKS = '/tasks';
11+
export const PATH_SETTINGS = '/settings';

packages/orchestrator-ui-components/src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export * from './WFOBadges';
2-
export * from './WFOBreadcrumbs';
2+
export * from './WFOPageTemplate/WFOBreadcrumbs';
33
export * from './WFOFilterTabs';
44
export * from './WFOPageTemplate';
55
export * from './WFOSearchBar';

0 commit comments

Comments
 (0)