Skip to content

Commit

Permalink
fix(RHINENG-715): Redirect on incorrect group id
Browse files Browse the repository at this point in the history
Fixes https://issues.redhat.com/browse/RHINENG-715.

This will redirect to /groups when user enters the group details page with incorrect group UUID.
  • Loading branch information
gkarat committed Dec 19, 2023
1 parent 1d6e1d6 commit d8d5d4c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/InventoryGroupDetail/InventoryGroupDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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');
}

Expand Down

0 comments on commit d8d5d4c

Please sign in to comment.