fix dependant plugins setting
This commit is contained in:
@@ -3,7 +3,7 @@ import { getBackendSrv, isFetchError } from '@grafana/runtime';
|
||||
import { accessControlQueryParam } from 'app/core/utils/accessControl';
|
||||
|
||||
import { API_ROOT, GCOM_API_ROOT, INSTANCE_API_ROOT } from './constants';
|
||||
import { isLocalPluginVisibleByConfig, isRemotePluginVisibleByConfig } from './helpers';
|
||||
import { dependantPlugins, isLocalPluginVisibleByConfig, isRemotePluginVisibleByConfig } from './helpers';
|
||||
import {
|
||||
LocalPlugin,
|
||||
RemotePlugin,
|
||||
@@ -29,6 +29,7 @@ export async function getPluginDetails(id: string): Promise<CatalogPluginDetails
|
||||
|
||||
return {
|
||||
grafanaDependency: dependencies?.grafanaDependency ?? dependencies?.grafanaVersion ?? '',
|
||||
dependantPlugins: dependantPlugins(id),
|
||||
pluginDependencies: dependencies?.plugins || [],
|
||||
links: local?.info.links || remote?.json?.info.links || [],
|
||||
readme: localReadme || remote?.readme,
|
||||
|
||||
+10
-4
@@ -126,11 +126,17 @@ export function InstallControlsButton({
|
||||
uninstallTitle = 'Preinstalled plugin. Remove from Grafana config before uninstalling.';
|
||||
}
|
||||
|
||||
// TODO && parent plugin is still installed
|
||||
let uninstallConfirmationBody = 'Are you sure you want to uninstall this plugin?';
|
||||
// TODO && dependant plugin is still installed
|
||||
const dependencyOf = plugin.details?.dependantPlugins?.map((dep) => dep.name);
|
||||
if (dependencyOf?.length) {
|
||||
disableUninstall = true;
|
||||
uninstallTitle = `Dependent plugins must be removed first: ${dependencyOf.join(', ')}`;
|
||||
uninstallConfirmationBody = `This plugin is a dependency of ${dependencyOf.join(', ')}. Are you sure you want to uninstall this plugin?`;
|
||||
}
|
||||
|
||||
// TODO && dependency plugin is still installed
|
||||
const hasDependency = plugin.details?.pluginDependencies?.map((dep) => dep.name);
|
||||
if (hasDependency?.length) {
|
||||
uninstallConfirmationBody = `This plugin has dependencies on ${hasDependency.join(', ')}. Are you sure you want to uninstall this plugin?`;
|
||||
}
|
||||
|
||||
if (pluginStatus === PluginStatus.UNINSTALL) {
|
||||
@@ -139,7 +145,7 @@ export function InstallControlsButton({
|
||||
<ConfirmModal
|
||||
isOpen={isConfirmModalVisible}
|
||||
title={`Uninstall ${plugin.name}`}
|
||||
body="Are you sure you want to uninstall this plugin?"
|
||||
body={uninstallConfirmationBody}
|
||||
confirmText="Confirm"
|
||||
icon="exclamation-triangle"
|
||||
onConfirm={onUninstall}
|
||||
|
||||
@@ -169,12 +169,6 @@ export function mapRemoteToCatalog(plugin: RemotePlugin, error?: PluginError): C
|
||||
latestVersion: plugin.version,
|
||||
url,
|
||||
raiseAnIssueUrl,
|
||||
details: {
|
||||
pluginDependencies: plugin.json?.dependencies?.plugins || [],
|
||||
dependantPlugins: dependantPlugins(id),
|
||||
links: plugin.json?.info.links || [],
|
||||
grafanaDependency: plugin.json?.dependencies?.grafanaDependency,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -227,13 +221,6 @@ export function mapLocalToCatalog(plugin: LocalPlugin, error?: PluginError): Cat
|
||||
iam: plugin.iam,
|
||||
latestVersion: plugin.latestVersion,
|
||||
raiseAnIssueUrl,
|
||||
details: {
|
||||
pluginDependencies: plugin.dependencies?.plugins || [],
|
||||
dependantPlugins: dependantPlugins(id),
|
||||
links: plugin.info.links || [],
|
||||
grafanaDependency: plugin.dependencies?.grafanaDependency,
|
||||
versions: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -299,13 +286,6 @@ export function mapToCatalogPlugin(local?: LocalPlugin, remote?: RemotePlugin, e
|
||||
latestVersion: local?.latestVersion || remote?.version || '',
|
||||
url: remote?.url || '',
|
||||
raiseAnIssueUrl: remote?.raiseAnIssueUrl || local?.raiseAnIssueUrl,
|
||||
details: {
|
||||
pluginDependencies: local?.dependencies?.plugins || remote?.json?.dependencies?.plugins || [],
|
||||
dependantPlugins: dependantPlugins(id),
|
||||
links: local?.info.links || remote?.json?.info.links || [],
|
||||
grafanaDependency: local?.dependencies?.grafanaDependency || remote?.json?.dependencies?.grafanaDependency || '',
|
||||
versions: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user