Skip to content

Commit

Permalink
Added and updated breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
Elson9 committed Jun 18, 2024
1 parent 4b92b6f commit 3ebeada
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/nextapp/pages/manager/namespaces/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
Skeleton,
Tooltip,
VStack,
Stack
Stack,
} from '@chakra-ui/react';
import ConfirmationDialog from '@/components/confirmation-dialog';
import Head from 'next/head';
Expand Down Expand Up @@ -53,13 +53,14 @@ import { RiApps2Fill } from 'react-icons/ri';
import PreviewBanner from '@/components/preview-banner';
import { QueryKey, useQueryClient } from 'react-query';
import { useRouter } from 'next/router';
import Card from '@/components/card'
import GatewayGetStarted from '@/components/gateway-get-started'
import Card from '@/components/card';
import GatewayGetStarted from '@/components/gateway-get-started';
import EmptyPane from '@/components/empty-pane';
import { Namespace, Query } from '@/shared/types/query.types';
import useCurrentNamespace from '@/shared/hooks/use-current-namespace';
import { useGlobal } from '@/shared/services/global';
import EditNamespaceDisplayName from '@/components/edit-display-name';
import { useNamespaceRootBreadcrumbs } from '@/shared/hooks';

const actions = [
{
Expand Down Expand Up @@ -120,6 +121,7 @@ const secondaryActions = [

const NamespacesPage: React.FC = () => {
const { user } = useAuth();
const breadcrumbs = useNamespaceRootBreadcrumbs();
const hasNamespace = !!user?.namespace;
const router = useRouter();
const toast = useToast();
Expand Down Expand Up @@ -271,15 +273,14 @@ const NamespacesPage: React.FC = () => {
</Head>
<ApproveBanner />
<PreviewBanner />
<Container maxW="6xl">
<PageHeader title={hasNamespace ? title : 'My Gateways'} />
<Container maxW="6xl" mt={4}>
<PageHeader
title={hasNamespace ? title : 'My Gateways'}
breadcrumb={breadcrumbs}
/>
<>
{isError && (
<Heading>Gateways Failed to Load</Heading>
)}
{isSuccess && data.allNamespaces.length == 0 && (
<GatewayGetStarted />
)}
{isError && <Heading>Gateways Failed to Load</Heading>}
{isSuccess && data.allNamespaces.length == 0 && <GatewayGetStarted />}
</>
{hasNamespace && (
<Grid gap={10} templateColumns="1fr 292px" mb={8}>
Expand Down Expand Up @@ -444,4 +445,4 @@ const query = gql`
name
}
}
`;
`;
1 change: 1 addition & 0 deletions src/nextapp/shared/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { default as useNamespaceBreadcrumbs } from './use-namespace-breadcrumbs';
export { default as useNamespaceRootBreadcrumbs } from './use-namespace-root-breadcrumbs';
3 changes: 2 additions & 1 deletion src/nextapp/shared/hooks/use-namespace-breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const useNamespaceBreadcrumbs = (

if (user) {
return [
{ href: '/manager/namespaces', text: `Namespaces (${user.namespace})` },
{ href: '/manager/gateways', text: 'My Gateways' },
{ href: '/manager/namespaces', text: `Gateway (${user.namespace})` },
...appendedBreadcrumbs,
];
}
Expand Down
24 changes: 24 additions & 0 deletions src/nextapp/shared/hooks/use-namespace-root-breadcrumbs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useAuth } from '@/shared/services/auth';

type Breadcrumb = {
href?: string;
text: string;
};

const useNamespaceRootBreadcrumbs = (): Breadcrumb[] => {
const { user } = useAuth();

if (user && user.namespace) {
return [
{ href: '/manager/gateways', text: 'My Gateways' },
{ text: `Gateway (${user.namespace})` },
];
}

return [
{ href: '/manager/gateways', text: 'My Gateways' },
{ text: 'Gateway' },
];
};

export default useNamespaceRootBreadcrumbs;

0 comments on commit 3ebeada

Please sign in to comment.