diff --git a/x-pack/plugins/features/server/oss_features.ts b/x-pack/plugins/features/server/oss_features.ts index 46dd5fd086b4a..c102bbb19fbcf 100644 --- a/x-pack/plugins/features/server/oss_features.ts +++ b/x-pack/plugins/features/server/oss_features.ts @@ -5,14 +5,17 @@ */ import { i18n } from '@kbn/i18n'; import { KibanaFeatureConfig } from '../common'; -import { DEFAULT_APP_CATEGORIES } from '../../../../src/core/server'; +import { DEFAULT_APP_CATEGORIES, ISavedObjectTypeRegistry } from '../../../../src/core/server'; export interface BuildOSSFeaturesParams { - savedObjectTypes: string[]; + savedObjectTypeRegistry: ISavedObjectTypeRegistry; includeTimelion: boolean; } -export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSSFeaturesParams) => { +export const buildOSSFeatures = ({ + savedObjectTypeRegistry, + includeTimelion, +}: BuildOSSFeaturesParams) => { return [ { id: 'discover', @@ -346,7 +349,7 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS }, api: ['copySavedObjectsToSpaces'], savedObject: { - all: [...savedObjectTypes], + all: [...savedObjectTypeRegistry.getImportableAndExportableTypes().map((t) => t.name)], read: [], }, ui: ['read', 'edit', 'delete', 'copyIntoSpace', 'shareIntoSpace'], @@ -360,7 +363,7 @@ export const buildOSSFeatures = ({ savedObjectTypes, includeTimelion }: BuildOSS api: ['copySavedObjectsToSpaces'], savedObject: { all: [], - read: [...savedObjectTypes], + read: [...savedObjectTypeRegistry.getImportableAndExportableTypes().map((t) => t.name)], }, ui: ['read'], }, diff --git a/x-pack/plugins/features/server/plugin.ts b/x-pack/plugins/features/server/plugin.ts index 857bba4c606d4..a83b4490210ae 100644 --- a/x-pack/plugins/features/server/plugin.ts +++ b/x-pack/plugins/features/server/plugin.ts @@ -109,16 +109,11 @@ export class Plugin { public stop() {} private registerOssFeatures(savedObjects: SavedObjectsServiceStart) { - const registry = savedObjects.getTypeRegistry(); - const savedObjectTypes = registry.getVisibleTypes().map((t) => t.name); + const savedObjectTypeRegistry = savedObjects.getTypeRegistry(); - this.logger.debug( - `Registering OSS features with SO types: ${savedObjectTypes.join(', ')}. "includeTimelion": ${ - this.isTimelionEnabled - }.` - ); + this.logger.debug(`Registering OSS features. "includeTimelion": ${this.isTimelionEnabled}.`); const features = buildOSSFeatures({ - savedObjectTypes, + savedObjectTypeRegistry, includeTimelion: this.isTimelionEnabled, });