mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
* 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
27 lines
839 B
TypeScript
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;
|
|
}
|