-
Couldn't load subscription status.
- Fork 1.1k
Query cancel for new discover #10727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
a9ee6ab
add cancel button on ui
ruchidh bf0bbda
abort query
ruchidh 093d05f
s3 implemenetaion
ruchidh 09fdab6
tets cases done
ruchidh 00e196a
change cancel icon
ruchidh 69d78a0
add timeput delay for cancel button and fix canel icon border
ruchidh f75a813
query cancel for s3 tested
ruchidh 0585282
Update opensearch_dashboards.yml
ruchidh 9235963
Delete scripts/cance_query.md
ruchidh 8f549d9
Update sql_async_search_strategy.ts
ruchidh 9796031
Remove unnecessary whitespace in sql_async_search_strategy
ruchidh 13a5104
Delete src/plugins/query_enhancements/server/search/ppl_async_search_…
ruchidh 23f08f3
Delete src/plugins/query_enhancements/server/search/sql_async_search_…
ruchidh a993e67
Remove unnecessary comment on query cancellation
ruchidh 0ea035d
Add inProgressQueryId check in SQL async search
ruchidh 5326882
Clean up comments in abortAllActiveQueries function
ruchidh 1496f15
Fix comment formatting in opensearch_dashboards.yml
ruchidh 42d4f19
Changeset file for PR #10727 created/updated
opensearch-changeset-bot[bot] fdff680
Update query_editor_top_row.test.tsx
ruchidh 837d3e7
Remove abort signal handling tests
ruchidh 83467e7
Merge branch 'main' into ruchi/cancel-query
ruchidh f996e7b
Add setBreakdownField reducer to query editor slice
ruchidh 8c83511
Remove contextProvider configuration comment
ruchidh 520fc20
update QueryEditorTopRow tests
ruchidh 1415f71
Update opensearch_dashboards.yml
ruchidh d6c28e9
Add comments for new OpenSearch Dashboards features
ruchidh 0b787e1
Adjust cancel button display delay
ruchidh 2c7815e
Update overall_status_middleware.ts
ruchidh 1b5c29f
Refactor overall status middleware for clarity
ruchidh ca6d5c0
fix logic for opensearch cancel
ruchidh 85b8439
query execution
ruchidh aea55a0
Refactor import statements for overall status middleware
ruchidh 3bb7f04
Add shouldShowCancelButton to dependencies
ruchidh 546225c
Update overall_status_middleware.ts
ruchidh 02ff6e2
Refactor condition for resetting user query flag
ruchidh 94503ac
Format export statements for query editor selectors
ruchidh c20d497
Merge branch 'main' into ruchi/cancel-query
ruchidh 36a3298
Update query_execution_button.test.tsx
ruchidh e12b541
update eui class for hardcocded text
ruchidh feaf536
Update _query_editor.scss
ruchidh 5c44212
Update _query_editor.scss
ruchidh 6f85122
refactor timing logic fo cancel logic
ruchidh eb7972f
Update index.ts
ruchidh eb27e1e
Fix missing newline at end of use_cancel_button_timing.ts
ruchidh a2a8aa5
Update query_editor_top_row.tsx
ruchidh 5e8323c
Fix type assertion for useCancelButtonTiming mock
ruchidh 26d1292
initial load opensearch
ruchidh 1fdda8a
intiial load
ruchidh 8aa08e7
pass overallstatus param
ruchidh b20850e
Merge branch 'main' into ruchi/cancel-query
ruchidh 5c5036a
add test cases
ruchidh 58ffd27
Update use_cancel_button_timing.test.ts
ruchidh 883f2bf
fix test cases
ruchidh 6ee4ffb
fix editor run test case
ruchidh a9b4687
Update use_search.test.tsx
ruchidh 3e2001a
Update search_bar.test.tsx
ruchidh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| feat: | ||
| - Add cancel query feature to discover ([#10727](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/10727)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...ic/application/components/dashboard_top_nav/__snapshots__/dashboard_top_nav.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| * | ||
| * Any modifications Copyright OpenSearch Contributors. See | ||
| * GitHub history for details. | ||
| */ | ||
|
|
||
| export { useCancelButtonTiming } from './use_cancel_button_timing'; |
111 changes: 111 additions & 0 deletions
111
src/plugins/data/public/ui/hooks/use_cancel_button_timing.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| * | ||
| * Any modifications Copyright OpenSearch Contributors. See | ||
| * GitHub history for details. | ||
| */ | ||
|
|
||
| import { renderHook, act } from '@testing-library/react-hooks'; | ||
| import { useCancelButtonTiming } from './use_cancel_button_timing'; | ||
|
|
||
| describe('useCancelButtonTiming', () => { | ||
| beforeEach(() => { | ||
| jest.useFakeTimers(); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| jest.runOnlyPendingTimers(); | ||
| jest.useRealTimers(); | ||
| }); | ||
|
|
||
| it('should show cancel button initially when showInitially is true', () => { | ||
| const { result } = renderHook(() => useCancelButtonTiming(false, true)); | ||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('should not show cancel button initially when showInitially is false', () => { | ||
| const { result } = renderHook(() => useCancelButtonTiming(false, false)); | ||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it('should show cancel button after 50ms delay when shouldShow becomes true', () => { | ||
| const { result, rerender } = renderHook( | ||
| ({ shouldShow }) => useCancelButtonTiming(shouldShow, false), | ||
| { initialProps: { shouldShow: false } } | ||
| ); | ||
|
|
||
| expect(result.current).toBe(false); | ||
|
|
||
| rerender({ shouldShow: true }); | ||
| expect(result.current).toBe(false); // Still false immediately | ||
|
|
||
| act(() => { | ||
| jest.advanceTimersByTime(50); | ||
| }); | ||
|
|
||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('should keep cancel button visible for minimum 200ms when hiding', () => { | ||
| const { result, rerender } = renderHook( | ||
| ({ shouldShow }) => useCancelButtonTiming(shouldShow, true), | ||
| { initialProps: { shouldShow: false } } | ||
| ); | ||
|
|
||
| expect(result.current).toBe(true); | ||
|
|
||
| // Start hiding process | ||
| rerender({ shouldShow: false }); | ||
| expect(result.current).toBe(true); // Still visible | ||
|
|
||
| // Wait 100ms (less than 200ms minimum) | ||
| act(() => { | ||
| jest.advanceTimersByTime(100); | ||
| }); | ||
| expect(result.current).toBe(true); | ||
|
|
||
| // Complete 200ms minimum display time | ||
| act(() => { | ||
| jest.advanceTimersByTime(100); | ||
| }); | ||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it('should transition from initial mode to delayed mode after first query', () => { | ||
| const { result, rerender } = renderHook( | ||
| ({ shouldShow }) => useCancelButtonTiming(shouldShow, true), | ||
| { initialProps: { shouldShow: true } } | ||
| ); | ||
|
|
||
| expect(result.current).toBe(true); | ||
|
|
||
| // Complete initial query | ||
| rerender({ shouldShow: false }); | ||
| act(() => { | ||
| jest.advanceTimersByTime(200); | ||
| }); | ||
| expect(result.current).toBe(false); | ||
|
|
||
| // Start new query - should now use 50ms delay | ||
| rerender({ shouldShow: true }); | ||
| expect(result.current).toBe(false); // No longer shows immediately | ||
|
|
||
| act(() => { | ||
| jest.advanceTimersByTime(50); | ||
| }); | ||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it('should clean up timers on unmount', () => { | ||
| const clearTimeoutSpy = jest.spyOn(global, 'clearTimeout'); | ||
| const { unmount } = renderHook(() => useCancelButtonTiming(true, true)); | ||
|
|
||
| unmount(); | ||
| expect(clearTimeoutSpy).toHaveBeenCalled(); | ||
| clearTimeoutSpy.mockRestore(); | ||
| }); | ||
| }); |
73 changes: 73 additions & 0 deletions
73
src/plugins/data/public/ui/hooks/use_cancel_button_timing.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| /* | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * The OpenSearch Contributors require contributions made to | ||
| * this file be licensed under the Apache-2.0 license or a | ||
| * compatible open source license. | ||
| * | ||
| * Any modifications Copyright OpenSearch Contributors. See | ||
| * GitHub history for details. | ||
| */ | ||
|
|
||
| import { useState, useEffect, useRef } from 'react'; | ||
|
|
||
| /** | ||
| * Custom hook for managing cancel button visibility with proper timing | ||
| * - Shows cancel button initially on page load if showInitially=true (for initial queries) | ||
| * - Hides button when initial query completes | ||
| * - Shows cancel button after 50ms delay when shouldShow becomes true (prevents flickering for quick queries) | ||
| * - Keeps button visible for minimum 200ms (smooth UX) | ||
| */ | ||
| export const useCancelButtonTiming = (shouldShow: boolean, showInitially: boolean = true) => { | ||
| const [shouldShowCancelButton, setShouldShowCancelButton] = useState(showInitially); | ||
| const cancelButtonTimerRef = useRef<NodeJS.Timeout | null>(null); | ||
| const minimumDisplayTimerRef = useRef<NodeJS.Timeout | null>(null); | ||
| const hasCompletedInitialQueryRef = useRef(false); // Track if initial query has completed | ||
|
|
||
| useEffect(() => { | ||
| if (shouldShow) { | ||
| // Clear any existing minimum display timer | ||
| if (minimumDisplayTimerRef.current) { | ||
| clearTimeout(minimumDisplayTimerRef.current); | ||
| minimumDisplayTimerRef.current = null; | ||
| } | ||
|
|
||
| // Start timer to show cancel button after 50ms (existing logic) | ||
| cancelButtonTimerRef.current = setTimeout(() => { | ||
| setShouldShowCancelButton(true); | ||
| }, 50); | ||
| } else { | ||
| // Clear the show timer | ||
| if (cancelButtonTimerRef.current) { | ||
| clearTimeout(cancelButtonTimerRef.current); | ||
| cancelButtonTimerRef.current = null; | ||
| } | ||
|
|
||
| // Mark that initial query has completed (if we were showing initially) | ||
| if (showInitially && !hasCompletedInitialQueryRef.current) { | ||
| hasCompletedInitialQueryRef.current = true; | ||
| } | ||
|
|
||
| // If button is currently visible, keep it visible for minimum 200ms | ||
| if (shouldShowCancelButton) { | ||
| minimumDisplayTimerRef.current = setTimeout(() => { | ||
| setShouldShowCancelButton(false); | ||
| }, 200); | ||
| } else { | ||
| setShouldShowCancelButton(false); | ||
| } | ||
| } | ||
|
|
||
| // Cleanup timers on unmount | ||
| return () => { | ||
| if (cancelButtonTimerRef.current) { | ||
| clearTimeout(cancelButtonTimerRef.current); | ||
| } | ||
| if (minimumDisplayTimerRef.current) { | ||
| clearTimeout(minimumDisplayTimerRef.current); | ||
| } | ||
| }; | ||
| }, [shouldShow, shouldShowCancelButton, showInitially]); | ||
|
|
||
| return shouldShowCancelButton; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this included by mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure why it's showing up, though i didn't make any changes, tried to reset but still shows up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can do:
before commiting.
And better yet, something we learned from @ashwin-pc , if you have temporary
opensearch_dashboards.ymlchanges you need to make, create aopensearch_dashboards.dev.ymlwithin this folder and have your personal changes in there. Then you never have to interact with theopensearch_dashboards.ymlfile. This is what mine looks like:Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and i believe its showing up because you prob made changes to this file for your local configs, and your IDE is auto-formatting it.
TBH its more proper to add the extra whitespace like your change does, but ideally in the future its best to leave this file out of the diff to make it easier for reviewers.
You can use vim to undo this change if you really wanted and commit it, but not a blocker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks justin that would help