mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 14:52:46 +08:00

* Progress * Progress * Update * Update * Update * Update * Responsive improvements * Update * Update * Update * Revert height change * Update * add missing testid * update * Fixes * update * Refactoring * fix bug in app chrome service * Fixed e2e tests * fix * fix * Update * Update * fix bookmarks e2e * Update * improve responsiveness on small screens for breadcrumbs * Always use two levels when menu is docked * Adding kiosk toggle button to dashboards only * update * Update * Update * when menu is docked and no actions use 1 level * removed formatting change that caused unnessary diff in PR * remove extra separator line after merge with main * Fix double separators * Update * remove temp change * Update
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { useLayoutEffect } from 'react';
|
|
import * as React from 'react';
|
|
|
|
import { useGrafana } from 'app/core/context/GrafanaContext';
|
|
|
|
export interface AppChromeUpdateProps {
|
|
actions?: React.ReactNode;
|
|
breadcrumbActions?: React.ReactNode;
|
|
}
|
|
/**
|
|
* This is the way core pages add actions to the second chrome toolbar
|
|
*/
|
|
export const AppChromeUpdate = React.memo<AppChromeUpdateProps>(
|
|
({ actions, breadcrumbActions }: AppChromeUpdateProps) => {
|
|
const { chrome } = useGrafana();
|
|
|
|
// Unmount cleanup
|
|
useLayoutEffect(() => {
|
|
return () => {
|
|
chrome.update({ actions: undefined, breadcrumbActions: undefined });
|
|
};
|
|
}, [chrome]);
|
|
|
|
// 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 dashboard to another for example
|
|
useLayoutEffect(() => {
|
|
chrome.update({ actions, breadcrumbActions });
|
|
});
|
|
|
|
return null;
|
|
}
|
|
);
|
|
|
|
AppChromeUpdate.displayName = 'TopNavUpdate';
|