mirror of
https://github.com/grafana/grafana.git
synced 2025-09-19 22:52:51 +08:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import Mousetrap from 'mousetrap';
|
|
import React, { useEffect, useState } from 'react';
|
|
import { Features, ToggleFeatures } from 'react-enable';
|
|
|
|
import { NavModelItem } from '@grafana/data';
|
|
import { Page } from 'app/core/components/Page/Page';
|
|
|
|
import FEATURES from '../features';
|
|
|
|
interface Props {
|
|
pageId: string;
|
|
isLoading?: boolean;
|
|
pageNav?: NavModelItem;
|
|
}
|
|
|
|
const SHOW_TOGGLES_KEY_COMBO = 'ctrl+1';
|
|
const combokeys = new Mousetrap(document.body);
|
|
|
|
export const AlertingPageWrapper = ({ children, pageId, pageNav, isLoading }: React.PropsWithChildren<Props>) => {
|
|
const [showFeatureToggle, setShowFeatureToggles] = useState(false);
|
|
|
|
useEffect(() => {
|
|
combokeys.bind(SHOW_TOGGLES_KEY_COMBO, () => {
|
|
setShowFeatureToggles((show) => !show);
|
|
});
|
|
|
|
return () => {
|
|
combokeys.unbind(SHOW_TOGGLES_KEY_COMBO);
|
|
};
|
|
}, []);
|
|
|
|
return (
|
|
<Features features={FEATURES}>
|
|
<Page pageNav={pageNav} navId={pageId}>
|
|
<Page.Contents isLoading={isLoading}>{children}</Page.Contents>
|
|
</Page>
|
|
{showFeatureToggle ? <ToggleFeatures defaultOpen={true} /> : null}
|
|
</Features>
|
|
);
|
|
};
|