[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,7 +4,7 @@ import { bottomBarHotkeyComponentState } from '@/ui/layout/bottom-bar/states/bot
import { isBottomBarOpenedComponentState } from '@/ui/layout/bottom-bar/states/isBottomBarOpenedComponentState';
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
import { isDefined } from '~/utils/isDefined';
import { isDefined } from 'twenty-shared';
export const useBottomBar = () => {
const {

View File

@ -20,7 +20,7 @@ import { MouseEvent, ReactNode } from 'react';
import { flushSync } from 'react-dom';
import { Keys } from 'react-hotkeys-hook';
import { useRecoilCallback } from 'recoil';
import { isDefined } from 'twenty-ui';
import { isDefined } from 'twenty-shared';
import { sleep } from '~/utils/sleep';
import { useDropdown } from '../hooks/useDropdown';

View File

@ -1,7 +1,8 @@
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { ComponentProps, MouseEvent } from 'react';
import { IconComponent, isDefined, LightIconButton } from 'twenty-ui';
import { isDefined } from 'twenty-shared';
import { IconComponent, LightIconButton } from 'twenty-ui';
const StyledHeader = styled.li`
align-items: center;

View File

@ -8,7 +8,7 @@ import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousH
import { getScopeIdOrUndefinedFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdOrUndefinedFromComponentId';
import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
import { useCallback } from 'react';
import { isDefined } from '~/utils/isDefined';
import { isDefined } from 'twenty-shared';
export const useDropdown = (dropdownId?: string) => {
const {

View File

@ -5,7 +5,7 @@ import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDrop
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
import { getScopeIdFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdFromComponentId';
import { isDefined } from '~/utils/isDefined';
import { isDefined } from 'twenty-shared';
export const useDropdownV2 = () => {
const {

View File

@ -4,7 +4,7 @@ import { AnimatedContainer, Chip, ChipVariant } from 'twenty-ui';
import { ExpandedListDropdown } from '@/ui/layout/expandable-list/components/ExpandedListDropdown';
import { isFirstOverflowingChildElement } from '@/ui/layout/expandable-list/utils/isFirstOverflowingChildElement';
import { isDefined } from '~/utils/isDefined';
import { isDefined } from 'twenty-shared';
const StyledContainer = styled.div`
align-items: center;

View File

@ -2,14 +2,10 @@ import styled from '@emotion/styled';
import { expect } from '@storybook/jest';
import { Meta, StoryObj } from '@storybook/react';
import { userEvent, within } from '@storybook/test';
import {
ComponentDecorator,
isDefined,
MAIN_COLOR_NAMES,
Tag,
} from 'twenty-ui';
import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
import { isDefined } from 'twenty-shared';
import { ComponentDecorator, MAIN_COLOR_NAMES, Tag } from 'twenty-ui';
const StyledContainer = styled.div`
padding: ${({ theme }) => theme.spacing(1)};

View File

@ -1,4 +1,4 @@
import { isDefined } from '~/utils/isDefined';
import { isDefined } from 'twenty-shared';
export const isFirstOverflowingChildElement = ({
containerElement,

View File

@ -6,9 +6,9 @@ import { useOnboardingStatus } from '@/onboarding/hooks/useOnboardingStatus';
import { AppPath } from '@/types/AppPath';
import { isDefaultLayoutAuthModalVisibleState } from '@/ui/layout/states/isDefaultLayoutAuthModalVisibleState';
import { useSubscriptionStatus } from '@/workspace/hooks/useSubscriptionStatus';
import { isDefined } from 'twenty-shared';
import { OnboardingStatus, SubscriptionStatus } from '~/generated/graphql';
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';
import { isDefined } from '~/utils/isDefined';
export const useShowAuthModal = () => {
const isMatchingLocation = useIsMatchingLocation();

View File

@ -6,7 +6,7 @@ import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { motion } from 'framer-motion';
import { useRecoilValue, useSetRecoilState } from 'recoil';
import { isDefined } from '~/utils/isDefined';
import { isDefined } from 'twenty-shared';
import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';
import { rightDrawerPageState } from '../states/rightDrawerPageState';

View File

@ -14,7 +14,7 @@ import { RightDrawerWorkflowEditStep } from '@/workflow/workflow-steps/component
import { RightDrawerWorkflowViewStep } from '@/workflow/workflow-steps/components/RightDrawerWorkflowViewStep';
import { RightDrawerWorkflowSelectAction } from '@/workflow/workflow-steps/workflow-actions/components/RightDrawerWorkflowSelectAction';
import { RightDrawerWorkflowSelectTriggerType } from '@/workflow/workflow-trigger/components/RightDrawerWorkflowSelectTriggerType';
import { isDefined } from 'twenty-ui';
import { isDefined } from 'twenty-shared';
import { rightDrawerPageState } from '../states/rightDrawerPageState';
import { RightDrawerPages } from '../types/RightDrawerPages';

View File

@ -3,8 +3,8 @@ import { ReactNode, useEffect } from 'react';
import { useSelectableListHotKeys } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys';
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
import { SelectableListScope } from '@/ui/layout/selectable-list/scopes/SelectableListScope';
import { isDefined } from 'twenty-shared';
import { arrayToChunks } from '~/utils/array/arrayToChunks';
import { isDefined } from '~/utils/isDefined';
type SelectableListProps = {
children: ReactNode;

View File

@ -2,7 +2,7 @@ import { useRecoilCallback, useSetRecoilState } from 'recoil';
import { useSelectableListStates } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListStates';
import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
import { isDefined } from '~/utils/isDefined';
import { isDefined } from 'twenty-shared';
export const useSelectableList = (selectableListId?: string) => {
const {

View File

@ -7,11 +7,11 @@ import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
import { AppTooltip, Avatar, AvatarType, IconComponent } from 'twenty-ui';
import { v4 as uuidV4 } from 'uuid';
import { isDefined } from 'twenty-shared';
import {
beautifyExactDateTime,
beautifyPastDateRelativeToNow,
} from '~/utils/date-utils';
import { isDefined } from '~/utils/isDefined';
type ShowPageSummaryCardProps = {
avatarPlaceholder: string;

View File

@ -2,7 +2,7 @@ import { sortedFieldByTableFamilyState } from '@/ui/layout/table/states/sortedFi
import { TableMetadata } from '@/ui/layout/table/types/TableMetadata';
import { useMemo } from 'react';
import { useRecoilValue } from 'recoil';
import { isDefined } from 'twenty-ui';
import { isDefined } from 'twenty-shared';
export const useSortedArray = <T>(
arrayToSort: T[],