From 40c930e69320e897759e7eb81552f04fa8b5277d Mon Sep 17 00:00:00 2001 From: lavanya-bmw Date: Fri, 12 Jul 2024 12:44:22 +0530 Subject: [PATCH 1/3] feat(table): updated table component to support error messages --- CHANGELOG.md | 4 +++ package.json | 2 +- .../components/Error/Error400Overlay.tsx | 21 +++++++---- .../components/Error/Error500Overlay.tsx | 10 ++++-- src/components/basic/Table/index.tsx | 35 +++++++++++-------- 5 files changed, 49 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12396438..893745fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.0.26 + +- Updated table component to support error messages + ## 3.0.25 - Updated images for markdown files diff --git a/package.json b/package.json index 82861b94..762f5f75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@catena-x/portal-shared-components", - "version": "3.0.25", + "version": "3.0.26", "description": "Catena-X Portal Shared Components", "author": "Catena-X Contributors", "license": "Apache-2.0", diff --git a/src/components/basic/Table/components/Error/Error400Overlay.tsx b/src/components/basic/Table/components/Error/Error400Overlay.tsx index be08c2ca..16fb23ee 100644 --- a/src/components/basic/Table/components/Error/Error400Overlay.tsx +++ b/src/components/basic/Table/components/Error/Error400Overlay.tsx @@ -36,7 +36,11 @@ const flexColumn = { alignItems: 'center', } -export const Error400Overlay = () => ( +export const Error400Overlay = ({ + errorMessage4xx, +}: { + errorMessage4xx?: string +}) => ( ( - - Something went wrong. Please contact - - your administrator + {errorMessage4xx ? ( + {errorMessage4xx} + ) : ( + <> + + Something went wrong. Please contact + + your administrator + + )} ) diff --git a/src/components/basic/Table/components/Error/Error500Overlay.tsx b/src/components/basic/Table/components/Error/Error500Overlay.tsx index 05d9c283..3b111e1f 100644 --- a/src/components/basic/Table/components/Error/Error500Overlay.tsx +++ b/src/components/basic/Table/components/Error/Error500Overlay.tsx @@ -29,7 +29,13 @@ const flexColumn = { alignItems: 'center', } -export const Error500Overlay = ({ reload }: { reload: () => void }) => ( +export const Error500Overlay = ({ + reload, + errorMessage5xx, +}: { + reload: () => void + errorMessage5xx?: string +}) => ( void }) => ( }} variant="body2" > - Load Failed. Reload + {errorMessage5xx ?? 'Load Failed. Reload'}
void autoFocus?: boolean @@ -175,6 +176,25 @@ export const Table = ({ } } + const renderErrorMessage = () => { + if (error == null) { + return {noRowsMsg ?? 'No rows'} + } else if (error != null) { + if (error.status >= 400 && error.status < 500) { + return + } else { + return ( + { + reload?.() + }} + errorMessage5xx={error.message} + /> + ) + } + } + } + const NoRowsOverlay = () => { return ( - {error != null && error.status === 500 && ( - { - reload?.() - }} - /> - )} - {error != null && - (error.status === 400 || - error.status === 404 || - error.status === 401) && } - {error == null && ( - {noRowsMsg ?? 'No rows'} - )} + {renderErrorMessage()} ) } From 4e93f0dc4d8b0f8cc9a608b2a4a384e073bebda0 Mon Sep 17 00:00:00 2001 From: lavanya-bmw Date: Fri, 12 Jul 2024 13:46:36 +0530 Subject: [PATCH 2/3] fix(semantic hub): remove condition --- src/components/basic/Table/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/basic/Table/index.tsx b/src/components/basic/Table/index.tsx index e4ebb8af..5b21423f 100644 --- a/src/components/basic/Table/index.tsx +++ b/src/components/basic/Table/index.tsx @@ -179,7 +179,7 @@ export const Table = ({ const renderErrorMessage = () => { if (error == null) { return {noRowsMsg ?? 'No rows'} - } else if (error != null) { + } else { if (error.status >= 400 && error.status < 500) { return } else { From cf4f646f70f3dbe9a50528e19aff5dc4ccd9765e Mon Sep 17 00:00:00 2001 From: lavanya-bmw Date: Fri, 12 Jul 2024 18:30:58 +0530 Subject: [PATCH 3/3] fix(semantic hub): review changes --- src/components/basic/Table/index.tsx | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/components/basic/Table/index.tsx b/src/components/basic/Table/index.tsx index 5b21423f..5a496074 100644 --- a/src/components/basic/Table/index.tsx +++ b/src/components/basic/Table/index.tsx @@ -179,20 +179,18 @@ export const Table = ({ const renderErrorMessage = () => { if (error == null) { return {noRowsMsg ?? 'No rows'} - } else { - if (error.status >= 400 && error.status < 500) { - return - } else { - return ( - { - reload?.() - }} - errorMessage5xx={error.message} - /> - ) - } } + if (error.status >= 400 && error.status < 500) { + return + } + return ( + { + reload?.() + }} + errorMessage5xx={error.message} + /> + ) } const NoRowsOverlay = () => {