mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* move section nav to app chrome * unit tests * Move SectionNav to AppChrome folder * fix duplicate variable rendering --------- Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
24 lines
797 B
TypeScript
24 lines
797 B
TypeScript
import React, { useLayoutEffect } from 'react';
|
|
|
|
import { useGrafana } from 'app/core/context/GrafanaContext';
|
|
|
|
export interface AppChromeUpdateProps {
|
|
actions?: React.ReactNode;
|
|
}
|
|
/**
|
|
* This needs to be moved to @grafana/ui or runtime.
|
|
* This is the way core pages and plugins update the breadcrumbs and page toolbar actions
|
|
*/
|
|
export const AppChromeUpdate = React.memo<AppChromeUpdateProps>(({ actions }: AppChromeUpdateProps) => {
|
|
const { chrome } = useGrafana();
|
|
|
|
// We use useLayoutEffect here to make sure that the chrome is updated before the page is rendered
|
|
// This prevents flickering actions when going from one dashbaord to another for example
|
|
useLayoutEffect(() => {
|
|
chrome.update({ actions });
|
|
});
|
|
return null;
|
|
});
|
|
|
|
AppChromeUpdate.displayName = 'TopNavUpdate';
|