Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] Changing select index error message to be more informative (#173) #275

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/components/query_compare/search_result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -54,7 +54,7 @@ export const SearchConfig: FunctionComponent<SearchConfigProps> = ({
if (!selectedIndex.length) {
setQueryError({
...queryError,
selectIndex: 'An index is required. Select an index.',
selectIndex: SelectIndexError.unselected,
});
}
};
Expand Down
6 changes: 5 additions & 1 deletion public/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}