| 
									
										
										
										
											2019-09-08 23:58:57 -07:00
										 |  |  | import React, { FC } from 'react'; | 
					
						
							| 
									
										
										
										
											2021-07-12 16:42:04 +02:00
										 |  |  | import { Badge, BadgeProps } from '@grafana/ui'; | 
					
						
							| 
									
										
										
										
											2019-10-31 10:48:05 +01:00
										 |  |  | import { PluginState } from '@grafana/data'; | 
					
						
							| 
									
										
										
										
											2019-04-12 04:46:42 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | interface Props { | 
					
						
							|  |  |  |   state?: PluginState; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-12 16:42:04 +02:00
										 |  |  | export const PluginStateInfo: FC<Props> = (props) => { | 
					
						
							|  |  |  |   const display = getFeatureStateInfo(props.state); | 
					
						
							| 
									
										
										
										
											2019-05-07 12:18:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-12 16:42:04 +02:00
										 |  |  |   if (!display) { | 
					
						
							| 
									
										
										
										
											2019-09-23 02:34:00 -07:00
										 |  |  |     return null; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-13 10:51:34 +02:00
										 |  |  |   return <Badge color={display.color} title={display.tooltip} text={display.text} icon={display.icon} />; | 
					
						
							| 
									
										
										
										
											2019-04-12 04:46:42 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-12 16:42:04 +02: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; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |