diff --git a/packages/twenty-front/src/modules/favorites/components/CurrentWorkspaceMemberFavoritesFolders.tsx b/packages/twenty-front/src/modules/favorites/components/CurrentWorkspaceMemberFavoritesFolders.tsx index 8805692451cf..fec72708a4de 100644 --- a/packages/twenty-front/src/modules/favorites/components/CurrentWorkspaceMemberFavoritesFolders.tsx +++ b/packages/twenty-front/src/modules/favorites/components/CurrentWorkspaceMemberFavoritesFolders.tsx @@ -1,29 +1,27 @@ -import { useRecoilState, useRecoilValue } from 'recoil'; -import { IconFolderPlus, LightIconButton, isDefined } from 'twenty-ui'; - import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState'; import { CurrentWorkspaceMemberOrphanFavorites } from '@/favorites/components/CurrentWorkspaceMemberOrphanFavorites'; import { FavoritesDragProvider } from '@/favorites/components/FavoritesDragProvider'; import { FavoriteFolders } from '@/favorites/components/FavoritesFolders'; import { FavoritesSkeletonLoader } from '@/favorites/components/FavoritesSkeletonLoader'; import { useFavorites } from '@/favorites/hooks/useFavorites'; +import { useFavoritesByFolder } from '@/favorites/hooks/useFavoritesByFolder'; import { isFavoriteFolderCreatingState } from '@/favorites/states/isFavoriteFolderCreatingState'; import { useIsPrefetchLoading } from '@/prefetch/hooks/useIsPrefetchLoading'; import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper'; import { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection'; import { NavigationDrawerSectionTitle } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle'; import { useNavigationSection } from '@/ui/navigation/navigation-drawer/hooks/useNavigationSection'; -import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; +import { useRecoilState, useRecoilValue } from 'recoil'; +import { IconFolderPlus, LightIconButton, isDefined } from 'twenty-ui'; export const CurrentWorkspaceMemberFavoritesFolders = () => { const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState); const { sortedFavorites: favorites } = useFavorites(); + const { favoritesByFolder } = useFavoritesByFolder(); + const [isFavoriteFolderCreating, setIsFavoriteFolderCreating] = useRecoilState(isFavoriteFolderCreatingState); - const isFavoriteFolderEnabled = useIsFeatureEnabled( - 'IS_FAVORITE_FOLDER_ENABLED', - ); const loading = useIsPrefetchLoading(); const { @@ -38,21 +36,15 @@ export const CurrentWorkspaceMemberFavoritesFolders = () => { setIsFavoriteFolderCreating((current) => !current); }; - const shouldDisplayFavoritesWithFeatureFlagEnabled = true; - - //todo: remove this logic once feature flag gating is removed - const shouldDisplayFavoritesWithoutFeatureFlagEnabled = - favorites.length > 0 || isFavoriteFolderCreating; - - const shouldDisplayFavorites = isFavoriteFolderEnabled - ? shouldDisplayFavoritesWithFeatureFlagEnabled - : shouldDisplayFavoritesWithoutFeatureFlagEnabled; - if (loading && isDefined(currentWorkspaceMember)) { return ; } - if (!shouldDisplayFavorites) { + if ( + (!favorites || favorites.length === 0) && + !isFavoriteFolderCreating && + !favoritesByFolder.length + ) { return null; } @@ -63,24 +55,17 @@ export const CurrentWorkspaceMemberFavoritesFolders = () => { label="Favorites" onClick={toggleNavigationSection} rightIcon={ - isFavoriteFolderEnabled ? ( - - ) : undefined + } /> - {isNavigationSectionOpen && ( - {isFavoriteFolderEnabled && ( - - )} + )} diff --git a/packages/twenty-front/src/modules/favorites/components/FavoritesFolders.tsx b/packages/twenty-front/src/modules/favorites/components/FavoritesFolders.tsx index 6810eb491ec0..3fd41f5ef300 100644 --- a/packages/twenty-front/src/modules/favorites/components/FavoritesFolders.tsx +++ b/packages/twenty-front/src/modules/favorites/components/FavoritesFolders.tsx @@ -1,13 +1,12 @@ -import { useState } from 'react'; -import { useRecoilState } from 'recoil'; -import { IconFolder } from 'twenty-ui'; - import { CurrentWorkspaceMemberFavorites } from '@/favorites/components/CurrentWorkspaceMemberFavorites'; import { FavoriteFolderHotkeyScope } from '@/favorites/constants/FavoriteFolderRightIconDropdownHotkeyScope'; import { useCreateFavoriteFolder } from '@/favorites/hooks/useCreateFavoriteFolder'; import { useFavoritesByFolder } from '@/favorites/hooks/useFavoritesByFolder'; import { isFavoriteFolderCreatingState } from '@/favorites/states/isFavoriteFolderCreatingState'; import { NavigationDrawerInput } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerInput'; +import { useState } from 'react'; +import { useRecoilState } from 'recoil'; +import { IconFolder } from 'twenty-ui'; type FavoriteFoldersProps = { isNavigationSectionOpen: boolean; diff --git a/packages/twenty-front/src/modules/prefetch/components/PrefetchDataProvider.tsx b/packages/twenty-front/src/modules/prefetch/components/PrefetchDataProvider.tsx index 87f5228daf72..04fdb0a21c7b 100644 --- a/packages/twenty-front/src/modules/prefetch/components/PrefetchDataProvider.tsx +++ b/packages/twenty-front/src/modules/prefetch/components/PrefetchDataProvider.tsx @@ -1,17 +1,10 @@ -import React from 'react'; - -import { PrefetchFavoriteFoldersRunQueriesEffect } from '@/prefetch/components/PrefetchFavortiteFoldersRunQueriesEffect'; import { PrefetchRunQueriesEffect } from '@/prefetch/components/PrefetchRunQueriesEffect'; -import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; +import React from 'react'; export const PrefetchDataProvider = ({ children }: React.PropsWithChildren) => { - const isFavoriteFolderEnabled = useIsFeatureEnabled( - 'IS_FAVORITE_FOLDER_ENABLED', - ); return ( <> - {isFavoriteFolderEnabled && } {children} ); diff --git a/packages/twenty-front/src/modules/prefetch/components/PrefetchFavortiteFoldersRunQueriesEffect.tsx b/packages/twenty-front/src/modules/prefetch/components/PrefetchFavortiteFoldersRunQueriesEffect.tsx deleted file mode 100644 index c8e93949da45..000000000000 --- a/packages/twenty-front/src/modules/prefetch/components/PrefetchFavortiteFoldersRunQueriesEffect.tsx +++ /dev/null @@ -1,45 +0,0 @@ -import { currentUserState } from '@/auth/states/currentUserState'; -import { FavoriteFolder } from '@/favorites/types/FavoriteFolder'; -import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems'; -import { useCombinedFindManyRecords } from '@/object-record/multiple-objects/hooks/useCombinedFindManyRecords'; -import { PREFETCH_CONFIG } from '@/prefetch/constants/PrefetchConfig'; -import { usePrefetchRunQuery } from '@/prefetch/hooks/internal/usePrefetchRunQuery'; -import { PrefetchKey } from '@/prefetch/types/PrefetchKey'; -import { useEffect } from 'react'; -import { useRecoilValue } from 'recoil'; -import { isDefined } from '~/utils/isDefined'; - -// TODO: Remove this component once we merge it with PrefetchRunQueriesEffect (once we remove feature flag) -export const PrefetchFavoriteFoldersRunQueriesEffect = () => { - const currentUser = useRecoilValue(currentUserState); - - const { upsertRecordsInCache: upsertFavoritesFoldersInCache } = - usePrefetchRunQuery({ - prefetchKey: PrefetchKey.AllFavoritesFolders, - }); - - const { objectMetadataItems } = useObjectMetadataItems(); - - const operationSignatures = Object.values(PREFETCH_CONFIG) - .filter(({ objectNameSingular }) => objectNameSingular === 'favoriteFolder') - .map(({ objectNameSingular, operationSignatureFactory }) => { - const objectMetadataItem = objectMetadataItems.find( - (item) => item.nameSingular === objectNameSingular, - ); - - return operationSignatureFactory({ objectMetadataItem }); - }); - - const { result } = useCombinedFindManyRecords({ - operationSignatures, - skip: !currentUser, - }); - - useEffect(() => { - if (isDefined(result.favoriteFolders)) { - upsertFavoritesFoldersInCache(result.favoriteFolders as FavoriteFolder[]); - } - }, [result, upsertFavoritesFoldersInCache]); - - return null; -}; diff --git a/packages/twenty-front/src/modules/prefetch/components/PrefetchRunQueriesEffect.tsx b/packages/twenty-front/src/modules/prefetch/components/PrefetchRunQueriesEffect.tsx index 3541e90e8c5a..2c9d4d581f2d 100644 --- a/packages/twenty-front/src/modules/prefetch/components/PrefetchRunQueriesEffect.tsx +++ b/packages/twenty-front/src/modules/prefetch/components/PrefetchRunQueriesEffect.tsx @@ -3,6 +3,7 @@ import { useRecoilValue } from 'recoil'; import { currentUserState } from '@/auth/states/currentUserState'; import { Favorite } from '@/favorites/types/Favorite'; +import { FavoriteFolder } from '@/favorites/types/FavoriteFolder'; import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems'; import { useCombinedFindManyRecords } from '@/object-record/multiple-objects/hooks/useCombinedFindManyRecords'; import { PREFETCH_CONFIG } from '@/prefetch/constants/PrefetchConfig'; @@ -23,15 +24,14 @@ export const PrefetchRunQueriesEffect = () => { usePrefetchRunQuery({ prefetchKey: PrefetchKey.AllFavorites, }); - + const { upsertRecordsInCache: upsertFavoritesFoldersInCache } = + usePrefetchRunQuery({ + prefetchKey: PrefetchKey.AllFavoritesFolders, + }); const { objectMetadataItems } = useObjectMetadataItems(); const operationSignatures = Object.values(PREFETCH_CONFIG) - .filter( - ({ objectNameSingular }) => - // TODO: Remove this filter once we merge PrefetchFavortiteFoldersRunQueriesEffect with this component - objectNameSingular !== 'favoriteFolder', - ) + .map(({ objectNameSingular, operationSignatureFactory }) => { const objectMetadataItem = objectMetadataItems.find( (item) => item.nameSingular === objectNameSingular, @@ -53,7 +53,15 @@ export const PrefetchRunQueriesEffect = () => { if (isDefined(result.favorites)) { upsertFavoritesInCache(result.favorites as Favorite[]); } - }, [result, upsertViewsInCache, upsertFavoritesInCache]); + if (isDefined(result.favoriteFolders)) { + upsertFavoritesFoldersInCache(result.favoriteFolders as FavoriteFolder[]); + } + }, [ + result, + upsertViewsInCache, + upsertFavoritesInCache, + upsertFavoritesFoldersInCache, + ]); return <>; }; diff --git a/packages/twenty-front/src/modules/prefetch/hooks/useIsPrefetchLoading.ts b/packages/twenty-front/src/modules/prefetch/hooks/useIsPrefetchLoading.ts index 9a291c81160c..7df0fa8921e7 100644 --- a/packages/twenty-front/src/modules/prefetch/hooks/useIsPrefetchLoading.ts +++ b/packages/twenty-front/src/modules/prefetch/hooks/useIsPrefetchLoading.ts @@ -1,12 +1,8 @@ import { prefetchIsLoadedFamilyState } from '@/prefetch/states/prefetchIsLoadedFamilyState'; import { PrefetchKey } from '@/prefetch/types/PrefetchKey'; -import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useRecoilValue } from 'recoil'; export const useIsPrefetchLoading = () => { - const isFavoriteFolderEnabled = useIsFeatureEnabled( - 'IS_FAVORITE_FOLDER_ENABLED', - ); const isFavoriteFoldersPrefetched = useRecoilValue( prefetchIsLoadedFamilyState(PrefetchKey.AllFavoritesFolders), ); @@ -21,6 +17,6 @@ export const useIsPrefetchLoading = () => { return ( !areViewsPrefetched || !areFavoritesPrefetched || - (isFavoriteFolderEnabled && !isFavoriteFoldersPrefetched) + !isFavoriteFoldersPrefetched ); }; diff --git a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerDropdown.tsx b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerDropdown.tsx index 039ce52194cc..371a2c6aec52 100644 --- a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerDropdown.tsx +++ b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerDropdown.tsx @@ -22,7 +22,6 @@ import { ViewPickerListContent } from '@/views/view-picker/components/ViewPicker import { VIEW_PICKER_DROPDOWN_ID } from '@/views/view-picker/constants/ViewPickerDropdownId'; import { useUpdateViewFromCurrentState } from '@/views/view-picker/hooks/useUpdateViewFromCurrentState'; import { useViewPickerMode } from '@/views/view-picker/hooks/useViewPickerMode'; -import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { isDefined } from '~/utils/isDefined'; const StyledDropdownLabelAdornments = styled.span` @@ -51,9 +50,6 @@ const StyledViewName = styled.span` export const ViewPickerDropdown = () => { const theme = useTheme(); - const isFavoriteFolderEnabled = useIsFeatureEnabled( - 'IS_FAVORITE_FOLDER_ENABLED', - ); const { currentViewWithCombinedFiltersAndSorts } = useGetCurrentView(); @@ -110,9 +106,7 @@ export const ViewPickerDropdown = () => { case 'list': return ; case 'favorite-folders-picker': - return ( - isFavoriteFolderEnabled && - ); + return ; case 'create-empty': case 'create-from-current': return ( diff --git a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerOptionDropdown.tsx b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerOptionDropdown.tsx index dec445f120fb..9cd3fdab1267 100644 --- a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerOptionDropdown.tsx +++ b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerOptionDropdown.tsx @@ -8,7 +8,6 @@ import { View } from '@/views/types/View'; import { useDeleteViewFromCurrentState } from '@/views/view-picker/hooks/useDeleteViewFromCurrentState'; import { useViewPickerMode } from '@/views/view-picker/hooks/useViewPickerMode'; import { viewPickerReferenceViewIdComponentState } from '@/views/view-picker/states/viewPickerReferenceViewIdComponentState'; -import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useState } from 'react'; import { IconHeart, @@ -41,10 +40,6 @@ export const ViewPickerOptionDropdown = ({ ); const { setViewPickerMode } = useViewPickerMode(); - const isFavoriteFolderEnabled = useIsFeatureEnabled( - 'IS_FAVORITE_FOLDER_ENABLED', - ); - const { sortedFavorites: favorites } = useFavorites(); const { createFavorite } = useCreateFavorite(); @@ -86,22 +81,19 @@ export const ViewPickerOptionDropdown = ({ dropdownContent={ {isIndexView ? ( - isFavoriteFolderEnabled && ( + + ) : ( + <> - ) - ) : ( - <> - {isFavoriteFolderEnabled && ( - - )} + { - const isFavoriteFolderEnabled = useIsFeatureEnabled( - 'IS_FAVORITE_FOLDER_ENABLED', - ); - const isMobile = useIsMobile(); return ( <> {!isMobile && ( <> - {isFavoriteFolderEnabled ? ( - isFavorite ? ( - - ) : ( - - ) + {isFavorite ? ( + ) : ( >, ) { - const isFavoriteFolderEntityEnabled = - await this.featureFlagService.isFeatureEnabled( - FeatureFlagKey.IsFavoriteFolderEntityEnabled, - payload.workspaceId, - ); - - if (!isFavoriteFolderEntityEnabled) { - return; - } - for (const eventPayload of payload.events) { const favoriteRepository = await this.twentyORMGlobalManager.getRepositoryForWorkspace( diff --git a/packages/twenty-server/src/modules/favorite-folder/standard-objects/favorite-folder.workspace-entity.ts b/packages/twenty-server/src/modules/favorite-folder/standard-objects/favorite-folder.workspace-entity.ts index 6e4aa8b621eb..c58dab4027ef 100644 --- a/packages/twenty-server/src/modules/favorite-folder/standard-objects/favorite-folder.workspace-entity.ts +++ b/packages/twenty-server/src/modules/favorite-folder/standard-objects/favorite-folder.workspace-entity.ts @@ -1,6 +1,5 @@ import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface'; -import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum'; import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity'; import { RelationMetadataType, @@ -9,7 +8,6 @@ import { import { BaseWorkspaceEntity } from 'src/engine/twenty-orm/base.workspace-entity'; import { WorkspaceEntity } from 'src/engine/twenty-orm/decorators/workspace-entity.decorator'; import { WorkspaceField } from 'src/engine/twenty-orm/decorators/workspace-field.decorator'; -import { WorkspaceGate } from 'src/engine/twenty-orm/decorators/workspace-gate.decorator'; import { WorkspaceIsSystem } from 'src/engine/twenty-orm/decorators/workspace-is-system.decorator'; import { WorkspaceRelation } from 'src/engine/twenty-orm/decorators/workspace-relation.decorator'; import { FAVORITE_FOLDER_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids'; @@ -25,9 +23,6 @@ import { FavoriteWorkspaceEntity } from 'src/modules/favorite/standard-objects/f icon: 'IconFolder', }) @WorkspaceIsSystem() -@WorkspaceGate({ - featureFlag: FeatureFlagKey.IsFavoriteFolderEntityEnabled, -}) export class FavoriteFolderWorkspaceEntity extends BaseWorkspaceEntity { @WorkspaceField({ standardId: FAVORITE_FOLDER_STANDARD_FIELD_IDS.position, diff --git a/packages/twenty-server/src/modules/favorite/standard-objects/favorite.workspace-entity.ts b/packages/twenty-server/src/modules/favorite/standard-objects/favorite.workspace-entity.ts index 1b14cd5da11e..e9fef0ae7ac3 100644 --- a/packages/twenty-server/src/modules/favorite/standard-objects/favorite.workspace-entity.ts +++ b/packages/twenty-server/src/modules/favorite/standard-objects/favorite.workspace-entity.ts @@ -106,16 +106,10 @@ export class FavoriteWorkspaceEntity extends BaseWorkspaceEntity { inverseSideTarget: () => FavoriteFolderWorkspaceEntity, inverseSideFieldKey: 'favorites', }) - @WorkspaceGate({ - featureFlag: FeatureFlagKey.IsFavoriteFolderEntityEnabled, - }) @WorkspaceIsNullable() favoriteFolder: Relation | null; @WorkspaceJoinColumn('favoriteFolder') - @WorkspaceGate({ - featureFlag: FeatureFlagKey.IsFavoriteFolderEntityEnabled, - }) favoriteFolderId: string; @WorkspaceRelation({