From a377ff433666514360366f9befc77e5f77324e89 Mon Sep 17 00:00:00 2001 From: Usmanfee Date: Wed, 19 Mar 2025 13:21:40 +0100 Subject: [PATCH 1/3] chore: empty table messages --- src/components/basic/Table/PageLoadingTable.tsx | 17 +++++++++++++++++ src/components/basic/Table/index.tsx | 14 +++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/components/basic/Table/PageLoadingTable.tsx b/src/components/basic/Table/PageLoadingTable.tsx index 8dac8310..9f46fb54 100644 --- a/src/components/basic/Table/PageLoadingTable.tsx +++ b/src/components/basic/Table/PageLoadingTable.tsx @@ -53,6 +53,8 @@ export interface PageLoadingTableProps allItems?: Row[] callbackToPage?: (data: PaginResult) => void allItemsLoadedHint?: string + emptyDataMsg: string + noSearchResultsMsg: string } const scrollOffset = 350 // Adjust this value for earlier load @@ -65,6 +67,8 @@ export const PageLoadingTable = function ({ allItems, callbackToPage, allItemsLoadedHint = 'All items have been loaded.', + emptyDataMsg, + noSearchResultsMsg, ...props }: PageLoadingTableProps) { const [page, setPage] = useState(0) @@ -79,12 +83,14 @@ export const PageLoadingTable = function ({ }, }) const [loading, setLoading] = useState(true) + const [noRowsMsg, setNoRowsMsg] = useState('') function nextPage() { setPage(page + 1) } const hasMore = data ? hasMorePages(data) : false const maxRows = data ? getMaxRows(data) : 0 + const { searchExpr } = props useEffect(() => { if (!allItems) { @@ -130,6 +136,16 @@ export const PageLoadingTable = function ({ } }, [isSuccess, isFetching, data, clear, loaded]) + useEffect(() => { + if (data) { + if (!searchExpr && data.content.length === 0) { + setNoRowsMsg(emptyDataMsg) + } else if (searchExpr && data.content.length === 0) { + setNoRowsMsg(noSearchResultsMsg) + } + } + }, [data, searchExpr]) + const handleScroll = useCallback(() => { const scrollableElement = document.documentElement if ( @@ -159,6 +175,7 @@ export const PageLoadingTable = function ({ error={error} rows={items} reload={refetch} + noRowsMsg={noRowsMsg} {...props} /> {/* Display loading spinner while fetching data */} diff --git a/src/components/basic/Table/index.tsx b/src/components/basic/Table/index.tsx index 0f22ebd8..b8aebfd6 100644 --- a/src/components/basic/Table/index.tsx +++ b/src/components/basic/Table/index.tsx @@ -195,7 +195,19 @@ export const Table = ({ const renderErrorMessage = () => { if (rowsCount === 0 || error == null) { - return {noRowsMsg ?? 'No rows'} + if (noRowsMsg && noRowsMsg.includes('\n')) { + const messageParts = noRowsMsg.split(/[\n|]/) + return ( + + {messageParts.map((part, index) => ( + + {part.trim()} + + ))} + + ) + } + return <> } if (error.status >= 400 && error.status < 500) { return From 36387bd32f52d7826c3674f3eaf9250e8b22a32c Mon Sep 17 00:00:00 2001 From: Usmanfee Date: Wed, 19 Mar 2025 17:20:51 +0100 Subject: [PATCH 2/3] chore(fix): fallback table messages --- src/components/basic/Table/PageLoadingTable.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/basic/Table/PageLoadingTable.tsx b/src/components/basic/Table/PageLoadingTable.tsx index 9f46fb54..a7d69c3d 100644 --- a/src/components/basic/Table/PageLoadingTable.tsx +++ b/src/components/basic/Table/PageLoadingTable.tsx @@ -53,8 +53,8 @@ export interface PageLoadingTableProps allItems?: Row[] callbackToPage?: (data: PaginResult) => void allItemsLoadedHint?: string - emptyDataMsg: string - noSearchResultsMsg: string + emptyDataMsg?: string + noSearchResultsMsg?: string } const scrollOffset = 350 // Adjust this value for earlier load @@ -67,8 +67,8 @@ export const PageLoadingTable = function ({ allItems, callbackToPage, allItemsLoadedHint = 'All items have been loaded.', - emptyDataMsg, - noSearchResultsMsg, + emptyDataMsg = 'No data found', + noSearchResultsMsg = 'No search results found', ...props }: PageLoadingTableProps) { const [page, setPage] = useState(0) From 7f05958ab6a1bbd9193f4d6b7a37023f5c89a9b2 Mon Sep 17 00:00:00 2001 From: Usmanfee Date: Fri, 7 Nov 2025 16:49:52 +0100 Subject: [PATCH 3/3] chore: updated changelog --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc47ee9d..6dd62cdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ ## [3.7.6](https://github.com/eclipse-tractusx/portal-shared-components/compare/v3.7.5...v3.7.6) (2025-02-13) + ### Bug Fixes * upgrade storybook to version 8.5.3 ([4f4df10](https://github.com/eclipse-tractusx/portal-shared-components/commit/4f4df107bf6ca02ca959660c121f4dc18ac7b10a)) @@ -43,6 +44,9 @@ * upgrade storybook to version 8.5.3 ([6cccaec](https://github.com/eclipse-tractusx/portal-shared-components/commit/6cccaec07fd20259fc9568ffc1e4a430203200e9)) ## [3.7.5](https://github.com/eclipse-tractusx/portal-shared-components/compare/v3.7.4...v3.7.5) (2025-01-20) +- **Table Empty Text** [4.0.3] + - fixed empty table messages with consistency [#446](https://github.com/eclipse-tractusx/portal-shared-components/pull/446) + ### Bug Fixes diff --git a/package.json b/package.json index a1a6b036..7ed5c643 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@catena-x/portal-shared-components", - "version": "4.0.2", + "version": "4.0.3", "description": "Eclipse Tractus-X Portal Shared Components", "author": "Eclipse Tractus-X Contributors", "license": "Apache-2.0",