From c5aa711362ba510609ad20912b2d82a9b6aec262 Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Sat, 12 Oct 2024 21:01:59 +0800 Subject: [PATCH] Add data source info in discover url when navigating (#347) (#348) * add data source in url Signed-off-by: tygao * doc: add changelog Signed-off-by: tygao --------- Signed-off-by: tygao (cherry picked from commit f7fde7d52670beb7943565eb6be9144817348b55) Signed-off-by: github-actions[bot] # Conflicts: # CHANGELOG.md Co-authored-by: github-actions[bot] --- public/utils/alerting.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/public/utils/alerting.ts b/public/utils/alerting.ts index 2751e2f4..d5c02cba 100644 --- a/public/utils/alerting.ts +++ b/public/utils/alerting.ts @@ -88,13 +88,17 @@ export const buildUrlQuery = async ( from: timeDsl.from, to: timeDsl.to, }; - let indexPatternTitle = indexPattern.title; + const indexPatternTitle = indexPattern.title; + let dataSource; if (dataSourceId) { try { const dataSourceObject = await savedObjects.client.get('data-source', dataSourceId); - const dataSourceTitle = dataSourceObject?.get('title'); - // If index pattern refers to a data source, discover list will display data source name as dataSourceTitle::indexPatternTitle - indexPatternTitle = `${dataSourceTitle}::${indexPatternTitle}`; + const dataSourceTitle = dataSourceObject?.get('title') ?? ''; + dataSource = { + id: dataSourceId, + title: dataSourceTitle, + type: 'OpenSearch', + }; } catch (e) { console.error('Get data source object error'); } @@ -107,6 +111,7 @@ export const buildUrlQuery = async ( id: indexPattern.id, timeFieldName: indexPattern.timeFieldName, title: indexPatternTitle, + ...(dataSource ? { dataSource } : {}), }, language: 'kuery', query: '',