From 143ea888c8aa76b5279ad38cc5f1ab4132e17b24 Mon Sep 17 00:00:00 2001 From: Philipp Rothmann Date: Wed, 2 Nov 2022 14:00:22 +0100 Subject: [PATCH] readd admin views --- src/components/Header/HeaderLIT.tsx | 50 ++++++++++++---------------- src/services/auth/redux/actions.ts | 3 +- src/services/auth/redux/selectors.ts | 1 + 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/src/components/Header/HeaderLIT.tsx b/src/components/Header/HeaderLIT.tsx index a1f725d..e312314 100644 --- a/src/components/Header/HeaderLIT.tsx +++ b/src/components/Header/HeaderLIT.tsx @@ -1,4 +1,4 @@ -import React, { Fragment, useMemo, useState } from 'react'; +import React, { Fragment, useMemo } from 'react'; import { Disclosure, Menu, Transition } from '@headlessui/react'; import { MenuIcon, XIcon } from '@heroicons/react/outline'; import { useAuth } from 'src/services/auth'; @@ -6,15 +6,8 @@ import Gravatar from 'react-gravatar'; import { Link, useLocation } from 'react-router-dom'; import clsx from 'clsx'; import { useApps } from 'src/services/apps'; -import _ from 'lodash'; - -import { UserModal } from '../UserModal'; - -// @ts-ignore -const HYDRA_LOGOUT_URL = window.env.REACT_APP_SSO_LOGOUT_URL; const navigation = [ - { name: 'Dashboard', to: '/dashboard', requiresAdmin: false }, { name: 'Users', to: '/users', requiresAdmin: true }, { name: 'Apps', to: '/apps', requiresAdmin: true }, ]; @@ -35,29 +28,17 @@ function filterNavigationByDashboardRole(isAdmin: boolean) { interface HeaderProps {} const HeaderLIT: React.FC = () => { - const [currentUserModal, setCurrentUserModal] = useState(false); - const [currentUserId, setCurrentUserId] = useState(null); const { logOut, currentUser, isAdmin } = useAuth(); const { pathname } = useLocation(); - const { apps, loadApps, appTableLoading } = useApps(); - - const currentUserModalOpen = (id: any) => { - setCurrentUserId(id); - setCurrentUserModal(true); - }; - - const currentUserModalClose = () => { - setCurrentUserModal(false); - setCurrentUserId(null); - }; - + const { apps } = useApps(); const navigationItems = filterNavigationByDashboardRole(isAdmin); + console.log(isAdmin); + console.log(navigationItems); const signOutUrl = useMemo(() => { - const { hostname } = window.location; - // If we are developing locally, we need to use the init cluster's public URL - return HYDRA_LOGOUT_URL; + // @ts-ignore + return window.env.REACT_APP_SSO_LOGOUT_URL; }, []); return ( @@ -100,6 +81,21 @@ const HeaderLIT: React.FC = () => { {app.name} ))} + {navigationItems.map((item) => ( + + {item.name} + + ))}
@@ -165,10 +161,6 @@ const HeaderLIT: React.FC = () => {
)} - - {currentUserModal && ( - - )} ); }; diff --git a/src/services/auth/redux/actions.ts b/src/services/auth/redux/actions.ts index 6d746ca..0988311 100644 --- a/src/services/auth/redux/actions.ts +++ b/src/services/auth/redux/actions.ts @@ -1,5 +1,4 @@ -import axios from 'axios'; -import { createApiAction, createApiCall, performApiCall } from 'src/services/api'; +import { createApiAction } from 'src/services/api'; import { SuccessAction } from 'src/services/api/redux/types'; export enum AuthActionTypes { diff --git a/src/services/auth/redux/selectors.ts b/src/services/auth/redux/selectors.ts index 0feaae5..55e1002 100644 --- a/src/services/auth/redux/selectors.ts +++ b/src/services/auth/redux/selectors.ts @@ -12,6 +12,7 @@ export const getCurrentUser = (state: State) => state.auth.userInfo; export const getIsAdmin = (state: State) => { // check since old users wont have this if (state.auth.userInfo) { + console.log(state.auth.userInfo); if (!state.auth.userInfo.app_roles) { return false; }