Skip to content

Commit cca2994

Browse files
authored
chore: Migrate showAddClusterWizard to Jotai (#4113)
* chore: migrate showAddClusterWizard * fix: add missing replacement
1 parent 4c2c913 commit cca2994

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

src/components/Clusters/components/AddClusterDialog.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ 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 { useRecoilState, useRecoilValue } from 'recoil';
6+
import { useAtom, useAtomValue } from 'jotai';
77
import { showAddClusterWizard } from 'state/showAddClusterWizard';
88

99
function AddClusterDialogComponent({ dialogRef }) {
1010
const [kubeconfig, setKubeconfig] = useState(undefined);
11-
const showWizard = useRecoilValue(showAddClusterWizard);
11+
const showWizard = useAtomValue(showAddClusterWizard);
1212

1313
useEffect(() => {
1414
if (!showWizard) {
@@ -26,7 +26,7 @@ function AddClusterDialogComponent({ dialogRef }) {
2626
}
2727
export function AddClusterDialog() {
2828
const { t } = useTranslation();
29-
const [showWizard, setShowWizard] = useRecoilState(showAddClusterWizard);
29+
const [showWizard, setShowWizard] = useAtom(showAddClusterWizard);
3030
const dialogRef = useRef(null);
3131

3232
return (

src/components/Clusters/components/AddClusterWizard.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
} from '@ui5/webcomponents-react';
1111
import { useTranslation } from 'react-i18next';
1212
import { useRecoilValue, useSetRecoilState } from 'recoil';
13+
import { useSetAtom } from 'jotai';
1314

1415
import { ResourceForm } from 'shared/ResourceForm';
1516
import { useCustomFormValidator } from 'shared/hooks/useCustomFormValidator/useCustomFormValidator';
@@ -18,6 +19,8 @@ import { useClustersInfo } from 'state/utils/getClustersInfo';
1819
import { configurationAtom } from 'state/configuration/configurationAtom';
1920
import { authDataState } from 'state/authDataAtom';
2021
import { showAddClusterWizard } from 'state/showAddClusterWizard';
22+
import { isFormOpenState } from 'state/formOpenAtom';
23+
import { checkAuthRequiredInputs } from '../helper';
2124

2225
import { addByContext, getUser, hasKubeconfigAuth } from '../shared';
2326
import { AuthForm } from './AuthForm';
@@ -28,8 +31,6 @@ import { WizardButtons } from 'shared/components/WizardButtons/WizardButtons';
2831
import { ClusterPreview } from './ClusterPreview';
2932

3033
import './AddClusterWizard.scss';
31-
import { isFormOpenState } from 'state/formOpenAtom';
32-
import { checkAuthRequiredInputs } from '../helper';
3334

3435
export function AddClusterWizard({
3536
kubeconfig,
@@ -49,7 +50,7 @@ export function AddClusterWizard({
4950
busolaClusterParams?.config?.storage || 'sessionStorage',
5051
);
5152
const [selected, setSelected] = useState(1);
52-
const setShowWizard = useSetRecoilState(showAddClusterWizard);
53+
const setShowWizard = useSetAtom(showAddClusterWizard);
5354
const [showTitleDescription, setShowTitleDescription] = useState(false);
5455
const setIsFormOpen = useSetRecoilState(isFormOpenState);
5556
const [chosenContext, setChosenContext] = useState(undefined);

src/components/Clusters/views/ClusterList.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import jsyaml from 'js-yaml';
33
import { saveAs } from 'file-saver';
44
import { useTranslation } from 'react-i18next';
55
import { useSetAtom } from 'jotai';
6-
import { useSetRecoilState } from 'recoil';
76

87
import { useClustersInfo } from 'state/utils/getClustersInfo';
98
import { showAddClusterWizard } from 'state/showAddClusterWizard';
@@ -49,7 +48,7 @@ function ClusterList() {
4948
});
5049

5150
const [chosenCluster, setChosenCluster] = useState(null);
52-
const setShowAdd = useSetRecoilState(showAddClusterWizard);
51+
const setShowAdd = useSetAtom(showAddClusterWizard);
5352
const setLayoutColumn = useSetAtom(columnLayoutState);
5453
const setShowCompanion = useSetAtom(showKymaCompanionState);
5554

src/shared/components/FileInput/FileInput.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useRef, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
3-
import { useRecoilValue } from 'recoil';
3+
import { useAtomValue } from 'jotai';
44

55
import PropTypes from 'prop-types';
66
import { Icon } from '@ui5/webcomponents-react';
@@ -9,7 +9,6 @@ import { showYamlUploadDialogState } from 'state/showYamlUploadDialogAtom';
99
import { showAddClusterWizard } from 'state/showAddClusterWizard';
1010

1111
import './FileInput.scss';
12-
import { useAtomValue } from 'jotai';
1312

1413
FileInput.propTypes = {
1514
fileInputChanged: PropTypes.func.isRequired,
@@ -28,8 +27,8 @@ export function FileInput({
2827
customMessage,
2928
}) {
3029
const [fileNames, setFileNames] = useState([]);
30+
const openAddCluster = useAtomValue(showAddClusterWizard);
3131
const openAdd = useAtomValue(showYamlUploadDialogState);
32-
const openAddCluster = useRecoilValue(showAddClusterWizard);
3332
const [draggingOverCounter, setDraggingCounter] = useState(0);
3433
const { t } = useTranslation();
3534
const fileNameRef = useRef(null);

src/state/showAddClusterWizard.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import { atom, RecoilState } from 'recoil';
2-
3-
type ShowAddClusterWizard = boolean;
1+
import { atom } from 'jotai';
42

53
const DEFAULT_SHOW_ADD_CLUSTER_WIZARD = false;
64

7-
export const showAddClusterWizard: RecoilState<ShowAddClusterWizard> = atom<
8-
ShowAddClusterWizard
9-
>({
10-
key: 'showAddClusterWizard',
11-
default: DEFAULT_SHOW_ADD_CLUSTER_WIZARD,
12-
});
5+
export const showAddClusterWizard = atom<boolean>(
6+
DEFAULT_SHOW_ADD_CLUSTER_WIZARD,
7+
);
8+
showAddClusterWizard.debugLabel = 'showAddClusterWizard';

0 commit comments

Comments
 (0)