Skip to content

Commit 2b67e7d

Browse files
authored
fix: Add checking subtitleText in empty list component (#4603)
* fix: add checking subtitleText in empty list component * refactor: check subtitle text in ExtensibilityList instead of empty list component * fix: pass translated description to empty list component * fix: links not working in empty list component * fix: change return value from object to string
1 parent 55a174d commit 2b67e7d

File tree

4 files changed

+12
-33
lines changed

4 files changed

+12
-33
lines changed

public/i18n/en.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ command-palette:
214214
rolebindings: Role Bindings
215215
serviceaccounts: Service Accounts
216216
serviceentries: Service Entries
217+
services: Services
217218
statefulsets: Stateful Sets
218219
storageclasses: Storage Classes
219220
subscriptions: Subscriptions

src/components/Extensibility/ExtensibilityList.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useGetCRbyPath } from './useGetCRbyPath';
1313
import ExtensibilityCreate from './ExtensibilityCreate';
1414
import {
1515
applyFormula,
16-
getResourceDescAndUrl,
16+
getResourceUrl,
1717
getTextSearchProperties,
1818
TranslationBundleContext,
1919
useCreateResourceDescription,
@@ -123,8 +123,7 @@ export const ExtensibilityListCore = ({
123123
defaultSearch: true,
124124
});
125125

126-
const { description: subtitleText, url: emptyListUrl } =
127-
getResourceDescAndUrl(description);
126+
const emptyListUrl = getResourceUrl(description);
128127

129128
return (
130129
<ResourcesList
@@ -143,7 +142,7 @@ export const ExtensibilityListCore = ({
143142
textSearchProperties(defaultSearchProperties),
144143
}}
145144
emptyListProps={{
146-
subtitleText: subtitleText,
145+
subtitleText: newListProps?.description,
147146
url: emptyListUrl,
148147
}}
149148
/>

src/components/Extensibility/helpers/index.js

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,8 @@ export const useCreateResourceDescription = (descID) => {
168168
}
169169
};
170170

171-
export const getResourceDescAndUrl = (descID) => {
172-
if (!descID)
173-
return {
174-
description: null,
175-
url: null,
176-
};
171+
export const getResourceUrl = (descID) => {
172+
if (!descID) return null;
177173

178174
const helmBracketsRegex = /{{"(.*?)"}}/g;
179175
const trans = descID.replace(helmBracketsRegex, '$1');
@@ -183,19 +179,9 @@ export const getResourceDescAndUrl = (descID) => {
183179

184180
if (links?.length >= 1) {
185181
const matchedLink = links[0];
186-
const processedTrans = trans.replace(
187-
matchedLink.matchedText,
188-
`<0>${matchedLink.urlText}</0>`,
189-
);
190-
return {
191-
description: processedTrans,
192-
url: matchedLink.url,
193-
};
182+
return matchedLink.url;
194183
} else {
195-
return {
196-
description: trans,
197-
url: null,
198-
};
184+
return null;
199185
}
200186
}
201187
};

src/shared/components/EmptyListComponent/EmptyListComponent.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactNode } from 'react';
2-
import { Trans, useTranslation } from 'react-i18next';
2+
import { 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';
@@ -28,15 +28,6 @@ export const EmptyListComponent = ({
2828
image = 'NoEntries',
2929
}: EmptyListComponentProps) => {
3030
const { t } = useTranslation();
31-
const subtitle = subtitleText ? (
32-
<Trans
33-
i18nKey={subtitleText}
34-
defaults={subtitleText}
35-
components={[<ExternalLink key={subtitleText} url={url} />]}
36-
/>
37-
) : (
38-
''
39-
);
4031

4132
if (showButton === undefined) {
4233
showButton = typeof onClick === 'function';
@@ -57,7 +48,9 @@ export const EmptyListComponent = ({
5748
{titleText}
5849
</Title>
5950
}
60-
subtitle={<span className="sap-margin-top-small">{subtitle}</span>}
51+
subtitle={
52+
<span className="sap-margin-top-small">{subtitleText ?? ''}</span>
53+
}
6154
>
6255
<div className="emptyListComponent__buttons">
6356
{showButton && <Button onClick={onClick}>{buttonText}</Button>}

0 commit comments

Comments
 (0)