Skip to content

Commit

Permalink
feat: Display logged in user
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-nour-fdc committed Aug 14, 2024
1 parent 312834b commit 8fe3970
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ You should have received a copy of the MIT License
along with kuberpult. If not, see <https://directory.fsf.org/wiki/License:Expat>.
Copyright freiheit.com*/
import { jwtDecode } from 'jwt-decode';
import { Textfield } from '../textfield';
import React, { useCallback } from 'react';
import { SideBar } from '../SideBar/SideBar';
Expand Down Expand Up @@ -47,6 +48,17 @@ export const TopAppBar: React.FC<TopAppBarProps> = (props) => {
const teamsParam = (params.get('teams') || '').split(',').filter((val) => val !== '');

const version = useKuberpultVersion() || '2.6.0';
let user_email = 'default';
const cookieValue = document.cookie
.split('; ')
.find((row) => row.startsWith('kuberpult.oauth='))
?.split('=')[1];
if (cookieValue) {
const decodedToken: any = jwtDecode(cookieValue);
if (decodedToken) {
user_email = decodedToken.email || 'default';
}
}

const hideWithoutWarningsValue = hideWithoutWarnings(params);
const allWarnings: Warning[] = useAllWarnings();
Expand Down Expand Up @@ -127,6 +139,9 @@ export const TopAppBar: React.FC<TopAppBarProps> = (props) => {
{renderedTeamsFilter}
{renderedWarningsFilter}
{renderedWarnings}
<div className="mdc-top-app-bar__section mdc-top-app-bar__section--align-end">
<strong className="sub-headline1">Hello {user_email}</strong>
</div>
<div className="mdc-top-app-bar__section mdc-top-app-bar__section--align-end">
<strong className="sub-headline1">Planned Actions</strong>
<Button
Expand Down

0 comments on commit 8fe3970

Please sign in to comment.