11import React , { useEffect , useRef , useState } from "react" ;
22import { useTranslation } from "react-i18next" ;
3- import { Link } from "react-router" ;
3+ import { useNavigate } from "react-router" ;
44import i18n from "../i18n/i18n" ;
55import languages from "../i18n/languages" ;
66import opencastLogo from "../img/opencast-white.svg?url" ;
77import { setSpecificServiceFilter } from "../slices/tableFilterSlice" ;
8- import { loadServicesIntoTable } from "../thunks/tableThunks" ;
98import { getErrorCount , getHealthStatus } from "../selectors/healthSelectors" ;
109import {
1110 getOrgProperties ,
@@ -23,6 +22,7 @@ import { UserInfoState } from "../slices/userInfoSlice";
2322import { Tooltip } from "./shared/Tooltip" ;
2423import { HiTranslate } from "react-icons/hi" ;
2524import { IconContext } from "react-icons" ;
25+ import ButtonLikeAnchor from "./shared/ButtonLikeAnchor" ;
2626import { ModalHandle } from "./shared/modals/Modal" ;
2727
2828// References for detecting a click outside of the container of the dropdown menus
@@ -73,14 +73,6 @@ const Header = () => {
7373 registrationModalRef . current ?. open ( )
7474 } ;
7575
76- const redirectToServices = async ( ) => {
77- // Load services into table
78- await dispatch ( loadServicesIntoTable ( ) ) ;
79-
80- // set the action filter value of services to true
81- await dispatch ( setSpecificServiceFilter ( { filter : "actions" , filterValue : "true" } ) ) ;
82- } ;
83-
8476 const showHotKeyCheatSheet = ( ) => {
8577 hotKeyCheatSheetModalRef . current ?. open ( )
8678 } ;
@@ -216,7 +208,6 @@ const Header = () => {
216208 { displayMenuNotify && (
217209 < MenuNotify
218210 healthStatus = { healthStatus }
219- redirectToServices = { redirectToServices }
220211 />
221212 ) }
222213 </ div >
@@ -288,12 +279,12 @@ const MenuLang = () => {
288279 { /* one list item for each available language */ }
289280 { languages . map ( ( language , key ) => (
290281 < li key = { key } >
291- < button
292- className = { "button-like-anchor" + ( i18n . language === language . code ? " selected" : "" ) }
282+ < ButtonLikeAnchor
283+ extraClassName = { ( i18n . language === language . code ? "selected" : "" ) }
293284 onClick = { ( ) => changeLanguage ( language . code ) }
294285 >
295286 { language . long }
296- </ button >
287+ </ ButtonLikeAnchor >
297288 </ li >
298289 ) ) }
299290 </ ul >
@@ -302,20 +293,27 @@ const MenuLang = () => {
302293
303294const MenuNotify = ( {
304295 healthStatus,
305- redirectToServices
306296} : {
307297 healthStatus : HealthStatus [ ] ,
308- redirectToServices : ( ) => Promise < void > ,
309298} ) => {
299+ const dispatch = useAppDispatch ( ) ;
300+ const navigate = useNavigate ( ) ;
301+
302+ const redirectToServices = async ( ) => {
303+ // set the action filter value of services to true
304+ await dispatch ( setSpecificServiceFilter ( { filter : "actions" , filterValue : "true" } ) ) ;
305+ navigate ( "/systems/services" ) ;
306+ } ;
307+
310308 return (
311309 < ul className = "dropdown-ul" >
312310 { /* For each service in the serviceList (Background Services) one list item */ }
313311 { healthStatus . map ( ( service , key ) => (
314312 < li key = { key } >
315313 { ! ! service . status && (
316- < Link
317- to = "/systems/services "
318- onClick = { async ( ) => await redirectToServices ( ) }
314+ < button
315+ className = "button-like-anchor "
316+ onClick = { ( ) => redirectToServices ( ) }
319317 >
320318 < span > { service . name } </ span >
321319 { service . error ? (
@@ -327,7 +325,7 @@ const MenuNotify = ({
327325 { service . status }
328326 </ span >
329327 ) }
330- </ Link >
328+ </ button >
331329 ) }
332330 </ li >
333331 ) ) }
@@ -396,16 +394,16 @@ const MenuHelp = ({
396394 </ li >
397395 ) }
398396 < li >
399- < button className = "button-like-anchor" onClick = { ( ) => showHotKeys ( ) } >
397+ < ButtonLikeAnchor onClick = { ( ) => showHotKeys ( ) } >
400398 < span > { t ( "HELP.HOTKEY_CHEAT_SHEET" ) } </ span >
401- </ button >
399+ </ ButtonLikeAnchor >
402400 </ li >
403401 { /* Adoter registration Modal */ }
404402 { user . isAdmin && (
405403 < li >
406- < button className = "button-like-anchor" onClick = { ( ) => showAdoptersRegistrationModal ( ) } >
404+ < ButtonLikeAnchor onClick = { ( ) => showAdoptersRegistrationModal ( ) } >
407405 < span > { t ( "HELP.ADOPTER_REGISTRATION" ) } </ span >
408- </ button >
406+ </ ButtonLikeAnchor >
409407 </ li >
410408 ) }
411409 </ ul >
@@ -418,9 +416,9 @@ const MenuUser = () => {
418416 return (
419417 < ul className = "dropdown-ul" >
420418 < li >
421- < button className = "button-like-anchor" onClick = { ( ) => logout ( ) } >
419+ < ButtonLikeAnchor onClick = { ( ) => logout ( ) } >
422420 < span className = "logout-icon" > { t ( "LOGOUT" ) } </ span >
423- </ button >
421+ </ ButtonLikeAnchor >
424422 </ li >
425423 </ ul >
426424 ) ;
0 commit comments