Skip to content

Commit 7ac8a8c

Browse files
christinewengqn895
authored andcommitted
[Security Solution] Change alerts page data view and add help text (elastic#231374)
## Summary **Security changes** Security users have been able to add run time fields to the security default data view. While implementing the managed data view feature elastic#223451, the conflict arise where we want the default data view to be kibana managed, but we do not want to take away user's ability to add run time fields. As a result, it was decided to exclude security default data view as `managed`, and the data view in alerts page is changed to security default. With these changes, users can see run time fields created before they upgrade to `9.2`, and they will be able to continue adding run time fields. <img width="488" height="306" alt="image" src="https://github.com/user-attachments/assets/9026ef05-3adb-4b23-9abf-b5e12d6d95d9" /> **Discover / Data view picker changes** Even though we can't have the default data view as `managed`, we want to bring awareness of the security advanced setting to users. Currently, indices in advanced settings always override user changes in editor flyout. To minimize confusion, this PR added an optional prop `getDataViewHelpText` in the data view picker component. This will allow a help text to be shown when user is editing the security default data view. <img width="987" height="470" alt="image" src="https://github.com/user-attachments/assets/f2cfb169-c0f6-4e32-8081-f186b010d0ee" /> ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
1 parent 92afc1b commit 7ac8a8c

File tree

18 files changed

+88
-60
lines changed

18 files changed

+88
-60
lines changed

src/platform/plugins/shared/data_view_editor/public/components/data_view_editor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const DataViewEditor = ({
2525
requireTimestampField = false,
2626
editData,
2727
allowAdHocDataView,
28+
getDataViewHelpText,
2829
}: DataViewEditorPropsWithServices) => {
2930
const { Provider: KibanaReactContextProvider } =
3031
createKibanaReactContext<DataViewEditorContext>(services);
@@ -44,6 +45,7 @@ export const DataViewEditor = ({
4445
requireTimestampField={requireTimestampField}
4546
editData={editData}
4647
allowAdHocDataView={allowAdHocDataView}
48+
getDataViewHelpText={getDataViewHelpText}
4749
/>
4850
</EuiFlyout>
4951
</KibanaReactContextProvider>

src/platform/plugins/shared/data_view_editor/public/components/data_view_editor_flyout_content.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import React, { useEffect, useCallback } from 'react';
10+
import type { ReactNode } from 'react';
11+
import React, { useEffect, useCallback, useMemo } from 'react';
1112
import { css } from '@emotion/react';
1213
import {
1314
EuiTitle,
@@ -70,6 +71,7 @@ export interface Props {
7071
showManagementLink?: boolean;
7172
allowAdHoc: boolean;
7273
dataViewEditorService: DataViewEditorService;
74+
getDataViewHelpText?: (dataView: DataView) => ReactNode | string | undefined;
7375
}
7476

7577
const editorTitle = i18n.translate('indexPatternEditor.title', {
@@ -87,6 +89,7 @@ const IndexPatternEditorFlyoutContentComponent = ({
8789
editData,
8890
allowAdHoc,
8991
showManagementLink,
92+
getDataViewHelpText,
9093
dataViewEditorService,
9194
}: Props) => {
9295
const styles = useMemoCss(componentStyles);
@@ -195,6 +198,10 @@ const IndexPatternEditorFlyoutContentComponent = ({
195198
}, [dataViewEditorService, type]);
196199

197200
const getRollupIndices = (rollupCapsRes: RollupIndicesCapsResponse) => Object.keys(rollupCapsRes);
201+
const titleHelpText = useMemo(
202+
() => editData && getDataViewHelpText && getDataViewHelpText(editData),
203+
[editData, getDataViewHelpText]
204+
);
198205

199206
const onTypeChange = useCallback(
200207
(newType: INDEX_PATTERN_TYPE) => {
@@ -298,6 +305,7 @@ const IndexPatternEditorFlyoutContentComponent = ({
298305
indexPatternValidationProvider={
299306
dataViewEditorService.indexPatternValidationProvider
300307
}
308+
titleHelpText={titleHelpText}
301309
/>
302310
</EuiFlexItem>
303311
</EuiFlexGroup>

src/platform/plugins/shared/data_view_editor/public/components/data_view_flyout_content_container.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const DataViewFlyoutContentContainer = ({
2525
editData,
2626
allowAdHocDataView,
2727
showManagementLink,
28+
getDataViewHelpText,
2829
}: DataViewEditorProps) => {
2930
const {
3031
services: { dataViews, notifications, http },
@@ -100,6 +101,7 @@ const DataViewFlyoutContentContainer = ({
100101
showManagementLink={showManagementLink}
101102
allowAdHoc={allowAdHocDataView || false}
102103
dataViewEditorService={dataViewEditorService}
104+
getDataViewHelpText={getDataViewHelpText}
103105
/>
104106
);
105107
};

src/platform/plugins/shared/data_view_editor/public/components/form_fields/title_field.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import type { ChangeEvent } from 'react';
10+
import type { ChangeEvent, ReactNode } from 'react';
1111
import React, { useState, useMemo } from 'react';
1212
import { i18n } from '@kbn/i18n';
1313
import { EuiFormRow, EuiFieldText } from '@elastic/eui';
@@ -30,6 +30,7 @@ interface TitleFieldProps {
3030
matchedIndices: MatchedIndicesSet;
3131
rollupIndex: string | null | undefined;
3232
}>;
33+
titleHelpText?: ReactNode | string;
3334
}
3435

3536
const rollupIndexPatternNoMatchError = {
@@ -114,11 +115,13 @@ interface GetTitleConfigArgs {
114115
isRollup: boolean;
115116
matchedIndices: MatchedItem[];
116117
rollupIndicesCapabilities: RollupIndicesCapsResponse;
118+
titleHelpText?: ReactNode | string;
117119
}
118120

119121
const getTitleConfig = ({
120122
isRollup,
121123
rollupIndicesCapabilities,
124+
titleHelpText,
122125
}: GetTitleConfigArgs): FieldConfig<string> => {
123126
const titleFieldConfig = schema.title;
124127

@@ -134,6 +137,7 @@ const getTitleConfig = ({
134137
return {
135138
...titleFieldConfig!,
136139
validations,
140+
helpText: titleHelpText,
137141
};
138142
};
139143

@@ -142,6 +146,7 @@ export const TitleField = ({
142146
matchedIndices$,
143147
rollupIndicesCapabilities,
144148
indexPatternValidationProvider,
149+
titleHelpText,
145150
}: TitleFieldProps) => {
146151
const [appendedWildcard, setAppendedWildcard] = useState<boolean>(false);
147152
const matchedIndices = useObservable(matchedIndices$, matchedIndiciesDefault).exactMatchedIndices;
@@ -152,8 +157,9 @@ export const TitleField = ({
152157
isRollup,
153158
matchedIndices,
154159
rollupIndicesCapabilities,
160+
titleHelpText,
155161
}),
156-
[isRollup, matchedIndices, rollupIndicesCapabilities]
162+
[isRollup, matchedIndices, rollupIndicesCapabilities, titleHelpText]
157163
);
158164

159165
return (

src/platform/plugins/shared/data_view_editor/public/open_editor.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export const getEditorOpener =
5050
requireTimestampField = false,
5151
allowAdHocDataView = false,
5252
editData,
53+
getDataViewHelpText,
5354
}: DataViewEditorProps): CloseEditor => {
5455
const closeEditor = () => {
5556
if (overlayRef) {
@@ -80,6 +81,7 @@ export const getEditorOpener =
8081
requireTimestampField={requireTimestampField}
8182
allowAdHocDataView={allowAdHocDataView}
8283
showManagementLink={Boolean(editData && editData.isPersisted())}
84+
getDataViewHelpText={getDataViewHelpText}
8385
/>
8486
</KibanaReactContextProvider>,
8587
core

src/platform/plugins/shared/data_view_editor/public/types.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import type { FC } from 'react';
10+
import type { FC, ReactNode } from 'react';
1111
import type {
1212
ApplicationStart,
1313
IUiSettingsClient,
@@ -71,6 +71,10 @@ export interface DataViewEditorProps {
7171
* if set to true a link to the management page is shown
7272
*/
7373
showManagementLink?: boolean;
74+
/**
75+
* Optional callback to get help text based on the active data view
76+
*/
77+
getDataViewHelpText?: (dataView: DataView) => ReactNode | string | undefined;
7478
}
7579

7680
// eslint-disable-next-line @typescript-eslint/no-empty-interface

src/platform/plugins/shared/unified_search/public/dataview_picker/change_dataview.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export function ChangeDataView({
7070
onEditDataView,
7171
onCreateDefaultAdHocDataView,
7272
onClosePopover,
73+
getDataViewHelpText,
7374
}: DataViewPickerProps) {
7475
const { euiTheme } = useEuiTheme();
7576
const [isPopoverOpen, setPopoverIsOpen] = useState(false);
@@ -178,6 +179,7 @@ export function ChangeDataView({
178179
onSave: (updatedDataView) => {
179180
onEditDataView(updatedDataView);
180181
},
182+
getDataViewHelpText,
181183
});
182184
} else {
183185
application.navigateToApp('management', {
@@ -272,6 +274,7 @@ export function ChangeDataView({
272274
onEditDataView,
273275
searchListInputId,
274276
selectableProps,
277+
getDataViewHelpText,
275278
]);
276279

277280
return (

src/platform/plugins/shared/unified_search/public/dataview_picker/data_view_picker.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10+
import type { ReactNode } from 'react';
1011
import React from 'react';
1112
import type { EuiButtonProps, EuiSelectableProps } from '@elastic/eui';
1213
import type { DataView, DataViewListItem, DataViewSpec } from '@kbn/data-views-plugin/public';
@@ -76,6 +77,10 @@ export interface DataViewPickerProps {
7677
* Optional callback when data view picker is closed
7778
*/
7879
onClosePopover?: () => void;
80+
/**
81+
* Optional callback to get help text based on the active data view
82+
*/
83+
getDataViewHelpText?: (dataView: DataView) => ReactNode | string | undefined;
7984
}
8085

8186
export const DataViewPicker = ({
@@ -93,6 +98,7 @@ export const DataViewPicker = ({
9398
selectableProps,
9499
onCreateDefaultAdHocDataView,
95100
isDisabled,
101+
getDataViewHelpText,
96102
}: DataViewPickerProps) => {
97103
return (
98104
<ChangeDataView
@@ -110,6 +116,7 @@ export const DataViewPicker = ({
110116
savedDataViews={savedDataViews}
111117
selectableProps={selectableProps}
112118
isDisabled={isDisabled}
119+
getDataViewHelpText={getDataViewHelpText}
113120
/>
114121
);
115122
};

x-pack/solutions/security/plugins/security_solution/public/data_view_manager/components/data_view_picker/index.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
import { DataViewPicker as UnifiedDataViewPicker } from '@kbn/unified-search-plugin/public';
99
import React, { useCallback, useRef, useMemo, memo } from 'react';
1010
import { useDispatch, useSelector } from 'react-redux';
11-
1211
import { DataView } from '@kbn/data-views-plugin/public';
12+
import { EuiCode } from '@elastic/eui';
13+
import { FormattedMessage } from '@kbn/i18n-react';
1314
import { EXPLORE_DATA_VIEW_PREFIX } from '../../../../common/constants';
1415
import type { SourcererUrlState } from '../../../sourcerer/store/model';
1516
import { useUpdateUrlParam } from '../../../common/utils/global_query_string';
@@ -21,7 +22,7 @@ import { useSelectDataView } from '../../hooks/use_select_data_view';
2122
import { DataViewManagerScopeName } from '../../constants';
2223
import { useManagedDataViews } from '../../hooks/use_managed_data_views';
2324
import { useSavedDataViews } from '../../hooks/use_saved_data_views';
24-
import { DEFAULT_SECURITY_DATA_VIEW, LOADING } from './translations';
25+
import { LOADING } from './translations';
2526
import { DATA_VIEW_PICKER_TEST_ID } from './constants';
2627
import { useDataView } from '../../hooks/use_data_view';
2728
import { browserFieldsManager } from '../../utils/security_browser_fields_manager';
@@ -137,6 +138,20 @@ export const DataViewPicker = memo(({ scope, onClosePopover, disabled }: DataVie
137138
[dataViewId, data.dataViews, scope, dataViewFieldEditor, handleChangeDataView]
138139
);
139140

141+
const getDataViewHelpText = useCallback(
142+
(dv: DataView) =>
143+
dv.id === defaultDataViewId ? (
144+
<FormattedMessage
145+
id="xpack.securitySolution.dataViewManager.getDataViewHelpText"
146+
defaultMessage="Changes made here won't be saved permanently. To update the default Security indices, edit {code} in Advanced Settings."
147+
values={{
148+
code: <EuiCode>{'securitySolution:defaultIndex'}</EuiCode>,
149+
}}
150+
/>
151+
) : undefined,
152+
[defaultDataViewId]
153+
);
154+
140155
/**
141156
* Selects data view again. After changes are made to the data view, this results in cache invalidation and will force the reload everywhere.
142157
*/
@@ -162,16 +177,10 @@ export const DataViewPicker = memo(({ scope, onClosePopover, disabled }: DataVie
162177
return { label: LOADING };
163178
}
164179

165-
if (dataView?.id === defaultDataViewId) {
166-
return {
167-
label: DEFAULT_SECURITY_DATA_VIEW,
168-
};
169-
}
170-
171180
return {
172181
label: dataView?.name || dataView?.id || 'Data view',
173182
};
174-
}, [dataView?.id, dataView?.name, defaultDataViewId, status]);
183+
}, [dataView?.id, dataView?.name, status]);
175184

176185
return (
177186
<div data-test-subj={DATA_VIEW_PICKER_TEST_ID}>
@@ -187,6 +196,7 @@ export const DataViewPicker = memo(({ scope, onClosePopover, disabled }: DataVie
187196
savedDataViews={savedDataViews}
188197
managedDataViews={managedDataViews}
189198
onClosePopover={onClosePopover}
199+
getDataViewHelpText={getDataViewHelpText}
190200
/>
191201
</div>
192202
);

x-pack/solutions/security/plugins/security_solution/public/data_view_manager/components/data_view_picker/translations.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ export const LOADING = i18n.translate('xpack.securitySolution.dataViewManager.lo
1414
export const DEFAULT_SECURITY_DATA_VIEW = i18n.translate(
1515
'xpack.securitySolution.dataViewManager.defaultSecurityDataView',
1616
{
17-
defaultMessage: 'Default security data view',
17+
defaultMessage: 'Security solution default',
1818
}
1919
);
2020

2121
export const DEFAULT_SECURITY_ALERT_DATA_VIEW = i18n.translate(
2222
'xpack.securitySolution.dataViewManager.defaultSecurityAlertDataView',
2323
{
24-
defaultMessage: 'Security alert data view',
24+
defaultMessage: 'Security solution alerts',
25+
}
26+
);
27+
28+
export const SECURITY_SOLUTION_EXPLORE_DATA_VIEW = i18n.translate(
29+
'xpack.securitySolution.dataViewManager.securitySolutionExploreDataView',
30+
{
31+
defaultMessage: 'Security solution explore',
2532
}
2633
);

0 commit comments

Comments
 (0)