diff --git a/src/components/Home/Home.jsx b/src/components/Home/Home.jsx index 8da2eddc..83306021 100644 --- a/src/components/Home/Home.jsx +++ b/src/components/Home/Home.jsx @@ -200,11 +200,16 @@ function Home() { navigate({ pathname: `/explore`, search: createSearchParams({ [type]: value }).toString() }); }; - const renderCards = (cardArray, isLoading) => { - if (cardArray && cardArray.length < 1 && !isLoading) { - return ; - } + const isNoData = () => + !isLoading && + !isLoadingBookmarks && + !isLoadingPopular && + !isLoadingRecent && + bookmarkData.length === 0 && + popularData.length === 0 && + recentData.length === 0; + const renderCards = (cardArray) => { return ( cardArray && cardArray.map((item, index) => { @@ -232,68 +237,68 @@ function Home() { ); }; - return ( - <> - {isLoading ? ( - - ) : ( - - -
- - Most popular images - -
-
handleClickViewAll('sortby', sortByCriteria.downloads.value)}> - - View all - -
-
- {isLoadingPopular ? : renderCards(popularData, isLoadingPopular)} - {/* currently most popular will be by downloads until stars are implemented */} - -
- - Recently updated images - -
-
- handleClickViewAll('sortby', sortByCriteria.updateTime.value)} - > - View all - -
-
- {isLoadingRecent ? : renderCards(recentData, isLoadingRecent)} - {!isEmpty(bookmarkData) && ( - <> - -
- - Bookmarks - -
-
- handleClickViewAll('filter', 'IsBookmarked')} - > - View all - -
-
- {isLoadingBookmarks ? : renderCards(bookmarkData, isLoadingBookmarks)} - - )} + const renderContent = () => { + return isNoData() === true ? ( + + ) : ( + + +
+ + Most popular images + +
+
handleClickViewAll('sortby', sortByCriteria.downloads.value)}> + + View all + +
+
+ {isLoadingPopular ? : renderCards(popularData, isLoadingPopular)} + {/* currently most popular will be by downloads until stars are implemented */} + +
+ + Recently updated images + +
+
+ handleClickViewAll('sortby', sortByCriteria.updateTime.value)} + > + View all + +
- )} - - ); + {isLoadingRecent ? : renderCards(recentData, isLoadingRecent)} + {!isEmpty(bookmarkData) && ( + <> + +
+ + Bookmarks + +
+
+ handleClickViewAll('filter', 'IsBookmarked')} + > + View all + +
+
+ {isLoadingBookmarks ? : renderCards(bookmarkData, isLoadingBookmarks)} + + )} +
+ ); + }; + + return <>{isLoading ? : renderContent()}; } export default Home; diff --git a/tests/values/test-constants.js b/tests/values/test-constants.js index 63ca2ce9..a05e302a 100644 --- a/tests/values/test-constants.js +++ b/tests/values/test-constants.js @@ -23,9 +23,9 @@ const endpoints = { globalSearch: (searchTerm, sortCriteria, pageNumber = 1, pageSize = 10) => `/v2/_zot/ext/search?query={GlobalSearch(query:%22${searchTerm}%22,%20requestedPage:%20{limit:${pageSize}%20offset:${ 10 * (pageNumber - 1) - }%20sortBy:%20${sortCriteria}}%20)%20{Page%20{TotalCount%20ItemCount}%20Repos%20{Name%20LastUpdated%20Size%20Platforms%20{%20Os%20Arch%20}%20IsStarred%20IsBookmarked%20NewestImage%20{%20Tag%20Vulnerabilities%20{MaxSeverity%20Count}%20Description%20IsSigned%20Licenses%20Vendor%20Labels%20}%20DownloadCount}}}`, + }%20sortBy:%20${sortCriteria}}%20)%20{Page%20{TotalCount%20ItemCount}%20Repos%20{Name%20LastUpdated%20Size%20Platforms%20{%20Os%20Arch%20}%20IsStarred%20IsBookmarked%20NewestImage%20{%20Tag%20Vulnerabilities%20{MaxSeverity%20Count}%20Description%20IsSigned%20SignatureInfo%20{%20Tool%20IsTrusted%20Author%20}%20Licenses%20Vendor%20Labels%20}%20DownloadCount}}}`, image: (name) => - `/v2/_zot/ext/search?query={Image(image:%20%22${name}%22){RepoName%20IsSigned%20Vulnerabilities%20{MaxSeverity%20Count}%20%20Referrers%20{MediaType%20ArtifactType%20Size%20Digest%20Annotations{Key%20Value}}%20Tag%20Manifests%20{History%20{Layer%20{Size%20Digest}%20HistoryDescription%20{CreatedBy%20EmptyLayer}}%20Digest%20ConfigDigest%20LastUpdated%20Size%20Platform%20{Os%20Arch}}%20Vendor%20Licenses%20}}` + `/v2/_zot/ext/search?query={Image(image:%20%22${name}%22){RepoName%20IsSigned%20SignatureInfo%20{%20Tool%20IsTrusted%20Author%20}%20Vulnerabilities%20{MaxSeverity%20Count}%20%20Referrers%20{MediaType%20ArtifactType%20Size%20Digest%20Annotations{Key%20Value}}%20Tag%20Manifests%20{History%20{Layer%20{Size%20Digest}%20HistoryDescription%20{CreatedBy%20EmptyLayer}}%20Digest%20ConfigDigest%20LastUpdated%20Size%20Platform%20{Os%20Arch}}%20Vendor%20Licenses%20}}` }; export { hosts, endpoints, sortCriteria, pageSizes };