mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Disable selecting enterprise plugins with no license (#28758)
* Add unlicensed property to plugins * Disable selecting unlicensed plugin * Add customizable plugin market place url * License: workaround enabled only in enterprise * linter * Move licensing info to front end * Update pkg/services/licensing/oss.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/services/licensing/oss.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/setting/setting.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/setting/setting.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/api/frontendsettings.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update sample.ini * Update docs * Update packages/grafana-runtime/src/config.ts Co-authored-by: Torkel Ödegaard <torkel@grafana.org> * Update public/app/features/datasources/state/buildCategories.ts Co-authored-by: Torkel Ödegaard <torkel@grafana.org> * Update pkg/api/frontendsettings.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update pkg/setting/setting.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Fix spelling Co-authored-by: Leonard Gram <leo@xlson.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
This commit is contained in:
@@ -129,10 +129,9 @@ interface DataSourceTypeCardProps {
|
||||
const DataSourceTypeCard: FC<DataSourceTypeCardProps> = props => {
|
||||
const { plugin, onLearnMoreClick } = props;
|
||||
const isPhantom = plugin.module === 'phantom';
|
||||
const onClick = !isPhantom ? props.onClick : () => {};
|
||||
|
||||
const onClick = !isPhantom && !plugin.unlicensed ? props.onClick : () => {};
|
||||
// find first plugin info link
|
||||
const learnMoreLink = plugin.info.links && plugin.info.links.length > 0 ? plugin.info.links[0] : null;
|
||||
const learnMoreLink = plugin.info?.links?.length > 0 ? plugin.info.links[0] : null;
|
||||
|
||||
return (
|
||||
<Card
|
||||
@@ -154,7 +153,7 @@ const DataSourceTypeCard: FC<DataSourceTypeCardProps> = props => {
|
||||
{learnMoreLink.name}
|
||||
</LinkButton>
|
||||
)}
|
||||
{!isPhantom && <Button>Select</Button>}
|
||||
{!isPhantom && <Button disabled={plugin.unlicensed}>Select</Button>}
|
||||
</>
|
||||
}
|
||||
labels={
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { DataSourcePluginMeta, PluginType } from '@grafana/data';
|
||||
import { DataSourcePluginCategory } from 'app/types';
|
||||
import { config } from '../../../core/config';
|
||||
|
||||
export function buildCategories(plugins: DataSourcePluginMeta[]): DataSourcePluginCategory[] {
|
||||
const categories: DataSourcePluginCategory[] = [
|
||||
@@ -22,10 +23,15 @@ export function buildCategories(plugins: DataSourcePluginMeta[]): DataSourcePlug
|
||||
categoryIndex[category.id] = category;
|
||||
}
|
||||
|
||||
const { edition, hasValidLicense } = config.licenseInfo;
|
||||
|
||||
for (const plugin of plugins) {
|
||||
const enterprisePlugin = enterprisePlugins.find(item => item.id === plugin.id);
|
||||
// Force category for enterprise plugins
|
||||
if (plugin.enterprise || enterprisePlugins.find(item => item.id === plugin.id)) {
|
||||
if (plugin.enterprise || enterprisePlugin) {
|
||||
plugin.category = 'enterprise';
|
||||
plugin.unlicensed = edition !== 'Open Source' && !hasValidLicense;
|
||||
plugin.info.links = enterprisePlugin?.info?.links || plugin.info.links;
|
||||
}
|
||||
|
||||
// Fix link name
|
||||
@@ -197,7 +203,7 @@ function getPhantomPlugin(options: GetPhantomPluginOptions): DataSourcePluginMet
|
||||
author: { name: 'Grafana Labs' },
|
||||
links: [
|
||||
{
|
||||
url: 'https://grafana.com/grafana/plugins/' + options.id,
|
||||
url: config.marketplaceUrl + options.id,
|
||||
name: 'Install now',
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user