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 = () => ( -