Skip to content

Commit

Permalink
Hide incompatible index patterns (#354)
Browse files Browse the repository at this point in the history
* Display a message when there is no supported data source

Signed-off-by: Kapian1234 <[email protected]>

* filter out incompatible index patterns

Signed-off-by: Kapian1234 <[email protected]>

* Display a message when there is no supported data source

Signed-off-by: Kapian1234 <[email protected]>

* remove log

Signed-off-by: Kapian1234 <[email protected]>

* remove unused import

Signed-off-by: Kapian1234 <[email protected]>

* add changelog

Signed-off-by: Kapian1234 <[email protected]>

* modify changelog

Signed-off-by: Kapian1234 <[email protected]>

* resolve some issues

Signed-off-by: Kapian1234 <[email protected]>

---------

Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Jincheng Wan <[email protected]>
(cherry picked from commit e3ec245)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
github-actions[bot] committed Oct 21, 2024
1 parent 0dec84f commit 43a2e31
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions public/components/visualization/source_selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import React, { useCallback, useMemo, useState, useEffect, useRef } from 'react';
import { i18n } from '@osd/i18n';

import { useOpenSearchDashboards } from '../../../../../src/plugins/opensearch_dashboards_react/public';
import {
DataSource,
Expand Down Expand Up @@ -139,13 +138,9 @@ export const SourceSelector = ({
}
);
if (!res.exists) {
dataSourceIdToIndexPatternIds[key].forEach((indexPatternId) => {
indexPatternOptions.options.forEach((option) => {
if (option.value === indexPatternId) {
option.disabled = true;
}
});
});
indexPatternOptions.options = indexPatternOptions.options.filter(
(option) => !dataSourceIdToIndexPatternIds[key].includes(option.value)
);
}
}
);
Expand All @@ -171,10 +166,31 @@ export const SourceSelector = ({
dataSources.dataSourceService.reload();
}, [dataSources.dataSourceService]);

const options = useMemo(() => {
if (dataSourceOptions[0] && dataSourceOptions[0].options.length > 0) {
return dataSourceOptions;
}
return [
{
label: i18n.translate('dashboardAssistant.datasource.selector.group.label', {
defaultMessage: 'Index patterns',
}),
options: [
{
label: i18n.translate('dashboardAssistant.datasource.selector.emptyMessage.label', {
defaultMessage: 'No supported index patterns',
}),
disabled: true,
},
],
},
];
}, [dataSourceOptions]);

return (
<DataSourceSelectable
dataSources={currentDataSources}
dataSourceOptionList={dataSourceOptions}
dataSourceOptionList={options}
setDataSourceOptionList={onSetDataSourceOptions}
onDataSourceSelect={onDataSourceSelect}
selectedSources={selectedSources}
Expand Down

0 comments on commit 43a2e31

Please sign in to comment.