-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:twentyhq/twenty into search-at-work…
…space-creation
- Loading branch information
Showing
34 changed files
with
467 additions
and
117 deletions.
There are no files selected for viewing
27 changes: 5 additions & 22 deletions
27
packages/twenty-front/src/modules/favorites/components/WorkspaceFavorites.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...s/twenty-front/src/modules/navigation/hooks/useObjectMetadataItemsInWorkspaceFavorites.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useFavorites } from '@/favorites/hooks/useFavorites'; | ||
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems'; | ||
import { usePrefetchedData } from '@/prefetch/hooks/usePrefetchedData'; | ||
import { PrefetchKey } from '@/prefetch/types/PrefetchKey'; | ||
import { View } from '@/views/types/View'; | ||
|
||
export const useFilteredObjectMetadataItemsForWorkspaceFavorites = () => { | ||
const { records: views } = usePrefetchedData<View>(PrefetchKey.AllViews); | ||
|
||
const { workspaceFavorites } = useFavorites(); | ||
|
||
const workspaceFavoriteIds = new Set( | ||
workspaceFavorites.map((favorite) => favorite.recordId), | ||
); | ||
|
||
const favoriteViewObjectMetadataIds = new Set( | ||
views.reduce<string[]>((acc, view) => { | ||
if (workspaceFavoriteIds.has(view.id)) { | ||
acc.push(view.objectMetadataId); | ||
} | ||
return acc; | ||
}, []), | ||
); | ||
|
||
const { activeObjectMetadataItems } = useFilteredObjectMetadataItems(); | ||
|
||
const activeObjectMetadataItemsInWorkspaceFavorites = | ||
activeObjectMetadataItems.filter((item) => | ||
favoriteViewObjectMetadataIds.has(item.id), | ||
); | ||
|
||
return { | ||
activeObjectMetadataItems: activeObjectMetadataItemsInWorkspaceFavorites, | ||
}; | ||
}; |
57 changes: 57 additions & 0 deletions
57
...ges/twenty-front/src/modules/object-metadata/components/NavigationDrawerOpenedSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { useFilteredObjectMetadataItemsForWorkspaceFavorites } from '@/navigation/hooks/useObjectMetadataItemsInWorkspaceFavorites'; | ||
import { NavigationDrawerSectionForObjectMetadataItems } from '@/object-metadata/components/NavigationDrawerSectionForObjectMetadataItems'; | ||
import { NavigationDrawerSectionForObjectMetadataItemsSkeletonLoader } from '@/object-metadata/components/NavigationDrawerSectionForObjectMetadataItemsSkeletonLoader'; | ||
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems'; | ||
import { useIsPrefetchLoading } from '@/prefetch/hooks/useIsPrefetchLoading'; | ||
import { usePrefetchedData } from '@/prefetch/hooks/usePrefetchedData'; | ||
import { PrefetchKey } from '@/prefetch/types/PrefetchKey'; | ||
import { View } from '@/views/types/View'; | ||
|
||
export const NavigationDrawerOpenedSection = () => { | ||
const { activeObjectMetadataItems } = useFilteredObjectMetadataItems(); | ||
const filteredActiveObjectMetadataItems = activeObjectMetadataItems.filter( | ||
(item) => !item.isRemote, | ||
); | ||
|
||
const { records: views } = usePrefetchedData<View>(PrefetchKey.AllViews); | ||
const loading = useIsPrefetchLoading(); | ||
|
||
const currentObjectNamePlural = useParams().objectNamePlural; | ||
|
||
const { activeObjectMetadataItems: workspaceFavoritesObjectMetadataItems } = | ||
useFilteredObjectMetadataItemsForWorkspaceFavorites(); | ||
|
||
if (!currentObjectNamePlural) { | ||
return; | ||
} | ||
|
||
const objectMetadataItem = filteredActiveObjectMetadataItems.find( | ||
(item) => item.namePlural === currentObjectNamePlural, | ||
); | ||
|
||
if (!objectMetadataItem) { | ||
return; | ||
} | ||
|
||
const shouldDisplayObjectInOpenedSection = | ||
!workspaceFavoritesObjectMetadataItems | ||
.map((item) => item.id) | ||
.includes(objectMetadataItem.id); | ||
|
||
if (loading) { | ||
return <NavigationDrawerSectionForObjectMetadataItemsSkeletonLoader />; | ||
} | ||
|
||
return ( | ||
shouldDisplayObjectInOpenedSection && ( | ||
<NavigationDrawerSectionForObjectMetadataItems | ||
sectionTitle={'Opened'} | ||
objectMetadataItems={[objectMetadataItem]} | ||
views={views} | ||
isRemote={false} | ||
/> | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
...ages/twenty-front/src/modules/ui/layout/hooks/__tests__/useIsMenuNavbarDisplayed.test.tsx
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
packages/twenty-front/src/modules/ui/layout/hooks/useIsMenuNavbarDisplayed.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.