mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* #44449: report interactions with showPreviews toggle * #44449: hookify showPreviews * #44449: report dashboard_list_viewed event rather than enabled/disabled_dashboard_previews
14 lines
625 B
TypeScript
14 lines
625 B
TypeScript
import { PREVIEWS_LOCAL_STORAGE_KEY } from '../constants';
|
|
import { config } from '@grafana/runtime/src';
|
|
import { useLocalStorage } from 'react-use';
|
|
|
|
export const useShowDashboardPreviews = () => {
|
|
const previewFeatureEnabled = Boolean(config.featureToggles.dashboardPreviews);
|
|
const [showPreviews, setShowPreviews] = useLocalStorage<boolean>(PREVIEWS_LOCAL_STORAGE_KEY, previewFeatureEnabled);
|
|
const onShowPreviewsChange = (showPreviews: boolean) => {
|
|
setShowPreviews(showPreviews);
|
|
};
|
|
|
|
return { showPreviews: Boolean(showPreviews && previewFeatureEnabled), previewFeatureEnabled, onShowPreviewsChange };
|
|
};
|