diff --git a/public/app/core/components/PageHeader/PageHeader.tsx b/public/app/core/components/PageHeader/PageHeader.tsx index a7eda15bc22..f998cb9981f 100644 --- a/public/app/core/components/PageHeader/PageHeader.tsx +++ b/public/app/core/components/PageHeader/PageHeader.tsx @@ -3,12 +3,13 @@ import { observer } from 'mobx-react'; import { NavModel, NavModelItem } from '../../nav_model_srv'; import classNames from 'classnames'; import appEvents from 'app/core/app_events'; +import { toJS } from 'mobx'; export interface IProps { model: NavModel; } -const SelectNav = observer(({ main, customCss }: { main: NavModelItem; customCss: string }) => { +const SelectNav = ({ main, customCss }: { main: NavModelItem; customCss: string }) => { const defaultSelectedItem = main.children.find(navItem => { return navItem.active === true; }); @@ -43,9 +44,9 @@ const SelectNav = observer(({ main, customCss }: { main: NavModelItem; customCss ); -}); +}; -const Tabs = observer(({ main, customCss }: { main: NavModelItem; customCss: string }) => { +const Tabs = ({ main, customCss }: { main: NavModelItem; customCss: string }) => { return ( ); -}); +}; const Navigation = ({ main }: { main: NavModelItem }) => { return ( @@ -86,6 +87,11 @@ export default class PageHeader extends React.Component { super(props); } + shouldComponentUpdate() { + //Hack to re-render on changed props from angular with the @observer decorator + return true; + } + renderTitle(title: string, breadcrumbs: any[]) { if (!title && (!breadcrumbs || breadcrumbs.length === 0)) { return null; @@ -141,12 +147,15 @@ export default class PageHeader extends React.Component { if (!model) { return null; } + + const main = toJS(model.main); // Convert to JS if its a mobx observable + return (
- {this.renderHeaderTitle(model.main)} - {model.main.children && } + {this.renderHeaderTitle(main)} + {main.children && }