Skip to content

Commit

Permalink
[Fleet] Remove usage of IFieldType in Fleet (elastic#123960)
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet authored and awahab07 committed Jan 31, 2022
1 parent 2200c5a commit 2e1172a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useState, useEffect, useMemo } from 'react';

import { fromKueryExpression } from '@kbn/es-query';

import type { IFieldType } from '../../../../../../../src/plugins/data/public';
import type { FieldSpec } from '../../../../../../../src/plugins/data/common';
import { QueryStringInput } from '../../../../../../../src/plugins/data/public';
import { useStartServices } from '../hooks';
import { INDEX_NAME, AGENTS_PREFIX } from '../constants';
Expand All @@ -32,7 +32,7 @@ export const SearchBar: React.FunctionComponent<Props> = ({
indexPattern = INDEX_NAME,
}) => {
const { data } = useStartServices();
const [indexPatternFields, setIndexPatternFields] = useState<IFieldType[]>();
const [indexPatternFields, setIndexPatternFields] = useState<FieldSpec[]>();

const isQueryValid = useMemo(() => {
if (!value || value === '') {
Expand All @@ -50,7 +50,7 @@ export const SearchBar: React.FunctionComponent<Props> = ({
useEffect(() => {
const fetchFields = async () => {
try {
const _fields: IFieldType[] = await data.indexPatterns.getFieldsForWildcard({
const _fields: FieldSpec[] = await data.dataViews.getFieldsForWildcard({
pattern: indexPattern,
});
const fields = (_fields || []).filter((field) => {
Expand All @@ -69,7 +69,7 @@ export const SearchBar: React.FunctionComponent<Props> = ({
}
};
fetchFields();
}, [data.indexPatterns, fieldPrefix, indexPattern]);
}, [data.dataViews, fieldPrefix, indexPattern]);

return (
<QueryStringInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React, { memo, useState, useEffect } from 'react';
import { i18n } from '@kbn/i18n';

import type { IFieldType } from '../../../../../../../../../../../src/plugins/data/public';
import type { FieldSpec } from '../../../../../../../../../../../src/plugins/data/common';
import { QueryStringInput } from '../../../../../../../../../../../src/plugins/data/public';
import { useStartServices } from '../../../../../hooks';

Expand All @@ -27,15 +27,15 @@ export const LogQueryBar: React.FunctionComponent<{
onUpdateQuery: (query: string, runQuery?: boolean) => void;
}> = memo(({ query, isQueryValid, onUpdateQuery }) => {
const { data } = useStartServices();
const [indexPatternFields, setIndexPatternFields] = useState<IFieldType[]>();
const [indexPatternFields, setIndexPatternFields] = useState<FieldSpec[]>();

useEffect(() => {
const fetchFields = async () => {
try {
const fields = (
((await data.indexPatterns.getFieldsForWildcard({
(await data.dataViews.getFieldsForWildcard({
pattern: AGENT_LOG_INDEX_PATTERN,
})) as IFieldType[]) || []
})) || []
).filter((field) => {
return !EXCLUDED_FIELDS.includes(field.name);
});
Expand All @@ -45,7 +45,7 @@ export const LogQueryBar: React.FunctionComponent<{
}
};
fetchFields();
}, [data.indexPatterns]);
}, [data.dataViews]);

return (
<QueryStringInput
Expand Down

0 comments on commit 2e1172a

Please sign in to comment.