Skip to content

Commit

Permalink
Add standard object to left pannel when required
Browse files Browse the repository at this point in the history
  • Loading branch information
martmull committed May 27, 2024
1 parent f1d778a commit caa7c1b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import styled from '@emotion/styled';
import { Avatar } from 'twenty-ui';

import { useIsLogged } from '@/auth/hooks/useIsLogged';
import { FavoritesSkeletonLoader } from '@/favorites/components/FavoritesSkeletonLoader';
import { useIsMockedDrawerPage } from '@/navigation/hooks/useIsMockedDrawerPage';
import { useIsPrefetchLoading } from '@/prefetch/hooks/useIsPrefetchLoading';
import { DraggableItem } from '@/ui/layout/draggable-list/components/DraggableItem';
import { DraggableList } from '@/ui/layout/draggable-list/components/DraggableList';
Expand Down Expand Up @@ -36,9 +36,11 @@ const StyledNavigationDrawerItem = styled(NavigationDrawerItem)`
export const Favorites = () => {
const { favorites, handleReorderFavorite } = useFavorites();
const loading = useIsPrefetchLoading();
const isLogged = useIsLogged();
const isMockedDrawerPage = useIsMockedDrawerPage();

if (loading && isLogged) {
const displayLoader = loading && !isMockedDrawerPage;

if (displayLoader) {
return <FavoritesSkeletonLoader />;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { AppPath } from '@/types/AppPath';
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';

export const useIsMockedDrawerPage = () => {
const isMatchingLocation = useIsMatchingLocation();
return (
isMatchingLocation(AppPath.SignInUp) ||
isMatchingLocation(AppPath.PlanRequired) ||
isMatchingLocation(AppPath.PlanRequiredSuccess) ||
isMatchingLocation(AppPath.CreateWorkspace)
);
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useLocation } from 'react-router-dom';
import { useIcons } from 'twenty-ui';

import { useIsLogged } from '@/auth/hooks/useIsLogged';
import { useIsMockedDrawerPage } from '@/navigation/hooks/useIsMockedDrawerPage';
import { ObjectMetadataNavItemsSkeletonLoader } from '@/object-metadata/components/ObjectMetadataNavItemsSkeletonLoader';
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
import { useIsPrefetchLoading } from '@/prefetch/hooks/useIsPrefetchLoading';
Expand All @@ -18,9 +18,11 @@ export const ObjectMetadataNavItems = () => {

const { records: views } = usePrefetchedData<View>(PrefetchKey.AllViews);
const loading = useIsPrefetchLoading();
const isLogged = useIsLogged();
const isMockedDrawerPage = useIsMockedDrawerPage();

if (loading && isLogged) {
const displayLoader = loading && !isMockedDrawerPage;

if (displayLoader) {
return <ObjectMetadataNavItemsSkeletonLoader />;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from '@emotion/styled';

import { useIsLogged } from '@/auth/hooks/useIsLogged';
import { useIsMockedDrawerPage } from '@/navigation/hooks/useIsMockedDrawerPage';
import { useIsPrefetchLoading } from '@/prefetch/hooks/useIsPrefetchLoading';
import { NavigationDrawerSectionTitleSkeletonLoader } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitleSkeletonLoader';

Expand All @@ -21,9 +21,11 @@ export const NavigationDrawerSectionTitle = ({
label,
}: NavigationDrawerSectionTitleProps) => {
const loading = useIsPrefetchLoading();
const isLogged = useIsLogged();
const isMockedDrawerPage = useIsMockedDrawerPage();

if (loading && isLogged) {
const displayLoader = loading && !isMockedDrawerPage;

if (displayLoader) {
return <NavigationDrawerSectionTitleSkeletonLoader />;
}
return <StyledTitle>{label}</StyledTitle>;
Expand Down

0 comments on commit caa7c1b

Please sign in to comment.