Skip to content

Commit 4fb91c3

Browse files
authored
fix: Accessible name of Hint Button and remove redundant component (#4132)
* fix: fix hint button and remove redundant component * chore: change to tsx
1 parent 67858aa commit 4fb91c3

File tree

2 files changed

+23
-49
lines changed

2 files changed

+23
-49
lines changed

src/components/Clusters/components/AddClusterDialog.js renamed to src/components/Clusters/components/AddClusterDialog.tsx

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,21 @@ import { Dialog } from '@ui5/webcomponents-react';
33
import { useTranslation } from 'react-i18next';
44
import { ErrorBoundary } from 'shared/components/ErrorBoundary/ErrorBoundary';
55
import { AddClusterWizard } from './AddClusterWizard';
6-
import { useAtom, useAtomValue } from 'jotai';
6+
import { useAtom } from 'jotai';
77
import { showAddClusterWizard } from 'state/showAddClusterWizard';
88

9-
function AddClusterDialogComponent({ dialogRef }) {
9+
export function AddClusterDialog() {
10+
const { t } = useTranslation();
11+
const [showWizard, setShowWizard] = useAtom(showAddClusterWizard);
1012
const [kubeconfig, setKubeconfig] = useState(undefined);
11-
const showWizard = useAtomValue(showAddClusterWizard);
13+
const dialogRef = useRef(null);
1214

1315
useEffect(() => {
1416
if (!showWizard) {
1517
setKubeconfig(undefined);
1618
}
1719
}, [showWizard]);
1820

19-
return showWizard ? (
20-
<AddClusterWizard
21-
kubeconfig={kubeconfig}
22-
setKubeconfig={setKubeconfig}
23-
dialogRef={dialogRef}
24-
/>
25-
) : null;
26-
}
27-
export function AddClusterDialog() {
28-
const { t } = useTranslation();
29-
const [showWizard, setShowWizard] = useAtom(showAddClusterWizard);
30-
const dialogRef = useRef(null);
31-
3221
return (
3322
<Dialog
3423
open={showWizard}
@@ -38,7 +27,13 @@ export function AddClusterDialog() {
3827
ref={dialogRef}
3928
>
4029
<ErrorBoundary>
41-
<AddClusterDialogComponent dialogRef={dialogRef} />
30+
{showWizard ? (
31+
<AddClusterWizard
32+
kubeconfig={kubeconfig}
33+
setKubeconfig={setKubeconfig}
34+
dialogRef={dialogRef}
35+
/>
36+
) : null}
4237
</ErrorBoundary>
4338
</Dialog>
4439
);

src/components/Clusters/components/AddClusterWizard.js

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { useEffect, useState } from 'react';
22
import { createPortal } from 'react-dom';
3-
import {
4-
Wizard,
5-
WizardStep,
6-
Title,
7-
Button,
8-
Popover,
9-
Text,
10-
} from '@ui5/webcomponents-react';
3+
import { Wizard, WizardStep, Title } from '@ui5/webcomponents-react';
114
import { useTranslation } from 'react-i18next';
125
import { useRecoilValue, useSetRecoilState } from 'recoil';
136
import { useSetAtom } from 'jotai';
@@ -31,12 +24,13 @@ import { WizardButtons } from 'shared/components/WizardButtons/WizardButtons';
3124
import { ClusterPreview } from './ClusterPreview';
3225

3326
import './AddClusterWizard.scss';
27+
import { HintButton } from 'shared/components/DescriptionHint/DescriptionHint';
3428

3529
export function AddClusterWizard({
3630
kubeconfig,
3731
setKubeconfig,
38-
config,
3932
dialogRef,
33+
config = {},
4034
}) {
4135
const busolaClusterParams = useRecoilValue(configurationAtom);
4236
const { t } = useTranslation();
@@ -175,7 +169,6 @@ export function AddClusterWizard({
175169
>
176170
<KubeconfigUpload
177171
kubeconfig={kubeconfig}
178-
config={config}
179172
setKubeconfig={updateKubeconfig}
180173
formRef={authFormRef}
181174
/>
@@ -231,28 +224,14 @@ export function AddClusterWizard({
231224
<div className="add-cluster__content-container">
232225
<Title level="H5" className="sap-margin-bottom-small">
233226
{t('clusters.storage.choose-storage.label')}
234-
<>
235-
<Button
236-
id="storageDescriptionOpener"
237-
icon="hint"
238-
design="Transparent"
239-
className="sap-margin-begin-tiny"
240-
onClick={() => setShowTitleDescription(true)}
241-
/>
242-
{createPortal(
243-
<Popover
244-
opener="storageDescriptionOpener"
245-
open={showTitleDescription}
246-
onClose={() => setShowTitleDescription(false)}
247-
placement="End"
248-
>
249-
<Text className="description">
250-
{t('clusters.storage.info')}
251-
</Text>
252-
</Popover>,
253-
document.body,
254-
)}
255-
</>
227+
<HintButton
228+
id="storageDescriptionOpener"
229+
className="sap-margin-begin-tiny"
230+
setShowTitleDescription={setShowTitleDescription}
231+
description={t('clusters.storage.info')}
232+
showTitleDescription={showTitleDescription}
233+
ariaTitle={t('clusters.storage.choose-storage.label')}
234+
/>
256235
</Title>
257236
<ChooseStorage storage={storage} setStorage={setStorage} />
258237
</div>

0 commit comments

Comments
 (0)