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

View file

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