From 79361d92cb043659f585b8bab3c36e37c7376d71 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 20 Jul 2023 23:05:48 +0300 Subject: [PATCH] Ensure `No search results found` isn't shown without a search --- ...NoSearchResults.js => NoSearchResults.tsx} | 15 +++++------ frontend/src/Search/SearchIndex.js | 25 +++++++++++-------- 2 files changed, 21 insertions(+), 19 deletions(-) rename frontend/src/Search/{NoSearchResults.js => NoSearchResults.tsx} (63%) diff --git a/frontend/src/Search/NoSearchResults.js b/frontend/src/Search/NoSearchResults.tsx similarity index 63% rename from frontend/src/Search/NoSearchResults.js rename to frontend/src/Search/NoSearchResults.tsx index 03fce4be9..4ffd1d7fd 100644 --- a/frontend/src/Search/NoSearchResults.js +++ b/frontend/src/Search/NoSearchResults.tsx @@ -1,9 +1,12 @@ -import PropTypes from 'prop-types'; import React from 'react'; import translate from 'Utilities/String/translate'; import styles from './NoSearchResults.css'; -function NoSearchResults(props) { +interface NoSearchResultsProps { + totalItems: number; +} + +function NoSearchResults(props: NoSearchResultsProps) { const { totalItems } = props; if (totalItems > 0) { @@ -18,15 +21,9 @@ function NoSearchResults(props) { return (
-
- {translate('NoSearchResultsFound')} -
+
{translate('NoSearchResultsFound')}
); } -NoSearchResults.propTypes = { - totalItems: PropTypes.number.isRequired -}; - export default NoSearchResults; diff --git a/frontend/src/Search/SearchIndex.js b/frontend/src/Search/SearchIndex.js index ba25b0912..3bcceadd5 100644 --- a/frontend/src/Search/SearchIndex.js +++ b/frontend/src/Search/SearchIndex.js @@ -326,15 +326,17 @@ class SearchIndex extends Component { innerClassName={styles.tableInnerContentBody} > { - isFetching && !isPopulated && - + isFetching && !isPopulated ? + : + null } { - !isFetching && !!error && + !isFetching && !!error ? {getErrorMessage(error, 'Failed to load search results from API')} - + : + null } { @@ -359,16 +361,18 @@ class SearchIndex extends Component { } { - !error && !isFetching && !hasIndexers && + !error && !isFetching && !hasIndexers ? + /> : + null } { - !error && !isFetching && hasIndexers && !items.length && - + !error && !isFetching && isPopulated && hasIndexers && !items.length ? + : + null } { - isLoaded && !!jumpBarItems.order.length && + isLoaded && !!jumpBarItems.order.length ? + /> : + null }