Make title clickable instead of card (#17511)

This commit is contained in:
Erik Jan de Wit 2023-03-21 10:25:57 +01:00 committed by GitHub
parent 6d2177f2c8
commit 1cde3dd30e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 12 deletions

View file

@ -21,7 +21,7 @@ export const ClickableCard = ({
role="button"
aria-pressed="false"
tabIndex={0}
isHoverable
isSelectableRaised
onKeyDown={onKeyDown}
onClick={onClick}
{...rest}

View file

@ -1,4 +1,5 @@
import {
Card,
CardActions,
CardBody,
CardFooter,
@ -11,8 +12,7 @@ import {
Label,
} from "@patternfly/react-core";
import { ReactElement, useState } from "react";
import { To, useNavigate } from "react-router-dom";
import { ClickableCard } from "./ClickableCard";
import { Link, To } from "react-router-dom";
import "./keycloak-card.css";
@ -33,19 +33,14 @@ export const KeycloakCard = ({
footerText,
to,
}: KeycloakCardProps) => {
const navigate = useNavigate();
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const onDropdownToggle = () => {
setIsDropdownOpen(!isDropdownOpen);
};
const handleCardMenuClick = (e: any) => {
e.stopPropagation();
};
return (
<ClickableCard isSelectable onClick={() => navigate(to)}>
<Card isSelectable>
<CardHeader>
<CardActions>
{dropdownItems && (
@ -54,13 +49,14 @@ export const KeycloakCard = ({
isPlain
position={"right"}
toggle={<KebabToggle onToggle={onDropdownToggle} />}
onClick={(e) => handleCardMenuClick(e)}
isOpen={isDropdownOpen}
dropdownItems={dropdownItems}
/>
)}
</CardActions>
<CardTitle data-testid="keycloak-card-title">{title}</CardTitle>
<CardTitle data-testid="keycloak-card-title">
<Link to={to}>{title}</Link>
</CardTitle>
</CardHeader>
<CardBody />
<CardFooter>
@ -75,6 +71,6 @@ export const KeycloakCard = ({
</FlexItem>
</Flex>
</CardFooter>
</ClickableCard>
</Card>
);
};