Skip to content

Commit

Permalink
feat(backup): Do not display backup link if flag not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
zatteo committed Jul 13, 2023
1 parent 5183013 commit 6f94e19
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/photos/components/AppRouter.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { createHashRouter, Navigate, RouterProvider } from 'react-router-dom'
import { isFlagshipApp } from 'cozy-device-helper'
import flag from 'cozy-flags'

import { Spinner } from 'cozy-ui/transpiled/react'

Expand All @@ -15,7 +16,8 @@ function ErrorBoundary() {
return <Navigate to="photos" replace />
}

const DEFAULT_ROUTE = isFlagshipApp() ? 'backup' : 'photos'
const DEFAULT_ROUTE =
flag('flagship.backup.enabled') && isFlagshipApp() ? 'backup' : 'photos'

const router = createHashRouter([
{
Expand Down
35 changes: 34 additions & 1 deletion src/photos/components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,43 @@ const NavLinks = () => {
)
}

const NoBackupNavLinks = () => {
const { t } = useI18n()

return (
<>
<NavItem>
<NavLink to="/photos">
<NavIcon icon="image" />
<NavText>{t('Nav.photos')}</NavText>
</NavLink>
</NavItem>
<NavItem data-testid="nav-to-albums">
<NavLink to="/albums">
<NavIcon icon="album" />
<NavText>{t('Nav.albums')}</NavText>
</NavLink>
</NavItem>
</>
)
}

const getNavLinks = () => {
if (flag('flagship.backup.enabled')) {
if (isFlagshipApp()) {
return <FlagshipNavLinks />
} else {
return <NavLinks />
}
}

return <NoBackupNavLinks />
}

export const Layout = ({ t }) => (
<LayoutUI>
<Sidebar className={styles['pho-sidebar']}>
<Nav>{isFlagshipApp() ? <FlagshipNavLinks /> : <NavLinks />}</Nav>
<Nav>{getNavLinks()}</Nav>
{!isFlagshipApp() && <ButtonClient />}
</Sidebar>

Expand Down

0 comments on commit 6f94e19

Please sign in to comment.