grafana/public/app/features/plugins/angularDeprecation/AngularDeprecationNotice.tsx
Giuseppe Guerra bf4d025012
Dashboards: Add alert and panel icon for dashboards that use Angular plugins (#70951)
* Add angularDeprecationUI feature toggle

* Add angular notice in angular panel header

* Show angular notice for angular datasources

* Show angular notice at the top of the dashboard

* Changed Angular deprecation messages

* Fix angular deprecation alert displayed for new dashboards

* re-generate feature flags

* Removed unnecessary changes

* Add angular deprecation dashboard notice tests

* Add test for angular deprecation panel icon

* Update test suite name

* Moved isAngularDatasourcePlugin to app/features/plugins/angularDeprecation

* Add hasAngularPlugins to DashboardModel

* re-generate feature toggles

* Fix tests

* Fix data source spelling

* Fix typing issues

* Extract plugin type into a separate function

* re-generate feature flags

* reportInteraction on angular dashboard notice dismiss

* re-generate feature flags

* Re-generate feature flags

* lint
2023-08-29 16:05:47 +02:00

55 lines
1.7 KiB
TypeScript

import React from 'react';
import { reportInteraction } from '@grafana/runtime';
import { Alert } from '@grafana/ui';
import { LocalStorageValueProvider } from 'app/core/components/LocalStorageValueProvider';
const LOCAL_STORAGE_KEY_PREFIX = 'grafana.angularDeprecation.dashboardNotice.isDismissed';
function localStorageKey(dashboardUid: string): string {
return LOCAL_STORAGE_KEY_PREFIX + '.' + dashboardUid;
}
export interface Props {
dashboardUid: string;
}
export function AngularDeprecationNotice({ dashboardUid }: Props) {
return (
<LocalStorageValueProvider<boolean> storageKey={localStorageKey(dashboardUid)} defaultValue={false}>
{(isDismissed, onDismiss) => {
if (isDismissed) {
return null;
}
return (
<div>
<Alert
severity="warning"
title="This dashboard depends on Angular, which is deprecated and will stop working in future releases of Grafana."
onRemove={() => {
reportInteraction('angular_deprecation_notice_dismissed');
onDismiss(true);
}}
>
<div className="markdown-html">
<ul>
<li>
<a
href="https://grafana.com/docs/grafana/latest/developers/angular_deprecation/"
className="external-link"
target="_blank"
rel="noreferrer"
>
Read our deprecation notice and migration advice.
</a>
</li>
</ul>
</div>
</Alert>
</div>
);
}}
</LocalStorageValueProvider>
);
}