From 91197673e3e6ad2e581325b7ec805c6ac7cee484 Mon Sep 17 00:00:00 2001 From: Lin Wang Date: Fri, 22 Nov 2024 12:08:02 +0800 Subject: [PATCH] Set default index pattern when workspace disabled Signed-off-by: Lin Wang --- src/plugins/home/public/application/sample_data_client.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/plugins/home/public/application/sample_data_client.js b/src/plugins/home/public/application/sample_data_client.js index 045736c428f6..51a387675219 100644 --- a/src/plugins/home/public/application/sample_data_client.js +++ b/src/plugins/home/public/application/sample_data_client.js @@ -41,11 +41,16 @@ export async function listSampleDataSets(dataSourceId) { return await getServices().http.get(sampleDataUrl, { query }); } +const isWorkspaceEnabled = () => { + const workspaces = getServices().application.capabilities.workspaces; + return !!(workspaces && workspaces.enabled); +}; + export async function installSampleDataSet(id, sampleDataDefaultIndex, dataSourceId) { const query = buildQuery(dataSourceId); await getServices().http.post(`${sampleDataUrl}/${id}`, { query }); - if (getServices().uiSettings.isDefault('defaultIndex')) { + if (!isWorkspaceEnabled() && getServices().uiSettings.isDefault('defaultIndex')) { getServices().uiSettings.set('defaultIndex', sampleDataDefaultIndex); } @@ -59,6 +64,7 @@ export async function uninstallSampleDataSet(id, sampleDataDefaultIndex, dataSou const uiSettings = getServices().uiSettings; if ( + !isWorkspaceEnabled() && !uiSettings.isDefault('defaultIndex') && uiSettings.get('defaultIndex') === sampleDataDefaultIndex ) {