Skip to content

Commit 7000b0a

Browse files
kibanamachineNicholasPerettiPhilippeOberti
authored
[9.1] [Security solution][Explore] Integrate new dataView in explore's map (elastic#233674) (elastic#235060)
# Backport This will backport the following commits from `main` to `9.1`: - [[Security solution][Explore] Integrate new dataView in explore's map (elastic#233674)](elastic#233674) <!--- Backport version: 9.6.6 --> ### 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"],"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":["9.1","8.19"],"targetPullRequestStates":[{"branch":"9.1","label":"v9.1.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"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--> Co-authored-by: Nicholas Peretti <[email protected]> Co-authored-by: Philippe Oberti <[email protected]>
1 parent da78df4 commit 7000b0a

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

@@ -113,6 +115,8 @@ export const EmbeddedMapComponent = ({
113115

114116
const { addError } = useAppToasts();
115117

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

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

129148
const fetchData = async () => {
@@ -150,17 +169,19 @@ export const EmbeddedMapComponent = ({
150169
return () => {
151170
canceled = true;
152171
};
153-
}, [addError, availableDataViews, euiTheme, isFieldInIndexPattern]);
172+
}, [addError, availableDataViews, euiTheme, isFieldInIndexPattern, newDataViewPickerEnabled]);
154173

155174
useEffect(() => {
175+
if (newDataViewPickerEnabled) return;
176+
156177
const dataViews = kibanaDataViews.filter((dataView) =>
157178
selectedPatterns.includes(dataView.title)
158179
);
159180
if (selectedPatterns.length > 0 && dataViews.length === 0) {
160181
setIsIndexError(true);
161182
}
162183
setAvailableDataViews((prevViews) => (isEqual(prevViews, dataViews) ? prevViews : dataViews));
163-
}, [kibanaDataViews, selectedPatterns]);
184+
}, [kibanaDataViews, selectedPatterns, newDataViewPickerEnabled]);
164185

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

0 commit comments

Comments
 (0)