diff --git a/public/app/features/auth-config/AuthProvidersListPage.tsx b/public/app/features/auth-config/AuthProvidersListPage.tsx index 54eb4e630e1..af05c498ccf 100644 --- a/public/app/features/auth-config/AuthProvidersListPage.tsx +++ b/public/app/features/auth-config/AuthProvidersListPage.tsx @@ -9,6 +9,8 @@ import { Page } from 'app/core/components/Page/Page'; import { config } from 'app/core/config'; import { StoreState } from 'app/types/store'; +import { isOpenSourceBuildOrUnlicenced } from '../admin/EnterpriseAuthFeaturesCard'; + import AuthDrawer from './AuthDrawer'; import ConfigureAuthCTA from './components/ConfigureAuthCTA'; import { ProviderCard, ProviderSAMLCard, ProviderSCIMCard } from './components/ProviderCard'; @@ -119,7 +121,7 @@ export const AuthConfigPageUnconnected = ({ configPath={settings.configPath} /> ))} - {config.buildInfo.edition === GrafanaEdition.OpenSource && ( + {isOpenSourceBuildOrUnlicenced() && ( <> diff --git a/public/app/features/datasources/components/CloudInfoBox.tsx b/public/app/features/datasources/components/CloudInfoBox.tsx index c274f91e121..9982973f4d4 100644 --- a/public/app/features/datasources/components/CloudInfoBox.tsx +++ b/public/app/features/datasources/components/CloudInfoBox.tsx @@ -1,8 +1,7 @@ import { DataSourceSettings, LocalStorageValueProvider } from '@grafana/data'; -import { GrafanaEdition } from '@grafana/data/internal'; import { Trans, t } from '@grafana/i18n'; import { Alert, TextLink } from '@grafana/ui'; -import { config } from 'app/core/config'; +import { isOpenSourceBuildOrUnlicenced } from 'app/features/admin/EnterpriseAuthFeaturesCard'; const LOCAL_STORAGE_KEY = 'datasources.settings.cloudInfoBox.isDismissed'; @@ -20,7 +19,7 @@ export function CloudInfoBox({ dataSource }: Props) { } // Skip showing this info box in some editions - if (config.buildInfo.edition !== GrafanaEdition.OpenSource) { + if (!isOpenSourceBuildOrUnlicenced()) { return null; } diff --git a/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx b/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx index 5e5a61b0365..791cdc21227 100644 --- a/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx +++ b/public/app/features/plugins/admin/components/InstallControls/InstallControlsButton.tsx @@ -2,13 +2,13 @@ import { useEffect, useState } from 'react'; import { useLocation } from 'react-router-dom-v5-compat'; import { AppEvents } from '@grafana/data'; -import { GrafanaEdition } from '@grafana/data/internal'; import { t, Trans } from '@grafana/i18n'; import { config, locationService, reportInteraction } from '@grafana/runtime'; import { Button, ConfirmModal, LinkButton, Stack } from '@grafana/ui'; import appEvents from 'app/core/app_events'; import { useQueryParams } from 'app/core/hooks/useQueryParams'; import { removePluginFromNavTree } from 'app/core/reducers/navBarTree'; +import { isOpenSourceBuildOrUnlicenced } from 'app/features/admin/EnterpriseAuthFeaturesCard'; import { useDispatch } from 'app/types/store'; import { getExternalManageLink, isDisabledAngularPlugin } from '../../helpers'; @@ -168,10 +168,8 @@ export function InstallControlsButton({ ); } - const isOpenSource = config.buildInfo.edition === GrafanaEdition.OpenSource; - // Show learn more button for an enterprise plugin if your on OSS - if (plugin.isEnterprise && isOpenSource) { + if (plugin.isEnterprise && isOpenSourceBuildOrUnlicenced()) { return ( + - {isOpenSource && ( - - This plugin is only available in Grafana Cloud and Grafana Enterprise. - - )} - {isEnterprise && ( - - No valid Grafana Enterprise license detected. - - )} + + This plugin is only available in Grafana Cloud and Grafana Enterprise. + { it('should display an install button for enterprise plugins if license is valid', async () => { config.licenseInfo.enabledFeatures = { 'enterprise.plugins': true }; + config.licenseInfo.stateInfo = 'Licensed'; const { queryByRole } = renderPluginDetails({ id, isInstalled: false, isEnterprise: true }); expect(await queryByRole('button', { name: /install/i })).toBeInTheDocument(); + config.licenseInfo.stateInfo = ''; }); it('should not display install button for enterprise plugins if license is invalid (but allow uninstall)', async () => { config.licenseInfo.enabledFeatures = {}; config.buildInfo.edition = GrafanaEdition.Enterprise; + const bannerText = 'This plugin is only available in Grafana Cloud and Grafana Enterprise.'; + const { queryByRole, queryByText } = renderPluginDetails({ id, isInstalled: true, isEnterprise: true }); expect(await queryByRole('button', { name: /Install/ })).not.toBeInTheDocument(); expect(await queryByRole('button', { name: /Uninstall/ })).toBeInTheDocument(); - expect(queryByText(/no valid Grafana Enterprise license detected/i)).toBeInTheDocument(); + expect(queryByText(bannerText)).toBeInTheDocument(); expect(queryByRole('link', { name: /learn more/i })).toBeInTheDocument(); }); diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json index 9e9f54e4cad..dd9a430f824 100644 --- a/public/locales/en-US/grafana.json +++ b/public/locales/en-US/grafana.json @@ -11012,7 +11012,6 @@ "body-not-published": "This plugin is not published to <2>grafana.com/plugins and can't be managed via the catalog.", "enterprise-plugin-info": "This plugin is only available in Grafana Cloud and Grafana Enterprise.", "learn-more": "Learn more", - "no-valid-grafana-enterprise-license-detected": "No valid Grafana Enterprise license detected.", "title-dev-alert": "This is a development build of the plugin and can't be uninstalled.", "title-plugin-doesnt-support-version-grafana": "This plugin doesn't support your version of Grafana.", "title-remote-plugins-unavailable": "The install controls have been disabled because the Grafana server cannot access grafana.com.",