Skip to content
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

[Backport 2.17] Fix running recent query button #8281

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/8252.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Run recent query button work properly ([#8252](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8252))
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
icon: 'play',
type: 'icon',
onClick: (item: RecentQueryTableItem) => {
onClickRecentQuery(recentQueries[item.id].query, recentQueries[item.id].timeRange);
onClickRecentQuery(
recentQueries.find((recentQuery) => recentQuery.id === item.id)?.query!,
recentQueries.find((recentQuery) => recentQuery.id === item.id)?.timeRange

Check warning on line 56 in src/plugins/data/public/query/query_string/language_service/lib/recent_query.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/language_service/lib/recent_query.tsx#L54-L56

Added lines #L54 - L56 were not covered by tests
);
},
'data-test-subj': 'action-run',
},
Expand All @@ -76,8 +79,8 @@
const recentQueryItems: RecentQueryTableItem[] = recentQueries
.filter((item, idx) => idx < MAX_RECENT_QUERY_SIZE)
.filter((item) => item.query.language === currentLanguage)
.map((query, idx) => ({
id: idx,
.map((query) => ({

Check warning on line 82 in src/plugins/data/public/query/query_string/language_service/lib/recent_query.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/query/query_string/language_service/lib/recent_query.tsx#L82

Added line #L82 was not covered by tests
id: query.id,
query: query.query.query,
timeRange: query.timeRange,
time: moment(query.time).format('MMM D, YYYY HH:mm:ss'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { EditorInstance } from '../../../ui/query_editor/editors';

export interface RecentQueryItem {
id: number;
query: Query;
time: number;
timeRange?: TimeRange;
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/data/public/query/query_string/query_history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import uuid from 'uuid';
import { BehaviorSubject } from 'rxjs';
import { DataStorage } from '../../../common';
import { Query, TimeRange } from '../..';
Expand Down Expand Up @@ -61,6 +62,7 @@ export class QueryHistory {
time: timestamp,
query,
dateRange,
id: uuid.v4(),
};
this.storage.set(newKey, newItem);

Expand Down
Loading