grafana/public/app/core/context/GrafanaContext.ts
Torkel Ödegaard b8e72d6173
TopNav: KioskMode rewrite move to AppChrome responsibility and make it a global feature (#55149)
* Initial progress

* Moving keybindingSrv to context

* Simplfy KioskMode

* Removed unused logic

* Make kiosk=tv behave as before but when topnav is enabled

* Minor fix

* Fixing tests

* Fixing bug with notice when entering kiosk mode

* Fixed test
2022-09-15 14:04:58 +02:00

27 lines
839 B
TypeScript

import React, { useContext } from 'react';
import { GrafanaConfig } from '@grafana/data';
import { LocationService } from '@grafana/runtime/src/services/LocationService';
import { BackendSrv } from '@grafana/runtime/src/services/backendSrv';
import { AppChromeService } from '../components/AppChrome/AppChromeService';
import { KeybindingSrv } from '../services/keybindingSrv';
export interface GrafanaContextType {
backend: BackendSrv;
location: LocationService;
config: GrafanaConfig;
chrome: AppChromeService;
keybindings: KeybindingSrv;
}
export const GrafanaContext = React.createContext<GrafanaContextType | undefined>(undefined);
export function useGrafana(): GrafanaContextType {
const context = useContext(GrafanaContext);
if (!context) {
throw new Error('No GrafanaContext found');
}
return context;
}