The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix workspace favorites in storybook (#8519)
Thomas Trompettea0200e6d91dc
diff --git a/packages/twenty-front/src/modules/sign-in-background-mock/components/SignInAppNavigationDrawerMock.tsx b/packages/twenty-front/src/modules/sign-in-background-mock/components/SignInAppNavigationDrawerMock.tsxnew file mode 100644index 00000000000..d29cf365f8b--- /dev/null+++ b/packages/twenty-front/src/modules/sign-in-background-mock/components/SignInAppNavigationDrawerMock.tsx@@ -0,0 +1,75 @@+import { SupportDropdown } from '@/support/components/SupportDropdown';+import {+ NavigationDrawer,+ NavigationDrawerProps,+} from '@/ui/navigation/navigation-drawer/components/NavigationDrawer';++import { NavigationDrawerSectionForObjectMetadataItems } from '@/object-metadata/components/NavigationDrawerSectionForObjectMetadataItems';+import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';+import { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection';+import styled from '@emotion/styled';+import { IconSearch, IconSettings, useIsMobile } from 'twenty-ui';+import { generatedMockObjectMetadataItems } from '~/testing/mock-data/generatedMockObjectMetadataItems';++const StyledMainSection = styled(NavigationDrawerSection)`+ min-height: fit-content;+`;++const WORKSPACE_FAVORITES = [+ 'person',+ 'company',+ 'opportunity',+ 'task',+ 'note',+];++export type SignInAppNavigationDrawerMockProps = {+ className?: string;+};++export const SignInAppNavigationDrawerMock = ({+ className,+}: SignInAppNavigationDrawerMockProps) => {+ const isMobile = useIsMobile();++ const children = (+ <>+ {!isMobile && (+ <StyledMainSection>+ <NavigationDrawerItem+ label="Search"+ Icon={IconSearch}+ onClick={() => {}}+ keyboard={['⌘', 'K']}+ />+ <NavigationDrawerItem+ label="Settings"+ to={'/settings/profile'}+ onClick={() => {}}+ Icon={IconSettings}+ />+ </StyledMainSection>+ )}+ <NavigationDrawerSectionForObjectMetadataItems+ sectionTitle={'Workspace'}+ isRemote={false}+ objectMetadataItems={generatedMockObjectMetadataItems.filter((item) =>+ WORKSPACE_FAVORITES.includes(item.nameSingular),+ )}+ />+ </>+ );++ const footer = <SupportDropdown />;++ const drawerProps: NavigationDrawerProps = {+ children,+ footer,+ };++ return (+ <NavigationDrawer className={className} footer={drawerProps.footer}>+ {drawerProps.children}+ </NavigationDrawer>+ );+};diff --git a/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx b/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsxindex 94821fa81b9..1c7d7648012 100644--- a/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx+++ b/packages/twenty-front/src/modules/ui/layout/page/components/DefaultLayout.tsx@@ -6,6 +6,7 @@ import { AppNavigationDrawer } from '@/navigation/components/AppNavigationDrawerimport { MobileNavigationBar } from '@/navigation/components/MobileNavigationBar';import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';import { OBJECT_SETTINGS_WIDTH } from '@/settings/data-model/constants/ObjectSettings';+import { SignInAppNavigationDrawerMock } from '@/sign-in-background-mock/components/SignInAppNavigationDrawerMock';import { SignInBackgroundMockPage } from '@/sign-in-background-mock/components/SignInBackgroundMockPage';import { useShowAuthModal } from '@/ui/layout/hooks/useShowAuthModal';import { NAV_DRAWER_WIDTHS } from '@/ui/navigation/navigation-drawer/constants/NavDrawerWidths';@@ -52,6 +53,10 @@ const StyledAppNavigationDrawer = styled(AppNavigationDrawer)`flex-shrink: 0;`;+const StyledAppNavigationDrawerMock = styled(SignInAppNavigationDrawerMock)`+ flex-shrink: 0;+`;+const StyledMainContainer = styled.div`display: flex;flex: 0 1 100%;@@ -93,7 +98,11 @@ export const DefaultLayout = () => {duration: theme.animation.duration.normal,}}>- <StyledAppNavigationDrawer />+ {showAuthModal ? (+ <StyledAppNavigationDrawerMock />+ ) : (+ <StyledAppNavigationDrawer />+ )}<StyledMainContainer>{showAuthModal ? (<>diff --git a/packages/twenty-front/src/testing/mock-data/favorite.ts b/packages/twenty-front/src/testing/mock-data/favorite.tsindex 3a9d3dfe128..f87ab361c50 100644--- a/packages/twenty-front/src/testing/mock-data/favorite.ts+++ b/packages/twenty-front/src/testing/mock-data/favorite.ts@@ -1,5 +1,6 @@import { companiesQueryResult } from '~/testing/mock-data/companies';import { mockedWorkspaceMemberData } from '~/testing/mock-data/users';+import { mockedViewsData } from '~/testing/mock-data/views';export const mockedFavoritesData = [{@@ -33,4 +34,97 @@ export const mockedFavoritesData = [note: null,__typename: 'Favorite',},+ {+ id: '20202020-dede-koko-873b-de4264d89026',+ createdAt: new Date().toISOString(),+ updatedAt: new Date().toISOString(),+ deletedAt: null,+ position: 1,+ recordId: null,+ workflowId: null,+ workflow: null,+ workflowRunId: null,+ workflowRun: null,+ workflowVersionId: null,+ workflowVersion: null,+ workspaceMemberId: null,+ workspaceMember: null,+ companyId: null,+ company: null,+ viewId: mockedViewsData[0].id,+ view: mockedViewsData[0],+ taskId: null,+ task: null,+ rocketId: null,+ rocket: null,+ personId: null,+ person: null,+ opportunityId: null,+ opportunity: null,+ noteId: null,+ note: null,+ __typename: 'Favorite',+ },+ {+ id: '20202020-dede-koko-873b-de4264d89026',+ createdAt: new Date().toISOString(),+ updatedAt: new Date().toISOString(),+ deletedAt: null,+ position: 1,+ recordId: null,+ workflowId: null,+ workflow: null,+ workflowRunId: null,+ workflowRun: null,+ workflowVersionId: null,+ workflowVersion: null,+ workspaceMemberId: null,+ workspaceMember: null,+ companyId: null,+ company: null,+ viewId: mockedViewsData[1].id,+ view: mockedViewsData[1],+ taskId: null,+ task: null,+ rocketId: null,+ rocket: null,+ personId: null,+ person: null,+ opportunityId: null,+ opportunity: null,+ noteId: null,+ note: null,+ __typename: 'Favorite',+ },+ {+ id: '20202020-dede-koko-873b-de4264d89026',+ createdAt: new Date().toISOString(),+ updatedAt: new Date().toISOString(),+ deletedAt: null,+ position: 1,+ recordId: null,+ workflowId: null,+ workflow: null,+ workflowRunId: null,+ workflowRun: null,+ workflowVersionId: null,+ workflowVersion: null,+ workspaceMemberId: null,+ workspaceMember: null,+ companyId: null,+ company: null,+ viewId: mockedViewsData[1].id,+ view: mockedViewsData[1],+ taskId: null,+ task: null,+ rocketId: null,+ rocket: null,+ personId: null,+ person: null,+ opportunityId: null,+ opportunity: null,+ noteId: null,+ note: null,+ __typename: 'Favorite',+ },];diff --git a/packages/twenty-front/src/testing/mock-data/views.ts b/packages/twenty-front/src/testing/mock-data/views.tsindex 2bb0edd27e9..77eab014239 100644--- a/packages/twenty-front/src/testing/mock-data/views.ts+++ b/packages/twenty-front/src/testing/mock-data/views.ts@@ -67,7 +67,7 @@ export const mockedViewsData = [objectMetadataId: companyObjectMetadata?.id,type: 'table',icon: 'IconSkyline',- key: 'INDEX',+ key: null,kanbanFieldMetadataId: null,position: 0,createdAt: '2021-09-01T00:00:00.000Z',