From d2934e8da4fb892f4b285ec30dab61c8f88b87ac Mon Sep 17 00:00:00 2001 From: Jozef Dochan <51478129+dochan-consultis@users.noreply.github.com> Date: Thu, 22 May 2025 14:45:06 +0200 Subject: [PATCH] feat: Display landing page only in demo mode (#226) --- frontend/messages/en.json | 2 +- .../src/app/[locale]/HeaderNavbarMenu.tsx | 30 +++-- frontend/src/app/[locale]/LandingPage.tsx | 106 +++++++++++++++++ frontend/src/app/[locale]/page.tsx | 107 ++---------------- 4 files changed, 132 insertions(+), 113 deletions(-) create mode 100644 frontend/src/app/[locale]/LandingPage.tsx diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 34af3c9..409a0e4 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -84,7 +84,7 @@ "languages": "Languages" }, "Toast": { - "need_signed_in": "You need signed in", + "need_signed_in": "You need to sign in", "session_expired": "Session expired" }, "Auth": { diff --git a/frontend/src/app/[locale]/HeaderNavbarMenu.tsx b/frontend/src/app/[locale]/HeaderNavbarMenu.tsx index 506ae15..b2b0353 100644 --- a/frontend/src/app/[locale]/HeaderNavbarMenu.tsx +++ b/frontend/src/app/[locale]/HeaderNavbarMenu.tsx @@ -24,6 +24,7 @@ import DropdownAccount from './DropdownAccount'; import DropdownLanguage from './DropdownLanguage'; import UserAvatar from '@/components/UserAvatar'; import { LocaleCodeType } from '@/types/locale'; +import Config from '@/config/config'; type NabbarMenuMessages = { projects: string; @@ -54,20 +55,25 @@ export default function HeaderNavbarMenu({ messages, locale }: Props) { label: messages.projects, isExternal: false, }, - { - uid: 'docs', - href: 'https://kimatata.github.io/unittcms/docs/getstarted/selfhost', - label: messages.docs, - isExternal: true, - }, - { - uid: 'roadmap', - href: 'https://kimatata.github.io/unittcms/docs/roadmap/', - label: messages.roadmap, - isExternal: true, - }, ]; + if (Config.isDemoSite) { + commonLinks.push( + { + uid: 'docs', + href: 'https://kimatata.github.io/unittcms/docs/getstarted/selfhost', + label: messages.docs, + isExternal: true, + }, + { + uid: 'roadmap', + href: 'https://kimatata.github.io/unittcms/docs/roadmap/', + label: messages.roadmap, + isExternal: true, + } + ); + } + const router = useRouter(); const pathname = usePathname(); async function changeLocale(nextLocale: string) { diff --git a/frontend/src/app/[locale]/LandingPage.tsx b/frontend/src/app/[locale]/LandingPage.tsx new file mode 100644 index 0000000..0dd7701 --- /dev/null +++ b/frontend/src/app/[locale]/LandingPage.tsx @@ -0,0 +1,106 @@ +import { useTranslations } from 'next-intl'; +import { Divider } from '@heroui/react'; +import PaneMainTitle from './PaneMainTitle'; +import PaneMainFeatures from './PaneMainFeatures'; +import DemoImage from './DemoImage'; +import { title, subtitle } from '@/components/primitives'; +import { PageType } from '@/types/base'; +import { LocaleCodeType } from '@/types/locale'; + +export default function LandingPage({ params }: PageType) { + const t = useTranslations('Index'); + + const demoImages = [ + { + uid: 'project', + title: t('project_title'), + subTitle: t('project_subtitle'), + }, + { + uid: 'case', + title: t('case_management_title'), + subTitle: t('case_management_subtitle'), + }, + { + uid: 'run', + title: t('run_management_title'), + subTitle: t('run_management_subtitle'), + }, + { + uid: 'member', + title: t('member_management_title'), + subTitle: t('member_management_subtitle'), + }, + ]; + + return ( + + + + + + + + + + 📋 + + + + + + + + + + + + + {demoImages.map((demoImage) => ( + + + {demoImage.title} + {demoImage.subTitle} + + + + + + + ))} + + + + + Copyright © 2024-present UnitTCMS + + + ); +} diff --git a/frontend/src/app/[locale]/page.tsx b/frontend/src/app/[locale]/page.tsx index 60430f0..0102db1 100644 --- a/frontend/src/app/[locale]/page.tsx +++ b/frontend/src/app/[locale]/page.tsx @@ -1,106 +1,13 @@ -import { useTranslations } from 'next-intl'; -import { Divider } from '@heroui/react'; -import { title, subtitle } from '@/components/primitives'; -import PaneMainTitle from './PaneMainTitle'; -import PaneMainFeatures from './PaneMainFeatures'; -import DemoImage from './DemoImage'; +import { redirect } from 'next/navigation' import { PageType } from '@/types/base'; -import { LocaleCodeType } from '@/types/locale'; +import Config from '@/config/config'; +import LandingPage from '@/src/app/[locale]/LandingPage'; export default function Home({ params }: PageType) { - const t = useTranslations('Index'); - const demoImages = [ - { - uid: 'project', - title: t('project_title'), - subTitle: t('project_subtitle'), - }, - { - uid: 'case', - title: t('case_management_title'), - subTitle: t('case_management_subtitle'), - }, - { - uid: 'run', - title: t('run_management_title'), - subTitle: t('run_management_subtitle'), - }, - { - uid: 'member', - title: t('member_management_title'), - subTitle: t('member_management_subtitle'), - }, - ]; + if (!Config.isDemoSite) { + redirect(`/${params.locale}/projects`) + } - return ( - - - - - - - - - - 📋 - - - - - - - - - - - - - {demoImages.map((demoImage) => ( - - - {demoImage.title} - {demoImage.subTitle} - - - - - - - ))} - - - - - Copyright © 2024-present UnitTCMS - - - ); + return }