[CHORE] Avoid isDefined duplicated reference, move it to twenty-shared (#9967)

# Introduction
Avoid having multiple `isDefined` definition across our pacakges
Also avoid importing `isDefined` from `twenty-ui` which exposes a huge
barrel for a such little util function

## In a nutshell
Removed own `isDefined.ts` definition from `twenty-ui` `twenty-front`
and `twenty-server` to move it to `twenty-shared`.
Updated imports for each packages, and added explicit dependencies to
`twenty-shared` if not already in place

Related PR https://github.com/twentyhq/twenty/pull/9941
This commit is contained in:
Paul Rastoin
2025-02-01 12:10:10 +01:00
committed by GitHub
parent d9b86475d3
commit 7fd89678b7
559 changed files with 731 additions and 770 deletions

View File

@ -4,9 +4,9 @@ import { AvatarType } from '@ui/display/avatar/types/AvatarType';
import { Chip, ChipSize, ChipVariant } from '@ui/display/chip/components/Chip';
import { IconComponent } from '@ui/display/icon/types/IconComponent';
import { ThemeContext } from '@ui/theme';
import { isDefined } from '@ui/utilities/isDefined';
import { Nullable } from '@ui/utilities/types/Nullable';
import { MouseEvent, useContext } from 'react';
import { isDefined } from 'twenty-shared';
// Import Link from react-router-dom instead of UndecoratedLink
import { Link } from 'react-router-dom';

View File

@ -9,7 +9,7 @@ import {
ThemeContext,
ThemeType,
} from '@ui/theme';
import { isDefined } from '@ui/utilities';
import { isDefined } from 'twenty-shared';
const spacing5 = THEME_COMMON.spacing(5);
const spacing2 = THEME_COMMON.spacing(2);

View File

@ -4,7 +4,7 @@ import { createPortal } from 'react-dom';
import { THEME_COMMON } from '@ui/theme';
import { isDefined } from '@ui/utilities';
import { isDefined } from 'twenty-shared';
import { AppTooltip, TooltipDelay } from './AppTooltip';
const spacing4 = THEME_COMMON.spacing(4);

View File

@ -1,12 +1,12 @@
import { useCallback, useEffect, useState } from 'react';
import { millisecondsToSeconds } from 'date-fns';
import {
animate,
AnimationPlaybackControls,
ValueAnimationTransition,
} from 'framer-motion';
import { useCallback, useEffect, useState } from 'react';
import { isDefined } from '@ui/utilities';
import { isDefined } from 'twenty-shared';
export const useProgressAnimation = ({
autoPlay = true,

View File

@ -1,7 +1,7 @@
import styled from '@emotion/styled';
import React, { ReactNode } from 'react';
import { isDefined } from '@ui/utilities';
import { isDefined } from 'twenty-shared';
import { ButtonPosition, ButtonProps } from './Button';

View File

@ -1,7 +1,7 @@
import styled from '@emotion/styled';
import React from 'react';
import { isDefined } from '@ui/utilities';
import { isDefined } from 'twenty-shared';
import { FloatingButtonPosition, FloatingButtonProps } from './FloatingButton';

View File

@ -1,11 +1,11 @@
import { Loader } from '@ui/feedback/loader/components/Loader';
import { useTheme, css } from '@emotion/react';
import Editor, { EditorProps, Monaco } from '@monaco-editor/react';
import { codeEditorTheme } from '@ui/input';
import { isDefined } from '@ui/utilities';
import { css, useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { useState } from 'react';
import Editor, { EditorProps, Monaco } from '@monaco-editor/react';
import { Loader } from '@ui/feedback/loader/components/Loader';
import { codeEditorTheme } from '@ui/input';
import { editor } from 'monaco-editor';
import { useState } from 'react';
import { isDefined } from 'twenty-shared';
type CodeEditorProps = Omit<EditorProps, 'onChange'> & {
onChange?: (value: string) => void;

View File

@ -6,9 +6,9 @@ import { AnimationDurations } from '@ui/layout/animated-expandable-container/typ
import { AnimationMode } from '@ui/layout/animated-expandable-container/types/AnimationMode';
import { AnimationSize } from '@ui/layout/animated-expandable-container/types/AnimationSize';
import { getExpandableAnimationConfig } from '@ui/layout/animated-expandable-container/utils/getExpandableAnimationConfig';
import { isDefined } from '@ui/utilities';
import { AnimatePresence, motion } from 'framer-motion';
import { ReactNode, useRef, useState } from 'react';
import { isDefined } from 'twenty-shared';
const StyledMotionContainer = styled(motion.div)<{
containAnimation: boolean;

View File

@ -7,8 +7,8 @@ import {
} from '@ui/display';
import { LightIconButtonGroup } from '@ui/input';
import { MenuItemIconButton } from '@ui/navigation/menu-item/components/MenuItem';
import { isDefined } from '@ui/utilities';
import { MouseEvent } from 'react';
import { isDefined } from 'twenty-shared';
import {
StyledHoverableMenuItemBase,
StyledMenuItemLeftContent,

View File

@ -1,4 +1,4 @@
import { isDefined } from '@ui/utilities';
import { isDefined } from 'twenty-shared';
export const getCanvasElementForDropdownTesting = () => {
const canvasElement = document.getElementsByClassName(

View File

@ -1,5 +1,5 @@
import { MAIN_COLOR_NAMES, ThemeColor } from '@ui/theme';
import { isDefined } from '@ui/utilities';
import { isDefined } from 'twenty-shared';
export const getNextThemeColor = (currentColor?: ThemeColor): ThemeColor => {
if (!isDefined(currentColor)) {

View File

@ -1,6 +1,6 @@
import styled from '@emotion/styled';
import { isDefined } from '@ui/utilities';
import { ReactNode, useLayoutEffect, useRef, useState } from 'react';
import { isDefined } from 'twenty-shared';
type ComputeNodeDimensionsProps = {
children: (

View File

@ -10,7 +10,6 @@ export * from './device/getOsControlSymbol';
export * from './device/getOsShortcutSeparator';
export * from './device/getUserDevice';
export * from './dimensions/components/ComputeNodeDimensions';
export * from './isDefined';
export * from './responsive/hooks/useIsMobile';
export * from './screen-size/hooks/useScreenSize';
export * from './state/utils/createState';

View File

@ -1,4 +0,0 @@
import { isNull, isUndefined } from '@sniptt/guards';
export const isDefined = <T>(value: T | null | undefined): value is T =>
!isUndefined(value) && !isNull(value);

View File

@ -1,5 +1,5 @@
import { LinkType } from '@ui/navigation/link';
import { isDefined } from '../isDefined';
import { isDefined } from 'twenty-shared';
type getUrlDisplayValueByUrlTypeProps = {
type: LinkType;