Skip to content

Commit 023cb65

Browse files
authored
chore: Migrate isSidebarCondensedState to Jotai (#4109)
* chore: replace state * fix * cleanup * tests: wait to load
1 parent c7e2a46 commit 023cb65

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

src/header/SidebarSwitcher/SidebarSwitcher.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Button } from '@ui5/webcomponents-react';
22
import { useTranslation } from 'react-i18next';
3-
import { useRecoilState } from 'recoil';
3+
import { useAtom } from 'jotai';
44
import { isSidebarCondensedState } from 'state/preferences/isSidebarCondensedAtom';
55

66
export function SidebarSwitcher(props: any) {
77
const { t } = useTranslation();
8-
const [isSidebarCondensed, setSidebarCondensed] = useRecoilState(
8+
const [isSidebarCondensed, setSidebarCondensed] = useAtom(
99
isSidebarCondensedState,
1010
);
1111

src/sidebar/CategoryItem.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22
import { useTranslation } from 'react-i18next';
3-
import { SetterOrUpdater, useRecoilValue } from 'recoil';
3+
import { SetterOrUpdater } from 'recoil';
4+
import { useAtomValue } from 'jotai';
5+
46
import { Category } from 'state/navigation/categories';
57
import {
68
SideNavigationItem,
@@ -32,7 +34,7 @@ export function CategoryItem({
3234
const { t } = useTranslation();
3335
const categoryName = t(category.label, { defaultValue: category.label });
3436
const expanded = expandedCategories.includes(category.key);
35-
const isSidebarCondensed = useRecoilValue(isSidebarCondensedState);
37+
const isSidebarCondensed = useAtomValue(isSidebarCondensedState);
3638

3739
const handleAddExpandedCategory = (
3840
e: Ui5CustomEvent<

src/sidebar/SidebarNavigation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { useAtomValue, useSetAtom } from 'jotai';
12
import { useRecoilState, useRecoilValue } from 'recoil';
2-
import { useSetAtom } from 'jotai';
33
import {
44
SideNavigation,
55
SideNavigationItem,
@@ -24,7 +24,7 @@ import { useFormNavigation } from 'shared/hooks/useFormNavigation';
2424

2525
export function SidebarNavigation() {
2626
const navigationNodes = useRecoilValue(sidebarNavigationNodesSelector);
27-
const isSidebarCondensed = useRecoilValue(isSidebarCondensedState);
27+
const isSidebarCondensed = useAtomValue(isSidebarCondensedState);
2828
const namespace = useRecoilValue(activeNamespaceIdState);
2929
const { t } = useTranslation();
3030
const navigate = useNavigate();

src/sidebar/useSidebarCondensed.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect } from 'react';
2-
import { useSetRecoilState } from 'recoil';
2+
import { useSetAtom } from 'jotai';
33
import { isSidebarCondensedState } from 'state/preferences/isSidebarCondensedAtom';
44

55
function getWindowDimensions() {
@@ -26,7 +26,7 @@ function useWindowDimensions() {
2626

2727
export default function useSidebarCondensed() {
2828
const width = useWindowDimensions();
29-
const setSidebarCondensed = useSetRecoilState(isSidebarCondensedState);
29+
const setSidebarCondensed = useSetAtom(isSidebarCondensedState);
3030

3131
useEffect(() => {
3232
if (width <= 900) setSidebarCondensed(true);
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 IsSidebarCondensed = boolean;
1+
import { atom } from 'jotai';
42

53
const DEFAULT_IS_SIDEBAR_CONDENSED = false;
64

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

tests/integration/tests/kyma-namespace/z-run-after.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ context('Clean up Namespace', () => {
1212
.contains('Namespaces')
1313
.click();
1414

15+
cy.wait(1000);
16+
1517
cy.deleteFromGenericList('Namespace', Cypress.env('NAMESPACE_NAME'), {
1618
clearSearch: false,
1719
checkIfResourceIsRemoved: false,

0 commit comments

Comments
 (0)