diff --git a/x-pack/legacy/plugins/graph/index.ts b/x-pack/legacy/plugins/graph/index.ts index 53d32a836cfa1..5c7f8fa46c18b 100644 --- a/x-pack/legacy/plugins/graph/index.ts +++ b/x-pack/legacy/plugins/graph/index.ts @@ -4,8 +4,6 @@ * you may not use this file except in compliance with the Elastic License. */ -import { i18n } from '@kbn/i18n'; - // @ts-ignore import migrations from './migrations'; import mappings from './mappings.json'; @@ -30,40 +28,5 @@ export const graph: LegacyPluginInitializer = kibana => { .default('configAndData'), }).default(); }, - - init(server) { - server.plugins.xpack_main.registerFeature({ - id: 'graph', - name: i18n.translate('xpack.graph.featureRegistry.graphFeatureName', { - defaultMessage: 'Graph', - }), - order: 1200, - icon: 'graphApp', - navLinkId: 'graph', - app: ['graph', 'kibana'], - catalogue: ['graph'], - validLicenses: ['platinum', 'enterprise', 'trial'], - privileges: { - all: { - app: ['graph', 'kibana'], - catalogue: ['graph'], - savedObject: { - all: ['graph-workspace'], - read: ['index-pattern'], - }, - ui: ['save', 'delete'], - }, - read: { - app: ['graph', 'kibana'], - catalogue: ['graph'], - savedObject: { - all: [], - read: ['index-pattern', 'graph-workspace'], - }, - ui: [], - }, - }, - }); - }, }); }; diff --git a/x-pack/plugins/graph/kibana.json b/x-pack/plugins/graph/kibana.json index cf3a5fab92f56..96e7ea3ff2232 100644 --- a/x-pack/plugins/graph/kibana.json +++ b/x-pack/plugins/graph/kibana.json @@ -5,6 +5,6 @@ "server": true, "ui": true, "requiredPlugins": ["licensing", "data", "navigation"], - "optionalPlugins": ["home"], + "optionalPlugins": ["home", "features"], "configPath": ["xpack", "graph"] } diff --git a/x-pack/plugins/graph/server/plugin.ts b/x-pack/plugins/graph/server/plugin.ts index dcdf3f51d60bd..a169953d5a10b 100644 --- a/x-pack/plugins/graph/server/plugin.ts +++ b/x-pack/plugins/graph/server/plugin.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { Plugin, CoreSetup } from 'src/core/server'; import { LicensingPluginSetup } from '../../licensing/server'; import { LicenseState } from './lib/license_state'; @@ -11,13 +12,22 @@ import { registerSearchRoute } from './routes/search'; import { registerExploreRoute } from './routes/explore'; import { HomeServerPluginSetup } from '../../../../src/plugins/home/server'; import { registerSampleData } from './sample_data'; +import { PluginSetupContract as FeaturesPluginSetup } from '../../features/server'; export class GraphPlugin implements Plugin { private licenseState: LicenseState | null = null; public async setup( core: CoreSetup, - { licensing, home }: { licensing: LicensingPluginSetup; home?: HomeServerPluginSetup } + { + licensing, + home, + features, + }: { + licensing: LicensingPluginSetup; + home?: HomeServerPluginSetup; + features?: FeaturesPluginSetup; + } ) { const licenseState = new LicenseState(); licenseState.start(licensing.license$); @@ -27,6 +37,41 @@ export class GraphPlugin implements Plugin { registerSampleData(home.sampleData, licenseState); } + if (features) { + features.registerFeature({ + id: 'graph', + name: i18n.translate('xpack.graph.featureRegistry.graphFeatureName', { + defaultMessage: 'Graph', + }), + order: 1200, + icon: 'graphApp', + navLinkId: 'graph', + app: ['graph', 'kibana'], + catalogue: ['graph'], + validLicenses: ['platinum', 'enterprise', 'trial'], + privileges: { + all: { + app: ['graph', 'kibana'], + catalogue: ['graph'], + savedObject: { + all: ['graph-workspace'], + read: ['index-pattern'], + }, + ui: ['save', 'delete'], + }, + read: { + app: ['graph', 'kibana'], + catalogue: ['graph'], + savedObject: { + all: [], + read: ['index-pattern', 'graph-workspace'], + }, + ui: [], + }, + }, + }); + } + const router = core.http.createRouter(); registerSearchRoute({ licenseState, router }); registerExploreRoute({ licenseState, router });