PluginUpdateAvailableBadge.tsx 917 B

1234567891011121314151617181920212223242526272829303132
  1. import { css } from '@emotion/css';
  2. import React from 'react';
  3. import { GrafanaTheme2, PluginType } from '@grafana/data';
  4. import { useStyles2 } from '@grafana/ui';
  5. import { CatalogPlugin } from '../../types';
  6. type Props = {
  7. plugin: CatalogPlugin;
  8. };
  9. export function PluginUpdateAvailableBadge({ plugin }: Props): React.ReactElement | null {
  10. const styles = useStyles2(getStyles);
  11. // Currently renderer plugins are not supported by the catalog due to complications related to installation / update / uninstall.
  12. if (plugin.hasUpdate && !plugin.isCore && plugin.type !== PluginType.renderer) {
  13. return <p className={styles.hasUpdate}>Update available!</p>;
  14. }
  15. return null;
  16. }
  17. export const getStyles = (theme: GrafanaTheme2) => {
  18. return {
  19. hasUpdate: css`
  20. color: ${theme.colors.text.secondary};
  21. font-size: ${theme.typography.bodySmall.fontSize};
  22. margin-bottom: 0;
  23. `,
  24. };
  25. };