Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(global-header): added mount points for global header #2168

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
addressed comments
Signed-off-by: Yi Cai <yicai@redhat.com>
ciiay committed Jan 23, 2025
commit b9e035d763da81e9afa2f4583fea7aaecbb706dc
34 changes: 13 additions & 21 deletions packages/app/src/components/Root/Root.tsx
Original file line number Diff line number Diff line change
@@ -104,14 +104,14 @@ const getMenuItem = (menuItem: ResolvedMenuItem, isNestedMenuItem = false) => {
};

const ApplicationHeader = ({
headerMountPoints,
headerMountPosition,
mountPoints,
position,
}: {
headerMountPoints: ScalprumMountPoint[];
headerMountPosition: string;
mountPoints: ScalprumMountPoint[];
position: string;
}) =>
headerMountPoints
?.filter(({ config }) => config?.layout?.position === headerMountPosition)
mountPoints
?.filter(({ config }) => config?.layout?.position === position)
.map(({ Component, config }, index) => (
<ErrorBoundary
// eslint-disable-next-line react/no-array-index-key
@@ -127,10 +127,6 @@ export const Root = ({ children }: PropsWithChildren<{}>) => {
const [openItems, setOpenItems] = useState<{ [key: string]: boolean }>({});
const appHeaderMountPoints = mountPoints['application/header'] ?? [];

const appHeaderPositions = appHeaderMountPoints.map(({ config }) => {
return config?.layout?.position;
});

const { loading: loadingPermission, allowed: canDisplayRBACMenuItem } =
usePermission({
permission: policyEntityReadPermission,
@@ -275,19 +271,15 @@ export const Root = ({ children }: PropsWithChildren<{}>) => {
};
return (
<>
{appHeaderPositions.includes('above-sidebar') && (
<ApplicationHeader
mountPoints={appHeaderMountPoints}
position="above-sidebar"
/>
<SidebarPage>
<ApplicationHeader
headerMountPoints={appHeaderMountPoints}
headerMountPosition="above-sidebar"
mountPoints={appHeaderMountPoints}
position="above-main-content"
/>
)}
<SidebarPage>
{appHeaderPositions.includes('above-main-content') && (
<ApplicationHeader
headerMountPoints={appHeaderMountPoints}
headerMountPosition="above-main-content"
/>
)}
<Sidebar>
<SidebarLogo />
<SidebarGroup label="Search" icon={<SearchIcon />} to="/search">