useShowDashboardPreviews.ts 506 B

123456789101112
  1. import { useLocalStorage } from 'react-use';
  2. import { config } from '@grafana/runtime/src';
  3. import { PREVIEWS_LOCAL_STORAGE_KEY } from '../constants';
  4. export const useShowDashboardPreviews = () => {
  5. const previewFeatureEnabled = Boolean(config.featureToggles.dashboardPreviews);
  6. const [showPreviews, setShowPreviews] = useLocalStorage<boolean>(PREVIEWS_LOCAL_STORAGE_KEY, false);
  7. return { showPreviews: Boolean(showPreviews && previewFeatureEnabled), previewFeatureEnabled, setShowPreviews };
  8. };