diff --git a/changelogs/fragments/8252.yml b/changelogs/fragments/8252.yml deleted file mode 100644 index f612ecc2b2f8..000000000000 --- a/changelogs/fragments/8252.yml +++ /dev/null @@ -1,2 +0,0 @@ -fix: -- Run recent query button work properly ([#8252](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8252)) \ No newline at end of file diff --git a/src/plugins/data/public/query/query_string/language_service/lib/recent_query.tsx b/src/plugins/data/public/query/query_string/language_service/lib/recent_query.tsx index 0b58f0413966..2e3fdb7f55aa 100644 --- a/src/plugins/data/public/query/query_string/language_service/lib/recent_query.tsx +++ b/src/plugins/data/public/query/query_string/language_service/lib/recent_query.tsx @@ -51,10 +51,7 @@ export function RecentQueriesTable({ icon: 'play', type: 'icon', onClick: (item: RecentQueryTableItem) => { - onClickRecentQuery( - recentQueries.find((recentQuery) => recentQuery.id === item.id)?.query!, - recentQueries.find((recentQuery) => recentQuery.id === item.id)?.timeRange - ); + onClickRecentQuery(recentQueries[item.id].query, recentQueries[item.id].timeRange); }, 'data-test-subj': 'action-run', }, @@ -79,8 +76,8 @@ export function RecentQueriesTable({ const recentQueryItems: RecentQueryTableItem[] = recentQueries .filter((item, idx) => idx < MAX_RECENT_QUERY_SIZE) .filter((item) => item.query.language === currentLanguage) - .map((query) => ({ - id: query.id, + .map((query, idx) => ({ + id: idx, query: query.query.query, timeRange: query.timeRange, time: moment(query.time).format('MMM D, YYYY HH:mm:ss'), diff --git a/src/plugins/data/public/query/query_string/language_service/types.ts b/src/plugins/data/public/query/query_string/language_service/types.ts index dff25464db08..e82e12f95ec9 100644 --- a/src/plugins/data/public/query/query_string/language_service/types.ts +++ b/src/plugins/data/public/query/query_string/language_service/types.ts @@ -13,7 +13,6 @@ import { import { EditorInstance } from '../../../ui/query_editor/editors'; export interface RecentQueryItem { - id: number; query: Query; time: number; timeRange?: TimeRange; diff --git a/src/plugins/data/public/query/query_string/query_history.ts b/src/plugins/data/public/query/query_string/query_history.ts index 48dbf3511744..277287ee09d8 100644 --- a/src/plugins/data/public/query/query_string/query_history.ts +++ b/src/plugins/data/public/query/query_string/query_history.ts @@ -3,7 +3,6 @@ * SPDX-License-Identifier: Apache-2.0 */ -import uuid from 'uuid'; import { BehaviorSubject } from 'rxjs'; import { DataStorage } from '../../../common'; import { Query, TimeRange } from '../..'; @@ -62,7 +61,6 @@ export class QueryHistory { time: timestamp, query, dateRange, - id: uuid.v4(), }; this.storage.set(newKey, newItem);