Plugins: Show deprecated plugins (#74598)

* feat: add a `isDeprecated` field to `CatalogPlugin`

* tests: update the tests for merging local & remote

* feat: display a deprecated badge in the plugins list

* feat: show a deprecated warning if the plugin is deprecated

* Fix linting issues

* Review notes

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>

* refactor: remove `isDeprecated` from the details (it's already in the main CatalogPlugin object)

* refactor: use an enum for remote statuses

---------

Co-authored-by: Marcus Andersson <marcus.andersson@grafana.com>
This commit is contained in:
Levente Balogh
2023-09-12 12:49:10 +02:00
committed by GitHub
parent e4f26a5e4b
commit 2fac3bd41e
15 changed files with 185 additions and 34 deletions

View File

@@ -3,7 +3,7 @@ import { getBackendSrv, isFetchError } from '@grafana/runtime';
import { accessControlQueryParam } from 'app/core/utils/accessControl';
import { API_ROOT, GCOM_API_ROOT } from './constants';
import { isLocalPluginVisible, isRemotePluginVisible } from './helpers';
import { isLocalPluginVisibleByConfig, isRemotePluginVisibleByConfig } from './helpers';
import { LocalPlugin, RemotePlugin, CatalogPluginDetails, Version, PluginVersion } from './types';
export async function getPluginDetails(id: string): Promise<CatalogPluginDetails> {
@@ -29,9 +29,13 @@ export async function getPluginDetails(id: string): Promise<CatalogPluginDetails
}
export async function getRemotePlugins(): Promise<RemotePlugin[]> {
const { items: remotePlugins }: { items: RemotePlugin[] } = await getBackendSrv().get(`${GCOM_API_ROOT}/plugins`);
// We are also fetching deprecated plugins, because we would like to be able to label plugins in the list that are both installed and deprecated.
// (We won't show not installed deprecated plugins in the list)
const { items: remotePlugins }: { items: RemotePlugin[] } = await getBackendSrv().get(`${GCOM_API_ROOT}/plugins`, {
includeDeprecated: true,
});
return remotePlugins.filter(isRemotePluginVisible);
return remotePlugins.filter(isRemotePluginVisibleByConfig);
}
export async function getPluginErrors(): Promise<PluginError[]> {
@@ -97,7 +101,7 @@ export async function getLocalPlugins(): Promise<LocalPlugin[]> {
accessControlQueryParam({ embedded: 0 })
);
return localPlugins.filter(isLocalPluginVisible);
return localPlugins.filter(isLocalPluginVisibleByConfig);
}
export async function installPlugin(id: string) {