Skip to content

Commit

Permalink
Add view configs
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabarov committed Mar 28, 2024
1 parent fd28888 commit 09b153d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/main/frontend/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@
* exists in the frontend folder (not in generated folder) and you copied the file,
* as the import isn't updated automatically by Vaadin in this case.
******************************************************************************/
import Flow from 'Frontend/generated/flow/Flow';
import Flow from 'Frontend/generated/flow/Flow';
import { serverSideRoutes } from 'Frontend/generated/flow/Flow';
import fileRoutes from 'Frontend/generated/views';
import Login from "Frontend/views/login";
import {RouterBuilder} from "@vaadin/hilla-file-router/runtime.js";


const routerBuilder = new RouterBuilder()
.withFileRoutes(fileRoutes)
.withReactRoutes(
{ path: '/login', element: <Login />, handle: { title: 'Login' } },
{ path: '/login', element: <Login />, handle: { title: 'Login' } }
)
// @ts-ignore
.withServerRoutes(Flow)
.protect('/login');

Expand Down
5 changes: 5 additions & 0 deletions src/main/frontend/views/about.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { VerticalLayout } from "@vaadin/react-components/VerticalLayout.js";
import type {ViewConfig} from "@vaadin/hilla-file-router/types.js";

export const config: ViewConfig = {
loginRequired: true
};

/**
* Hilla views that allows access only for authenticated users.
Expand Down
6 changes: 6 additions & 0 deletions src/main/frontend/views/hilla.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { TextField } from "@vaadin/react-components/TextField.js";
import { HelloEndpoint } from "Frontend/generated/endpoints";
import { useState } from "react";
import {VerticalLayout} from "@vaadin/react-components/VerticalLayout.js";
import type {ViewConfig} from "@vaadin/hilla-file-router/types.js";

export const config: ViewConfig = {
loginRequired: true,
rolesAllowed: ['ROLE_USER'],
};

/**
* Hilla view that allows access only for users with a role 'USER'
Expand Down

0 comments on commit 09b153d

Please sign in to comment.