Enterprise: Make banners show for unlicensed enterprise (#111042)
This commit is contained in:
@@ -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() && (
|
||||
<>
|
||||
<ProviderSAMLCard />
|
||||
<ProviderSCIMCard />
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -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 (
|
||||
<LinkButton
|
||||
href={`${getExternalManageLink(plugin.id)}?utm_source=grafana_catalog_learn_more`}
|
||||
|
||||
+6
-18
@@ -1,11 +1,11 @@
|
||||
import { css } from '@emotion/css';
|
||||
|
||||
import { GrafanaTheme2, PluginType } from '@grafana/data';
|
||||
import { GrafanaEdition } from '@grafana/data/internal';
|
||||
import { Trans, t } from '@grafana/i18n';
|
||||
import { config, featureEnabled } from '@grafana/runtime';
|
||||
import { LinkButton, useStyles2, Alert, TextLink, Stack } from '@grafana/ui';
|
||||
import { contextSrv } from 'app/core/core';
|
||||
import { isOpenSourceBuildOrUnlicenced } from 'app/features/admin/EnterpriseAuthFeaturesCard';
|
||||
import { AccessControlAction } from 'app/types/accessControl';
|
||||
|
||||
import { getExternalManageLink } from '../../helpers';
|
||||
@@ -39,26 +39,14 @@ export const InstallControlsWarning = ({ plugin, pluginStatus, latestCompatibleV
|
||||
);
|
||||
}
|
||||
|
||||
const isOpenSource = config.buildInfo.edition === GrafanaEdition.OpenSource;
|
||||
const isEnterprise = config.buildInfo.edition === GrafanaEdition.Enterprise;
|
||||
|
||||
if (plugin.isEnterprise && !featureEnabled('enterprise.plugins')) {
|
||||
const severity = isOpenSource ? 'info' : 'warning';
|
||||
|
||||
if (plugin.isEnterprise && !featureEnabled('enterprise.plugins') && isOpenSourceBuildOrUnlicenced()) {
|
||||
return (
|
||||
<Alert severity={severity} title="" className={styles.alert}>
|
||||
<Alert severity={'info'} title="" className={styles.alert}>
|
||||
<Stack direction="row" alignItems="center">
|
||||
<span>
|
||||
{isOpenSource && (
|
||||
<Trans i18nKey="plugins.install-controls-warning.enterprise-plugin-info">
|
||||
This plugin is only available in Grafana Cloud and Grafana Enterprise.
|
||||
</Trans>
|
||||
)}
|
||||
{isEnterprise && (
|
||||
<Trans i18nKey="plugins.install-controls-warning.no-valid-grafana-enterprise-license-detected">
|
||||
No valid Grafana Enterprise license detected.
|
||||
</Trans>
|
||||
)}
|
||||
<Trans i18nKey="plugins.install-controls-warning.enterprise-plugin-info">
|
||||
This plugin is only available in Grafana Cloud and Grafana Enterprise.
|
||||
</Trans>
|
||||
</span>
|
||||
<LinkButton
|
||||
href={`${getExternalManageLink(plugin.id)}?utm_source=grafana_catalog_learn_more`}
|
||||
|
||||
@@ -291,21 +291,25 @@ describe('Plugin details page', () => {
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
|
||||
@@ -11012,7 +11012,6 @@
|
||||
"body-not-published": "This plugin is not published to <2>grafana.com/plugins</2> 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.",
|
||||
|
||||
Reference in New Issue
Block a user