Skip to content

Commit

Permalink
fix(productViewMissing): sw-625 local dev view, run
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Mar 2, 2023
1 parent 636bf16 commit 0feb615
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/components/productView/productViewMissing.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useLayoutEffect } from 'react';
import PropTypes from 'prop-types';
import { Button, Card, CardBody, CardFooter, CardTitle, Gallery, Title, PageSection } from '@patternfly/react-core';
import { ArrowRightIcon } from '@patternfly/react-icons';
Expand Down Expand Up @@ -31,10 +31,16 @@ const ProductViewMissing = ({
}) => {
const navigate = useAliasNavigate();
const { firstMatch, allConfigs } = useAliasRouteDetail();
const availableProducts = (firstMatch && [firstMatch]) || allConfigs;
const availableProducts = (!helpers.DEV_MODE && firstMatch && [firstMatch]) || allConfigs;
const isRedirect = availableProducts?.length <= availableProductsRedirect;

if (availableProducts?.length <= availableProductsRedirect) {
navigate(availableProducts[0].productPath);
useLayoutEffect(() => {
if (isRedirect) {
navigate(availableProducts[0].productPath);
}
});

if (isRedirect) {
return null;
}

Expand All @@ -55,7 +61,8 @@ const ProductViewMissing = ({
{availableProducts?.map(({ productGroup, productId, productPath }) => (
<Card
key={`missingViewCard-${productId}-${helpers.generateId()}`}
isHoverable
isSelectable
isSelected={firstMatch.productPath === productPath}
onClick={() => onNavigate(productPath)}
>
<CardTitle>
Expand Down

0 comments on commit 0feb615

Please sign in to comment.