grafana/public/app/features/plugins/admin/components/PluginDetailsDeprecatedWarning.tsx
Levente Balogh e7c1e5e4c9
Plugins: Display custom deprecation message if available (#75942)
* feat: display the deprecation context for a plugin if it is available

* Update public/app/features/plugins/admin/components/PluginDetailsDeprecatedWarning.tsx

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>

* feat: only extend the basic message with custom context

---------

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2023-10-04 14:30:03 +02:00

29 lines
916 B
TypeScript

import React, { useState } from 'react';
import { Alert } from '@grafana/ui';
import { CatalogPlugin } from '../types';
type Props = {
className?: string;
plugin: CatalogPlugin;
};
export function PluginDetailsDeprecatedWarning(props: Props): React.ReactElement | null {
const { className, plugin } = props;
const [dismissed, setDismissed] = useState(false);
const isWarningVisible = plugin.isDeprecated && !dismissed;
let deprecationMessage = `This ${plugin.type} plugin is deprecated and has been removed from the catalog. No further updates will be made to the
plugin.`;
if (plugin.details?.statusContext) {
deprecationMessage += ` More information: ${plugin.details.statusContext}`;
}
return isWarningVisible ? (
<Alert severity="warning" title="Deprecated" className={className} onRemove={() => setDismissed(true)}>
<p>{deprecationMessage}</p>
</Alert>
) : null;
}