Skip to content

Commit

Permalink
Set default index pattern when workspace disabled
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <[email protected]>
  • Loading branch information
wanglam committed Nov 22, 2024
1 parent 7cb72a2 commit 9119767
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/plugins/home/public/application/sample_data_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Check warning on line 46 in src/plugins/home/public/application/sample_data_client.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/home/public/application/sample_data_client.js#L45-L46

Added lines #L45 - L46 were not covered by tests
};

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')) {

Check warning on line 53 in src/plugins/home/public/application/sample_data_client.js

View check run for this annotation

Codecov / codecov/patch

src/plugins/home/public/application/sample_data_client.js#L53

Added line #L53 was not covered by tests
getServices().uiSettings.set('defaultIndex', sampleDataDefaultIndex);
}

Expand All @@ -59,6 +64,7 @@ export async function uninstallSampleDataSet(id, sampleDataDefaultIndex, dataSou
const uiSettings = getServices().uiSettings;

if (
!isWorkspaceEnabled() &&
!uiSettings.isDefault('defaultIndex') &&
uiSettings.get('defaultIndex') === sampleDataDefaultIndex
) {
Expand Down

0 comments on commit 9119767

Please sign in to comment.