diff --git a/services/frontend/src/components/NavigationBar/index.jsx b/services/frontend/src/components/NavigationBar/index.jsx deleted file mode 100644 index 169796a92d..0000000000 --- a/services/frontend/src/components/NavigationBar/index.jsx +++ /dev/null @@ -1,212 +0,0 @@ -import { Link, NavLink, useLocation } from 'react-router-dom' -import { Button, Dropdown, Label, Menu } from 'semantic-ui-react' - -import { checkUserAccess, getFullStudyProgrammeRights, isDefaultServiceProvider } from '@/common' -import { LanguagePicker } from '@/components/LanguagePicker' -import { adminerUrls, isDev, languageCenterViewEnabled } from '@/conf' -import { useGetAuthorizedUserQuery, useLogoutMutation, useShowAsUser } from '@/redux/auth' -import './navigationBar.css' - -const allNavigationItems = { - university: { key: 'university', label: 'University', path: '/university' }, - faculty: { key: 'faculties', label: 'Faculties', path: '/faculties' }, - populations: { - key: 'studyProgramme', - items: [ - { key: 'class', label: 'Class statistics', path: '/populations' }, - { key: 'overview', label: 'Overview', path: '/study-programme' }, - ], - label: 'Programmes', - }, - courseStatistics: { key: 'courseStatistics', label: 'Courses', path: '/coursestatistics' }, - students: { key: 'students', label: 'Students', path: '/students' }, - teachers: { key: 'teachers', label: 'Teachers', path: '/teachers', reqRights: ['teachers'] }, - users: { key: 'users', label: 'Users', path: '/users', reqRights: ['admin'] }, - studyGuidanceGroups: { - key: 'studyGuidanceGroups', - label: 'Guidance groups', - path: '/studyguidancegroups', - reqRights: ['studyGuidanceGroups'], - }, - customPopulations: { - key: 'customPopulation', - items: [ - { key: 'customSearch', label: 'Custom population', path: '/custompopulation' }, - { key: 'openUniSearch', label: 'Fetch open uni students by courses', path: '/openunipopulation' }, - { key: 'completedCoursesSearch', label: 'Completed courses of students', path: '/completedcoursessearch' }, - { key: 'languageCenterView', label: 'Language center view', path: '/languagecenterview' }, - { key: 'closeToGraduation', label: 'Students close to graduation', path: '/close-to-graduation' }, - ], - label: 'Special populations', - }, - updater: { key: 'updater', label: 'Updater', path: '/updater', reqRights: ['admin'] }, - feedback: { key: 'feedback', label: 'Give feedback', path: '/feedback' }, -} - -export const NavigationBar = () => { - const { isLoading, iamGroups, mockedBy, username, roles, isAdmin, programmeRights, fullAccessToStudentData } = - useGetAuthorizedUserQuery() - const fullStudyProgrammeRights = getFullStudyProgrammeRights(programmeRights) - const location = useLocation() - const showAsUser = useShowAsUser() - const [logout] = useLogoutMutation() - - const refreshNavigationRoutes = () => { - const visibleNavigationItems = {} - if (isLoading) { - return visibleNavigationItems - } - Object.keys(allNavigationItems).forEach(key => { - if (key === 'populations') { - if (!fullAccessToStudentData && programmeRights.length === 0) return - } - if (key === 'students') { - if ( - !checkUserAccess(['admin', 'fullSisuAccess', 'studyGuidanceGroups'], roles) && - fullStudyProgrammeRights.length === 0 - ) - return - } else if (key === 'courseStatistics') { - if ( - !checkUserAccess(['admin', 'fullSisuAccess', 'courseStatistics'], roles) && - fullStudyProgrammeRights.length === 0 - ) - return - } else if (key === 'faculty') { - if (!checkUserAccess(['admin', 'fullSisuAccess', 'facultyStatistics'], roles)) return - } else if (key === 'feedback') { - if (!isDefaultServiceProvider()) return - } - const { reqRights } = allNavigationItems[key] - if (!reqRights || reqRights.every(r => roles.includes(r) || (key === 'teachers' && isAdmin))) { - visibleNavigationItems[key] = allNavigationItems[key] - } - }) - return { ...visibleNavigationItems } - } - - const renderHome = () => ( - - -

oodikone

-
- {isDev && } -
- ) - - const showSearch = item => { - if (item.key === 'class' || item.key === 'overview') return true - if ( - checkUserAccess(['admin', 'openUniSearch'], roles) && - item.key === 'openUniSearch' && - isDefaultServiceProvider() - ) - return true - if ( - (checkUserAccess(['admin', 'fullSisuAccess', 'studyGuidanceGroups'], roles) || - fullStudyProgrammeRights.length > 0) && - item.key === 'customSearch' - ) - return true - if (item.key === 'completedCoursesSearch') return true - if ( - (checkUserAccess(['admin'], roles) || iamGroups.includes('grp-kielikeskus-esihenkilot')) && - item.key === 'languageCenterView' && - languageCenterViewEnabled - ) - return true - if (item.key === 'closeToGraduation' && checkUserAccess(['admin', 'fullSisuAccess', 'studyGuidanceGroups'], roles)) - return true - return false - } - - const visibleNavigationItems = refreshNavigationRoutes() - - const renderNavigationRoutes = () => - Object.values(visibleNavigationItems).map(({ items, key, label, path, tag }) => - items ? ( - location.pathname.includes(item.path))} - as={Dropdown} - data-cy={`navbar-${key}`} - key={`menu-item-drop-${key}`} - tabIndex="-1" - text={label} - > - - {items.map( - item => - showSearch(item) && ( - - {item.label} - - ) - )} - - - ) : ( - - {label} - {tag && ( -
- -
- )} -
- ) - ) - - const renderUserMenu = () => - isDev ? ( - - - {adminerUrls.map(({ url, text }) => ( - { - const win = window.open(url, '_blank') - win.focus() - }} - text={text} - /> - ))} - logout()} text="Logout" /> - - - ) : ( - logout()} tabIndex="-1"> - Logout - - ) - - const renderLanguagePicker = () => ( - - - - ) - - const renderStopMockingButton = () => ( - - - - ) - - return ( - - {renderHome()} - {!isLoading && renderNavigationRoutes()} - {!isLoading && renderUserMenu()} - {!isLoading && renderLanguagePicker()} - {!isLoading && mockedBy && renderStopMockingButton()} - - ) -} diff --git a/services/frontend/src/components/NavigationBar/navigationBar.css b/services/frontend/src/components/NavigationBar/navigationBar.css deleted file mode 100644 index 56e4b90297..0000000000 --- a/services/frontend/src/components/NavigationBar/navigationBar.css +++ /dev/null @@ -1,17 +0,0 @@ -.navBar { - display: grid !important; - grid-auto-flow: column !important; - border-radius: 0 !important; - border-top: none !important; -} - -.navBar::after { - content: none !important; -} - -.navBar .item { - display: flex; - justify-content: center; - align-items: center; - background-color: pink; -}