Add opened section (#7265)
When object is not part of the workspace favorite list, we want to show it in the "opened section" while its record page is accessed. This PR: - adds a new component `NavigationDrawerOpenedSection` - makes workflow versions and runs not system object + creates a prefilled view index for these - do not create workspace favorites for these so these do not appear in the workspace section <img width="1129" alt="Capture d’écran 2024-09-26 à 11 45 25" src="https://github.com/user-attachments/assets/c84d773c-0bef-4dce-b66a-55d7d00b0fb6">
This commit is contained in:
@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user