Skip to content

Commit 36315f9

Browse files
authored
fix: Descriptions rendering properly for all resources (kyma-project#4647)
1 parent 76f6700 commit 36315f9

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/shared/components/EmptyListComponent/EmptyListComponent.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ReactNode } from 'react';
2-
import { useTranslation } from 'react-i18next';
1+
import { ReactNode, useMemo } from 'react';
2+
import { Trans, useTranslation } from 'react-i18next';
33
import { Button, IllustratedMessage, Title } from '@ui5/webcomponents-react';
44
import '@ui5/webcomponents-fiori/dist/illustrations/AllIllustrations';
55
import { ExternalLink } from 'shared/components/ExternalLink/ExternalLink';
@@ -8,7 +8,7 @@ import './EmptyListComponent.scss';
88

99
type EmptyListComponentProps = {
1010
titleText: string;
11-
subtitleText: string;
11+
subtitleText: string | ReactNode;
1212
showButton?: boolean;
1313
buttonText?: string;
1414
url: string;
@@ -29,6 +29,19 @@ export const EmptyListComponent = ({
2929
}: EmptyListComponentProps) => {
3030
const { t } = useTranslation();
3131

32+
const subtitle = useMemo(() => {
33+
if (!subtitleText) return '';
34+
if (typeof subtitleText !== 'string') return subtitleText;
35+
36+
return (
37+
<Trans
38+
i18nKey={subtitleText}
39+
defaults={subtitleText}
40+
components={[<ExternalLink key={subtitleText} url={url} />]}
41+
/>
42+
);
43+
}, [subtitleText, url]);
44+
3245
if (showButton === undefined) {
3346
showButton = typeof onClick === 'function';
3447
}
@@ -48,9 +61,7 @@ export const EmptyListComponent = ({
4861
{titleText}
4962
</Title>
5063
}
51-
subtitle={
52-
<span className="sap-margin-top-small">{subtitleText ?? ''}</span>
53-
}
64+
subtitle={<span className="sap-margin-top-small">{subtitle}</span>}
5465
>
5566
<div className="emptyListComponent__buttons">
5667
{showButton && <Button onClick={onClick}>{buttonText}</Button>}

0 commit comments

Comments
 (0)