adds optional link to the subkey of a view header (#166)

* adds optional link to the subkey of a view header

* changes props to button props
This commit is contained in:
Sarah Rambacher 2020-10-13 09:15:16 -04:00 committed by GitHub
parent 3d16a021ea
commit 3882d3ec43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -12,15 +12,18 @@ import {
ToolbarItem,
Badge,
Select,
ButtonProps,
} from "@patternfly/react-core";
import { HelpContext } from "../help-enabler/HelpHeader";
import { useTranslation } from "react-i18next";
import { PageBreadCrumbs } from "../bread-crumb/PageBreadCrumbs";
import { ExternalLink } from "../external-link/ExternalLink";
export type ViewHeaderProps = {
titleKey: string;
badge?: string;
subKey: string;
subKeyLinkProps?: ButtonProps;
selectItems?: ReactElement[];
isEnabled?: boolean;
onSelect?: (value: string) => void;
@ -31,6 +34,7 @@ export const ViewHeader = ({
titleKey,
badge,
subKey,
subKeyLinkProps,
selectItems,
isEnabled = true,
onSelect,
@ -98,7 +102,16 @@ export const ViewHeader = ({
</Level>
{enabled && (
<TextContent>
<Text>{t(subKey)}</Text>
<Text>
{t(subKey)}
{subKeyLinkProps && (
<ExternalLink
{...subKeyLinkProps}
isInline
className="pf-u-ml-md"
/>
)}
</Text>
</TextContent>
)}
</PageSection>

View file

@ -22,6 +22,10 @@ Extended.args = {
titleKey: "This is the title",
badge: "badge",
subKey: "This is the description.",
subKeyLinkProps: {
title: "More information",
href: "http://google.com",
},
selectItems: [
<SelectOption key="first" value="first-item">
First item