|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | import { schema } from '@kbn/config-schema'; |
9 | | -import { UiSettingsParams } from '@kbn/core-ui-settings-common'; |
| 9 | +import { CoreSetup, Logger } from '@kbn/core/server'; |
10 | 10 | import { i18n } from '@kbn/i18n'; |
11 | | -import { OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS } from '@kbn/management-settings-ids'; |
| 11 | +import { |
| 12 | + OBSERVABILITY_ENABLE_STREAMS_UI, |
| 13 | + OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS, |
| 14 | +} from '@kbn/management-settings-ids'; |
| 15 | +import { StreamsPluginSetupDependencies, StreamsPluginStartDependencies } from './types'; |
| 16 | +import { STREAMS_TIERED_SIGNIFICANT_EVENT_FEATURE } from '../common'; |
12 | 17 |
|
13 | | -export const featureFlagUiSettings: Record<string, UiSettingsParams> = { |
14 | | - [OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS]: { |
15 | | - category: ['observability'], |
16 | | - name: i18n.translate('xpack.streams.significantEventsSettingsName', { |
17 | | - defaultMessage: 'Streams significant events', |
18 | | - }), |
19 | | - value: false, |
20 | | - description: i18n.translate('xpack.streams.significantEventsSettingsDescription', { |
21 | | - defaultMessage: 'Enable streams significant events.', |
22 | | - }), |
23 | | - type: 'boolean', |
24 | | - schema: schema.boolean(), |
25 | | - requiresPageReload: true, |
26 | | - solution: 'oblt', |
27 | | - technicalPreview: true, |
28 | | - }, |
29 | | -}; |
| 18 | +export function registerFeatureFlags( |
| 19 | + core: CoreSetup<StreamsPluginStartDependencies>, |
| 20 | + plugins: StreamsPluginSetupDependencies, |
| 21 | + logger: Logger |
| 22 | +) { |
| 23 | + core.pricing |
| 24 | + .isFeatureAvailable(STREAMS_TIERED_SIGNIFICANT_EVENT_FEATURE.id) |
| 25 | + .then((isSignificantEventsAvailable) => { |
| 26 | + if (isSignificantEventsAvailable) { |
| 27 | + core.uiSettings.register({ |
| 28 | + [OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS]: { |
| 29 | + category: ['observability'], |
| 30 | + name: i18n.translate('xpack.streams.significantEventsSettingsName', { |
| 31 | + defaultMessage: 'Streams significant events', |
| 32 | + }) as string, |
| 33 | + value: false, |
| 34 | + description: i18n.translate('xpack.streams.significantEventsSettingsDescription', { |
| 35 | + defaultMessage: 'Enable streams significant events.', |
| 36 | + }), |
| 37 | + type: 'boolean', |
| 38 | + schema: schema.boolean(), |
| 39 | + requiresPageReload: true, |
| 40 | + solution: 'oblt', |
| 41 | + technicalPreview: true, |
| 42 | + }, |
| 43 | + }); |
| 44 | + } |
| 45 | + }) |
| 46 | + .catch((error) => { |
| 47 | + logger.error(`Failed to register significant events ui settings: ${error}`); |
| 48 | + }); |
| 49 | + |
| 50 | + const isObservabilityServerless = |
| 51 | + plugins.cloud?.isServerlessEnabled && plugins.cloud?.serverless.projectType === 'observability'; |
| 52 | + |
| 53 | + core.uiSettings.register({ |
| 54 | + [OBSERVABILITY_ENABLE_STREAMS_UI]: { |
| 55 | + category: ['observability'], |
| 56 | + name: 'Streams UI', |
| 57 | + value: isObservabilityServerless, |
| 58 | + description: i18n.translate('xpack.streams.enableStreamsUIDescription', { |
| 59 | + defaultMessage: 'Enable the {streamsLink}.', |
| 60 | + values: { |
| 61 | + streamsLink: `<a href="https://www.elastic.co/docs/solutions/observability/logs/streams/streams">Streams UI</href>`, |
| 62 | + }, |
| 63 | + }), |
| 64 | + type: 'boolean', |
| 65 | + schema: schema.boolean(), |
| 66 | + requiresPageReload: true, |
| 67 | + solution: 'oblt', |
| 68 | + technicalPreview: true, |
| 69 | + }, |
| 70 | + }); |
| 71 | +} |
0 commit comments