Skip to content

Commit 7f3e9dd

Browse files
[8.19] [Security solution][Explore] Integrate new dataView in explore's map (elastic#233674) (elastic#235108)
# Backport This will backport the following commits from `main` to `8.19`: - [[Security solution][Explore] Integrate new dataView in explore's map (elastic#233674)](elastic#233674) <!--- Backport version: 10.0.2 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Nicholas Peretti","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-15T11:30:41Z","message":"[Security solution][Explore] Integrate new dataView in explore's map (elastic#233674)\n\n## Summary\n\nCloses elastic#232379.\n\n### 🛑 Problem\n\nAs described in elastic#232379, when the `newDataViewPickerEnabled` is enabled,\nthe maps doesn't show data anymore.\n\n### 💡 Solution\n\nIn this contribution we integrate the new `useDataView` hook inside the\n`embeddable_map` component.\n\nWe use the feature flag from\n`useIsExperimentalFeatureEnabled('newDataViewPickerEnabled')` to decide\nwhich data to use to create the layers list for the map.\n\nThe feature flag is also used to cancel effects in case it's enabled as\nthey wouldn't be needed anymore.\n\n---------\n\nCo-authored-by: Philippe Oberti <[email protected]>","sha":"188c7ea5e7120a3d346bb622a2a40e92c686b482","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Threat Hunting","Team: SecuritySolution","backport:version","v9.1.0","v8.19.0","v9.2.0","v9.1.4"],"title":"[Security solution][Explore] Integrate new dataView in explore's map","number":233674,"url":"https://github.com/elastic/kibana/pull/233674","mergeCommit":{"message":"[Security solution][Explore] Integrate new dataView in explore's map (elastic#233674)\n\n## Summary\n\nCloses elastic#232379.\n\n### 🛑 Problem\n\nAs described in elastic#232379, when the `newDataViewPickerEnabled` is enabled,\nthe maps doesn't show data anymore.\n\n### 💡 Solution\n\nIn this contribution we integrate the new `useDataView` hook inside the\n`embeddable_map` component.\n\nWe use the feature flag from\n`useIsExperimentalFeatureEnabled('newDataViewPickerEnabled')` to decide\nwhich data to use to create the layers list for the map.\n\nThe feature flag is also used to cancel effects in case it's enabled as\nthey wouldn't be needed anymore.\n\n---------\n\nCo-authored-by: Philippe Oberti <[email protected]>","sha":"188c7ea5e7120a3d346bb622a2a40e92c686b482"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/235060","number":235060,"state":"MERGED","mergeCommit":{"sha":"7000b0a67cda718a192e4add98eab257d4d3f12c","message":"[9.1] [Security solution][Explore] Integrate new dataView in explore's map (elastic#233674) (elastic#235060)\n\n# Backport\n\nThis will backport the following commits from `main` to `9.1`:\n- [[Security solution][Explore] Integrate new dataView in explore's map\n(elastic#233674)](https://github.com/elastic/kibana/pull/233674)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n\n\nCo-authored-by: Nicholas Peretti <[email protected]>\nCo-authored-by: Philippe Oberti <[email protected]>"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/233674","number":233674,"mergeCommit":{"message":"[Security solution][Explore] Integrate new dataView in explore's map (elastic#233674)\n\n## Summary\n\nCloses elastic#232379.\n\n### 🛑 Problem\n\nAs described in elastic#232379, when the `newDataViewPickerEnabled` is enabled,\nthe maps doesn't show data anymore.\n\n### 💡 Solution\n\nIn this contribution we integrate the new `useDataView` hook inside the\n`embeddable_map` component.\n\nWe use the feature flag from\n`useIsExperimentalFeatureEnabled('newDataViewPickerEnabled')` to decide\nwhich data to use to create the layers list for the map.\n\nThe feature flag is also used to cancel effects in case it's enabled as\nthey wouldn't be needed anymore.\n\n---------\n\nCo-authored-by: Philippe Oberti <[email protected]>","sha":"188c7ea5e7120a3d346bb622a2a40e92c686b482"}}]}] BACKPORT-->
1 parent c29f0cd commit 7f3e9dd

File tree

1 file changed

+24
-3
lines changed
  • x-pack/solutions/security/plugins/security_solution/public/explore/network/components/embeddables

1 file changed

+24
-3
lines changed

x-pack/solutions/security/plugins/security_solution/public/explore/network/components/embeddables/embedded_map.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ import { sourcererSelectors } from '../../../../sourcerer/store';
3131
import type { State } from '../../../../common/store';
3232
import type { SourcererDataView } from '../../../../sourcerer/store/model';
3333
import { SourcererScopeName } from '../../../../sourcerer/store/model';
34+
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
35+
import { useDataView } from '../../../../data_view_manager/hooks/use_data_view';
3436

3537
export const NETWORK_MAP_VISIBLE = 'network_map_visbile';
3638

@@ -112,6 +114,8 @@ export const EmbeddedMapComponent = ({
112114

113115
const { addError } = useAppToasts();
114116

117+
const newDataViewPickerEnabled = useIsExperimentalFeatureEnabled('newDataViewPickerEnabled');
118+
const { dataView: experimentalDataView } = useDataView(SourcererScopeName.explore);
115119
const kibanaDataViews = useSelector(sourcererSelectors.kibanaDataViews);
116120
const selectedPatterns = useSelector((state: State) => {
117121
return sourcererSelectors.sourcererScopeSelectedPatterns(state, SourcererScopeName.default);
@@ -122,7 +126,22 @@ export const EmbeddedMapComponent = ({
122126
const [layerList, setLayerList] = useState<LayerDescriptor[]>([]);
123127
const [availableDataViews, setAvailableDataViews] = useState<SourcererDataView[]>([]);
124128

129+
const experimentalDataViewLayerList = useMemo(
130+
() =>
131+
experimentalDataView.id && experimentalDataView.getIndexPattern()
132+
? getLayerList([
133+
{
134+
id: experimentalDataView.id,
135+
title: experimentalDataView.getIndexPattern(),
136+
},
137+
])
138+
: [],
139+
[experimentalDataView]
140+
);
141+
125142
useEffect(() => {
143+
if (newDataViewPickerEnabled) return;
144+
126145
let canceled = false;
127146

128147
const fetchData = async () => {
@@ -149,17 +168,19 @@ export const EmbeddedMapComponent = ({
149168
return () => {
150169
canceled = true;
151170
};
152-
}, [addError, availableDataViews, isFieldInIndexPattern]);
171+
}, [addError, availableDataViews, isFieldInIndexPattern, newDataViewPickerEnabled]);
153172

154173
useEffect(() => {
174+
if (newDataViewPickerEnabled) return;
175+
155176
const dataViews = kibanaDataViews.filter((dataView) =>
156177
selectedPatterns.includes(dataView.title)
157178
);
158179
if (selectedPatterns.length > 0 && dataViews.length === 0) {
159180
setIsIndexError(true);
160181
}
161182
setAvailableDataViews((prevViews) => (isEqual(prevViews, dataViews) ? prevViews : dataViews));
162-
}, [kibanaDataViews, selectedPatterns]);
183+
}, [kibanaDataViews, selectedPatterns, newDataViewPickerEnabled]);
163184

164185
// This portalNode provided by react-reverse-portal allows us re-parent the MapToolTip within our
165186
// own component tree instead of the embeddables (default). This is necessary to have access to
@@ -195,7 +216,7 @@ export const EmbeddedMapComponent = ({
195216
getTooltipRenderer={() => (tooltipProps: RenderTooltipContentParams) =>
196217
<OutPortal node={portalNode} {...tooltipProps} />}
197218
mapCenter={{ lon: -1.05469, lat: 15.96133, zoom: 1 }}
198-
layerList={layerList}
219+
layerList={newDataViewPickerEnabled ? experimentalDataViewLayerList : layerList}
199220
filters={appliedFilters}
200221
query={query}
201222
onApiAvailable={(api: MapApi) => {

0 commit comments

Comments
 (0)