Merge branch 'main' into feat/role-management-fixes

This commit is contained in:
Davor 2022-06-10 10:26:15 +02:00
commit 7691223a9c
4 changed files with 12 additions and 3 deletions

2
.env.example Normal file
View file

@ -0,0 +1,2 @@
REACT_APP_API_URL=http://127.0.0.1:5000/api/v1
REACT_APP_HYDRA_PUBLIC_URL=https://sso.init.stackspin.net

View file

@ -19,6 +19,8 @@ data:
KRATOS_PUBLIC_URL: {{ .Values.backend.kratos.publicUrl }} KRATOS_PUBLIC_URL: {{ .Values.backend.kratos.publicUrl }}
KRATOS_ADMIN_URL: {{ .Values.backend.kratos.adminUrl }} KRATOS_ADMIN_URL: {{ .Values.backend.kratos.adminUrl }}
HYDRA_PUBLIC_URL: {{ .Values.backend.oidc.baseUrl }} HYDRA_PUBLIC_URL: {{ .Values.backend.oidc.baseUrl }}
# React can only read this env variable if it's prepended with REACT_APP
REACT_APP_HYDRA_PUBLIC_URL: {{ .Values.backend.oidc.baseUrl }}
HYDRA_ADMIN_URL: {{ .Values.backend.hydra.adminUrl }} HYDRA_ADMIN_URL: {{ .Values.backend.hydra.adminUrl }}
LOGIN_PANEL_URL: {{ .Values.backend.loginPanelUrl }} LOGIN_PANEL_URL: {{ .Values.backend.loginPanelUrl }}
DATABASE_URL: {{ .Values.backend.databaseUrl }} DATABASE_URL: {{ .Values.backend.databaseUrl }}

View file

@ -1,2 +1,2 @@
export { isTouched } from './is-touched'; export * from './is-touched';
export { addParamsToLink } from './add-params-to-link'; export * from './add-params-to-link';

View file

@ -26,6 +26,8 @@ function filterNavigationByDashboardRole(isAdmin: boolean) {
return navigation.filter((item) => !item.requiresAdmin); return navigation.filter((item) => !item.requiresAdmin);
} }
const HYDRA_URL = process.env.REACT_APP_HYDRA_PUBLIC_URL;
// eslint-disable-next-line @typescript-eslint/no-empty-interface // eslint-disable-next-line @typescript-eslint/no-empty-interface
interface HeaderProps {} interface HeaderProps {}
@ -48,6 +50,8 @@ const Header: React.FC<HeaderProps> = () => {
const navigationItems = filterNavigationByDashboardRole(isAdmin); const navigationItems = filterNavigationByDashboardRole(isAdmin);
const signOutUrl = `${HYDRA_URL}/oauth2/sessions/logout`;
return ( return (
<> <>
<Disclosure as="nav" className="bg-white shadow relative z-10"> <Disclosure as="nav" className="bg-white shadow relative z-10">
@ -127,7 +131,8 @@ const Header: React.FC<HeaderProps> = () => {
<Menu.Item> <Menu.Item>
{({ active }) => ( {({ active }) => (
<a <a
onClick={logOut} onClick={() => logOut()}
href={signOutUrl}
className={classNames( className={classNames(
active ? 'bg-gray-100 cursor-pointer' : '', active ? 'bg-gray-100 cursor-pointer' : '',
'block px-4 py-2 text-sm text-gray-700 cursor-pointer', 'block px-4 py-2 text-sm text-gray-700 cursor-pointer',