mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AddDatasource: Improve plugin categories (#28584)
* add IoT category to datasources * add more enterprise plugins * add more enterprise plugins
This commit is contained in:
@@ -28,8 +28,8 @@ const plugins: DataSourcePluginMeta[] = [
|
||||
describe('buildCategories', () => {
|
||||
const categories = buildCategories(plugins);
|
||||
|
||||
it('should group plugins into categories', () => {
|
||||
expect(categories.length).toBe(7);
|
||||
it('should group plugins into categories and remove empty categories', () => {
|
||||
expect(categories.length).toBe(4);
|
||||
expect(categories[0].title).toBe('Time series databases');
|
||||
expect(categories[0].plugins.length).toBe(2);
|
||||
expect(categories[1].title).toBe('Logging & document databases');
|
||||
@@ -40,17 +40,17 @@ describe('buildCategories', () => {
|
||||
});
|
||||
|
||||
it('should add phantom plugin for Grafana cloud', () => {
|
||||
expect(categories[4].title).toBe('Cloud');
|
||||
expect(categories[4].plugins.length).toBe(2);
|
||||
expect(categories[4].plugins[1].id).toBe('gcloud');
|
||||
expect(categories[2].title).toBe('Cloud');
|
||||
expect(categories[2].plugins.length).toBe(2);
|
||||
expect(categories[2].plugins[1].id).toBe('gcloud');
|
||||
});
|
||||
|
||||
it('should set module to phantom on phantom plugins', () => {
|
||||
expect(categories[5].plugins[0].module).toBe('phantom');
|
||||
expect(categories[3].plugins[0].module).toBe('phantom');
|
||||
});
|
||||
|
||||
it('should add enterprise phantom plugins', () => {
|
||||
expect(categories[5].title).toBe('Enterprise plugins');
|
||||
expect(categories[5].plugins.length).toBe(7);
|
||||
expect(categories[3].title).toBe('Enterprise plugins');
|
||||
expect(categories[3].plugins.length).toBe(10);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ export function buildCategories(plugins: DataSourcePluginMeta[]): DataSourcePlug
|
||||
{ id: 'sql', title: 'SQL', plugins: [] },
|
||||
{ id: 'cloud', title: 'Cloud', plugins: [] },
|
||||
{ id: 'enterprise', title: 'Enterprise plugins', plugins: [] },
|
||||
{ id: 'iot', title: 'Industrial & IoT', plugins: [] },
|
||||
{ id: 'other', title: 'Others', plugins: [] },
|
||||
].filter(item => item);
|
||||
|
||||
@@ -23,7 +24,7 @@ export function buildCategories(plugins: DataSourcePluginMeta[]): DataSourcePlug
|
||||
|
||||
for (const plugin of plugins) {
|
||||
// Force category for enterprise plugins
|
||||
if (enterprisePlugins.find(item => item.id === plugin.id)) {
|
||||
if (plugin.enterprise || enterprisePlugins.find(item => item.id === plugin.id)) {
|
||||
plugin.category = 'enterprise';
|
||||
}
|
||||
|
||||
@@ -58,7 +59,8 @@ export function buildCategories(plugins: DataSourcePluginMeta[]): DataSourcePlug
|
||||
sortPlugins(category.plugins);
|
||||
}
|
||||
|
||||
return categories;
|
||||
// Only show categories with plugins
|
||||
return categories.filter(c => c.plugins.length > 0);
|
||||
}
|
||||
|
||||
function sortPlugins(plugins: DataSourcePluginMeta[]) {
|
||||
@@ -124,6 +126,24 @@ function getEnterprisePhantomPlugins(): DataSourcePluginMeta[] {
|
||||
name: 'New Relic',
|
||||
imgUrl: 'public/img/plugins/newrelic.svg',
|
||||
}),
|
||||
getPhantomPlugin({
|
||||
id: 'grafana-mongodb-datasource',
|
||||
description: 'MongoDB integration & data source',
|
||||
name: 'MongoDB',
|
||||
imgUrl: 'public/img/plugins/mongodb.svg',
|
||||
}),
|
||||
getPhantomPlugin({
|
||||
id: 'grafana-snowflake-datasource',
|
||||
description: 'Snowflake integration & data source',
|
||||
name: 'Snowflake',
|
||||
imgUrl: 'public/img/plugins/snowflake.svg',
|
||||
}),
|
||||
getPhantomPlugin({
|
||||
id: 'grafana-wavefront-datasource',
|
||||
description: 'Wavefront integration & data source',
|
||||
name: 'Wavefront',
|
||||
imgUrl: 'public/img/plugins/wavefront.svg',
|
||||
}),
|
||||
getPhantomPlugin({
|
||||
id: 'dlopes7-appdynamics-datasource',
|
||||
description: 'AppDynamics integration & data source',
|
||||
|
||||
Reference in New Issue
Block a user