Skip to content

Commit

Permalink
PreviewBadge: allow ReactNode content, rename prop to popoverContent (
Browse files Browse the repository at this point in the history
#2560)

Motivation: In OCM we have use case for showing dynamic badge content
(https://issues.redhat.com/browse/OCMUI-1145) where we don't get separate
"Learn More" URL but might render links in the text itself.

The existing `PreviewBadge` component supports this fine at run time,
only the `popoverText: string` type was too restrictive at compile time.
=> Relaxing the type + renames `popoverText` -> `popoverContent`.
  • Loading branch information
cben authored Apr 25, 2024
1 parent b744d09 commit 38295d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions libs/ui-lib/lib/common/components/ui/DeveloperPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React from 'react';
import { useTranslation } from '../../hooks/use-translation-wrapper';
import { PreviewBadge, PreviewBadgeProps } from './PreviewBadge';

export type DeveloperPreviewProps = Omit<PreviewBadgeProps, 'text' | 'popoverText'>;
export type DeveloperPreviewProps = Omit<PreviewBadgeProps, 'text' | 'popoverContent'>;

export const DeveloperPreview: React.FC<DeveloperPreviewProps> = (props) => {
const { t } = useTranslation();
return (
<PreviewBadge
text={t('ai:Developer Preview')}
popoverText={t(
popoverContent={t(
'ai:Developer preview features are not intended to be used in production environments. The clusters deployed with the developer preview features are considered to be development clusters and are not supported through the Red Hat Customer Portal case management system.',
)}
{...props}
Expand Down
6 changes: 3 additions & 3 deletions libs/ui-lib/lib/common/components/ui/PreviewBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export type PreviewBadgeProps = {
className?: string;
text: string;
externalLink?: string;
popoverText: string;
popoverContent: React.ReactNode;
} & WithTestID;

export const PreviewBadge: React.FC<PreviewBadgeProps> = ({
position = PreviewBadgePosition.inline,
className = 'pf-v5-u-ml-md',
text,
popoverText,
popoverContent,
externalLink,
testId,
}) => {
Expand All @@ -39,7 +39,7 @@ export const PreviewBadge: React.FC<PreviewBadgeProps> = ({
}
const bodyContent = (
<>
<div style={{ marginBottom: 'var(--pf-v5-global--spacer--sm)' }}>{popoverText}</div>
<div style={{ marginBottom: 'var(--pf-v5-global--spacer--sm)' }}>{popoverContent}</div>
{externalLink && (
<>
<ExternalLink href={externalLink}>{t('ai:Learn more')}</ExternalLink>
Expand Down
4 changes: 2 additions & 2 deletions libs/ui-lib/lib/common/components/ui/TechnologyPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PreviewBadge, PreviewBadgeProps } from './PreviewBadge';

export type TechnologyPreviewProps = Omit<
PreviewBadgeProps,
'text' | 'popoverText' | 'externalLink'
'text' | 'popoverContent' | 'externalLink'
>;

export const TechnologyPreview: React.FC<TechnologyPreviewProps> = (props) => {
Expand All @@ -14,7 +14,7 @@ export const TechnologyPreview: React.FC<TechnologyPreviewProps> = (props) => {
return (
<PreviewBadge
text={t('ai:Technology Preview')}
popoverText={t(
popoverContent={t(
'ai:Technology preview features provide early access to upcoming product innovations, enabling you to test functionality and provide feedback during the development process.',
)}
externalLink={TECH_SUPPORT_LEVEL_LINK}
Expand Down

0 comments on commit 38295d0

Please sign in to comment.