diff --git a/public/components/query_compare/search_result/index.tsx b/public/components/query_compare/search_result/index.tsx index e9a65d3..d5573b8 100644 --- a/public/components/query_compare/search_result/index.tsx +++ b/public/components/query_compare/search_result/index.tsx @@ -11,7 +11,7 @@ import { SearchConfigsPanel } from './search_components/search_configs/search_co import { SearchInputBar } from './search_components/search_bar'; import { ServiceEndpoints } from '../../../../common'; import { Header } from '../../common/header'; -import { SearchResults, QueryError, QueryStringError } from '../../../types/index'; +import { SearchResults, QueryError, QueryStringError, SelectIndexError } from '../../../types/index'; import { ResultComponents } from './result_components/result_components'; import { useSearchRelevanceContext, initialQueryErrorState } from '../../../contexts'; @@ -53,7 +53,7 @@ export const SearchResult = ({ http }: SearchResultProps) => { const validateQuery = (selectedIndex: string, queryString: string, queryError: QueryError) => { // Check if select an index if (!selectedIndex.length) { - queryError.selectIndex = 'An index is required. Select an index.'; + queryError.selectIndex = SelectIndexError.unselected; } // Check if query string is empty diff --git a/public/components/query_compare/search_result/search_components/search_configs/search_config.tsx b/public/components/query_compare/search_result/search_components/search_configs/search_config.tsx index 8f98e55..5fc8cd1 100644 --- a/public/components/query_compare/search_result/search_components/search_configs/search_config.tsx +++ b/public/components/query_compare/search_result/search_components/search_configs/search_config.tsx @@ -15,7 +15,7 @@ import { } from '@elastic/eui'; import { useSearchRelevanceContext } from '../../../../../contexts'; -import { QueryError, QueryStringError } from '../../../../../types/index'; +import { QueryError, QueryStringError, SelectIndexError } from '../../../../../types/index'; interface SearchConfigProps { queryNumber: 1 | 2; @@ -54,7 +54,7 @@ export const SearchConfig: FunctionComponent = ({ if (!selectedIndex.length) { setQueryError({ ...queryError, - selectIndex: 'An index is required. Select an index.', + selectIndex: SelectIndexError.unselected, }); } }; diff --git a/public/types/index.ts b/public/types/index.ts index 865ec41..e1dbffe 100644 --- a/public/types/index.ts +++ b/public/types/index.ts @@ -45,12 +45,16 @@ export interface SearchResults { }; } +export enum SelectIndexError { + unselected = 'An index is required to compare search results. Select an index.' +} + export enum QueryStringError { empty = 'A query is required. Enter a query.', invalid = 'Query syntax is invalid. Enter a valid query.', } export interface QueryError { - selectIndex: 'An index is required. Select an index.' | ''; + selectIndex: SelectIndexError | string; queryString: QueryStringError | string; }