import { css } from '@emotion/css'; import React from 'react'; import { GrafanaTheme2, PluginType } from '@grafana/data'; import { config, featureEnabled } from '@grafana/runtime'; import { HorizontalGroup, Icon, LinkButton, useStyles2 } from '@grafana/ui'; import { getExternalManageLink, isInstallControlsEnabled } from '../../helpers'; import { isGrafanaAdmin } from '../../permissions'; import { useIsRemotePluginsAvailable } from '../../state/hooks'; import { CatalogPlugin, PluginStatus, Version } from '../../types'; import { ExternallyManagedButton } from './ExternallyManagedButton'; import { InstallControlsButton } from './InstallControlsButton'; interface Props { plugin: CatalogPlugin; latestCompatibleVersion?: Version; } export const InstallControls = ({ plugin, latestCompatibleVersion }: Props) => { const styles = useStyles2(getStyles); const isExternallyManaged = config.pluginAdminExternalManageEnabled; const hasPermission = isGrafanaAdmin(); const isRemotePluginsAvailable = useIsRemotePluginsAvailable(); const isCompatible = Boolean(latestCompatibleVersion); const isInstallControlsDisabled = plugin.isCore || plugin.isDisabled || !isInstallControlsEnabled(); const pluginStatus = plugin.isInstalled ? plugin.hasUpdate ? PluginStatus.UPDATE : PluginStatus.UNINSTALL : PluginStatus.INSTALL; if (isInstallControlsDisabled) { return null; } if (plugin.type === PluginType.renderer) { return