Skip to content

Commit

Permalink
add theme$ to integrations header portal
Browse files Browse the repository at this point in the history
  • Loading branch information
hop-dev committed Jan 5, 2022
1 parent 265a031 commit ef66867
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const IntegrationsAppContext: React.FC<{
<Router history={history}>
<AgentPolicyContextProvider>
<PackageInstallProvider notifications={startServices.notifications}>
<IntegrationsHeader {...{ setHeaderActionMenu }} />
<IntegrationsHeader {...{ setHeaderActionMenu, theme$ }} />
{children}
</PackageInstallProvider>
</AgentPolicyContextProvider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ import { DeploymentDetails } from './deployment_details';

export const IntegrationsHeader = ({
setHeaderActionMenu,
theme$,
}: {
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
theme$: AppMountParameters['theme$'];
}) => {
return (
<HeaderPortal {...{ setHeaderActionMenu }}>
<HeaderPortal {...{ setHeaderActionMenu, theme$ }}>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem>
<EuiHeaderLinks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ import { toMountPoint } from '../../../../../../../../src/plugins/kibana_react/p

export interface Props {
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
theme$: AppMountParameters['theme$'];
}

export const HeaderPortal: FC<Props> = ({ children, setHeaderActionMenu }) => {
export const HeaderPortal: FC<Props> = ({ children, setHeaderActionMenu, theme$ }) => {
const portalNode = useMemo(() => createPortalNode(), []);

useEffect(() => {
setHeaderActionMenu((element) => {
const mount = toMountPoint(<OutPortal node={portalNode} />);
const mount = toMountPoint(<OutPortal node={portalNode} />, { theme$ });
return mount(element);
});

return () => {
portalNode.unmount();
setHeaderActionMenu(undefined);
};
}, [portalNode, setHeaderActionMenu]);
}, [portalNode, setHeaderActionMenu, theme$]);

return <InPortal node={portalNode}>{children}</InPortal>;
};

0 comments on commit ef66867

Please sign in to comment.