Skip to content

Commit f50527e

Browse files
authored
Merge branch 'main' into ska/relocate-services-and-tests
2 parents eae1dae + 7e0601a commit f50527e

12 files changed

Lines changed: 147 additions & 93 deletions

File tree

src/platform/packages/shared/serverless/settings/observability_project/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export const OBSERVABILITY_PROJECT_SETTINGS = [
2424
settings.OBSERVABILITY_APM_ENABLE_SERVICE_INVENTORY_TABLE_SEARCH_BAR,
2525
settings.OBSERVABILITY_LOGS_DATA_ACCESS_LOG_SOURCES_ID,
2626
settings.OBSERVABILITY_ENABLE_STREAMS_UI,
27+
];
28+
29+
export const OBSERVABILITY_STREAMS_TIERED_PROJECT_SETTINGS = [
2730
settings.OBSERVABILITY_STREAMS_ENABLE_SIGNIFICANT_EVENTS,
2831
];
2932

x-pack/platform/plugins/shared/streams/server/feature_flags.ts

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,66 @@
66
*/
77

88
import { schema } from '@kbn/config-schema';
9-
import { UiSettingsParams } from '@kbn/core-ui-settings-common';
9+
import { CoreSetup, Logger } from '@kbn/core/server';
1010
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';
1217

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+
}

x-pack/platform/plugins/shared/streams/server/plugin.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import { KibanaFeatureScope } from '@kbn/features-plugin/common';
1919
import { i18n } from '@kbn/i18n';
2020
import { STREAMS_RULE_TYPE_IDS } from '@kbn/rule-data-utils';
2121
import { registerRoutes } from '@kbn/server-route-repository';
22-
import { schema } from '@kbn/config-schema';
23-
import { OBSERVABILITY_ENABLE_STREAMS_UI } from '@kbn/management-settings-ids';
2422
import { StreamsConfig, configSchema, exposeToBrowserConfig } from '../common/config';
2523
import {
2624
STREAMS_API_PRIVILEGES,
@@ -29,6 +27,7 @@ import {
2927
STREAMS_TIERED_FEATURES,
3028
STREAMS_UI_PRIVILEGES,
3129
} from '../common/constants';
30+
import { registerFeatureFlags } from './feature_flags';
3231
import { ContentService } from './lib/content/content_service';
3332
import { registerRules } from './lib/rules/register_rules';
3433
import { AssetService } from './lib/streams/assets/asset_service';
@@ -42,7 +41,6 @@ import {
4241
StreamsPluginStartDependencies,
4342
StreamsServer,
4443
} from './types';
45-
import { featureFlagUiSettings } from './feature_flags';
4644

4745
// eslint-disable-next-line @typescript-eslint/no-empty-interface
4846
export interface StreamsPluginSetup {}
@@ -93,8 +91,6 @@ export class StreamsPlugin
9391

9492
registerRules({ plugins, logger: this.logger.get('rules') });
9593

96-
core.uiSettings.register(featureFlagUiSettings);
97-
9894
const assetService = new AssetService(core, this.logger);
9995
const streamsService = new StreamsService(core, this.logger, this.isDev);
10096
const contentService = new ContentService(core, this.logger);
@@ -205,28 +201,7 @@ export class StreamsPlugin
205201
runDevModeChecks: this.isDev,
206202
});
207203

208-
const isObservabilityServerless =
209-
plugins.cloud?.isServerlessEnabled &&
210-
plugins.cloud?.serverless.projectType === 'observability';
211-
212-
core.uiSettings.register({
213-
[OBSERVABILITY_ENABLE_STREAMS_UI]: {
214-
category: ['observability'],
215-
name: 'Streams UI',
216-
value: isObservabilityServerless,
217-
description: i18n.translate('xpack.streams.enableStreamsUIDescription', {
218-
defaultMessage: 'Enable the {streamsLink}.',
219-
values: {
220-
streamsLink: `<a href="https://www.elastic.co/docs/solutions/observability/logs/streams/streams">Streams UI</href>`,
221-
},
222-
}),
223-
type: 'boolean',
224-
schema: schema.boolean(),
225-
requiresPageReload: true,
226-
solution: 'oblt',
227-
technicalPreview: true,
228-
},
229-
});
204+
registerFeatureFlags(core, plugins, this.logger);
230205

231206
return {};
232207
}

x-pack/platform/plugins/shared/streams/server/routes/streams/significant_events/route.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,15 @@ const previewSignificantEventsRoute = createServerRoute({
5555
params,
5656
request,
5757
getScopedClients,
58-
logger,
58+
server,
5959
}): Promise<SignificantEventsPreviewResponse> => {
60+
const isAvailableForTier = server.core.pricing.isFeatureAvailable(
61+
STREAMS_TIERED_SIGNIFICANT_EVENT_FEATURE.id
62+
);
63+
if (!isAvailableForTier) {
64+
throw new SecurityError(`Cannot access API on the current pricing tier`);
65+
}
66+
6067
const { streamsClient, scopedClusterClient } = await getScopedClients({
6168
request,
6269
});

x-pack/platform/plugins/shared/streams/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"@kbn/management-settings-ids",
2323
"@kbn/server-route-repository-client",
2424
"@kbn/cloud-plugin",
25-
"@kbn/core-ui-settings-common",
2625
"@kbn/i18n",
2726
"@kbn/core-plugins-server",
2827
"@kbn/content-packs-schema",

x-pack/platform/plugins/shared/streams_app/public/components/data_management/preview_table/index.tsx

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -144,31 +144,34 @@ export function PreviewTable({
144144
}, [canonicalColumnOrder, setSorting, setVisibleColumns, visibleColumns.length]);
145145

146146
const leadingControlColumns: EuiDataGridControlColumn[] = useMemo(
147-
() => [
148-
{
149-
id: 'selection',
150-
width: 36,
151-
headerCellRender: () => null,
152-
rowCellRender: ({ rowIndex }) => (
153-
<EuiButtonIcon
154-
onClick={() => {
155-
if (selectableRow && onRowSelected) {
156-
onRowSelected(rowIndex);
157-
}
158-
}}
159-
aria-label={i18n.translate(
160-
'xpack.streams.resultPanel.euiDataGrid.preview.selectRowAriaLabel',
161-
{
162-
defaultMessage: 'Select row {rowIndex}',
163-
values: { rowIndex: rowIndex + 1 },
164-
}
165-
)}
166-
iconType={selectedRowIndex === rowIndex && selectableRow ? 'minimize' : 'expand'}
167-
color={selectedRowIndex === rowIndex && selectableRow ? 'primary' : 'text'}
168-
/>
169-
),
170-
},
171-
],
147+
() =>
148+
selectableRow
149+
? [
150+
{
151+
id: 'selection',
152+
width: 36,
153+
headerCellRender: () => null,
154+
rowCellRender: ({ rowIndex }) => (
155+
<EuiButtonIcon
156+
onClick={() => {
157+
if (selectableRow && onRowSelected) {
158+
onRowSelected(rowIndex);
159+
}
160+
}}
161+
aria-label={i18n.translate(
162+
'xpack.streams.resultPanel.euiDataGrid.preview.selectRowAriaLabel',
163+
{
164+
defaultMessage: 'Select row {rowIndex}',
165+
values: { rowIndex: rowIndex + 1 },
166+
}
167+
)}
168+
iconType={selectedRowIndex === rowIndex && selectableRow ? 'minimize' : 'expand'}
169+
color={selectedRowIndex === rowIndex && selectableRow ? 'primary' : 'text'}
170+
/>
171+
),
172+
},
173+
]
174+
: [],
172175
[onRowSelected, selectableRow, selectedRowIndex]
173176
);
174177

x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_management/classic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function ClassicStreamDetailManagement({
141141
tabs.significantEvents = otherTabs.significantEvents;
142142
}
143143

144-
if (!isValidManagementSubTab(tab)) {
144+
if (!isValidManagementSubTab(tab) || tabs[tab] === undefined) {
145145
return <RedirectTo path="/{key}/management/{tab}" params={{ path: { key, tab: 'enrich' } }} />;
146146
}
147147

x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_management/use_streams_detail_management_tabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
* 2.0; you may not use this file except in compliance with the Elastic License
55
* 2.0.
66
*/
7-
import React from 'react';
8-
import { Streams } from '@kbn/streams-schema';
97
import { i18n } from '@kbn/i18n';
10-
import { StreamDetailEnrichment } from '../stream_detail_enrichment';
8+
import { Streams } from '@kbn/streams-schema';
9+
import React from 'react';
1110
import { useStreamsPrivileges } from '../../../hooks/use_streams_privileges';
1211
import { StreamDetailSignificantEventsView } from '../../stream_detail_significant_events_view';
12+
import { StreamDetailEnrichment } from '../stream_detail_enrichment';
1313

1414
export function useStreamsDetailManagementTabs({
1515
definition,

x-pack/platform/plugins/shared/streams_app/public/components/data_management/stream_detail_management/wired.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function WiredStreamDetailManagement({
8787
...otherTabs,
8888
};
8989

90-
if (!isValidManagementSubTab(tab)) {
90+
if (!isValidManagementSubTab(tab) || tabs[tab] === undefined) {
9191
return <RedirectTo path="/{key}/management/{tab}" params={{ path: { key, tab: 'route' } }} />;
9292
}
9393

x-pack/platform/plugins/shared/streams_app/public/components/stream_detail_significant_events_view/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export function StreamDetailSignificantEventsView({
3232
const {
3333
core: { notifications },
3434
} = useKibana();
35-
3635
const {
3736
timeState: { start, end },
3837
} = useTimefilter();

0 commit comments

Comments
 (0)