Skip to content

Commit ed0cebd

Browse files
opensearch-trigger-bot[bot]github-actions[bot]paulstn
authored
[Backport 2.x] changes loading configuration for Explorer default (#1720)
* changes loading configuration for Explorer default (#1719) * ignore shift enter functionality added and sample query 's' removed Signed-off-by: Paul Sebastian <[email protected]> * create new-tab-like config for explorer by default Signed-off-by: Paul Sebastian <[email protected]> --------- Signed-off-by: Paul Sebastian <[email protected]> (cherry picked from commit 571a111) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * update snapshot Signed-off-by: Paul Sebastian <[email protected]> --------- Signed-off-by: Paul Sebastian <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Paul Sebastian <[email protected]>
1 parent 2cbc016 commit ed0cebd

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

public/components/event_analytics/explorer/__tests__/__snapshots__/data_grid.test.tsx.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ exports[`Datagrid component Renders data grid component 1`] = `
137137
},
138138
"basePath": BasePath {
139139
"basePath": "",
140+
"clientBasePath": "",
140141
"get": [Function],
142+
"getBasePath": [Function],
141143
"prepend": [Function],
142144
"remove": [Function],
143145
"serverBasePath": "",
@@ -165,7 +167,9 @@ exports[`Datagrid component Renders data grid component 1`] = `
165167
},
166168
"basePath": BasePath {
167169
"basePath": "",
170+
"clientBasePath": "",
168171
"get": [Function],
172+
"getBasePath": [Function],
169173
"prepend": [Function],
170174
"remove": [Function],
171175
"serverBasePath": "",
@@ -623,7 +627,9 @@ exports[`Datagrid component renders data grid with different timestamp 1`] = `
623627
},
624628
"basePath": BasePath {
625629
"basePath": "",
630+
"clientBasePath": "",
626631
"get": [Function],
632+
"getBasePath": [Function],
627633
"prepend": [Function],
628634
"remove": [Function],
629635
"serverBasePath": "",
@@ -651,7 +657,9 @@ exports[`Datagrid component renders data grid with different timestamp 1`] = `
651657
},
652658
"basePath": BasePath {
653659
"basePath": "",
660+
"clientBasePath": "",
654661
"get": [Function],
662+
"getBasePath": [Function],
655663
"prepend": [Function],
656664
"remove": [Function],
657665
"serverBasePath": "",
@@ -1109,7 +1117,9 @@ exports[`Datagrid component renders data grid with no timestamp 1`] = `
11091117
},
11101118
"basePath": BasePath {
11111119
"basePath": "",
1120+
"clientBasePath": "",
11121121
"get": [Function],
1122+
"getBasePath": [Function],
11131123
"prepend": [Function],
11141124
"remove": [Function],
11151125
"serverBasePath": "",
@@ -1137,7 +1147,9 @@ exports[`Datagrid component renders data grid with no timestamp 1`] = `
11371147
},
11381148
"basePath": BasePath {
11391149
"basePath": "",
1150+
"clientBasePath": "",
11401151
"get": [Function],
1152+
"getBasePath": [Function],
11411153
"prepend": [Function],
11421154
"remove": [Function],
11431155
"serverBasePath": "",

public/components/event_analytics/explorer/log_explorer.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* eslint-disable react-hooks/exhaustive-deps */
66
import { isEmpty } from 'lodash';
77
import React, { useContext, useEffect, useRef, useState } from 'react';
8-
import { useSelector } from 'react-redux';
8+
import { batch, useSelector, useDispatch } from 'react-redux';
99
import { useHistory } from 'react-router-dom';
1010
import { LogExplorerRouterContext } from '..';
1111
import {
@@ -26,6 +26,14 @@ import {
2626
} from '../../../../common/constants/shared';
2727
import { coreRefs } from '../../../../public/framework/core_refs';
2828

29+
import { init as initFields } from '../../event_analytics/redux/slices/field_slice';
30+
import { init as initPatterns } from '../../event_analytics/redux/slices/patterns_slice';
31+
import { init as initQueryResult } from '../../event_analytics/redux/slices/query_result_slice';
32+
import { init as initQuery } from '../../event_analytics/redux/slices/query_slice';
33+
import { init as initVisualizationConfig } from '../../event_analytics/redux/slices/viualization_config_slice';
34+
import { resetSummary as initQueryAssistSummary } from '../../event_analytics/redux/slices/query_assistant_summarization_slice';
35+
import { init as initSearchMetaData } from '../../event_analytics/redux/slices/search_meta_data_slice';
36+
2937
const searchBarConfigs = {
3038
[TAB_EVENT_ID]: {
3139
showSaveButton: true,
@@ -52,6 +60,7 @@ export const LogExplorer = ({
5260
dataSourcePluggables,
5361
}: ILogExplorerProps) => {
5462
const history = useHistory();
63+
const dispatch = useDispatch();
5564
const routerContext = useContext(LogExplorerRouterContext);
5665
const tabIds = useSelector(selectQueryTabs).queryTabIds.filter(
5766
(tabid: string) => !tabid.match(APP_ANALYTICS_TAB_ID_REGEX)
@@ -68,6 +77,7 @@ export const LogExplorer = ({
6877
explorerDataRef.current = explorerData;
6978
curSelectedTabIdRef.current = curSelectedTabId;
7079

80+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
7181
const [tabCreatedTypes, setTabCreatedTypes] = useState({});
7282

7383
const dispatchSavedObjectId = async () => {
@@ -87,6 +97,19 @@ export const LogExplorer = ({
8797
useEffect(() => {
8898
if (!isEmpty(savedObjectId)) {
8999
dispatchSavedObjectId();
100+
} else {
101+
// below piece of code was added to simulate creating a new tab if saved obj isn't being loaded,
102+
// since tabs being visually removed means 'new tab' cannot be created any other way
103+
const tabId = tabIds[0];
104+
batch(() => {
105+
dispatch(initQuery({ tabId }));
106+
dispatch(initQueryResult({ tabId }));
107+
dispatch(initFields({ tabId }));
108+
dispatch(initVisualizationConfig({ tabId }));
109+
dispatch(initPatterns({ tabId }));
110+
dispatch(initQueryAssistSummary({ tabId }));
111+
dispatch(initSearchMetaData({ tabId }));
112+
});
90113
}
91114
if (routerContext && routerContext.searchParams.has(CREATE_TAB_PARAM_KEY)) {
92115
// need to wait for current redux event loop to finish

0 commit comments

Comments
 (0)