Skip to content

Commit

Permalink
simplify url (#991)
Browse files Browse the repository at this point in the history
Signed-off-by: Teo Koon Peng <[email protected]>
  • Loading branch information
koonpeng committed Aug 7, 2024
1 parent 2e4b44c commit 3a6c952
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions packages/dashboard/src/app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { getDefaultTaskDefinition, TaskDefinition } from 'react-components';

import testConfig from '../app-config.json';
import { Authenticator, KeycloakAuthenticator, StubAuthenticator } from './auth';
import { BasePath } from './util/url';

export interface RobotResource {
icon?: string;
Expand Down Expand Up @@ -85,7 +84,7 @@ const authenticator: Authenticator = (() => {
if (APP_CONFIG_AUTH_PROVIDER === 'keycloak') {
return new KeycloakAuthenticator(
APP_CONFIG.authConfig as KeycloakAuthConfig,
`${window.location.origin}${BasePath}/silent-check-sso.html`,
`${import.meta.env.BASE_URL}silent-check-sso.html`,
);
} else if (APP_CONFIG_AUTH_PROVIDER === 'stub') {
return new StubAuthenticator();
Expand Down
18 changes: 7 additions & 11 deletions packages/dashboard/src/util/url.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export const BasePath =
import.meta.env.BASE_URL === undefined || import.meta.env.BASE_URL === '/'
? ''
: import.meta.env.BASE_URL;
/**
* Add /* after /admin to avoid the warning
* <Routes> (or called `useRoutes()`) at "/admin"
Expand All @@ -10,10 +6,10 @@ export const BasePath =
* This means if you navigate deeper,
* the parent won't match anymore and therefore the child routes will never render.
*/
export const DashboardRoute = BasePath === '' ? '/' : BasePath;
export const LoginRoute = `${BasePath}/login`;
export const TasksRoute = `${BasePath}/tasks`;
export const RobotsRoute = `${BasePath}/robots`;
export const AdminRoute = `${BasePath}/admin/*`;
export const CustomRoute1 = `${BasePath}/custom1`;
export const CustomRoute2 = `${BasePath}/custom2`;
export const DashboardRoute = import.meta.env.BASE_URL;
export const LoginRoute = `${import.meta.env.BASE_URL}login`;
export const TasksRoute = `${import.meta.env.BASE_URL}tasks`;
export const RobotsRoute = `${import.meta.env.BASE_URL}robots`;
export const AdminRoute = `${import.meta.env.BASE_URL}admin/*`;
export const CustomRoute1 = `${import.meta.env.BASE_URL}custom1`;
export const CustomRoute2 = `${import.meta.env.BASE_URL}custom2`;

0 comments on commit 3a6c952

Please sign in to comment.