mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Adds visual component for feature toggles (#63621)
This commit is contained in:
@@ -1,18 +1,40 @@
|
||||
import React from 'react';
|
||||
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 (
|
||||
<Page pageNav={pageNav} navId={pageId}>
|
||||
<Page.Contents isLoading={isLoading}>{children}</Page.Contents>
|
||||
</Page>
|
||||
<Features features={FEATURES}>
|
||||
<Page pageNav={pageNav} navId={pageId}>
|
||||
<Page.Contents isLoading={isLoading}>{children}</Page.Contents>
|
||||
</Page>
|
||||
{showFeatureToggle ? <ToggleFeatures defaultOpen={true} /> : null}
|
||||
</Features>
|
||||
);
|
||||
};
|
||||
|
||||
10
public/app/features/alerting/unified/features.ts
Normal file
10
public/app/features/alerting/unified/features.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { FeatureDescription } from 'react-enable/dist/FeatureState';
|
||||
|
||||
const FEATURES: FeatureDescription[] = [
|
||||
{
|
||||
name: 'notification-policies.v2.matching-instances',
|
||||
defaultValue: false,
|
||||
},
|
||||
];
|
||||
|
||||
export default FEATURES;
|
||||
Reference in New Issue
Block a user