2024-06-25 12:43:47 +01:00
|
|
|
import { useLayoutEffect } from 'react';
|
|
|
|
|
import * as React from 'react';
|
2022-07-06 17:00:56 +02:00
|
|
|
|
2022-07-23 17:09:03 +02:00
|
|
|
import { useGrafana } from 'app/core/context/GrafanaContext';
|
2022-07-06 17:00:56 +02:00
|
|
|
|
|
|
|
|
export interface AppChromeUpdateProps {
|
|
|
|
|
actions?: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
/**
|
2024-10-03 09:52:01 +01:00
|
|
|
* @deprecated This component is deprecated and will be removed in a future release.
|
2022-07-06 17:00:56 +02:00
|
|
|
*/
|
2022-09-12 15:45:14 +02:00
|
|
|
export const AppChromeUpdate = React.memo<AppChromeUpdateProps>(({ actions }: AppChromeUpdateProps) => {
|
2022-07-23 17:09:03 +02:00
|
|
|
const { chrome } = useGrafana();
|
|
|
|
|
|
2023-04-18 14:58:00 +01:00
|
|
|
// We use useLayoutEffect here to make sure that the chrome is updated before the page is rendered
|
2023-05-24 10:31:57 -07:00
|
|
|
// This prevents flickering actions when going from one dashboard to another for example
|
2023-04-18 14:58:00 +01:00
|
|
|
useLayoutEffect(() => {
|
2022-09-12 15:45:14 +02:00
|
|
|
chrome.update({ actions });
|
2022-07-06 17:00:56 +02:00
|
|
|
});
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AppChromeUpdate.displayName = 'TopNavUpdate';
|