Skip to content

Commit 05849e6

Browse files
committed
Merge branch 'main' into scheduling-endtime-display
2 parents d2e978f + c57779c commit 05849e6

File tree

110 files changed

+6883
-6989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+6883
-6989
lines changed

src/components/About.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ const About = () => {
4747
{
4848
path: "/about/imprint",
4949
accessRole: "ROLE_UI_USERS_VIEW",
50-
loadFn: () => { },
5150
text: "ABOUT.IMPRINT"
5251
},
5352
{
5453
path: "/about/privacy",
5554
accessRole: "ROLE_UI_GROUPS_VIEW",
56-
loadFn: () => { },
5755
text: "ABOUT.PRIVACY"
5856
},
5957
]}

src/components/Header.tsx

+24-26
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import React, { useEffect, useRef, useState } from "react";
22
import { useTranslation } from "react-i18next";
3-
import { Link } from "react-router";
3+
import { useNavigate } from "react-router";
44
import i18n from "../i18n/i18n";
55
import languages from "../i18n/languages";
66
import opencastLogo from "../img/opencast-white.svg?url";
77
import { setSpecificServiceFilter } from "../slices/tableFilterSlice";
8-
import { loadServicesIntoTable } from "../thunks/tableThunks";
98
import { getErrorCount, getHealthStatus } from "../selectors/healthSelectors";
109
import {
1110
getOrgProperties,
@@ -23,6 +22,7 @@ import { UserInfoState } from "../slices/userInfoSlice";
2322
import { Tooltip } from "./shared/Tooltip";
2423
import { HiTranslate } from "react-icons/hi";
2524
import { IconContext } from "react-icons";
25+
import ButtonLikeAnchor from "./shared/ButtonLikeAnchor";
2626
import { 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

303294
const 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
);

src/components/NavBar.tsx

+6-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import React, { useRef } from "react";
22
import { Link, useLocation } from "react-router";
33
import { hasAccess } from "../utils/utils";
4-
import { AppDispatch, useAppDispatch, useAppSelector } from "../store";
4+
import { useAppSelector } from "../store";
55
import { getUserInformation } from "../selectors/userInfoSelectors";
66
import cn from "classnames";
77
import { useTranslation } from "react-i18next";
88
import MainNav from "./shared/MainNav";
9-
import { setOffset } from "../slices/tableSlice";
109
import NewResourceModal, { NewResource } from "./shared/NewResourceModal";
1110
import { useHotkeys } from "react-hotkeys-hook";
1211
import { ModalHandle } from "./shared/modals/Modal";
@@ -15,13 +14,6 @@ import { ParseKeys } from "i18next";
1514
/**
1615
* Component that renders the nav bar
1716
*/
18-
type LinkType = {
19-
path: string
20-
accessRole: string
21-
loadFn: (dispatch: AppDispatch) => void
22-
text: ParseKeys
23-
}
24-
2517
type CreateType = {
2618
accessRole: string
2719
onShowModal?: () => Promise<void>
@@ -45,12 +37,14 @@ const NavBar = ({
4537
navAriaLabel?: ParseKeys
4638
displayNavigation: boolean
4739
setNavigation: React.Dispatch<React.SetStateAction<boolean>>
48-
links: LinkType[]
40+
links: {
41+
path: string
42+
accessRole: string
43+
text: ParseKeys
44+
}[]
4945
create?: CreateType
5046
}) => {
51-
5247
const { t } = useTranslation();
53-
const dispatch = useAppDispatch();
5448
const location = useLocation();
5549

5650
const user = useAppSelector(state => getUserInformation(state));
@@ -99,13 +93,6 @@ const NavBar = ({
9993
key={index}
10094
to={link.path}
10195
className={cn({ active: location.pathname === link.path || (location.pathname === "/" && link.path === "/events/events") })}
102-
onClick={() => {
103-
if (location.pathname !== link.path) {
104-
// Reset the current page to first page
105-
dispatch(setOffset(0));
106-
}
107-
link.loadFn(dispatch)
108-
}}
10996
>
11097
{t(link.text)}
11198
</Link>

src/components/configuration/Themes.tsx

+19-9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import MainView from "../MainView";
1313
import Footer from "../Footer";
1414
import { useAppDispatch, useAppSelector } from "../../store";
1515
import { fetchThemes } from "../../slices/themeSlice";
16+
import { resetTableProperties } from "../../slices/tableSlice";
1617

1718
/**
1819
* This component renders the table view of events
@@ -25,27 +26,37 @@ const Themes = () => {
2526

2627
const themes = useAppSelector(state => getTotalThemes(state));
2728

28-
const loadThemes = async () => {
29-
// Fetching themes from server
30-
await dispatch(fetchThemes());
29+
useEffect(() => {
30+
// State variable for interrupting the load function
31+
let allowLoadIntoTable = true;
3132

32-
// Load users into table
33-
dispatch(loadThemesIntoTable());
34-
};
33+
// Clear table of previous data
34+
dispatch(resetTableProperties());
3535

36-
useEffect(() => {
3736
dispatch(fetchFilters("themes"));
3837

3938
// Reset text filter
4039
dispatch(editTextFilter(""));
4140

4241
// Load themes on mount
42+
const loadThemes = async () => {
43+
// Fetching themes from server
44+
await dispatch(fetchThemes());
45+
46+
// Load users into table
47+
if (allowLoadIntoTable) {
48+
dispatch(loadThemesIntoTable());
49+
}
50+
};
4351
loadThemes();
4452

4553
// Fetch themes every minute
4654
let fetchThemesInterval = setInterval(loadThemes, 5000);
4755

48-
return () => clearInterval(fetchThemesInterval);
56+
return () => {
57+
allowLoadIntoTable = false;
58+
clearInterval(fetchThemesInterval);
59+
}
4960
// eslint-disable-next-line react-hooks/exhaustive-deps
5061
}, []);
5162

@@ -59,7 +70,6 @@ const Themes = () => {
5970
{
6071
path: "/configuration/themes",
6172
accessRole: "ROLE_UI_THEMES_VIEW",
62-
loadFn: loadThemes,
6373
text: "CONFIGURATION.NAVIGATION.THEMES"
6474
},
6575
]}

0 commit comments

Comments
 (0)