From d8d5d4c3a16c9f47f4c53774366d6151f30ddc77 Mon Sep 17 00:00:00 2001 From: Georgii Karataev Date: Thu, 14 Dec 2023 21:03:16 +0100 Subject: [PATCH] fix(RHINENG-715): Redirect on incorrect group id Fixes https://issues.redhat.com/browse/RHINENG-715. This will redirect to /groups when user enters the group details page with incorrect group UUID. --- .../InventoryGroupDetail/InventoryGroupDetail.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/InventoryGroupDetail/InventoryGroupDetail.js b/src/components/InventoryGroupDetail/InventoryGroupDetail.js index 23369ef01..9fee6fb1c 100644 --- a/src/components/InventoryGroupDetail/InventoryGroupDetail.js +++ b/src/components/InventoryGroupDetail/InventoryGroupDetail.js @@ -41,7 +41,9 @@ const InventoryGroupDetail = ({ groupId }) => { ); const dispatch = useDispatch(); - const { data, fulfilled } = useSelector((state) => state.groupDetail); + const { data, fulfilled, rejected, error } = useSelector( + (state) => state.groupDetail + ); const navigate = useInsightsNavigate(); const chrome = useChrome(); @@ -107,8 +109,10 @@ const InventoryGroupDetail = ({ groupId }) => { } }, [data]); - if (fulfilled && data?.total === 0) { - // group does not exist + if ( + (fulfilled && data.total === 0) || // group does not exist + (rejected && error.status === 400) // group name not correct + ) { navigate('/groups'); }