From 8f3bf88a759422ef36307bafcc26c38d5ddb15d5 Mon Sep 17 00:00:00 2001 From: Evan Kielley Date: Fri, 1 Sep 2023 13:46:57 -0700 Subject: [PATCH 1/3] Changing select index error message to be more informative (#173) Signed-off-by: Evan Kielley --- .../query_compare/search_result/index.tsx | 2 +- .../search_configs/search_config.tsx | 2 +- public/types/index.ts | 2 +- yarn.lock | 37 +++---------------- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/public/components/query_compare/search_result/index.tsx b/public/components/query_compare/search_result/index.tsx index e9a65d3..7df38e7 100644 --- a/public/components/query_compare/search_result/index.tsx +++ b/public/components/query_compare/search_result/index.tsx @@ -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 = 'An index is required to compare search results. Select an index.'; } // 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..17c6461 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 @@ -54,7 +54,7 @@ export const SearchConfig: FunctionComponent = ({ if (!selectedIndex.length) { setQueryError({ ...queryError, - selectIndex: 'An index is required. Select an index.', + selectIndex: 'An index is required to compare search results. Select an index.', }); } }; diff --git a/public/types/index.ts b/public/types/index.ts index 865ec41..716c4ae 100644 --- a/public/types/index.ts +++ b/public/types/index.ts @@ -51,6 +51,6 @@ export enum QueryStringError { } export interface QueryError { - selectIndex: 'An index is required. Select an index.' | ''; + selectIndex: 'An index is required to compare search results. Select an index.' | ''; queryString: QueryStringError | string; } diff --git a/yarn.lock b/yarn.lock index c1dad26..de5f176 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1350,7 +1350,7 @@ proxy-from-env@1.0.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" integrity sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A== -psl@^1.1.33: +psl@^1.1.28: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -1373,11 +1373,6 @@ qs@~6.5.2, qs@~6.5.3: resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== -querystringify@^2.1.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" - integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== - regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -1390,11 +1385,6 @@ request-progress@^3.0.0: dependencies: throttleit "^1.0.0" -requires-port@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" - integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== - resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -1651,15 +1641,13 @@ tmp@~0.2.1: dependencies: rimraf "^3.0.0" -tough-cookie@^4.1.3: - version "4.1.3" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf" - integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw== +tough-cookie@~2.5.0: + version "2.5.0" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" + integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== dependencies: - psl "^1.1.33" + psl "^1.1.28" punycode "^2.1.1" - universalify "^0.2.0" - url-parse "^1.5.3" tslib@^1.9.0: version "1.14.1" @@ -1700,11 +1688,6 @@ type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== -universalify@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0" - integrity sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg== - universalify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" @@ -1722,14 +1705,6 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -url-parse@^1.5.3: - version "1.5.10" - resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1" - integrity sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ== - dependencies: - querystringify "^2.1.1" - requires-port "^1.0.0" - uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" From 21798d4adbcb6a0d69e528955e08051bbf1a6e2b Mon Sep 17 00:00:00 2001 From: Evan Kielley Date: Tue, 5 Sep 2023 11:10:07 -0700 Subject: [PATCH 2/3] Changing select index error message to be a constant to keep code DRY (#173) Signed-off-by: Evan Kielley --- public/components/query_compare/search_result/index.tsx | 4 ++-- .../search_components/search_configs/search_config.tsx | 4 ++-- public/types/index.ts | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/public/components/query_compare/search_result/index.tsx b/public/components/query_compare/search_result/index.tsx index 7df38e7..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 to compare search results. 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 17c6461..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 to compare search results. Select an index.', + selectIndex: SelectIndexError.unselected, }); } }; diff --git a/public/types/index.ts b/public/types/index.ts index 716c4ae..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 to compare search results. Select an index.' | ''; + selectIndex: SelectIndexError | string; queryString: QueryStringError | string; } From b18f4addf19b6c7ce4e3b1fb8113d740fef48842 Mon Sep 17 00:00:00 2001 From: Evan Kielley Date: Tue, 5 Sep 2023 14:40:22 -0700 Subject: [PATCH 3/3] Reverting change to yarn.lock Signed-off-by: Evan Kielley --- yarn.lock | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index de5f176..c1dad26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1350,7 +1350,7 @@ proxy-from-env@1.0.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.0.0.tgz#33c50398f70ea7eb96d21f7b817630a55791c7ee" integrity sha512-F2JHgJQ1iqwnHDcQjVBsq3n/uoaFL+iPW/eAeL7kVxy/2RrWaN4WroKjjvbsoRtv0ftelNyC01bjRhn/bhcf4A== -psl@^1.1.28: +psl@^1.1.33: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== @@ -1373,6 +1373,11 @@ qs@~6.5.2, qs@~6.5.3: resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== +querystringify@^2.1.1: + version "2.2.0" + resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" + integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== + regexpp@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f" @@ -1385,6 +1390,11 @@ request-progress@^3.0.0: dependencies: throttleit "^1.0.0" +requires-port@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== + resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" @@ -1641,13 +1651,15 @@ tmp@~0.2.1: dependencies: rimraf "^3.0.0" -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== +tough-cookie@^4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.3.tgz#97b9adb0728b42280aa3d814b6b999b2ff0318bf" + integrity sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw== dependencies: - psl "^1.1.28" + psl "^1.1.33" punycode "^2.1.1" + universalify "^0.2.0" + url-parse "^1.5.3" tslib@^1.9.0: version "1.14.1" @@ -1688,6 +1700,11 @@ type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== +universalify@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0" + integrity sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg== + universalify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717" @@ -1705,6 +1722,14 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" +url-parse@^1.5.3: + version "1.5.10" + resolved "https://registry.yarnpkg.com/url-parse/-/url-parse-1.5.10.tgz#9d3c2f736c1d75dd3bd2be507dcc111f1e2ea9c1" + integrity sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ== + dependencies: + querystringify "^2.1.1" + requires-port "^1.0.0" + uuid@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"