Migrate twenty ui to jotai (#17900)
## Remove Recoil from twenty-ui Completely removes the `recoil` dependency from `twenty-ui` by converting all atoms, hooks, and providers to Jotai equivalents. ### twenty-ui - `createState` now returns a Jotai `PrimitiveAtom` instead of a Recoil atom - `iconsState`, `IconsProvider`, `useIcons` converted to Jotai (`useSetAtom`, `useAtomValue`) - `RecoilRootDecorator` now uses Jotai `Provider` (name kept for compat) - Deleted unused `invalidAvatarUrlsState` (Avatar already uses `invalidAvatarUrlsAtomV2`) - Removed `recoil` from `package.json` ### twenty-front - Created local Recoil `createState` at `@/ui/utilities/state/utils/createState` for ~112 state files still on Recoil - Updated all imports accordingly - Removed `iconsState` from Recoil snapshot preservation in `useAuth` (lives in Jotai store now)
This commit is contained in:
@@ -20,7 +20,6 @@ import {
|
||||
import { isMultiWorkspaceEnabledState } from '@/client-config/states/isMultiWorkspaceEnabledState';
|
||||
import { SnackBarComponentInstanceContext } from '@/ui/feedback/snack-bar-manager/contexts/SnackBarComponentInstanceContext';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { iconsState } from 'twenty-ui/display';
|
||||
import { SupportDriver } from '~/generated-metadata/graphql';
|
||||
|
||||
const redirectSpy = jest.fn();
|
||||
@@ -159,7 +158,6 @@ describe('useAuth', () => {
|
||||
const { result } = renderHook(
|
||||
() => {
|
||||
const client = useApolloClient();
|
||||
const icons = useRecoilValue(iconsState);
|
||||
const workspaceAuthProviders = useRecoilValue(
|
||||
workspaceAuthProvidersState,
|
||||
);
|
||||
@@ -175,7 +173,6 @@ describe('useAuth', () => {
|
||||
...useAuth(),
|
||||
client,
|
||||
state: {
|
||||
icons,
|
||||
workspaceAuthProviders,
|
||||
billing,
|
||||
isDeveloperDefaultSignInPrefilled,
|
||||
@@ -200,7 +197,6 @@ describe('useAuth', () => {
|
||||
|
||||
const { state } = result.current;
|
||||
|
||||
expect(state.icons).toEqual({});
|
||||
expect(state.workspaceAuthProviders).toEqual(null);
|
||||
expect(state.billing).toBeNull();
|
||||
expect(state.isDeveloperDefaultSignInPrefilled).toBe(false);
|
||||
|
||||
@@ -67,7 +67,6 @@ import { i18n } from '@lingui/core';
|
||||
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { SOURCE_LOCALE } from 'twenty-shared/translations';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { iconsState } from 'twenty-ui/display';
|
||||
import { cookieStorage } from '~/utils/cookie-storage';
|
||||
import { getWorkspaceUrl } from '~/utils/getWorkspaceUrl';
|
||||
|
||||
@@ -132,7 +131,6 @@ export const useAuth = () => {
|
||||
|
||||
const emptySnapshot = snapshot_UNSTABLE();
|
||||
|
||||
const iconsValue = snapshot.getLoadable(iconsState).getValue();
|
||||
const authProvidersValue = snapshot
|
||||
.getLoadable(workspaceAuthProvidersState)
|
||||
.getValue();
|
||||
@@ -164,7 +162,6 @@ export const useAuth = () => {
|
||||
.getValue();
|
||||
|
||||
const initialSnapshot = emptySnapshot.map(({ set }) => {
|
||||
set(iconsState, iconsValue);
|
||||
set(workspaceAuthProvidersState, authProvidersValue);
|
||||
set(billingState, billing);
|
||||
set(
|
||||
|
||||
Reference in New Issue
Block a user