diff --git a/public/app/features/alerting/AlertRuleList.tsx b/public/app/features/alerting/AlertRuleList.tsx index b832404497e..10de691e571 100644 --- a/public/app/features/alerting/AlertRuleList.tsx +++ b/public/app/features/alerting/AlertRuleList.tsx @@ -14,7 +14,7 @@ import { ShowModalReactEvent } from '../../types/events'; import { AlertHowToModal } from './AlertHowToModal'; import AlertRuleItem from './AlertRuleItem'; -import { UnifiedAlertingPromotion } from './components/UnifiedAlertingPromotion'; +import { DeprecationNotice } from './components/DeprecationNotice'; import { getAlertRulesAsync, togglePauseAlertRule } from './state/actions'; import { setSearchQuery } from './state/reducers'; import { getAlertRuleItems, getSearchQuery } from './state/selectors'; @@ -127,7 +127,7 @@ export class AlertRuleListUnconnected extends PureComponent { How to add an alert - + {alertRules.map((rule) => { return ( diff --git a/public/app/features/alerting/components/DeprecationNotice.tsx b/public/app/features/alerting/components/DeprecationNotice.tsx new file mode 100644 index 00000000000..ce95598a8cf --- /dev/null +++ b/public/app/features/alerting/components/DeprecationNotice.tsx @@ -0,0 +1,29 @@ +import React, { FC } from 'react'; + +import { Alert } from '@grafana/ui'; + +export const LOCAL_STORAGE_KEY = 'grafana.legacyalerting.unifiedalertingpromo'; + +const DeprecationNotice: FC<{}> = () => ( + +

+ You are using Grafana legacy alerting, it has been deprecated and will be removed in the next major version of + Grafana. +
+ We encourage you to upgrade to the new Grafana alerting experience. +

+

+ See{' '} + + What’s New with Grafana alerting + {' '} + to learn more about what‘s new or learn{' '} + + how to enable the new Grafana alerting feature + + . +

+
+); + +export { DeprecationNotice }; diff --git a/public/app/features/alerting/components/UnifiedAlertingPromotion.test.tsx b/public/app/features/alerting/components/UnifiedAlertingPromotion.test.tsx deleted file mode 100644 index b6d03473696..00000000000 --- a/public/app/features/alerting/components/UnifiedAlertingPromotion.test.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import React from 'react'; - -import { UnifiedAlertingPromotion, LOCAL_STORAGE_KEY } from './UnifiedAlertingPromotion'; - -describe('Unified Alerting promotion', () => { - beforeEach(() => { - window.localStorage.clear(); - }); - - it('should show by default', () => { - render(); - expect(screen.queryByText('Try out the Grafana 8 alerting!')).toBeInTheDocument(); - }); - - it('should be hidden if dismissed', async () => { - const promotion = render(); - expect(window.localStorage.getItem(LOCAL_STORAGE_KEY)).toBe('true'); - - const dismissButton = promotion.getByRole('button'); - await userEvent.click(dismissButton); - - expect(screen.queryByText('Try out the Grafana 8 alerting!')).not.toBeInTheDocument(); - expect(window.localStorage.getItem(LOCAL_STORAGE_KEY)).toBe('false'); - }); - - it('should not render if previously dismissed', () => { - window.localStorage.setItem(LOCAL_STORAGE_KEY, 'false'); - render(); - - expect(screen.queryByText('Try out the Grafana 8 alerting!')).not.toBeInTheDocument(); - }); -}); diff --git a/public/app/features/alerting/components/UnifiedAlertingPromotion.tsx b/public/app/features/alerting/components/UnifiedAlertingPromotion.tsx deleted file mode 100644 index 2d89487dd42..00000000000 --- a/public/app/features/alerting/components/UnifiedAlertingPromotion.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import React, { FC } from 'react'; -import { useLocalStorage } from 'react-use'; - -import { Alert } from '@grafana/ui'; - -export const LOCAL_STORAGE_KEY = 'grafana.legacyalerting.unifiedalertingpromo'; - -const UnifiedAlertingPromotion: FC<{}> = () => { - const [showUnifiedAlertingPromotion, setShowUnifiedAlertingPromotion] = useLocalStorage( - LOCAL_STORAGE_KEY, - true - ); - - if (!showUnifiedAlertingPromotion) { - return null; - } - - return ( - setShowUnifiedAlertingPromotion(false)} - > -

- You are using the legacy Grafana alerting. -
- While we have no plans of deprecating it any time soon, we invite you to give the improved Grafana 8 alerting a - try. -

-

- See{' '} - - What’s New with Grafana 8 alerting - {' '} - to learn more about what‘s new in Grafana 8 alerting or learn{' '} - - how to enable the new Grafana 8 alerting feature - - . -

-
- ); -}; - -export { UnifiedAlertingPromotion };