mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ES|QL] Hides system indices (#166909)
## Summary
Closes https://github.com/elastic/kibana/issues/166874
Hides indices starting with . (and considered as system from the
autocomplete)
<img width="785" alt="image"
src="9c4cce79
-c844-41b6-a30e-06dad49f7c52">
Followed the exact pattern that the dataview management page is using.
This commit is contained in:
parent
5b24da796d
commit
93ce98831a
3 changed files with 41 additions and 8 deletions
|
@ -5,8 +5,14 @@
|
|||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { parseErrors, parseWarning, getInlineEditorText, getWrappedInPipesCode } from './helpers';
|
||||
import { dataViewPluginMocks } from '@kbn/data-views-plugin/public/mocks';
|
||||
import {
|
||||
parseErrors,
|
||||
parseWarning,
|
||||
getInlineEditorText,
|
||||
getWrappedInPipesCode,
|
||||
getIndicesForAutocomplete,
|
||||
} from './helpers';
|
||||
|
||||
describe('helpers', function () {
|
||||
describe('parseErrors', function () {
|
||||
|
@ -159,4 +165,25 @@ describe('helpers', function () {
|
|||
expect(code).toEqual('FROM index1 | keep field1, field2 | order field1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getIndicesForAutocomplete', function () {
|
||||
it('should not return system indices', async function () {
|
||||
const dataViewsMock = dataViewPluginMocks.createStartContract();
|
||||
const updatedDataViewsMock = {
|
||||
...dataViewsMock,
|
||||
getIndices: jest.fn().mockResolvedValue([
|
||||
{
|
||||
name: '.system1',
|
||||
title: 'system1',
|
||||
},
|
||||
{
|
||||
name: 'logs',
|
||||
title: 'logs',
|
||||
},
|
||||
]),
|
||||
};
|
||||
const indices = await getIndicesForAutocomplete(updatedDataViewsMock);
|
||||
expect(indices).toStrictEqual(['logs']);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,6 +10,7 @@ import { useRef } from 'react';
|
|||
import useDebounce from 'react-use/lib/useDebounce';
|
||||
import { monaco } from '@kbn/monaco';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
|
||||
|
||||
export interface MonacoError {
|
||||
message: string;
|
||||
|
@ -172,3 +173,12 @@ export const getWrappedInPipesCode = (code: string, isWrapped: boolean): string
|
|||
});
|
||||
return codeNoLines.join(isWrapped ? ' | ' : '\n| ');
|
||||
};
|
||||
|
||||
export const getIndicesForAutocomplete = async (dataViews: DataViewsPublicPluginStart) => {
|
||||
const indices = await dataViews.getIndices({
|
||||
showAllIndices: false,
|
||||
pattern: '*',
|
||||
isRollupIndex: () => false,
|
||||
});
|
||||
return indices.filter((index) => !index.name.startsWith('.')).map((i) => i.name);
|
||||
};
|
||||
|
|
|
@ -56,6 +56,7 @@ import {
|
|||
getDocumentationSections,
|
||||
MonacoError,
|
||||
getWrappedInPipesCode,
|
||||
getIndicesForAutocomplete,
|
||||
} from './helpers';
|
||||
import { EditorFooter } from './editor_footer';
|
||||
import { ResizableButton } from './resizable_button';
|
||||
|
@ -371,12 +372,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
|
|||
|
||||
const getSourceIdentifiers: ESQLCustomAutocompleteCallbacks['getSourceIdentifiers'] =
|
||||
useCallback(async () => {
|
||||
const indices = await dataViews.getIndices({
|
||||
showAllIndices: false,
|
||||
pattern: '*',
|
||||
isRollupIndex: () => false,
|
||||
});
|
||||
return indices.map((i) => i.name);
|
||||
return await getIndicesForAutocomplete(dataViews);
|
||||
}, [dataViews]);
|
||||
|
||||
const getFieldsIdentifiers: ESQLCustomAutocompleteCallbacks['getFieldsIdentifiers'] = useCallback(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue