From c7c33f73eae5ae8cd80fb26387b5989c2273a94c Mon Sep 17 00:00:00 2001 From: JF-Cozy Date: Tue, 22 Oct 2024 15:45:57 +0200 Subject: [PATCH] feat(Assistant): Move AssistantWrapperMobile for better rendering with FAB --- src/assistant/AssistantWrapperMobile.jsx | 50 ++++++++++++------------ src/components/AddButton/AddButton.jsx | 1 - src/components/Home.jsx | 2 - src/containers/App.jsx | 2 + src/containers/App.spec.jsx | 1 + test/AppLike.jsx | 9 +++-- 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/assistant/AssistantWrapperMobile.jsx b/src/assistant/AssistantWrapperMobile.jsx index 9d6ec80c21..f434019b36 100644 --- a/src/assistant/AssistantWrapperMobile.jsx +++ b/src/assistant/AssistantWrapperMobile.jsx @@ -7,11 +7,11 @@ import { getFlagshipMetadata } from 'cozy-device-helper' import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints' import { useCozyTheme } from 'cozy-ui/transpiled/react/providers/CozyTheme' import SearchBar from 'cozy-ui/transpiled/react/SearchBar' -import Portal from 'cozy-ui/transpiled/react/Portal' import Icon from 'cozy-ui/transpiled/react/Icon' import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n' import AssistantIcon from 'assets/images/icon-assistant.png' +import { FLAG_FAB_BUTTON_ENABLED } from 'components/AddButton/helpers' import styles from './styles.styl' @@ -24,31 +24,29 @@ export const AssistantWrapperMobile = () => { if (!flag('cozy.assistant.enabled') || !isMobile) return null return ( - -
- - } - type="button" - label={t('assistant.search.placeholder')} - onClick={() => navigate('search')} - /> -
-
+
+ + } + type="button" + label={t('assistant.search.placeholder')} + onClick={() => navigate('connected/search')} + /> +
) } diff --git a/src/components/AddButton/AddButton.jsx b/src/components/AddButton/AddButton.jsx index 7251e1c338..93338bd0df 100644 --- a/src/components/AddButton/AddButton.jsx +++ b/src/components/AddButton/AddButton.jsx @@ -24,7 +24,6 @@ const styles = { right: '1rem', bottom: '1rem', position: 'fixed', - zIndex: 'var(--zIndex-low)', marginBottom: immersive ? 'var(--flagship-bottom-height)' : 0 }) } diff --git a/src/components/Home.jsx b/src/components/Home.jsx index e8c830f1d6..0a3ec8a13c 100644 --- a/src/components/Home.jsx +++ b/src/components/Home.jsx @@ -9,7 +9,6 @@ import { getFlagshipMetadata } from 'cozy-device-helper' import { Main, Content } from 'cozy-ui/transpiled/react/Layout' import { useBreakpoints } from 'cozy-ui/transpiled/react/providers/Breakpoints' -import AssistantWrapperMobile from 'assistant/AssistantWrapperMobile' import AssistantWrapperDesktop from 'assistant/AssistantWrapperDesktop' import Applications from 'components/Applications' import ScrollToTopOnMount from 'components/ScrollToTopOnMount' @@ -30,7 +29,6 @@ const Home = ({ setAppsReady, wrapper }) => { {pathname === '/connected' && } - { + {isFlagshipApp() && } {flag(FLAG_FAB_BUTTON_ENABLED) && isMobile && } diff --git a/src/containers/App.spec.jsx b/src/containers/App.spec.jsx index cc7bf5c1c4..8ea3a353f3 100644 --- a/src/containers/App.spec.jsx +++ b/src/containers/App.spec.jsx @@ -31,6 +31,7 @@ jest.mock('react-router-dom', () => ({ ...jest.requireActual('react-router-dom'), // eslint-disable-next-line react/display-name Routes: jest.fn(), + useNavigate: () => () => {}, // eslint-disable-next-line react/display-name withRouter: Component => props => })) diff --git a/test/AppLike.jsx b/test/AppLike.jsx index 48db81948b..bc4d7e29b3 100644 --- a/test/AppLike.jsx +++ b/test/AppLike.jsx @@ -1,14 +1,17 @@ import React from 'react' import { createStore } from 'redux' -import { CozyProvider } from 'cozy-client' -import { createMockClient } from 'cozy-client/dist/mock' import { Provider as ReduxProvider } from 'react-redux' import PropTypes from 'prop-types' + +import { CozyProvider } from 'cozy-client' +import { createMockClient } from 'cozy-client/dist/mock' import { BreakpointsProvider } from 'cozy-ui/transpiled/react/providers/Breakpoints' import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme' import I18n from 'cozy-ui/transpiled/react/providers/I18n' -import { BackupDataProvider } from 'components/BackupNotification/useBackupData' import AlertProvider from 'cozy-ui/transpiled/react/providers/Alert' + +import { BackupDataProvider } from 'components/BackupNotification/useBackupData' + import enLocale from '../src/locales/en.json' const fakeDefaultReduxState = {