Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4699 update the onboarding app placeholder #5616

Merged
merged 6 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import styled from '@emotion/styled';
import { Avatar } from 'twenty-ui';

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 @@ -35,8 +36,11 @@ const StyledNavigationDrawerItem = styled(NavigationDrawerItem)`
export const Favorites = () => {
const { favorites, handleReorderFavorite } = useFavorites();
const loading = useIsPrefetchLoading();
const isMockedDrawerPage = useIsMockedDrawerPage();

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { renderHook } from '@testing-library/react';
import { RecoilRoot } from 'recoil';

import { useIsMockedDrawerPage } from '@/navigation/hooks/useIsMockedDrawerPage';
import { AppPath } from '@/types/AppPath';
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';

jest.mock('~/hooks/useIsMatchingLocation');
const mockUseIsMatchingLocation = jest.mocked(useIsMatchingLocation);

const setupMockIsMatchingLocation = (pathname: string) => {
martmull marked this conversation as resolved.
Show resolved Hide resolved
mockUseIsMatchingLocation.mockReturnValueOnce(
(path: string) => path === pathname,
);
};

const getResult = () =>
renderHook(
() => {
return useIsMockedDrawerPage();
},
{
wrapper: RecoilRoot,
},
);

const shouldReturnTrueLocations = [
AppPath.Verify,
AppPath.Invite,
AppPath.SignInUp,
AppPath.ResetPassword,
AppPath.CreateWorkspace,
AppPath.PlanRequired,
AppPath.PlanRequiredSuccess,
];

describe('useIsMockedDrawerPage', () => {
Object.values(AppPath).forEach((location) => {
const expectedResult = shouldReturnTrueLocations.includes(location);
it(`should return ${
expectedResult ? 'true' : 'false'
} for location ${location}`, () => {
setupMockIsMatchingLocation(location);
const { result } = getResult();
if (expectedResult) {
expect(result.current).toBeTruthy();
} else {
expect(result.current).toBeFalsy();
}
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { AppPath } from '@/types/AppPath';
import { useIsMatchingLocation } from '~/hooks/useIsMatchingLocation';

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

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 @@ -17,8 +18,11 @@ export const ObjectMetadataNavItems = () => {

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const StyledTableContainer = styled.div`
export const SignInBackgroundMockPage = () => {
return (
<PageContainer>
<PageHeader title="Objects" Icon={IconBuildingSkyscraper}>
<PageHeader title="Companies" Icon={IconBuildingSkyscraper}>
<PageHotkeysEffect onAddButtonClick={() => {}} />
<PageAddButton onClick={() => {}} />
</PageHeader>
Expand Down
Loading
Loading