From 8eb551a6c9f53033c52ae810d2ec52f5067fd63a Mon Sep 17 00:00:00 2001 From: Norbert Csaba Herczeg Date: Thu, 26 Sep 2024 11:53:37 +0200 Subject: [PATCH] JNG-5940 additional routes --- docs/pages/01_ui_react.adoc | 28 +++++++++++++++++++ .../resources/actor/src/extra-routes.tsx.hbs | 5 ++++ .../main/resources/actor/src/routes.tsx.hbs | 3 +- .../src/main/resources/ui-react.yaml | 4 +++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 judo-ui-react/src/main/resources/actor/src/extra-routes.tsx.hbs diff --git a/docs/pages/01_ui_react.adoc b/docs/pages/01_ui_react.adoc index dea7e0af..23f4e29c 100644 --- a/docs/pages/01_ui_react.adoc +++ b/docs/pages/01_ui_react.adoc @@ -579,6 +579,34 @@ const CustomDashboard: FC = () => { }; ---- +=== Adding custom routes + +Adding custom routes can be done via adding the `src/extra-routes.tsx` tp the generator-ignore files and filling the +array with our additional routes. + +*src/extra-routes.tsx:* +[source,typescriptjsx] +---- +import type { ReactElement } from 'react'; + +const Hello = () => { + return ( + <> +
+ Hello +
+ + ); +}; + +export const extraRoutes: Array<{ path: string; element: ReactElement; exact?: boolean }> = [ + { + path: 'hello', + element: , + }, +]; +---- + === Filtering Enumeration options Enumeration options can be filtered based on current view/form data if needed. Filtering actions are available on diff --git a/judo-ui-react/src/main/resources/actor/src/extra-routes.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/extra-routes.tsx.hbs new file mode 100644 index 00000000..afcb8efd --- /dev/null +++ b/judo-ui-react/src/main/resources/actor/src/extra-routes.tsx.hbs @@ -0,0 +1,5 @@ +{{> fragment.header.hbs }} + +import type { ReactElement } from 'react'; + +export const extraRoutes: Array<{path: string, element: ReactElement, exact?: boolean}> = []; diff --git a/judo-ui-react/src/main/resources/actor/src/routes.tsx.hbs b/judo-ui-react/src/main/resources/actor/src/routes.tsx.hbs index a044a888..e4193756 100644 --- a/judo-ui-react/src/main/resources/actor/src/routes.tsx.hbs +++ b/judo-ui-react/src/main/resources/actor/src/routes.tsx.hbs @@ -6,8 +6,9 @@ import { lazy, Suspense } from 'react'; import { OBJECTCLASS } from '@pandino/pandino-api'; import { ComponentProxy } from '@pandino/react-hooks'; import { Redirect } from './pages/Redirect'; +import { extraRoutes } from './extra-routes'; -let routes: Array<{path: string, element: ReactElement, exact?: boolean}> = []; +let routes: Array<{path: string, element: ReactElement, exact?: boolean}> = [...extraRoutes]; routes.push({ path: '_redirect', diff --git a/judo-ui-react/src/main/resources/ui-react.yaml b/judo-ui-react/src/main/resources/ui-react.yaml index 76b0775a..69176b2c 100644 --- a/judo-ui-react/src/main/resources/ui-react.yaml +++ b/judo-ui-react/src/main/resources/ui-react.yaml @@ -185,6 +185,10 @@ templates: pathExpression: "'src/routes.tsx'" templateName: actor/src/routes.tsx.hbs + - name: actor/src/extra-routes.tsx + pathExpression: "'src/extra-routes.tsx'" + templateName: actor/src/extra-routes.tsx.hbs + - name: actor/src/vite-env.d.ts pathExpression: "'src/vite-env.d.ts'" templateName: actor/src/vite-env.d.ts.hbs