2019-09-09 01:58:57 -05:00
|
|
|
import React, { FC } from 'react';
|
2021-07-12 09:42:04 -05:00
|
|
|
import { Badge, BadgeProps } from '@grafana/ui';
|
2019-10-31 04:48:05 -05:00
|
|
|
import { PluginState } from '@grafana/data';
|
2019-04-12 06:46:42 -05:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
state?: PluginState;
|
|
|
|
}
|
|
|
|
|
2021-07-12 09:42:04 -05:00
|
|
|
export const PluginStateInfo: FC<Props> = (props) => {
|
|
|
|
const display = getFeatureStateInfo(props.state);
|
2019-05-07 05:18:08 -05:00
|
|
|
|
2021-07-12 09:42:04 -05:00
|
|
|
if (!display) {
|
2019-09-23 04:34:00 -05:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-13 03:51:34 -05:00
|
|
|
return <Badge color={display.color} title={display.tooltip} text={display.text} icon={display.icon} />;
|
2019-04-12 06:46:42 -05:00
|
|
|
};
|
|
|
|
|
2021-07-12 09:42:04 -05:00
|
|
|
function getFeatureStateInfo(state?: PluginState): BadgeProps | null {
|
|
|
|
switch (state) {
|
|
|
|
case PluginState.deprecated:
|
|
|
|
return {
|
|
|
|
text: 'Deprecated',
|
|
|
|
color: 'red',
|
|
|
|
tooltip: `This feature is deprecated and will be removed in a future release`,
|
|
|
|
};
|
|
|
|
case PluginState.alpha:
|
|
|
|
return {
|
|
|
|
text: 'Alpha',
|
|
|
|
color: 'blue',
|
|
|
|
tooltip: `This feature is experimental and future updates might not be backward compatible`,
|
|
|
|
};
|
|
|
|
case PluginState.beta:
|
|
|
|
return {
|
|
|
|
text: 'Beta',
|
|
|
|
color: 'blue',
|
|
|
|
tooltip: `This feature is close to complete but not fully tested`,
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|