Commit 32555fc7 by Ryan McKinley Committed by GitHub

Plugins: add a deprecated state (#23496)

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
parent f458da4d
...@@ -4,6 +4,7 @@ import { KeyValue } from './data'; ...@@ -4,6 +4,7 @@ import { KeyValue } from './data';
export enum PluginState { export enum PluginState {
alpha = 'alpha', // Only included it `enable_alpha` is true alpha = 'alpha', // Only included it `enable_alpha` is true
beta = 'beta', // Will show a warning banner beta = 'beta', // Will show a warning banner
deprecated = 'deprecated', // Will continue to work -- but not show up in the the options to add
} }
export enum PluginType { export enum PluginType {
......
...@@ -41,7 +41,7 @@ export const VisualizationTabUnconnected: FC<Props> = ({ panel, plugin, changePa ...@@ -41,7 +41,7 @@ export const VisualizationTabUnconnected: FC<Props> = ({ panel, plugin, changePa
if (e.key === 'Enter') { if (e.key === 'Enter') {
const query = e.currentTarget.value; const query = e.currentTarget.value;
const plugins = getAllPanelPluginMeta(); const plugins = getAllPanelPluginMeta();
const match = filterPluginList(plugins, query); const match = filterPluginList(plugins, query, plugin.meta);
if (match && match.length) { if (match && match.length) {
onPluginTypeChange(match[0]); onPluginTypeChange(match[0]);
} }
......
...@@ -3,7 +3,7 @@ import React, { useCallback, useMemo } from 'react'; ...@@ -3,7 +3,7 @@ import React, { useCallback, useMemo } from 'react';
import config from 'app/core/config'; import config from 'app/core/config';
import VizTypePickerPlugin from './VizTypePickerPlugin'; import VizTypePickerPlugin from './VizTypePickerPlugin';
import { EmptySearchResult, stylesFactory, useTheme } from '@grafana/ui'; import { EmptySearchResult, stylesFactory, useTheme } from '@grafana/ui';
import { GrafanaTheme, PanelPluginMeta } from '@grafana/data'; import { GrafanaTheme, PanelPluginMeta, PluginState } from '@grafana/data';
import { css } from 'emotion'; import { css } from 'emotion';
export interface Props { export interface Props {
...@@ -22,14 +22,26 @@ export function getAllPanelPluginMeta(): PanelPluginMeta[] { ...@@ -22,14 +22,26 @@ export function getAllPanelPluginMeta(): PanelPluginMeta[] {
.sort((a: PanelPluginMeta, b: PanelPluginMeta) => a.sort - b.sort); .sort((a: PanelPluginMeta, b: PanelPluginMeta) => a.sort - b.sort);
} }
export function filterPluginList(pluginsList: PanelPluginMeta[], searchQuery: string): PanelPluginMeta[] { export function filterPluginList(
pluginsList: PanelPluginMeta[],
searchQuery: string,
current: PanelPluginMeta
): PanelPluginMeta[] {
if (!searchQuery.length) { if (!searchQuery.length) {
return pluginsList; return pluginsList.filter(p => {
if (p.state === PluginState.deprecated) {
return current.id === p.id;
}
return true;
});
} }
const query = searchQuery.toLowerCase(); const query = searchQuery.toLowerCase();
const first: PanelPluginMeta[] = []; const first: PanelPluginMeta[] = [];
const match: PanelPluginMeta[] = []; const match: PanelPluginMeta[] = [];
for (const item of pluginsList) { for (const item of pluginsList) {
if (item.state === PluginState.deprecated && current.id !== item.id) {
continue;
}
const name = item.name.toLowerCase(); const name = item.name.toLowerCase();
const idx = name.indexOf(query); const idx = name.indexOf(query);
if (idx === 0) { if (idx === 0) {
...@@ -65,7 +77,7 @@ export const VizTypePicker: React.FC<Props> = ({ searchQuery, onTypeChange, curr ...@@ -65,7 +77,7 @@ export const VizTypePicker: React.FC<Props> = ({ searchQuery, onTypeChange, curr
}; };
const getFilteredPluginList = useCallback((): PanelPluginMeta[] => { const getFilteredPluginList = useCallback((): PanelPluginMeta[] => {
return filterPluginList(pluginsList, searchQuery); return filterPluginList(pluginsList, searchQuery, current);
}, [searchQuery]); }, [searchQuery]);
const filteredPluginList = getFilteredPluginList(); const filteredPluginList = getFilteredPluginList();
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"type": "panel", "type": "panel",
"name": "Singlestat", "name": "Singlestat",
"id": "singlestat", "id": "singlestat",
"state": "deprecated",
"info": { "info": {
"description": "Singlestat Panel for Grafana", "description": "Singlestat Panel for Grafana",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment