-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
492 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import AppBar from '@mui/material/AppBar'; | ||
import Toolbar from '@mui/material/Toolbar'; | ||
import {PropsWithChildren} from "react"; | ||
import {useKeycloakUrls, useKeycloakUser} from '@alchemy/react-auth'; | ||
import config from "./config.ts"; | ||
import {keycloakClient} from "./lib/apiClient.ts"; | ||
import MenuItem from "@mui/material/MenuItem"; | ||
import Box from "@mui/material/Box"; | ||
import {UserMenu} from '@alchemy/phrasea-ui'; | ||
import {useTranslation} from "react-i18next"; | ||
|
||
type Props = PropsWithChildren<{}>; | ||
|
||
export default function DashboardBar({ | ||
children | ||
}: Props) { | ||
const menuHeight = 42; | ||
const {t} = useTranslation(); | ||
const {getLoginUrl, getAccountUrl} = useKeycloakUrls({ | ||
autoConnectIdP: config.autoConnectIdP, | ||
keycloakClient, | ||
}); | ||
|
||
const {user, logout} = useKeycloakUser(); | ||
|
||
return ( | ||
<AppBar position="sticky"> | ||
<Toolbar> | ||
<div style={{ | ||
flexGrow: 1 | ||
}}> | ||
{children} | ||
</div> | ||
|
||
|
||
<Box sx={{flexGrow: 0}}> | ||
{!user ? ( | ||
<MenuItem component={'a'} href={getLoginUrl()}> | ||
{t('menu.sign_in', 'Sign in')} | ||
</MenuItem> | ||
) : ( | ||
<UserMenu | ||
menuHeight={menuHeight} | ||
username={user?.username} | ||
accountUrl={getAccountUrl()} | ||
onLogout={logout} | ||
/> | ||
)} | ||
</Box> | ||
</Toolbar> | ||
</AppBar> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {oauthClient} from './lib/apiClient'; | ||
import {AuthenticationProvider, SessionExpireContainer, useAuthorizationCode} from '@alchemy/react-auth'; | ||
import Dashboard from "./Dashboard.tsx"; | ||
|
||
type Props = {}; | ||
|
||
export default function Root({}: Props) { | ||
useAuthorizationCode({ | ||
oauthClient, | ||
navigate: (path, {replace} = {}) => { | ||
if (replace) { | ||
document.location.replace(path); | ||
} else { | ||
document.location.href = path | ||
} | ||
}, | ||
successUri: '/' | ||
}); | ||
|
||
return ( | ||
<AuthenticationProvider oauthClient={oauthClient}> | ||
<SessionExpireContainer/> | ||
<Dashboard /> | ||
</AuthenticationProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {configureClientAuthentication, KeycloakClient} from '@alchemy/auth'; | ||
import {createHttpClient} from '@alchemy/api'; | ||
|
||
import config from '../config'; | ||
|
||
export const keycloakClient = new KeycloakClient({ | ||
clientId: config.clientId, | ||
baseUrl: config.keycloakUrl, | ||
realm: config.realmName, | ||
}); | ||
export const oauthClient = keycloakClient.client; | ||
|
||
const apiClient = createHttpClient(window.config.baseUrl); | ||
|
||
configureClientAuthentication(apiClient, oauthClient); | ||
|
||
export default apiClient; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.