Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Cai <[email protected]>
  • Loading branch information
ciiay committed Jan 14, 2025
1 parent 314e8f0 commit d4a06d4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions packages/app/src/components/Root/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,24 @@ const getMenuItem = (menuItem: ResolvedMenuItem, isNestedMenuItem = false) => {
);
};

const GlobalHeader = ({ mountPoints }: { mountPoints: MountPoints }) =>
const ApplicationHeader = ({ mountPoints }: { mountPoints: MountPoints }) =>
mountPoints['application/header']?.map(({ Component, config }) => (
<Component key="global-header" {...config?.props} />
<Component
key={`app-header-${config?.layout?.position}`}
{...config?.props}
/>
));

export const Root = ({ children }: PropsWithChildren<{}>) => {
const { dynamicRoutes, menuItems, mountPoints } =
useContext(DynamicRootContext);
const [openItems, setOpenItems] = useState<{ [key: string]: boolean }>({});

const { position: globalHeaderPosition } =
mountPoints['application/header']?.[0]?.config?.layout ?? {};
const headerPositions = mountPoints['application/header']?.map(
({ config }) => {
return config?.layout?.position;
},
);

const { loading: loadingPermission, allowed: canDisplayRBACMenuItem } =
usePermission({
Expand Down Expand Up @@ -259,12 +265,12 @@ export const Root = ({ children }: PropsWithChildren<{}>) => {
};
return (
<>
{globalHeaderPosition === 'above-sidebar' && (
<GlobalHeader mountPoints={mountPoints} />
{headerPositions.includes('above-sidebar') && (
<ApplicationHeader mountPoints={mountPoints} />
)}
<SidebarPage>
{globalHeaderPosition === 'above-main-content' && (
<GlobalHeader mountPoints={mountPoints} />
{headerPositions.includes('above-main-content') && (
<ApplicationHeader mountPoints={mountPoints} />
)}
<Sidebar>
<SidebarLogo />
Expand Down

0 comments on commit d4a06d4

Please sign in to comment.