mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Plugins: Show that Secrets Manager Plugin is active in the UI (#50953)
* add special handling on the plugin gathering side to check whether secrets manager plugins are enabled or not * show disabled badge in front end if the plugin is not enabled * Only show error in disabled badge hover if one is present (otherwise it shows "undefined") * refactor to make use of fields already available in the DTO * fix typo * if there is no error returned for the plugin, just show 'disabled' * fix typo * Update public/app/features/plugins/admin/components/Badges/PluginDisabledBadge.tsx Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com> * Update frontendsettings.go add clarifying comment * fix unit test * rework task to use new frontend property combined with plugin type to determine if the plugin should be disabled * Update helpers.test.ts revert test change * fix unit test * bogus commit to trigger precommit * undo commit * run precommit manually Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
This commit is contained in:
@@ -18,7 +18,10 @@ function errorCodeToTooltip(error?: PluginErrorCode): string | undefined {
|
||||
return 'Plugin disabled due to invalid plugin signature';
|
||||
case PluginErrorCode.missingSignature:
|
||||
return 'Plugin disabled due to missing plugin signature';
|
||||
case null:
|
||||
case undefined:
|
||||
return 'Plugin disabled';
|
||||
default:
|
||||
return `Plugin disabled due to unkown error: ${error}`;
|
||||
return `Plugin disabled due to unknown error${error ? `: ${error}` : ''}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ function renderDescriptionFromError(error?: PluginErrorCode): ReactElement {
|
||||
default:
|
||||
return (
|
||||
<p>
|
||||
We failed to run this plugin due to an unkown reason and have therefor disabled it. We recommend you to
|
||||
We failed to run this plugin due to an unkown reason and have therefore disabled it. We recommend you to
|
||||
reinstall the plugin to make sure you are running a working version of this plugin.
|
||||
</p>
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PluginSignatureStatus, dateTimeParse, PluginError, PluginErrorCode } from '@grafana/data';
|
||||
import { PluginSignatureStatus, dateTimeParse, PluginError, PluginType, PluginErrorCode } from '@grafana/data';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { Settings } from 'app/core/config';
|
||||
import { getBackendSrv } from 'app/core/services/backend_srv';
|
||||
@@ -61,7 +61,7 @@ export function mapRemoteToCatalog(plugin: RemotePlugin, error?: PluginError): C
|
||||
status,
|
||||
} = plugin;
|
||||
|
||||
const isDisabled = !!error;
|
||||
const isDisabled = !!error || isDisabledSecretsPlugin(typeCode);
|
||||
return {
|
||||
description,
|
||||
downloads,
|
||||
@@ -103,6 +103,7 @@ export function mapLocalToCatalog(plugin: LocalPlugin, error?: PluginError): Cat
|
||||
hasUpdate,
|
||||
} = plugin;
|
||||
|
||||
const isDisabled = !!error || isDisabledSecretsPlugin(type);
|
||||
return {
|
||||
description,
|
||||
downloads: 0,
|
||||
@@ -119,7 +120,7 @@ export function mapLocalToCatalog(plugin: LocalPlugin, error?: PluginError): Cat
|
||||
installedVersion: version,
|
||||
hasUpdate,
|
||||
isInstalled: true,
|
||||
isDisabled: !!error,
|
||||
isDisabled: isDisabled,
|
||||
isCore: signature === 'internal',
|
||||
isPublished: false,
|
||||
isDev: Boolean(dev),
|
||||
@@ -134,7 +135,7 @@ export function mapToCatalogPlugin(local?: LocalPlugin, remote?: RemotePlugin, e
|
||||
const installedVersion = local?.info.version;
|
||||
const id = remote?.slug || local?.id || '';
|
||||
const type = local?.type || remote?.typeCode;
|
||||
const isDisabled = !!error;
|
||||
const isDisabled = !!error || isDisabledSecretsPlugin(type);
|
||||
|
||||
let logos = {
|
||||
small: `/public/img/icn-${type}.svg`,
|
||||
@@ -274,6 +275,10 @@ function isPluginVisible(id: string) {
|
||||
return !pluginCatalogHiddenPlugins.includes(id);
|
||||
}
|
||||
|
||||
function isDisabledSecretsPlugin(type?: PluginType): boolean {
|
||||
return type === PluginType.secretsmanager && !config.secretsManagerPluginEnabled;
|
||||
}
|
||||
|
||||
export function isLocalCorePlugin(local?: LocalPlugin): boolean {
|
||||
return Boolean(local?.signature === 'internal');
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ export enum PluginIconName {
|
||||
datasource = 'database',
|
||||
panel = 'credit-card',
|
||||
renderer = 'capture',
|
||||
secretsmanager = 'key-skeleton-alt',
|
||||
}
|
||||
|
||||
export interface CatalogPlugin {
|
||||
|
||||
Reference in New Issue
Block a user