Skip to content

Commit

Permalink
Merge pull request #728 from jembi/CU-86c19v2x6_Navigation-Breadcrumb…
Browse files Browse the repository at this point in the history
…s-missing

feat: add breadcrumb navigation to BasePageTemplate and update relate…
  • Loading branch information
drizzentic authored Jan 29, 2025
2 parents c3b53ab + 9cbb3c4 commit c0dc9ad
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 12 deletions.
39 changes: 37 additions & 2 deletions packages/base-components/BasePageTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,58 @@ import {
Button,
Card,
Divider,
alpha
alpha,
Link
} from '@mui/material'
import Breadcrumbs from '@mui/material/Breadcrumbs'

interface BasePageTemplateProps {
children: React.ReactNode | React.ReactNode[]
title: string
subtitle: string | React.ReactNode
button?: React.ReactNode
breadcrumbs?: Breadcrumb[]
}

interface Breadcrumb {
label: string
href?: string
}

export function BasePageTemplate({
children,
title,
subtitle,
button
button,
breadcrumbs
}: BasePageTemplateProps) {
return (
<Box padding={1}>
<Grid container padding={2} spacing={2}>
<Grid item xs={12}>
<Breadcrumbs aria-label="breadcrumb" sx={{marginBottom: '24px'}}>
{breadcrumbs?.map(breadcrumb => {
if (breadcrumb.href) {
return (
<Link
underline="hover"
sx={{
color: '#049D84'
}}
key={breadcrumb.label}
href={breadcrumb.href}
>
{breadcrumb.label}
</Link>
)
}
return (
<Typography key={breadcrumb.label}>
{breadcrumb.label}
</Typography>
)
})}
</Breadcrumbs>
<Typography
variant="h4"
gutterBottom
Expand All @@ -40,6 +72,9 @@ export function BasePageTemplate({
textAlign: 'left',
display: 'inline-block',
fontSmooth: 'never',
...(breadcrumbs && {
marginBottom: '24px'
}),
'-webkit-font-smoothing': 'antialiased',
'-moz-osx-font-smoothing': 'grayscale'
}}
Expand Down
1 change: 1 addition & 0 deletions packages/channels-app/src/screens/add.channel.screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function AddChannelScreen() {
<BasePageTemplate
title="Add Channel"
subtitle="Control client systems and their access roles. Add clients to enable their request routing and group them by roles for streamlined channel accesss managment."
breadcrumbs={[{label: 'Channels', href: '/#!/channels'}, {label: 'Add'}]}
>
<Grid
container
Expand Down
1 change: 1 addition & 0 deletions packages/channels-app/src/screens/edit.channel.screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function EditChannelScreen() {
<BasePageTemplate
title="Edit Channel"
subtitle="Control client systems and their access roles. Add clients to enable their request routing and group them by roles for streamlined channel accesss managment."
breadcrumbs={[{label: 'Channels', href: '/#!/channels'}, {label: 'Edit'}]}
>
<Grid
container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ export const ClientRoleForm = () => {
? pageHeadingTypography.editClientUserRole.caption
: pageHeadingTypography.addClientUserRole.caption
}
breadcrumbs={[
{label: 'Client Roles', href: '/#!/client-roles'},
{label: existingClientRole ? 'Edit' : 'Add'}
]}
>
<Card variant="outlined" sx={{margin: 'auto', maxWidth: 610}}>
<Box sx={{margin: 1}} role="form" aria-label="Client Role Form">
Expand All @@ -174,8 +178,8 @@ export const ClientRoleForm = () => {
label="Role Name"
variant="outlined"
helperText="Choose a short but descriptive name"
aria-required="true"
aria-describedby="role-name-helper-text"
aria-required="true"
aria-describedby="role-name-helper-text"
value={clientRole.roleName}
onChange={e => {
setClientRole(prevClientRole => ({
Expand Down
3 changes: 2 additions & 1 deletion packages/clients-app/src/pages/add-client/add-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import CryptoJS from 'crypto-js'
import './style.css'
import {AxiosError} from 'axios'
import {useSnackbar} from 'notistack'
import { BasePageTemplate } from '../../../../base-components'
import {BasePageTemplate} from '../../../../base-components'

export const AddClient = () => {
//TODO: Make sure that there is a safe guard when incrementing this value to prevent it from going over the number of steps
Expand Down Expand Up @@ -198,6 +198,7 @@ export const AddClient = () => {
<BasePageTemplate
title="Add Client"
subtitle="Control client systems and their access roles. Add clients to enable their request routing and group them by roles for streamlined channel access management"
breadcrumbs={[{label: 'Clients', href: '/#!/clients'}, {label: 'Add'}]}
>
<Grid item xs={12}>
<Card variant="outlined" sx={{margin: 'auto', maxWidth: 610}}>
Expand Down
9 changes: 2 additions & 7 deletions packages/clients-app/src/pages/clients-list/clients-list.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {
Button,
Typography
} from '@mui/material'
import {Button, Typography} from '@mui/material'
import {Client} from '../../types'
import {
GridColDef,
} from '@mui/x-data-grid'
import {GridColDef} from '@mui/x-data-grid'
import {useEffect, useState} from 'react'
import {fetchClients, deleteClient} from '@jembi/openhim-core-api'
import CreateIcon from '@mui/icons-material/Create'
Expand Down
1 change: 1 addition & 0 deletions packages/clients-app/src/pages/edit-client/edit-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const EditClient = () => {
<BasePageTemplate
title="Edit Client"
subtitle="Control client systems and their access roles. Add clients to enable their request routing and group them by roles for streamlined channel access management"
breadcrumbs={[{label: 'Clients', href: '/#!/clients'}, {label: 'Edit'}]}
>
<Grid item xs={12}>
<Card sx={{width: 550, margin: 'auto'}}>
Expand Down
4 changes: 4 additions & 0 deletions packages/rbac-app/src/screens/create.role.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ function AddUserRole() {
<BasePageTemplate
title="Add User Role"
subtitle="Easily assign and manage roles and permissions to users by selecting a role, viewing and editing its permissions, or creating a new role with customized permissions."
breadcrumbs={[
{label: 'User Roles', href: '/#!/user-roles'},
{label: 'Add'}
]}
>
<Grid
container
Expand Down
4 changes: 4 additions & 0 deletions packages/rbac-app/src/screens/edit.role.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ function EditUserRole() {
<BasePageTemplate
title="Edit User Role"
subtitle="Easily assign and manage roles and permissions to users by selecting a role, viewing and editing its permissions, or creating a new role with customized permissions."
breadcrumbs={[
{label: 'User Roles', href: '/#!/user-roles'},
{label: 'Edit'}
]}
>
<Grid
container
Expand Down
1 change: 1 addition & 0 deletions packages/users-app/src/screens/create.user.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function AddUserRole() {
<BasePageTemplate
title="Add User"
subtitle="Control client systems and their access roles. Add clients to enable their request routing and group them by roles for streamlined channel management."
breadcrumbs={[{label: 'Users', href: '/#!/users'}, {label: 'Add'}]}
>
<Grid
container
Expand Down
1 change: 1 addition & 0 deletions packages/users-app/src/screens/edit.user.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function AddUserRole() {
<BasePageTemplate
title="Edit User"
subtitle="Control client systems and their access roles. Edit clients to enable their request routing and group them by roles for streamlined channel management."
breadcrumbs={[{label: 'Users', href: '/#!/users'}, {label: 'Edit'}]}
>
<Grid
container
Expand Down

0 comments on commit c0dc9ad

Please sign in to comment.