Skip to content

Commit 82347d6

Browse files
[Explore] do not detect and auto select tab when switching dataset (#10807)
There is an issue when loading a saved explore, the active tab is set to Logs even when the saved explore has Visualization as active tab. When loading a saved explore, the active tab should already been set by src/plugins/explore/public/application/utils/hooks/use_page_initialization.ts, the current DatasetChangeMiddleware also get triggered after loading a saved explore, but it should NOT detectAndSetOptimalTab any more in this case. And for regular data set change, we don't need this detectAndSetOptimalTab as well, because data set change always reset the query to emtpy and the select tab should be Logs in this case. This commit removed detectAndSetOptimalTab from DatasetChangeMiddleware --------- Signed-off-by: Yulong Ruan <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
1 parent 385af17 commit 82347d6

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

changelogs/fragments/10807.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fix:
2+
- Fix active tab not set when loading saved explore if no vis rule matched ([#10807](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10807))

src/plugins/explore/public/application/utils/state_management/middleware/dataset_change_middleware.test.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { DEFAULT_DATA } from '../../../../../../data/common';
2121
import { getPromptModeIsAvailable } from '../../get_prompt_mode_is_available';
2222
import { getSummaryAgentIsAvailable } from '../../get_summary_agent_is_available';
2323
import * as queryActions from '../actions/query_actions';
24-
import * as tabActions from '../actions/detect_optimal_tab';
2524
import * as resetLegacyStateActions from '../actions/reset_legacy_state';
2625

2726
jest.mock('../../get_prompt_mode_is_available', () => ({
@@ -47,9 +46,6 @@ jest.mock('../actions/reset_legacy_state', () => ({
4746
const mockedExecuteQueries = queryActions.executeQueries as jest.MockedFunction<
4847
typeof queryActions.executeQueries
4948
>;
50-
const mockedDetectAndSetOptimalTab = tabActions.detectAndSetOptimalTab as jest.MockedFunction<
51-
typeof tabActions.detectAndSetOptimalTab
52-
>;
5349
const mockedGetPromptModeIsAvailable = getPromptModeIsAvailable as jest.MockedFunction<
5450
typeof getPromptModeIsAvailable
5551
>;
@@ -126,10 +122,6 @@ describe('createDatasetChangeMiddleware', () => {
126122
// Verify the executeQueries action was dispatched
127123
expect(mockedExecuteQueries).toHaveBeenCalledWith({ services: mockServices });
128124
expect(mockStore.dispatch).toHaveBeenCalledWith({ type: 'mock/executeQueries' });
129-
130-
// Verify the detectAndSetOptimalTab action was dispatched
131-
expect(mockedDetectAndSetOptimalTab).toHaveBeenCalledWith({ services: mockServices });
132-
expect(mockStore.dispatch).toHaveBeenCalledWith({ type: 'mock/detectOptimalTab' });
133125
});
134126

135127
it('should trigger side effects when dataset changes with setQueryWithHistory', async () => {
@@ -221,7 +213,6 @@ describe('createDatasetChangeMiddleware', () => {
221213

222214
// Verify that execute queries was not called
223215
expect(mockedExecuteQueries).not.toHaveBeenCalled();
224-
expect(mockedDetectAndSetOptimalTab).not.toHaveBeenCalled();
225216
});
226217

227218
it('should update prompt mode availability only if different from current state', async () => {

src/plugins/explore/public/application/utils/state_management/middleware/dataset_change_middleware.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ export const createDatasetChangeMiddleware = (
9595
}
9696

9797
await store.dispatch(executeQueries({ services }) as any);
98-
store.dispatch(detectAndSetOptimalTab({ services }) as any);
9998
} catch (error) {
10099
services.notifications?.toasts.addError(error, {
101100
title: 'Error loading dataset',

0 commit comments

Comments
 (0)