From 33ef71d81e880f40e61213e8f7fd5b4b35fc801c Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Wed, 28 Oct 2020 00:15:32 -0700 Subject: [PATCH] AddDatasource: Improve plugin categories (#28584) * add IoT category to datasources * add more enterprise plugins * add more enterprise plugins --- .../datasources/state/buildCategories.test.ts | 16 ++++++------- .../datasources/state/buildCategories.ts | 24 +++++++++++++++++-- public/img/plugins/mongodb.svg | 2 ++ public/img/plugins/snowflake.svg | 2 ++ public/img/plugins/wavefront.svg | 17 +++++++++++++ 5 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 public/img/plugins/mongodb.svg create mode 100644 public/img/plugins/snowflake.svg create mode 100644 public/img/plugins/wavefront.svg diff --git a/public/app/features/datasources/state/buildCategories.test.ts b/public/app/features/datasources/state/buildCategories.test.ts index e95b4bb0e7b..f2c8fcfd622 100644 --- a/public/app/features/datasources/state/buildCategories.test.ts +++ b/public/app/features/datasources/state/buildCategories.test.ts @@ -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); }); }); diff --git a/public/app/features/datasources/state/buildCategories.ts b/public/app/features/datasources/state/buildCategories.ts index 56f426692e8..f2235d94fdf 100644 --- a/public/app/features/datasources/state/buildCategories.ts +++ b/public/app/features/datasources/state/buildCategories.ts @@ -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', diff --git a/public/img/plugins/mongodb.svg b/public/img/plugins/mongodb.svg new file mode 100644 index 00000000000..01a953800ea --- /dev/null +++ b/public/img/plugins/mongodb.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/public/img/plugins/snowflake.svg b/public/img/plugins/snowflake.svg new file mode 100644 index 00000000000..cd2263db996 --- /dev/null +++ b/public/img/plugins/snowflake.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/public/img/plugins/wavefront.svg b/public/img/plugins/wavefront.svg new file mode 100644 index 00000000000..35b48980714 --- /dev/null +++ b/public/img/plugins/wavefront.svg @@ -0,0 +1,17 @@ + + + + + + image/svg+xml + + + + + + + + + + +