mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Bug Fix: Only display latest version if a plugin is not installed (#78178)
This commit is contained in:
parent
9452a6fcf7
commit
05cf8c9253
@ -4,24 +4,17 @@ import React from 'react';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
import { useStyles2, Icon, Stack } from '@grafana/ui';
|
||||
|
||||
import { Version, CatalogPlugin, PluginIconName } from '../types';
|
||||
import { CatalogPlugin, PluginIconName } from '../types';
|
||||
|
||||
type Props = {
|
||||
plugin: CatalogPlugin;
|
||||
latestCompatibleVersion?: Version;
|
||||
grafanaDependency?: string;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
export function PluginDetailsHeaderDependencies({
|
||||
plugin,
|
||||
latestCompatibleVersion,
|
||||
className,
|
||||
}: Props): React.ReactElement | null {
|
||||
export function PluginDetailsHeaderDependencies({ plugin, grafanaDependency }: Props): React.ReactElement | null {
|
||||
const styles = useStyles2(getStyles);
|
||||
const pluginDependencies = plugin.details?.pluginDependencies;
|
||||
const grafanaDependency = plugin.isInstalled
|
||||
? plugin.details?.grafanaDependency
|
||||
: latestCompatibleVersion?.grafanaDependency || plugin.details?.grafanaDependency;
|
||||
const hasNoDependencyInfo = !grafanaDependency && (!pluginDependencies || !pluginDependencies.length);
|
||||
|
||||
if (hasNoDependencyInfo) {
|
||||
|
@ -19,7 +19,11 @@ export const usePluginInfo = (plugin?: CatalogPlugin): PageInfoItem[] => {
|
||||
|
||||
// Populate info
|
||||
const latestCompatibleVersion = getLatestCompatibleVersion(plugin.details?.versions);
|
||||
const version = plugin.installedVersion || latestCompatibleVersion?.version;
|
||||
const useLatestCompatibleInfo = !plugin.isInstalled;
|
||||
let version = plugin.installedVersion;
|
||||
if (!version && useLatestCompatibleInfo && latestCompatibleVersion?.version) {
|
||||
version = latestCompatibleVersion?.version;
|
||||
}
|
||||
|
||||
if (Boolean(version)) {
|
||||
info.push({
|
||||
@ -47,15 +51,16 @@ export const usePluginInfo = (plugin?: CatalogPlugin): PageInfoItem[] => {
|
||||
}
|
||||
|
||||
const pluginDependencies = plugin.details?.pluginDependencies;
|
||||
const grafanaDependency = plugin.isInstalled
|
||||
? plugin.details?.grafanaDependency
|
||||
: latestCompatibleVersion?.grafanaDependency || plugin.details?.grafanaDependency;
|
||||
let grafanaDependency = plugin.details?.grafanaDependency;
|
||||
if (useLatestCompatibleInfo && latestCompatibleVersion?.grafanaDependency) {
|
||||
grafanaDependency = latestCompatibleVersion?.grafanaDependency;
|
||||
}
|
||||
const hasNoDependencyInfo = !grafanaDependency && (!pluginDependencies || !pluginDependencies.length);
|
||||
|
||||
if (!hasNoDependencyInfo) {
|
||||
info.push({
|
||||
label: 'Dependencies',
|
||||
value: <PluginDetailsHeaderDependencies plugin={plugin} latestCompatibleVersion={latestCompatibleVersion} />,
|
||||
value: <PluginDetailsHeaderDependencies plugin={plugin} grafanaDependency={grafanaDependency} />,
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user