Skip to content

The open alternative to Salesforce, designed for AI.

Make the mobile navigation menu a real home page (#24168)

Félix Malfait06bb4ea7ec03
diff --git a/packages/twenty-front/src/hooks/__tests__/usePageChangeEffectNavigateLocation.test.ts b/packages/twenty-front/src/hooks/__tests__/usePageChangeEffectNavigateLocation.test.ts
index afbcd715402..4f030dccc31 100644
--- a/packages/twenty-front/src/hooks/__tests__/usePageChangeEffectNavigateLocation.test.ts
+++ b/packages/twenty-front/src/hooks/__tests__/usePageChangeEffectNavigateLocation.test.ts
@@ -297,6 +297,16 @@ const testCases: {
{ loc: AppPath.AiChat, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.INVITE_TEAM, res: AppPath.InviteTeam },
{ loc: AppPath.AiChat, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.BOOK_CALL, res: AppPath.BookCall },
{ loc: AppPath.AiChat, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.COMPLETED, res: undefined },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.PLAN_REQUIRED, res: AppPath.PlanRequired },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: true, onboardingStatus: OnboardingStatus.COMPLETED, res: getSettingsPath(SettingsPath.Billing) },
+ { loc: AppPath.Home, isLogged: false, isWorkspaceSuspended: false, onboardingStatus: undefined, res: AppPath.SignInUp },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.WORKSPACE_ACTIVATION, res: AppPath.WorkspaceActivation },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.PROFILE_CREATION, res: AppPath.CreateProfile },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.SYNC_EMAIL, res: AppPath.SyncEmails },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.APPS_INSTALLATION, res: AppPath.InstallApps },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.INVITE_TEAM, res: AppPath.InviteTeam },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.BOOK_CALL, res: AppPath.BookCall },
+ { loc: AppPath.Home, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.COMPLETED, res: undefined },
{ loc: AppPath.OpportunitiesPage, isLogged: true, isWorkspaceSuspended: false, onboardingStatus: OnboardingStatus.PLAN_REQUIRED, res: AppPath.PlanRequired },
{ loc: AppPath.OpportunitiesPage, isLogged: true, isWorkspaceSuspended: true, onboardingStatus: OnboardingStatus.COMPLETED, res: getSettingsPath(SettingsPath.Billing) },
diff --git a/packages/twenty-front/src/modules/app/hooks/useCreateWorkspaceAppRouter.tsx b/packages/twenty-front/src/modules/app/hooks/useCreateWorkspaceAppRouter.tsx
index d0215379d8a..5b9c925c5d2 100644
--- a/packages/twenty-front/src/modules/app/hooks/useCreateWorkspaceAppRouter.tsx
+++ b/packages/twenty-front/src/modules/app/hooks/useCreateWorkspaceAppRouter.tsx
@@ -117,6 +117,12 @@ const AiChatPage = lazy(() =>
})),
);
+const MobileHomePage = lazy(() =>
+ import('~/pages/mobile-home/MobileHomePage').then((module) => ({
+ default: module.MobileHomePage,
+ })),
+);
+
const NotFound = lazy(() =>
import('~/pages/not-found/NotFound').then((module) => ({
default: module.NotFound,
@@ -184,6 +190,14 @@ const createWorkspaceAppRouter = (
</LazyRoute>
}
/>
+ <Route
+ path={AppPath.Home}
+ element={
+ <LazyRoute>
+ <MobileHomePage />
+ </LazyRoute>
+ }
+ />
<Route
path={AppPath.SettingsCatchAll}
element={
diff --git a/packages/twenty-front/src/modules/navigation-menu-item/display/sections/workspace/components/WorkspaceSection.tsx b/packages/twenty-front/src/modules/navigation-menu-item/display/sections/workspace/components/WorkspaceSection.tsx
index da87542a5aa..3436701c234 100644
--- a/packages/twenty-front/src/modules/navigation-menu-item/display/sections/workspace/components/WorkspaceSection.tsx
+++ b/packages/twenty-front/src/modules/navigation-menu-item/display/sections/workspace/components/WorkspaceSection.tsx
@@ -12,6 +12,7 @@ import {
} from 'twenty-ui/icon';
import { LightIconButton } from 'twenty-ui/input';
import { themeCssVariables } from 'twenty-ui/theme-constants';
+import { useIsMobile } from 'twenty-ui/utilities';
import { useEnterLayoutCustomizationMode } from '@/layout-customization/hooks/useEnterLayoutCustomizationMode';
import { isLayoutCustomizationModeEnabledState } from '@/layout-customization/states/isLayoutCustomizationModeEnabledState';
@@ -47,6 +48,7 @@ const StyledRightIconsContainer = styled.div`
`;
export const WorkspaceSection = () => {
+ const isMobile = useIsMobile();
const items = useNavigationMenuItemSectionItems();
const { workspaceNavigationMenuItemsSorted } = useSortedNavigationMenuItems();
const objectMetadataItems = useAtomStateValue(objectMetadataItemsSelector);
@@ -198,27 +200,31 @@ export const WorkspaceSection = () => {
sectionTitle={t`Workspace`}
items={items}
rightIcon={
- <StyledRightIconsContainer>
- {isLayoutCustomizationModeEnabled ? (
- <LightIconButton
- Icon={IconPlus}
- accent="tertiary"
- size="small"
- onClick={handleAddMenuItem}
- />
- ) : (
- hasLayoutsPermission && (
- <div onMouseEnter={preloadNavigationMenuItemDndKit}>
- <LightIconButton
- Icon={IconTool}
- accent="tertiary"
- size="small"
- onClick={handleEditClick}
- />
- </div>
- )
- )}
- </StyledRightIconsContainer>
+ // Customising the menu is a desktop job, so mobile shows neither the
+ // entry point nor the add button it turns into.
+ isMobile ? undefined : (
+ <StyledRightIconsContainer>
+ {isLayoutCustomizationModeEnabled ? (
+ <LightIconButton
+ Icon={IconPlus}
+ accent="tertiary"
+ size="small"
+ onClick={handleAddMenuItem}
+ />
+ ) : (
+ hasLayoutsPermission && (
+ <div onMouseEnter={preloadNavigationMenuItemDndKit}>
+ <LightIconButton
+ Icon={IconTool}
+ accent="tertiary"
+ size="small"
+ onClick={handleEditClick}
+ />
+ </div>
+ )
+ )}
+ </StyledRightIconsContainer>
+ )
}
selectedNavigationMenuItemId={selectedNavigationMenuItemIdInEditMode}
onNavigationMenuItemClick={
diff --git a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
index 1b15fbbc138..6df9cea0a88 100644
--- a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
@@ -2,6 +2,7 @@ import { useIsSettingsDrawer } from '@/navigation/hooks/useIsSettingsDrawer';
import { MainNavigationDrawer } from '@/navigation/components/MainNavigationDrawer';
import { SettingsNavigationDrawer } from '@/navigation/components/SettingsNavigationDrawer';
+import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
export type AppNavigationDrawerProps = {
className?: string;
@@ -10,11 +11,17 @@ export type AppNavigationDrawerProps = {
export const AppNavigationDrawer = ({
className,
}: AppNavigationDrawerProps) => {
+ const isMobile = useIsMobile();
const isSettingsDrawer = useIsSettingsDrawer();
- return isSettingsDrawer ? (
- <SettingsNavigationDrawer className={className} />
- ) : (
- <MainNavigationDrawer className={className} />
- );
+ if (isSettingsDrawer) {
+ return <SettingsNavigationDrawer className={className} />;
+ }
+
+ // The main navigation is the home page on mobile, not a drawer.
+ if (isMobile) {
+ return null;
+ }
+
+ return <MainNavigationDrawer className={className} />;
};
diff --git a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawer.tsx b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawer.tsx
index 2fd59b610a3..99faec2b850 100644
--- a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawer.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawer.tsx
@@ -12,10 +12,10 @@ import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomState
import { PermissionFlagType } from '~/generated-metadata/graphql';
export const MainNavigationDrawer = ({ className }: { className?: string }) => {
+ const currentWorkspace = useAtomStateValue(currentWorkspaceState);
const navigationDrawerActiveTab = useAtomStateValue(
navigationDrawerActiveTabState,
);
- const currentWorkspace = useAtomStateValue(currentWorkspaceState);
const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
const showAiChatContent =
diff --git a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
index e282748ace8..578f7990f69 100644
--- a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerTabsRow.tsx
@@ -8,22 +8,19 @@ import {
} from 'twenty-ui/icon';
import { OverflowingTextWithTooltip } from 'twenty-ui/surfaces';
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
-import { useIsMobile } from 'twenty-ui/utilities';
import { useContext } from 'react';
import { useSwitchToNewAiChat } from '@/ai/hooks/useSwitchToNewAiChat';
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
-import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { navigationDrawerActiveTabState } from '@/ui/navigation/states/navigationDrawerActiveTabState';
import {
type NavigationDrawerActiveTab,
NAVIGATION_DRAWER_TABS,
} from '@/ui/navigation/states/navigationDrawerTabs';
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { PermissionFlagType } from '~/generated-metadata/graphql';
const StyledRow = styled.div<{ isExpanded: boolean }>`
@@ -149,19 +146,12 @@ export const MainNavigationDrawerTabsRow = ({
navigationMenuTabLabel = t`Home`,
}: MainNavigationDrawerTabsRowProps) => {
const { theme } = useContext(ThemeContext);
- const isMobile = useIsMobile();
- const isNavigationDrawerExpanded = useAtomStateValue(
- isNavigationDrawerExpandedState,
- );
const [navigationDrawerActiveTab, setNavigationDrawerActiveTab] =
useAtomState(navigationDrawerActiveTabState);
const { switchToNewChat } = useSwitchToNewAiChat();
- const setIsNavigationDrawerExpanded = useSetAtomState(
- isNavigationDrawerExpandedState,
- );
const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
- const isExpanded = isNavigationDrawerExpanded || isMobile;
+ const isExpanded = useIsNavigationDrawerContentExpanded();
if (!hasAiPermission) {
return null;
@@ -180,9 +170,6 @@ export const MainNavigationDrawerTabsRow = ({
};
const handleNewChatClick = () => {
- if (isMobile) {
- setIsNavigationDrawerExpanded(false);
- }
switchToNewChat();
};
@@ -196,37 +183,28 @@ export const MainNavigationDrawerTabsRow = ({
const getTabIconColor = (isActive: boolean) =>
isActive ? theme.font.color.primary : theme.font.color.tertiary;
+ // The mobile home page adds a settings tab this two-tab pill does not have, so
+ // anything that is not the chat tab belongs to the menu tab here.
+ const isNavigationMenuTabActive =
+ navigationDrawerActiveTab !== NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY;
+
return (
<StyledRow isExpanded={isExpanded}>
<NavigationDrawerAnimatedCollapseWrapper>
<StyledTabsPill role="tablist" aria-label={t`Navigation tabs`}>
<StyledTabWrapper
- isActive={
- navigationDrawerActiveTab ===
- NAVIGATION_DRAWER_TABS.NAVIGATION_MENU
- }
+ isActive={isNavigationMenuTabActive}
role="tab"
- aria-selected={
- navigationDrawerActiveTab ===
- NAVIGATION_DRAWER_TABS.NAVIGATION_MENU
- }
+ aria-selected={isNavigationMenuTabActive}
aria-label={navigationMenuTabLabel}
- tabIndex={
- navigationDrawerActiveTab ===
- NAVIGATION_DRAWER_TABS.NAVIGATION_MENU
- ? 0
- : -1
- }
+ tabIndex={isNavigationMenuTabActive ? 0 : -1}
onClick={handleTabClick(NAVIGATION_DRAWER_TABS.NAVIGATION_MENU)}
onKeyDown={handleTabKeyDown(NAVIGATION_DRAWER_TABS.NAVIGATION_MENU)}
>
<StyledTabIcon>
<NavigationMenuTabIcon
size={theme.icon.size.md}
- color={getTabIconColor(
- navigationDrawerActiveTab ===
- NAVIGATION_DRAWER_TABS.NAVIGATION_MENU,
- )}
+ color={getTabIconColor(isNavigationMenuTabActive)}
/>
</StyledTabIcon>
</StyledTabWrapper>
diff --git a/packages/twenty-front/src/modules/navigation/components/MobileHomeTabsRow.tsx b/packages/twenty-front/src/modules/navigation/components/MobileHomeTabsRow.tsx
new file mode 100644
index 00000000000..546af1a742b
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/components/MobileHomeTabsRow.tsx
@@ -0,0 +1,180 @@
+import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
+import { navigationDrawerActiveTabState } from '@/ui/navigation/states/navigationDrawerActiveTabState';
+import {
+ type NavigationDrawerActiveTab,
+ NAVIGATION_DRAWER_TABS,
+} from '@/ui/navigation/states/navigationDrawerTabs';
+import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { useContext } from 'react';
+import {
+ type IconComponent,
+ IconComment,
+ IconHome,
+ IconSettings,
+} from 'twenty-ui/icon';
+import { isDefined } from 'twenty-shared/utils';
+import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
+import { PermissionFlagType } from '~/generated-metadata/graphql';
+
+const StyledPill = styled.div`
+ align-items: center;
+ background: ${themeCssVariables.background.secondary};
+ border: 1px solid ${themeCssVariables.border.color.medium};
+ border-radius: ${themeCssVariables.border.radius.pill};
+ box-sizing: border-box;
+ corner-shape: round;
+ display: flex;
+ gap: ${themeCssVariables.spacing[0.5]};
+ height: ${themeCssVariables.spacing[8]};
+ max-width: 100%;
+ padding: 3px;
+ width: max-content;
+`;
+
+const StyledTab = styled.div<{ isActive: boolean }>`
+ align-items: center;
+ background: ${({ isActive }) =>
+ isActive ? themeCssVariables.background.transparent.light : 'transparent'};
+ border-radius: ${themeCssVariables.border.radius.pill};
+ color: ${({ isActive }) =>
+ isActive
+ ? themeCssVariables.font.color.primary
+ : themeCssVariables.font.color.tertiary};
+ corner-shape: round;
+ cursor: pointer;
+ display: flex;
+ font-size: ${themeCssVariables.font.size.sm};
+ font-weight: ${themeCssVariables.font.weight.medium};
+ gap: ${themeCssVariables.spacing[1]};
+ height: 100%;
+ justify-content: center;
+ padding-inline: ${({ isActive }) =>
+ isActive ? themeCssVariables.spacing[3] : themeCssVariables.spacing[2]};
+ white-space: nowrap;
+
+ &:hover {
+ background: ${({ isActive }) =>
+ isActive
+ ? themeCssVariables.background.transparent.light
+ : themeCssVariables.background.transparent.lighter};
+ }
+`;
+
+const StyledTabIcon = styled.div`
+ align-items: center;
+ display: flex;
+ flex-shrink: 0;
+ justify-content: center;
+`;
+
+export const MobileHomeTabsRow = () => {
+ const { t } = useLingui();
+ const { theme } = useContext(ThemeContext);
+ const [navigationDrawerActiveTab, setNavigationDrawerActiveTab] =
+ useAtomState(navigationDrawerActiveTabState);
+ const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
+
+ const tabs: {
+ tab: NavigationDrawerActiveTab;
+ label: string;
+ Icon: IconComponent;
+ }[] = [
+ {
+ tab: NAVIGATION_DRAWER_TABS.NAVIGATION_MENU,
+ label: t`Home`,
+ Icon: IconHome,
+ },
+ ...(hasAiPermission
+ ? [
+ {
+ tab: NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY,
+ label: t`Chat`,
+ Icon: IconComment,
+ },
+ ]
+ : []),
+ {
+ tab: NAVIGATION_DRAWER_TABS.SETTINGS,
+ label: t`Settings`,
+ Icon: IconSettings,
+ },
+ ];
+
+ // Only the selected tab is in the tab order, so the arrow, Home and End keys
+ // are the only way to reach the others from the keyboard.
+ const getTabIndexForKey = (key: string, currentIndex: number) => {
+ if (key === 'ArrowRight') {
+ return (currentIndex + 1) % tabs.length;
+ }
+ if (key === 'ArrowLeft') {
+ return (currentIndex - 1 + tabs.length) % tabs.length;
+ }
+ if (key === 'Home') {
+ return 0;
+ }
+ if (key === 'End') {
+ return tabs.length - 1;
+ }
+ return null;
+ };
+
+ const handleTabKeyDown =
+ (currentIndex: number) => (event: React.KeyboardEvent<HTMLDivElement>) => {
+ if (event.key === 'Enter' || event.key === ' ') {
+ event.preventDefault();
+ setNavigationDrawerActiveTab(tabs[currentIndex].tab);
+ return;
+ }
+
+ const nextIndex = getTabIndexForKey(event.key, currentIndex);
+
+ if (!isDefined(nextIndex)) {
+ return;
+ }
+
+ event.preventDefault();
+ setNavigationDrawerActiveTab(tabs[nextIndex].tab);
+
+ const nextTabElement =
+ event.currentTarget.parentElement?.children[nextIndex];
+
+ if (nextTabElement instanceof HTMLElement) {
+ nextTabElement.focus();
+ }
+ };
+
+ return (
+ <StyledPill role="tablist" aria-label={t`Navigation tabs`}>
+ {tabs.map(({ tab, label, Icon }, index) => {
+ const isActive = navigationDrawerActiveTab === tab;
+
+ return (
+ <StyledTab
+ key={tab}
+ isActive={isActive}
+ role="tab"
+ aria-selected={isActive}
+ aria-label={label}
+ tabIndex={isActive ? 0 : -1}
+ onClick={() => setNavigationDrawerActiveTab(tab)}
+ onKeyDown={handleTabKeyDown(index)}
+ >
+ <StyledTabIcon>
+ <Icon
+ size={theme.icon.size.md}
+ color={
+ isActive
+ ? theme.font.color.primary
+ : theme.font.color.tertiary
+ }
+ />
+ </StyledTabIcon>
+ {isActive && label}
+ </StyledTab>
+ );
+ })}
+ </StyledPill>
+ );
+};
diff --git a/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx b/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
index 0312a712643..86b30c33de6 100644
--- a/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
@@ -3,44 +3,40 @@ import { useLingui } from '@lingui/react/macro';
import { useSwitchToNewAiChat } from '@/ai/hooks/useSwitchToNewAiChat';
import { MAIN_CONTEXT_STORE_INSTANCE_ID } from '@/context-store/constants/MainContextStoreInstanceId';
import { contextStoreCurrentObjectMetadataItemIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataItemIdComponentState';
-import { useDefaultHomePagePath } from '@/navigation/hooks/useDefaultHomePagePath';
+import { useIsSettingsDrawer } from '@/navigation/hooks/useIsSettingsDrawer';
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
-import { currentMobileNavigationDrawerState } from '@/navigation/states/currentMobileNavigationDrawerState';
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
import { useOpenRecordsSearchPageInSidePanel } from '@/side-panel/hooks/useOpenRecordsSearchPageInSidePanel';
import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
import { isSidePanelOpenedState } from '@/side-panel/states/isSidePanelOpenedState';
+import { currentMobileNavigationDrawerState } from '@/navigation/states/currentMobileNavigationDrawerState';
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
-import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
import { useSetAtomComponentState } from '@/ui/utilities/state/jotai/hooks/useSetAtomComponentState';
-import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
+import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { useNavigate } from 'react-router-dom';
+import { useLocation, useNavigate } from 'react-router-dom';
+import { AppPath } from 'twenty-shared/types';
import {
type IconComponent,
- IconList,
+ IconHome,
IconMessageCirclePlus,
IconSearch,
} from 'twenty-ui/icon';
import { NavigationBar } from 'twenty-ui/navigation';
import { PermissionFlagType } from '~/generated-metadata/graphql';
-type NavigationBarItemName = 'main' | 'search' | 'newAiChat';
+type NavigationBarItemName = 'home' | 'search' | 'newAiChat';
export const MobileNavigationBar = () => {
const { t } = useLingui();
const navigate = useNavigate();
- const { defaultHomePagePath } = useDefaultHomePagePath();
+ const { pathname } = useLocation();
const isSidePanelOpened = useAtomStateValue(isSidePanelOpenedState);
- const navigationMemorizedUrl = useAtomStateValue(navigationMemorizedUrlState);
const { closeSidePanelMenu } = useSidePanelMenu();
const { openRecordsSearchPage } = useOpenRecordsSearchPageInSidePanel();
const isSettingsPage = useIsSettingsPage();
- const [isNavigationDrawerExpanded, setIsNavigationDrawerExpanded] =
- useAtomState(isNavigationDrawerExpandedState);
- const [currentMobileNavigationDrawer, setCurrentMobileNavigationDrawer] =
- useAtomState(currentMobileNavigationDrawerState);
+ const isSettingsDrawer = useIsSettingsDrawer();
const { switchToNewChat } = useSwitchToNewAiChat();
const { alphaSortedActiveNonSystemObjectMetadataItems } =
useFilteredObjectMetadataItems();
@@ -50,12 +46,33 @@ export const MobileNavigationBar = () => {
contextStoreCurrentObjectMetadataItemIdComponentState,
MAIN_CONTEXT_STORE_INSTANCE_ID,
);
+ const setCurrentMobileNavigationDrawer = useSetAtomState(
+ currentMobileNavigationDrawerState,
+ );
+ const setIsNavigationDrawerExpanded = useSetAtomState(
+ isNavigationDrawerExpandedState,
+ );
+
+ // Settings is the one drawer left on mobile, and it stays open across
+ // navigation, so it would cover whatever the bottom bar goes to. Guarded so a
+ // tap outside settings leaves the persisted expansion alone: it is shared with
+ // the desktop drawer, which every tap would otherwise collapse.
+ const closeSettingsDrawer = () => {
+ if (!isSettingsDrawer) {
+ return;
+ }
- const activeItemName = isNavigationDrawerExpanded
- ? currentMobileNavigationDrawer
- : isSidePanelOpened
- ? 'search'
- : 'main';
+ setCurrentMobileNavigationDrawer('main');
+ setIsNavigationDrawerExpanded(false);
+ };
+
+ const isHomePage = pathname === AppPath.Home;
+
+ const activeItemName: NavigationBarItemName | undefined = isSidePanelOpened
+ ? 'search'
+ : isHomePage
+ ? 'home'
+ : undefined;
const items: {
name: NavigationBarItemName;
@@ -64,23 +81,13 @@ export const MobileNavigationBar = () => {
onClick: () => void;
}[] = [
{
- name: 'main',
- label: t`Main navigation`,
- Icon: IconList,
+ name: 'home',
+ label: t`Home`,
+ Icon: IconHome,
onClick: () => {
closeSidePanelMenu();
- setIsNavigationDrawerExpanded(
- (previousIsOpen) => activeItemName !== 'main' || !previousIsOpen,
- );
- setCurrentMobileNavigationDrawer('main');
-
- if (isSettingsPage) {
- navigate(
- navigationMemorizedUrl !== '/'
- ? navigationMemorizedUrl
- : defaultHomePagePath,
- );
- }
+ closeSettingsDrawer();
+ navigate(AppPath.Home);
},
},
{
@@ -88,8 +95,8 @@ export const MobileNavigationBar = () => {
label: t`Search`,
Icon: IconSearch,
onClick: () => {
- setIsNavigationDrawerExpanded(false);
closeSidePanelMenu();
+ closeSettingsDrawer();
if (isSettingsPage) {
const firstObjectMetadataItem =
@@ -111,8 +118,8 @@ export const MobileNavigationBar = () => {
label: t`New AI chat`,
Icon: IconMessageCirclePlus,
onClick: () => {
- setIsNavigationDrawerExpanded(false);
closeSidePanelMenu();
+ closeSettingsDrawer();
switchToNewChat();
},
},
@@ -120,5 +127,5 @@ export const MobileNavigationBar = () => {
: []),
];
- return <NavigationBar activeItemName={activeItemName} items={items} />;
+ return <NavigationBar activeItemName={activeItemName ?? ''} items={items} />;
};
diff --git a/packages/twenty-front/src/modules/navigation/hooks/useIsNavigationDrawerContentExpanded.ts b/packages/twenty-front/src/modules/navigation/hooks/useIsNavigationDrawerContentExpanded.ts
new file mode 100644
index 00000000000..9f8fc2959ff
--- /dev/null
+++ b/packages/twenty-front/src/modules/navigation/hooks/useIsNavigationDrawerContentExpanded.ts
@@ -0,0 +1,13 @@
+import { useNavigationDrawerExpanded } from '@/navigation/hooks/useNavigationDrawerExpanded';
+import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+
+// Whether the navigation content renders its full width rather than the icon
+// rail. Mobile has no rail: the content is either a full-width drawer or the
+// home page, so it always renders expanded there. Use this for the content,
+// and useNavigationDrawerExpanded for the drawer container itself.
+export const useIsNavigationDrawerContentExpanded = () => {
+ const isMobile = useIsMobile();
+ const isNavigationDrawerExpanded = useNavigationDrawerExpanded();
+
+ return isNavigationDrawerExpanded || isMobile;
+};
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
index fb10935138c..74cab0fbc49 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton.tsx
@@ -10,7 +10,13 @@ import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useMemo } from 'react';
-export const MultiWorkspaceDropdownButton = () => {
+type MultiWorkspaceDropdownButtonProps = {
+ shouldHideLabel?: boolean;
+};
+
+export const MultiWorkspaceDropdownButton = ({
+ shouldHideLabel = false,
+}: MultiWorkspaceDropdownButtonProps) => {
const [multiWorkspaceDropdown, setMultiWorkspaceDropdown] = useAtomState(
multiWorkspaceDropdownState,
);
@@ -32,13 +38,18 @@ export const MultiWorkspaceDropdownButton = () => {
return (
<Dropdown
dropdownId={MULTI_WORKSPACE_DROPDOWN_ID}
- dropdownOffset={{ y: -31, x: -5 }}
+ dropdownOffset={
+ // The drawer trigger is full width and the panel sits over it; the
+ // icon-only trigger is too small for that, so the panel drops below.
+ shouldHideLabel ? { y: 4, x: 0 } : { y: -31, x: -5 }
+ }
clickableComponent={
<MultiWorkspaceDropdownClickableComponent
disabled={isLayoutCustomizationModeEnabled}
+ shouldHideLabel={shouldHideLabel}
/>
}
- clickableComponentWidth="100%"
+ clickableComponentWidth={shouldHideLabel ? 'auto' : '100%'}
disableClickForClickableComponent={isLayoutCustomizationModeEnabled}
dropdownComponents={<DropdownComponents />}
onClose={() => {
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownClickableComponent.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownClickableComponent.tsx
index c59aee408db..b2da84c7ff8 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownClickableComponent.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspaceDropdownClickableComponent.tsx
@@ -7,7 +7,7 @@ import {
} from '@/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/internal/MultiWorkspacesDropdownStyles';
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
import { DEFAULT_WORKSPACE_LOGO } from '@/ui/navigation/navigation-drawer/constants/DefaultWorkspaceLogo';
-import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
import { useContext } from 'react';
@@ -16,17 +16,17 @@ import { ThemeContext } from 'twenty-ui/theme-constants';
type MultiWorkspaceDropdownClickableComponentProps = {
disabled?: boolean;
+ shouldHideLabel?: boolean;
};
export const MultiWorkspaceDropdownClickableComponent = ({
disabled,
+ shouldHideLabel = false,
}: MultiWorkspaceDropdownClickableComponentProps) => {
const { theme } = useContext(ThemeContext);
const currentWorkspace = useAtomStateValue(currentWorkspaceState);
- const isNavigationDrawerExpanded = useAtomStateValue(
- isNavigationDrawerExpandedState,
- );
+ const isNavigationDrawerExpanded = useIsNavigationDrawerContentExpanded();
return (
<StyledContainer
data-testid="workspace-dropdown"
@@ -39,17 +39,21 @@ export const MultiWorkspaceDropdownClickableComponent = ({
currentWorkspace?.logo ?? DEFAULT_WORKSPACE_LOGO,
)}
/>
- <StyledLabelWrapper>
- <NavigationDrawerAnimatedCollapseWrapper>
- <StyledLabel>{currentWorkspace?.displayName ?? ''}</StyledLabel>
- </NavigationDrawerAnimatedCollapseWrapper>
- </StyledLabelWrapper>
- <NavigationDrawerAnimatedCollapseWrapper>
- <StyledIconChevronDown
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
- />
- </NavigationDrawerAnimatedCollapseWrapper>
+ {!shouldHideLabel && (
+ <>
+ <StyledLabelWrapper>
+ <NavigationDrawerAnimatedCollapseWrapper>
+ <StyledLabel>{currentWorkspace?.displayName ?? ''}</StyledLabel>
+ </NavigationDrawerAnimatedCollapseWrapper>
+ </StyledLabelWrapper>
+ <NavigationDrawerAnimatedCollapseWrapper>
+ <StyledIconChevronDown
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ </NavigationDrawerAnimatedCollapseWrapper>
+ </>
+ )}
</StyledContainer>
);
};
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper.tsx
index fb758a13174..258c96610ce 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper.tsx
@@ -1,6 +1,5 @@
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
-import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { styled } from '@linaria/react';
import {
type AnimationControls,
@@ -22,9 +21,7 @@ export const NavigationDrawerAnimatedCollapseWrapper = ({
}) => {
const { theme } = useContext(ThemeContext);
const isSettingsPage = useIsSettingsPage();
- const isNavigationDrawerExpanded = useAtomStateValue(
- isNavigationDrawerExpandedState,
- );
+ const isNavigationDrawerExpanded = useIsNavigationDrawerContentExpanded();
if (isSettingsPage) {
return children;
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx
index a29f5099670..7b5e537a136 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton.tsx
@@ -1,4 +1,6 @@
+import { useIsSettingsDrawer } from '@/navigation/hooks/useIsSettingsDrawer';
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
+import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { navigationDrawerActiveTabState } from '@/ui/navigation/states/navigationDrawerActiveTabState';
import { NAVIGATION_DRAWER_TABS } from '@/ui/navigation/states/navigationDrawerTabs';
import { useAtomState } from '@/ui/utilities/state/jotai/hooks/useAtomState';
@@ -31,6 +33,8 @@ export const NavigationDrawerCollapseButton = ({
className,
direction = 'left',
}: NavigationDrawerCollapseButtonProps) => {
+ const isMobile = useIsMobile();
+ const isSettingsDrawer = useIsSettingsDrawer();
const [isNavigationDrawerExpanded, setIsNavigationDrawerExpanded] =
useAtomState(isNavigationDrawerExpandedState);
const setNavigationDrawerActiveTab = useSetAtomState(
@@ -44,6 +48,11 @@ export const NavigationDrawerCollapseButton = ({
setIsNavigationDrawerExpanded((previousIsExpanded) => !previousIsExpanded);
};
+ // The main navigation is a page on mobile, so there is no drawer to toggle.
+ if (isMobile && !isSettingsDrawer) {
+ return null;
+ }
+
return (
<StyledCollapseButton className={className} onClick={handleClick}>
<LightIconButton
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerHeader.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerHeader.tsx
index 8e9d8d98597..37584027597 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerHeader.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerHeader.tsx
@@ -7,9 +7,8 @@ import { MOBILE_VIEWPORT, themeCssVariables } from 'twenty-ui/theme-constants';
import { useOpenRecordsSearchPageInSidePanel } from '@/side-panel/hooks/useOpenRecordsSearchPageInSidePanel';
import { PAGE_BAR_MIN_HEIGHT } from '@/ui/layout/page/constants/PageBarMinHeight';
import { MultiWorkspaceDropdownButton } from '@/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton';
-import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { NavigationDrawerCollapseButton } from './NavigationDrawerCollapseButton';
const StyledContainer = styled.div<{ isExpanded: boolean }>`
@@ -74,16 +73,14 @@ export const NavigationDrawerHeader = ({
}: NavigationDrawerHeaderProps) => {
const isMobile = useIsMobile();
const { openRecordsSearchPage } = useOpenRecordsSearchPageInSidePanel();
- const isNavigationDrawerExpanded = useAtomStateValue(
- isNavigationDrawerExpandedState,
- );
+ const isExpanded = useIsNavigationDrawerContentExpanded();
return (
- <StyledContainer isExpanded={isNavigationDrawerExpanded}>
+ <StyledContainer isExpanded={isExpanded}>
<StyledWorkspaceDropdownContainer>
<MultiWorkspaceDropdownButton />
</StyledWorkspaceDropdownContainer>
- <StyledRightActions isExpanded={isNavigationDrawerExpanded}>
+ <StyledRightActions isExpanded={isExpanded}>
{!isMobile && (
<LightIconButton
Icon={IconSearch}
@@ -93,7 +90,7 @@ export const NavigationDrawerHeader = ({
aria-label={t`Search`}
/>
)}
- {isNavigationDrawerExpanded && showCollapseButton && (
+ {isExpanded && showCollapseButton && (
<StyledNavigationDrawerCollapseButtonContainer>
<NavigationDrawerCollapseButton direction="left" />
</StyledNavigationDrawerCollapseButtonContainer>
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
index 147f381d832..19748579ee8 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
@@ -1,4 +1,4 @@
-import { useNavigationDrawerExpanded } from '@/navigation/hooks/useNavigationDrawerExpanded';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { NAVIGATION_DRAWER_COLLAPSED_WIDTH } from '@/ui/layout/resizable-panel/constants/NavigationDrawerCollapsedWidth';
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
import { NavigationDrawerItemBreadcrumb } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemBreadcrumb';
@@ -270,7 +270,7 @@ export const NavigationDrawerItem = ({
}: NavigationDrawerItemProps) => {
const { theme } = useContext(ThemeContext);
const isMobile = useIsMobile();
- const isExpanded = useNavigationDrawerExpanded();
+ const isExpanded = useIsNavigationDrawerContentExpanded();
const setIsNavigationDrawerExpanded = useSetAtomState(
isNavigationDrawerExpandedState,
);
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItemsCollapsableContainer.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItemsCollapsableContainer.tsx
index f3103e010f5..e86cdc2d476 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItemsCollapsableContainer.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItemsCollapsableContainer.tsx
@@ -1,6 +1,5 @@
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
-import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { styled } from '@linaria/react';
import { type ReactNode, useContext } from 'react';
import {
@@ -44,9 +43,7 @@ export const NavigationDrawerItemsCollapsableContainer = ({
}: NavigationDrawerItemsCollapsableContainerProps) => {
const { theme } = useContext(ThemeContext);
const isSettingsPage = useIsSettingsPage();
- const isNavigationDrawerExpanded = useAtomStateValue(
- isNavigationDrawerExpandedState,
- );
+ const isNavigationDrawerExpanded = useIsNavigationDrawerContentExpanded();
const isExpanded = isNavigationDrawerExpanded || isSettingsPage;
const animate: AnimationControls | TargetAndTransition = isExpanded
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle.tsx
index dc93a8fc1e3..daba9b16ff9 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle.tsx
@@ -1,7 +1,6 @@
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
-import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
+import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { styled } from '@linaria/react';
import { motion } from 'framer-motion';
import React, { useContext } from 'react';
@@ -83,9 +82,7 @@ export const NavigationDrawerSectionTitle = ({
}: NavigationDrawerSectionTitleProps) => {
const { theme } = useContext(ThemeContext);
const isMobile = useIsMobile();
- const isNavigationDrawerExpanded = useAtomStateValue(
- isNavigationDrawerExpandedState,
- );
+ const isNavigationDrawerExpanded = useIsNavigationDrawerContentExpanded();
const isSettingsPage = useIsSettingsPage();
const handleTitleClick = (e: React.MouseEvent<HTMLDivElement>) => {
e.stopPropagation();
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawerCollapseButton.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawerCollapseButton.stories.tsx
index ae35611ecec..5f46a03fc3a 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawerCollapseButton.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawerCollapseButton.stories.tsx
@@ -1,11 +1,11 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { NavigationDrawerCollapseButton } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerCollapseButton';
-import { ComponentDecorator } from 'twenty-ui/testing';
+import { ComponentDecorator, RouterDecorator } from 'twenty-ui/testing';
const meta: Meta<typeof NavigationDrawerCollapseButton> = {
title: 'UI/Navigation/NavigationDrawer/NavigationDrawerCollapseButton',
- decorators: [ComponentDecorator],
+ decorators: [ComponentDecorator, RouterDecorator],
component: NavigationDrawerCollapseButton,
};
diff --git a/packages/twenty-front/src/modules/ui/navigation/states/navigationDrawerTabs.ts b/packages/twenty-front/src/modules/ui/navigation/states/navigationDrawerTabs.ts
index 64342864061..c16cd61abc1 100644
--- a/packages/twenty-front/src/modules/ui/navigation/states/navigationDrawerTabs.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/states/navigationDrawerTabs.ts
@@ -1,6 +1,7 @@
export const NAVIGATION_DRAWER_TABS = {
NAVIGATION_MENU: 'home',
AI_CHAT_HISTORY: 'chat',
+ SETTINGS: 'settings',
} as const;
export type NavigationDrawerActiveTab =
diff --git a/packages/twenty-front/src/pages/mobile-home/MobileHomePage.tsx b/packages/twenty-front/src/pages/mobile-home/MobileHomePage.tsx
new file mode 100644
index 00000000000..ac206d333a0
--- /dev/null
+++ b/packages/twenty-front/src/pages/mobile-home/MobileHomePage.tsx
@@ -0,0 +1,82 @@
+import { MainNavigationDrawerNavigationContent } from '@/navigation/components/MainNavigationDrawerNavigationContent';
+import { MobileHomeTabsRow } from '@/navigation/components/MobileHomeTabsRow';
+import { NavigationDrawerTabbedContent } from '@/navigation/components/NavigationDrawerTabbedContent';
+import { useDefaultHomePagePath } from '@/navigation/hooks/useDefaultHomePagePath';
+import { SettingsNavigationDrawerItems } from '@/settings/components/SettingsNavigationDrawerItems';
+import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
+import { MultiWorkspaceDropdownButton } from '@/ui/navigation/navigation-drawer/components/MultiWorkspaceDropdown/MultiWorkspaceDropdownButton';
+import { NavigationDrawerFixedContent } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerFixedContent';
+import { NavigationDrawerScrollableContent } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerScrollableContent';
+import { navigationDrawerActiveTabState } from '@/ui/navigation/states/navigationDrawerActiveTabState';
+import { NAVIGATION_DRAWER_TABS } from '@/ui/navigation/states/navigationDrawerTabs';
+import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
+import { styled } from '@linaria/react';
+import { Navigate } from 'react-router-dom';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
+import { PermissionFlagType } from '~/generated-metadata/graphql';
+
+const StyledContainer = styled.div`
+ box-sizing: border-box;
+ display: flex;
+ flex-direction: column;
+ gap: ${themeCssVariables.spacing[4]};
+ height: 100%;
+ min-height: 0;
+ padding: ${themeCssVariables.spacing[2]} 0 ${themeCssVariables.spacing[4]};
+ width: 100%;
+`;
+
+const StyledTopRow = styled.div`
+ align-items: center;
+ display: flex;
+ gap: ${themeCssVariables.spacing[2]};
+ justify-content: space-between;
+ width: 100%;
+`;
+
+export const MobileHomePage = () => {
+ const isMobile = useIsMobile();
+ const { defaultHomePagePath } = useDefaultHomePagePath();
+ const navigationDrawerActiveTab = useAtomStateValue(
+ navigationDrawerActiveTabState,
+ );
+ const hasAiPermission = useHasPermissionFlag(PermissionFlagType.AI);
+
+ // Desktop keeps the drawer, so the page has nothing to show there.
+ if (!isMobile) {
+ return <Navigate to={defaultHomePagePath} replace />;
+ }
+
+ const showAiChatContent =
+ hasAiPermission &&
+ navigationDrawerActiveTab === NAVIGATION_DRAWER_TABS.AI_CHAT_HISTORY;
+
+ const showSettingsContent =
+ navigationDrawerActiveTab === NAVIGATION_DRAWER_TABS.SETTINGS;
+
+ return (
+ <StyledContainer>
+ <NavigationDrawerFixedContent>
+ <StyledTopRow>
+ <MobileHomeTabsRow />
+ <MultiWorkspaceDropdownButton shouldHideLabel />
+ </StyledTopRow>
+ </NavigationDrawerFixedContent>
+
+ <NavigationDrawerScrollableContent>
+ <NavigationDrawerTabbedContent
+ showAiChatContent={showAiChatContent}
+ shouldMountAiChatContent={hasAiPermission}
+ navigationContent={
+ showSettingsContent ? (
+ <SettingsNavigationDrawerItems />
+ ) : (
+ <MainNavigationDrawerNavigationContent />
+ )
+ }
+ />
+ </NavigationDrawerScrollableContent>
+ </StyledContainer>
+ );
+};
diff --git a/packages/twenty-shared/src/types/AppPath.ts b/packages/twenty-shared/src/types/AppPath.ts
index c6840c94803..9cdbf65ec40 100644
--- a/packages/twenty-shared/src/types/AppPath.ts
+++ b/packages/twenty-shared/src/types/AppPath.ts
@@ -19,6 +19,8 @@ export enum AppPath {
// Onboarded
AiChat = '/chat/:threadId?',
Index = '/',
+ // Mobile only: the navigation menu is a page there rather than a drawer.
+ Home = '/home',
TasksPage = '/objects/tasks',
OpportunitiesPage = '/objects/opportunities',