diff --git a/packages/strapi-plugin-upload/admin/src/components/BrowseAssets/index.js b/packages/strapi-plugin-upload/admin/src/components/BrowseAssets/index.js index 6423f6c495..df77788848 100644 --- a/packages/strapi-plugin-upload/admin/src/components/BrowseAssets/index.js +++ b/packages/strapi-plugin-upload/admin/src/components/BrowseAssets/index.js @@ -1,7 +1,6 @@ import React from 'react'; - +import { isEmpty } from 'lodash'; import { PageFooter } from 'strapi-helper-plugin'; - import { generatePageFromStart, generateStartFromPage } from '../../utils'; import Filters from '../Filters'; import Flex from '../Flex'; @@ -76,6 +75,10 @@ const BrowseAssets = () => { hasSomeCheckboxSelected; const canSelectFile = multiple === true || (selectedFiles.length < 1 && !multiple); + const hasFilters = !isEmpty(params.filters.filter(filter => !filter.isDisabled)); + const hasSearch = !isEmpty(params._q); + const areResultsEmptyWithSearchOrFilters = isEmpty(files) && (hasSearch || hasFilters); + return ( @@ -99,7 +102,11 @@ const BrowseAssets = () => { {!files || files.length === 0 ? ( - + ) : ( { +const ListEmpty = ({ hasSearchApplied, onClick, numberOfRows }) => { const rows = generateRows(numberOfRows); + const titleId = hasSearchApplied + ? 'list.assets-empty.title-withSearch' + : 'list.assets-empty.title'; + const subtitleId = 'list.assets-empty.subtitle'; + const prefixedTitleId = getTrad(titleId); + const prefixedSubtitleId = getTrad(subtitleId); return ( @@ -29,23 +35,30 @@ const ListEmpty = ({ onClick, numberOfRows }) => { ); })}
- - -
- + + + {!hasSearchApplied && ( + <> + +
+ + + )}
); }; ListEmpty.defaultProps = { + hasSearchApplied: false, onClick: () => {}, numberOfRows: 3, }; ListEmpty.propTypes = { + hasSearchApplied: PropTypes.bool, onClick: PropTypes.func, numberOfRows: PropTypes.number, }; diff --git a/packages/strapi-plugin-upload/admin/src/containers/HomePage/index.js b/packages/strapi-plugin-upload/admin/src/containers/HomePage/index.js index 3fe3e83026..55e1ee23b7 100644 --- a/packages/strapi-plugin-upload/admin/src/containers/HomePage/index.js +++ b/packages/strapi-plugin-upload/admin/src/containers/HomePage/index.js @@ -1,5 +1,5 @@ import React, { useReducer, useState, useEffect } from 'react'; -import { includes, toString } from 'lodash'; +import { includes, isEmpty, toString } from 'lodash'; import { useHistory, useLocation } from 'react-router-dom'; import { Header } from '@buffetjs/custom'; import { useDebounce, useIsMounted } from '@buffetjs/hooks'; @@ -327,6 +327,11 @@ const HomePage = () => { return ; } + const filters = generateFiltersFromSearch(search); + const hasFilters = !isEmpty(filters); + const hasSearch = !isEmpty(searchValue); + const areResultsEmptyWithSearchOrFilters = isEmpty(data) && (hasSearch || hasFilters); + return (
@@ -345,13 +350,9 @@ const HomePage = () => { someChecked={hasSomeCheckboxSelected && !areAllCheckboxesSelected} /> - + - {dataCount > 0 ? ( + {dataCount > 0 && !areResultsEmptyWithSearchOrFilters ? ( <> { /> ) : ( - + )}