From 59a1cc2c7a898bacd54bc156e867be4bf54f7ccc Mon Sep 17 00:00:00 2001 From: Antoine Clausse Date: Fri, 8 Nov 2024 10:40:15 +0100 Subject: [PATCH] Merge pull request #21718 from overleaf/td-bs5-nav-logged-out [BS5] Add missing logged-out items to React nav bar GitOrigin-RevId: 3dc681dcac46cdb68675f6034be56e2b96292c32 --- services/web/app/views/layout-react.pug | 3 ++ .../web/frontend/extracted-translations.json | 2 + .../bootstrap-5/navbar/default-navbar.tsx | 12 +++--- .../bootstrap-5/navbar/logged-out-items.tsx | 37 +++++++++++++++++++ .../types/default-navbar-metadata.ts | 2 + 5 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 services/web/frontend/js/features/ui/components/bootstrap-5/navbar/logged-out-items.tsx diff --git a/services/web/app/views/layout-react.pug b/services/web/app/views/layout-react.pug index 5fa3fec4b3..0e9b375c3e 100644 --- a/services/web/app/views/layout-react.pug +++ b/services/web/app/views/layout-react.pug @@ -17,6 +17,7 @@ block append meta - const canDisplaySplitTestMenu = hasFeature('saas') && (canDisplayAdminMenu || staffAccess?.splitTestMetrics || staffAccess?.splitTestManagement) - const canDisplaySurveyMenu = hasFeature('saas') && canDisplayAdminMenu - const enableUpgradeButton = projectDashboardReact && usersBestSubscription && usersBestSubscription.type === 'free' + - const showSignUpLink = hasFeature('registration-page') meta(name="ol-navbar" data-type="json" content={ customLogo: settings.nav.custom_logo, @@ -29,6 +30,8 @@ block append meta suppressNavbarRight: !!suppressNavbarRight, suppressNavContentLinks: !!suppressNavContentLinks, showSubscriptionLink: nav.showSubscriptionLink, + showSignUpLink: showSignUpLink, + currentUrl: currentUrl, sessionUser: sessionUser ? { email: sessionUser.email} : undefined, adminUrl: settings.adminUrl, items: cloneAndTranslateText(nav.header_extras) diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json index 786478e482..80abedb18d 100644 --- a/services/web/frontend/extracted-translations.json +++ b/services/web/frontend/extracted-translations.json @@ -838,6 +838,7 @@ "log_entry_maximum_entries_see_full_logs": "", "log_entry_maximum_entries_title": "", "log_hint_extra_info": "", + "log_in": "", "log_in_with_primary_email_address": "", "log_out": "", "log_out_lowercase_dot": "", @@ -1380,6 +1381,7 @@ "showing_x_out_of_n_projects": "", "showing_x_results": "", "showing_x_results_of_total": "", + "sign_up": "", "simple_search_mode": "", "single_sign_on_sso": "", "skip": "", diff --git a/services/web/frontend/js/features/ui/components/bootstrap-5/navbar/default-navbar.tsx b/services/web/frontend/js/features/ui/components/bootstrap-5/navbar/default-navbar.tsx index 33f30962a1..45625be250 100644 --- a/services/web/frontend/js/features/ui/components/bootstrap-5/navbar/default-navbar.tsx +++ b/services/web/frontend/js/features/ui/components/bootstrap-5/navbar/default-navbar.tsx @@ -6,15 +6,12 @@ import AdminMenu from '@/features/ui/components/bootstrap-5/navbar/admin-menu' import type { DefaultNavbarMetadata } from '@/features/ui/components/types/default-navbar-metadata' import NavItemFromData from '@/features/ui/components/bootstrap-5/navbar/nav-item-from-data' import LoggedInItems from '@/features/ui/components/bootstrap-5/navbar/logged-in-items' +import LoggedOutItems from '@/features/ui/components/bootstrap-5/navbar/logged-out-items' import HeaderLogoOrTitle from '@/features/ui/components/bootstrap-5/navbar/header-logo-or-title' import MaterialIcon from '@/shared/components/material-icon' import { useContactUsModal } from '@/shared/hooks/use-contact-us-modal' import { UserProvider } from '@/shared/context/user-context' -function LoggedOutItems() { - return Logged out -} - function DefaultNavbar(props: DefaultNavbarMetadata) { const { customLogo, @@ -27,6 +24,8 @@ function DefaultNavbar(props: DefaultNavbarMetadata) { suppressNavbarRight, suppressNavContentLinks, showSubscriptionLink, + showSignUpLink, + currentUrl, sessionUser, adminUrl, items, @@ -117,7 +116,10 @@ function DefaultNavbar(props: DefaultNavbarMetadata) { showSubscriptionLink={showSubscriptionLink} /> ) : ( - + )} diff --git a/services/web/frontend/js/features/ui/components/bootstrap-5/navbar/logged-out-items.tsx b/services/web/frontend/js/features/ui/components/bootstrap-5/navbar/logged-out-items.tsx new file mode 100644 index 0000000000..988c9c452a --- /dev/null +++ b/services/web/frontend/js/features/ui/components/bootstrap-5/navbar/logged-out-items.tsx @@ -0,0 +1,37 @@ +import { useTranslation } from 'react-i18next' +import NavLinkItem from '@/features/ui/components/bootstrap-5/navbar/nav-link-item' +import { sendMB } from '@/infrastructure/event-tracking' + +export default function LoggedOutItems({ + showSignUpLink, + currentUrl, +}: { + showSignUpLink: boolean + currentUrl: string +}) { + const { t } = useTranslation() + + return ( + <> + {showSignUpLink ? ( + { + sendMB('menu-clicked-register', { page: currentUrl }) + }} + > + {t('sign_up')} + + ) : null} + { + sendMB('menu-clicked-login', { page: currentUrl }) + }} + > + {t('log_in')} + + + ) +} diff --git a/services/web/frontend/js/features/ui/components/types/default-navbar-metadata.ts b/services/web/frontend/js/features/ui/components/types/default-navbar-metadata.ts index 5cb1b08231..4bba1baf1c 100644 --- a/services/web/frontend/js/features/ui/components/types/default-navbar-metadata.ts +++ b/services/web/frontend/js/features/ui/components/types/default-navbar-metadata.ts @@ -14,6 +14,8 @@ export type DefaultNavbarMetadata = { suppressNavbarRight: boolean suppressNavContentLinks: boolean showSubscriptionLink: boolean + showSignUpLink: boolean + currentUrl: string sessionUser?: NavbarSessionUser adminUrl?: string items: NavbarItemData[]